Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: lxfb: use generic power management

Switch to the new generic framework by updating function signatures and
define a "struct dev_pm_ops" variable to bind PM callbacks. This way we can
remove the legacy .suspend & .resume bindings from "lxfb_driver".

The lxfb_suspend() is designed to function only in the case of Suspend.
Thus, the code was kept inside "if (state.event == PM_EVENT_SUSPEND)"
container. This is because, in the legacy framework, this callback was
invoked even in the event of Freeze and Hibernate. Hence, added the load of
unnecessary function-calls.

The goal can be achieved by binding the callback with only
"lxfb_pm_ops.suspend" in the new framework. This also avoids the step of
checking "if (state.event == PM_EVENT_SUSPEND)" every time the callback is
invoked.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Bjorn Helgaas <bjorn@helgaas.com>
Cc: Vaibhav Gupta <vaibhav.varodek@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Andres Salomon <dilinger@queued.net>
CC: Antonino Daplas <adaplas@gmail.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200819185654.151170-3-vaibhavgupta40@gmail.com

authored by

Vaibhav Gupta and committed by
Bartlomiej Zolnierkiewicz
df7a9ec3 fa41f287

+20 -26
-5
drivers/video/fbdev/geode/lxfb.h
··· 29 29 void __iomem *gp_regs; 30 30 void __iomem *dc_regs; 31 31 void __iomem *vp_regs; 32 - #ifdef CONFIG_PM 33 32 int powered_down; 34 33 35 34 /* register state, for power mgmt functionality */ ··· 49 50 uint32_t hcoeff[DC_HFILT_COUNT * 2]; 50 51 uint32_t vcoeff[DC_VFILT_COUNT]; 51 52 uint32_t vp_coeff[VP_COEFF_SIZE / 4]; 52 - #endif 53 53 }; 54 54 55 55 static inline unsigned int lx_get_pitch(unsigned int xres, int bpp) ··· 62 64 void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int, 63 65 unsigned int, unsigned int); 64 66 65 - #ifdef CONFIG_PM 66 67 int lx_powerdown(struct fb_info *info); 67 68 int lx_powerup(struct fb_info *info); 68 - #endif 69 - 70 69 71 70 /* Graphics Processor registers (table 6-29 from the data book) */ 72 71 enum gp_registers {
+20 -17
drivers/video/fbdev/geode/lxfb_core.c
··· 443 443 return info; 444 444 } 445 445 446 - #ifdef CONFIG_PM 447 - static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state) 446 + static int __maybe_unused lxfb_suspend(struct device *dev) 448 447 { 449 - struct fb_info *info = pci_get_drvdata(pdev); 448 + struct fb_info *info = dev_get_drvdata(dev); 450 449 451 - if (state.event == PM_EVENT_SUSPEND) { 452 - console_lock(); 453 - lx_powerdown(info); 454 - fb_set_suspend(info, 1); 455 - console_unlock(); 456 - } 450 + console_lock(); 451 + lx_powerdown(info); 452 + fb_set_suspend(info, 1); 453 + console_unlock(); 457 454 458 455 /* there's no point in setting PCI states; we emulate PCI, so 459 456 * we don't end up getting power savings anyways */ ··· 458 461 return 0; 459 462 } 460 463 461 - static int lxfb_resume(struct pci_dev *pdev) 464 + static int __maybe_unused lxfb_resume(struct device *dev) 462 465 { 463 - struct fb_info *info = pci_get_drvdata(pdev); 466 + struct fb_info *info = dev_get_drvdata(dev); 464 467 int ret; 465 468 466 469 console_lock(); ··· 474 477 console_unlock(); 475 478 return 0; 476 479 } 477 - #else 478 - #define lxfb_suspend NULL 479 - #define lxfb_resume NULL 480 - #endif 481 480 482 481 static int lxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) 483 482 { ··· 593 600 594 601 MODULE_DEVICE_TABLE(pci, lxfb_id_table); 595 602 603 + static const struct dev_pm_ops lxfb_pm_ops = { 604 + #ifdef CONFIG_PM_SLEEP 605 + .suspend = lxfb_suspend, 606 + .resume = lxfb_resume, 607 + .freeze = NULL, 608 + .thaw = lxfb_resume, 609 + .poweroff = NULL, 610 + .restore = lxfb_resume, 611 + #endif 612 + }; 613 + 596 614 static struct pci_driver lxfb_driver = { 597 615 .name = "lxfb", 598 616 .id_table = lxfb_id_table, 599 617 .probe = lxfb_probe, 600 618 .remove = lxfb_remove, 601 - .suspend = lxfb_suspend, 602 - .resume = lxfb_resume, 619 + .driver.pm = &lxfb_pm_ops, 603 620 }; 604 621 605 622 #ifndef MODULE
-4
drivers/video/fbdev/geode/lxfb_ops.c
··· 580 580 return 0; 581 581 } 582 582 583 - #ifdef CONFIG_PM 584 - 585 583 static void lx_save_regs(struct lxfb_par *par) 586 584 { 587 585 uint32_t filt; ··· 835 837 par->powered_down = 0; 836 838 return 0; 837 839 } 838 - 839 - #endif