.. | .. |
---|
55 | 55 | |
---|
56 | 56 | #include <asm/io.h> |
---|
57 | 57 | #include <asm/irq.h> |
---|
58 | | -#include <asm/pgtable.h> |
---|
59 | 58 | |
---|
60 | 59 | #include "savagefb.h" |
---|
61 | 60 | |
---|
.. | .. |
---|
1637 | 1636 | return 0; |
---|
1638 | 1637 | } |
---|
1639 | 1638 | |
---|
1640 | | -static struct fb_ops savagefb_ops = { |
---|
| 1639 | +static const struct fb_ops savagefb_ops = { |
---|
1641 | 1640 | .owner = THIS_MODULE, |
---|
1642 | 1641 | .fb_open = savagefb_open, |
---|
1643 | 1642 | .fb_release = savagefb_release, |
---|
.. | .. |
---|
1860 | 1859 | vga_out8(0x3d4, 0x68, par); /* memory control 1 */ |
---|
1861 | 1860 | if ((vga_in8(0x3d5, par) & 0xC0) == (0x01 << 6)) |
---|
1862 | 1861 | RamSavage4[1] = 8; |
---|
1863 | | - |
---|
1864 | | - /*FALLTHROUGH*/ |
---|
| 1862 | + fallthrough; |
---|
1865 | 1863 | |
---|
1866 | 1864 | case S3_SAVAGE2000: |
---|
1867 | 1865 | videoRam = RamSavage4[(config1 & 0xE0) >> 5] * 1024; |
---|
.. | .. |
---|
2155 | 2153 | |
---|
2156 | 2154 | err = fb_alloc_cmap(&info->cmap, NR_PALETTE, 0); |
---|
2157 | 2155 | if (!err) |
---|
2158 | | - info->flags |= FBINFO_HWACCEL_COPYAREA | |
---|
2159 | | - FBINFO_HWACCEL_FILLRECT | |
---|
2160 | | - FBINFO_HWACCEL_IMAGEBLIT; |
---|
| 2156 | + info->flags |= FBINFO_HWACCEL_COPYAREA | |
---|
| 2157 | + FBINFO_HWACCEL_FILLRECT | |
---|
| 2158 | + FBINFO_HWACCEL_IMAGEBLIT; |
---|
| 2159 | + else |
---|
| 2160 | + kfree(info->pixmap.addr); |
---|
2161 | 2161 | } |
---|
2162 | 2162 | #endif |
---|
2163 | 2163 | return err; |
---|
.. | .. |
---|
2333 | 2333 | DBG("savagefb_remove"); |
---|
2334 | 2334 | |
---|
2335 | 2335 | if (info) { |
---|
2336 | | - /* |
---|
2337 | | - * If unregister_framebuffer fails, then |
---|
2338 | | - * we will be leaving hooks that could cause |
---|
2339 | | - * oopsen laying around. |
---|
2340 | | - */ |
---|
2341 | | - if (unregister_framebuffer(info)) |
---|
2342 | | - printk(KERN_WARNING "savagefb: danger danger! " |
---|
2343 | | - "Oopsen imminent!\n"); |
---|
| 2336 | + unregister_framebuffer(info); |
---|
2344 | 2337 | |
---|
2345 | 2338 | #ifdef CONFIG_FB_SAVAGE_I2C |
---|
2346 | 2339 | savagefb_delete_i2c_busses(info); |
---|
.. | .. |
---|
2354 | 2347 | } |
---|
2355 | 2348 | } |
---|
2356 | 2349 | |
---|
2357 | | -static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg) |
---|
| 2350 | +static int savagefb_suspend_late(struct device *dev, pm_message_t mesg) |
---|
2358 | 2351 | { |
---|
2359 | | - struct fb_info *info = pci_get_drvdata(dev); |
---|
| 2352 | + struct fb_info *info = dev_get_drvdata(dev); |
---|
2360 | 2353 | struct savagefb_par *par = info->par; |
---|
2361 | 2354 | |
---|
2362 | 2355 | DBG("savagefb_suspend"); |
---|
.. | .. |
---|
2364 | 2357 | if (mesg.event == PM_EVENT_PRETHAW) |
---|
2365 | 2358 | mesg.event = PM_EVENT_FREEZE; |
---|
2366 | 2359 | par->pm_state = mesg.event; |
---|
2367 | | - dev->dev.power.power_state = mesg; |
---|
| 2360 | + dev->power.power_state = mesg; |
---|
2368 | 2361 | |
---|
2369 | 2362 | /* |
---|
2370 | 2363 | * For PM_EVENT_FREEZE, do not power down so the console |
---|
.. | .. |
---|
2382 | 2375 | savagefb_blank(FB_BLANK_POWERDOWN, info); |
---|
2383 | 2376 | savage_set_default_par(par, &par->save); |
---|
2384 | 2377 | savage_disable_mmio(par); |
---|
2385 | | - pci_save_state(dev); |
---|
2386 | | - pci_disable_device(dev); |
---|
2387 | | - pci_set_power_state(dev, pci_choose_state(dev, mesg)); |
---|
2388 | 2378 | console_unlock(); |
---|
2389 | 2379 | |
---|
2390 | 2380 | return 0; |
---|
2391 | 2381 | } |
---|
2392 | 2382 | |
---|
2393 | | -static int savagefb_resume(struct pci_dev* dev) |
---|
| 2383 | +static int __maybe_unused savagefb_suspend(struct device *dev) |
---|
2394 | 2384 | { |
---|
2395 | | - struct fb_info *info = pci_get_drvdata(dev); |
---|
| 2385 | + return savagefb_suspend_late(dev, PMSG_SUSPEND); |
---|
| 2386 | +} |
---|
| 2387 | + |
---|
| 2388 | +static int __maybe_unused savagefb_hibernate(struct device *dev) |
---|
| 2389 | +{ |
---|
| 2390 | + return savagefb_suspend_late(dev, PMSG_HIBERNATE); |
---|
| 2391 | +} |
---|
| 2392 | + |
---|
| 2393 | +static int __maybe_unused savagefb_freeze(struct device *dev) |
---|
| 2394 | +{ |
---|
| 2395 | + return savagefb_suspend_late(dev, PMSG_FREEZE); |
---|
| 2396 | +} |
---|
| 2397 | + |
---|
| 2398 | +static int __maybe_unused savagefb_resume(struct device *dev) |
---|
| 2399 | +{ |
---|
| 2400 | + struct fb_info *info = dev_get_drvdata(dev); |
---|
2396 | 2401 | struct savagefb_par *par = info->par; |
---|
2397 | 2402 | int cur_state = par->pm_state; |
---|
2398 | 2403 | |
---|
.. | .. |
---|
2404 | 2409 | * The adapter was not powered down coming back from a |
---|
2405 | 2410 | * PM_EVENT_FREEZE. |
---|
2406 | 2411 | */ |
---|
2407 | | - if (cur_state == PM_EVENT_FREEZE) { |
---|
2408 | | - pci_set_power_state(dev, PCI_D0); |
---|
| 2412 | + if (cur_state == PM_EVENT_FREEZE) |
---|
2409 | 2413 | return 0; |
---|
2410 | | - } |
---|
2411 | 2414 | |
---|
2412 | 2415 | console_lock(); |
---|
2413 | 2416 | |
---|
2414 | | - pci_set_power_state(dev, PCI_D0); |
---|
2415 | | - pci_restore_state(dev); |
---|
2416 | | - |
---|
2417 | | - if (pci_enable_device(dev)) |
---|
2418 | | - DBG("err"); |
---|
2419 | | - |
---|
2420 | | - pci_set_master(dev); |
---|
2421 | 2417 | savage_enable_mmio(par); |
---|
2422 | 2418 | savage_init_hw(par); |
---|
2423 | 2419 | savagefb_set_par(info); |
---|
.. | .. |
---|
2428 | 2424 | return 0; |
---|
2429 | 2425 | } |
---|
2430 | 2426 | |
---|
| 2427 | +static const struct dev_pm_ops savagefb_pm_ops = { |
---|
| 2428 | +#ifdef CONFIG_PM_SLEEP |
---|
| 2429 | + .suspend = savagefb_suspend, |
---|
| 2430 | + .resume = savagefb_resume, |
---|
| 2431 | + .freeze = savagefb_freeze, |
---|
| 2432 | + .thaw = savagefb_resume, |
---|
| 2433 | + .poweroff = savagefb_hibernate, |
---|
| 2434 | + .restore = savagefb_resume, |
---|
| 2435 | +#endif |
---|
| 2436 | +}; |
---|
2431 | 2437 | |
---|
2432 | 2438 | static const struct pci_device_id savagefb_devices[] = { |
---|
2433 | 2439 | {PCI_VENDOR_ID_S3, PCI_CHIP_SUPSAV_MX128, |
---|
.. | .. |
---|
2508 | 2514 | .name = "savagefb", |
---|
2509 | 2515 | .id_table = savagefb_devices, |
---|
2510 | 2516 | .probe = savagefb_probe, |
---|
2511 | | - .suspend = savagefb_suspend, |
---|
2512 | | - .resume = savagefb_resume, |
---|
| 2517 | + .driver.pm = &savagefb_pm_ops, |
---|
2513 | 2518 | .remove = savagefb_remove, |
---|
2514 | 2519 | }; |
---|
2515 | 2520 | |
---|