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

cb710/core.c: use generic power management

Drivers should not use legacy power management as they have to manage power
states and related operations, for the device, themselves. This driver was
handling them with the help of PCI helper functions like
pci_save/restore_state(), pci_enable/disable_device(), etc.

With generic PM, all essentials will be handled by the PCI core. Driver
needs to do only device-specific operations.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Link: https://lore.kernel.org/r/20200629081531.214734-2-vaibhavgupta40@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vaibhav Gupta and committed by
Greg Kroah-Hartman
69b4bf2b ae56942c

+7 -21
+7 -21
drivers/misc/cb710/core.c
··· 166 166 } 167 167 EXPORT_SYMBOL_GPL(cb710_set_irq_handler); 168 168 169 - #ifdef CONFIG_PM 170 - 171 - static int cb710_suspend(struct pci_dev *pdev, pm_message_t state) 169 + static int __maybe_unused cb710_suspend(struct device *dev_d) 172 170 { 171 + struct pci_dev *pdev = to_pci_dev(dev_d); 173 172 struct cb710_chip *chip = pci_get_drvdata(pdev); 174 173 175 174 devm_free_irq(&pdev->dev, pdev->irq, chip); 176 - pci_save_state(pdev); 177 - pci_disable_device(pdev); 178 - if (state.event & PM_EVENT_SLEEP) 179 - pci_set_power_state(pdev, PCI_D3hot); 180 175 return 0; 181 176 } 182 177 183 - static int cb710_resume(struct pci_dev *pdev) 178 + static int __maybe_unused cb710_resume(struct device *dev_d) 184 179 { 180 + struct pci_dev *pdev = to_pci_dev(dev_d); 185 181 struct cb710_chip *chip = pci_get_drvdata(pdev); 186 - int err; 187 - 188 - pci_set_power_state(pdev, PCI_D0); 189 - pci_restore_state(pdev); 190 - err = pcim_enable_device(pdev); 191 - if (err) 192 - return err; 193 182 194 183 return devm_request_irq(&pdev->dev, pdev->irq, 195 184 cb710_irq_handler, IRQF_SHARED, KBUILD_MODNAME, chip); 196 185 } 197 - 198 - #endif /* CONFIG_PM */ 199 186 200 187 static int cb710_probe(struct pci_dev *pdev, 201 188 const struct pci_device_id *ent) ··· 299 312 { 0, } 300 313 }; 301 314 315 + static SIMPLE_DEV_PM_OPS(cb710_pm_ops, cb710_suspend, cb710_resume); 316 + 302 317 static struct pci_driver cb710_driver = { 303 318 .name = KBUILD_MODNAME, 304 319 .id_table = cb710_pci_tbl, 305 320 .probe = cb710_probe, 306 321 .remove = cb710_remove_one, 307 - #ifdef CONFIG_PM 308 - .suspend = cb710_suspend, 309 - .resume = cb710_resume, 310 - #endif 322 + .driver.pm = &cb710_pm_ops, 311 323 }; 312 324 313 325 static int __init cb710_init_module(void)