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

fbdev: gxfb: 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 "gxfb_driver".

The gxfb_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
"gxfb_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-2-vaibhavgupta40@gmail.com

authored by

Vaibhav Gupta and committed by
Bartlomiej Zolnierkiewicz
fa41f287 ad6f93e9

+20 -25
-5
drivers/video/fbdev/geode/gxfb.h
··· 21 21 void __iomem *dc_regs; 22 22 void __iomem *vid_regs; 23 23 void __iomem *gp_regs; 24 - #ifdef CONFIG_PM 25 24 int powered_down; 26 25 27 26 /* register state, for power management functionality */ ··· 35 36 uint64_t fp[FP_REG_COUNT]; 36 37 37 38 uint32_t pal[DC_PAL_COUNT]; 38 - #endif 39 39 }; 40 40 41 41 unsigned int gx_frame_buffer_size(void); ··· 47 49 void gx_configure_display(struct fb_info *info); 48 50 int gx_blank_display(struct fb_info *info, int blank_mode); 49 51 50 - #ifdef CONFIG_PM 51 52 int gx_powerdown(struct fb_info *info); 52 53 int gx_powerup(struct fb_info *info); 53 - #endif 54 - 55 54 56 55 /* Graphics Processor registers (table 6-23 from the data book) */ 57 56 enum gp_registers {
+20 -16
drivers/video/fbdev/geode/gxfb_core.c
··· 322 322 return info; 323 323 } 324 324 325 - #ifdef CONFIG_PM 326 - static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state) 325 + static int __maybe_unused gxfb_suspend(struct device *dev) 327 326 { 328 - struct fb_info *info = pci_get_drvdata(pdev); 327 + struct fb_info *info = dev_get_drvdata(dev); 329 328 330 - if (state.event == PM_EVENT_SUSPEND) { 331 - console_lock(); 332 - gx_powerdown(info); 333 - fb_set_suspend(info, 1); 334 - console_unlock(); 335 - } 329 + console_lock(); 330 + gx_powerdown(info); 331 + fb_set_suspend(info, 1); 332 + console_unlock(); 336 333 337 334 /* there's no point in setting PCI states; we emulate PCI, so 338 335 * we don't end up getting power savings anyways */ ··· 337 340 return 0; 338 341 } 339 342 340 - static int gxfb_resume(struct pci_dev *pdev) 343 + static int __maybe_unused gxfb_resume(struct device *dev) 341 344 { 342 - struct fb_info *info = pci_get_drvdata(pdev); 345 + struct fb_info *info = dev_get_drvdata(dev); 343 346 int ret; 344 347 345 348 console_lock(); ··· 353 356 console_unlock(); 354 357 return 0; 355 358 } 356 - #endif 357 359 358 360 static int gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) 359 361 { ··· 463 467 464 468 MODULE_DEVICE_TABLE(pci, gxfb_id_table); 465 469 470 + static const struct dev_pm_ops gxfb_pm_ops = { 471 + #ifdef CONFIG_PM_SLEEP 472 + .suspend = gxfb_suspend, 473 + .resume = gxfb_resume, 474 + .freeze = NULL, 475 + .thaw = gxfb_resume, 476 + .poweroff = NULL, 477 + .restore = gxfb_resume, 478 + #endif 479 + }; 480 + 466 481 static struct pci_driver gxfb_driver = { 467 482 .name = "gxfb", 468 483 .id_table = gxfb_id_table, 469 484 .probe = gxfb_probe, 470 485 .remove = gxfb_remove, 471 - #ifdef CONFIG_PM 472 - .suspend = gxfb_suspend, 473 - .resume = gxfb_resume, 474 - #endif 486 + .driver.pm = &gxfb_pm_ops, 475 487 }; 476 488 477 489 #ifndef MODULE
-4
drivers/video/fbdev/geode/suspend_gx.c
··· 11 11 12 12 #include "gxfb.h" 13 13 14 - #ifdef CONFIG_PM 15 - 16 14 static void gx_save_regs(struct gxfb_par *par) 17 15 { 18 16 int i; ··· 257 259 par->powered_down = 0; 258 260 return 0; 259 261 } 260 - 261 - #endif