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

misc/tifm_7xx1.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.

The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use
device_wakeup_disable() instead.

Compile-tested only.

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

authored by

Vaibhav Gupta and committed by
Greg Kroah-Hartman
ff249c1c 6bf23661

+8 -22
+8 -22
drivers/misc/tifm_7xx1.c
··· 207 207 spin_unlock_irqrestore(&fm->lock, flags); 208 208 } 209 209 210 - #ifdef CONFIG_PM 211 - 212 - static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state) 210 + static int __maybe_unused tifm_7xx1_suspend(struct device *dev_d) 213 211 { 212 + struct pci_dev *dev = to_pci_dev(dev_d); 214 213 struct tifm_adapter *fm = pci_get_drvdata(dev); 215 214 int cnt; 216 215 ··· 220 221 tifm_7xx1_sock_power_off(fm->sockets[cnt]->addr); 221 222 } 222 223 223 - pci_save_state(dev); 224 - pci_enable_wake(dev, pci_choose_state(dev, state), 0); 225 - pci_disable_device(dev); 226 - pci_set_power_state(dev, pci_choose_state(dev, state)); 224 + device_wakeup_disable(dev_d); 227 225 return 0; 228 226 } 229 227 230 - static int tifm_7xx1_resume(struct pci_dev *dev) 228 + static int __maybe_unused tifm_7xx1_resume(struct device *dev_d) 231 229 { 230 + struct pci_dev *dev = to_pci_dev(dev_d); 232 231 struct tifm_adapter *fm = pci_get_drvdata(dev); 233 232 int rc; 234 233 unsigned long timeout; ··· 239 242 if (WARN_ON(fm->num_sockets > ARRAY_SIZE(new_ids))) 240 243 return -ENXIO; 241 244 242 - pci_set_power_state(dev, PCI_D0); 243 - pci_restore_state(dev); 244 - rc = pci_enable_device(dev); 245 - if (rc) 246 - return rc; 247 245 pci_set_master(dev); 248 246 249 247 dev_dbg(&dev->dev, "resuming host\n"); ··· 288 296 289 297 return 0; 290 298 } 291 - 292 - #else 293 - 294 - #define tifm_7xx1_suspend NULL 295 - #define tifm_7xx1_resume NULL 296 - 297 - #endif /* CONFIG_PM */ 298 299 299 300 static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm, 300 301 struct tifm_dev *sock) ··· 409 424 { } 410 425 }; 411 426 427 + static SIMPLE_DEV_PM_OPS(tifm_7xx1_pm_ops, tifm_7xx1_suspend, tifm_7xx1_resume); 428 + 412 429 static struct pci_driver tifm_7xx1_driver = { 413 430 .name = DRIVER_NAME, 414 431 .id_table = tifm_7xx1_pci_tbl, 415 432 .probe = tifm_7xx1_probe, 416 433 .remove = tifm_7xx1_remove, 417 - .suspend = tifm_7xx1_suspend, 418 - .resume = tifm_7xx1_resume, 434 + .driver.pm = &tifm_7xx1_pm_ops, 419 435 }; 420 436 421 437 module_pci_driver(tifm_7xx1_driver);