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

crypto: ccp - use generic power management

Drivers using legacy power management .suspen()/.resume() callbacks
have to manage PCI states and device's PM states themselves. They also
need to take care of standard configuration registers.

Switch to generic power management framework using a single
"struct dev_pm_ops" variable to take the unnecessary load from the driver.
This also avoids the need for the driver to directly call most of the PCI
helper functions and device power state control functions as through
the generic framework, PCI Core takes care of the necessary operations,
and drivers are required to do only device-specific jobs.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Acked-by: John Allen <john.allen@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Vaibhav Gupta and committed by
Herbert Xu
f892a21f 958ea4e0

+13 -22
+1 -3
drivers/crypto/ccp/ccp-dev.c
··· 531 531 return len; 532 532 } 533 533 534 - #ifdef CONFIG_PM 535 534 bool ccp_queues_suspended(struct ccp_device *ccp) 536 535 { 537 536 unsigned int suspended = 0; ··· 548 549 return ccp->cmd_q_count == suspended; 549 550 } 550 551 551 - int ccp_dev_suspend(struct sp_device *sp, pm_message_t state) 552 + int ccp_dev_suspend(struct sp_device *sp) 552 553 { 553 554 struct ccp_device *ccp = sp->ccp_data; 554 555 unsigned long flags; ··· 600 601 601 602 return 0; 602 603 } 603 - #endif 604 604 605 605 int ccp_dev_init(struct sp_device *sp) 606 606 {
+2 -4
drivers/crypto/ccp/sp-dev.c
··· 211 211 sp_del_device(sp); 212 212 } 213 213 214 - #ifdef CONFIG_PM 215 - int sp_suspend(struct sp_device *sp, pm_message_t state) 214 + int sp_suspend(struct sp_device *sp) 216 215 { 217 216 int ret; 218 217 219 218 if (sp->dev_vdata->ccp_vdata) { 220 - ret = ccp_dev_suspend(sp, state); 219 + ret = ccp_dev_suspend(sp); 221 220 if (ret) 222 221 return ret; 223 222 } ··· 236 237 237 238 return 0; 238 239 } 239 - #endif 240 240 241 241 struct sp_device *sp_get_psp_master_device(void) 242 242 {
+3 -3
drivers/crypto/ccp/sp-dev.h
··· 119 119 void sp_destroy(struct sp_device *sp); 120 120 struct sp_device *sp_get_master(void); 121 121 122 - int sp_suspend(struct sp_device *sp, pm_message_t state); 122 + int sp_suspend(struct sp_device *sp); 123 123 int sp_resume(struct sp_device *sp); 124 124 int sp_request_ccp_irq(struct sp_device *sp, irq_handler_t handler, 125 125 const char *name, void *data); ··· 134 134 int ccp_dev_init(struct sp_device *sp); 135 135 void ccp_dev_destroy(struct sp_device *sp); 136 136 137 - int ccp_dev_suspend(struct sp_device *sp, pm_message_t state); 137 + int ccp_dev_suspend(struct sp_device *sp); 138 138 int ccp_dev_resume(struct sp_device *sp); 139 139 140 140 #else /* !CONFIG_CRYPTO_DEV_SP_CCP */ ··· 145 145 } 146 146 static inline void ccp_dev_destroy(struct sp_device *sp) { } 147 147 148 - static inline int ccp_dev_suspend(struct sp_device *sp, pm_message_t state) 148 + static inline int ccp_dev_suspend(struct sp_device *sp) 149 149 { 150 150 return 0; 151 151 }
+6 -11
drivers/crypto/ccp/sp-pci.c
··· 252 252 sp_free_irqs(sp); 253 253 } 254 254 255 - #ifdef CONFIG_PM 256 - static int sp_pci_suspend(struct pci_dev *pdev, pm_message_t state) 255 + static int __maybe_unused sp_pci_suspend(struct device *dev) 257 256 { 258 - struct device *dev = &pdev->dev; 259 257 struct sp_device *sp = dev_get_drvdata(dev); 260 258 261 - return sp_suspend(sp, state); 259 + return sp_suspend(sp); 262 260 } 263 261 264 - static int sp_pci_resume(struct pci_dev *pdev) 262 + static int __maybe_unused sp_pci_resume(struct device *dev) 265 263 { 266 - struct device *dev = &pdev->dev; 267 264 struct sp_device *sp = dev_get_drvdata(dev); 268 265 269 266 return sp_resume(sp); 270 267 } 271 - #endif 272 268 273 269 #ifdef CONFIG_CRYPTO_DEV_SP_PSP 274 270 static const struct sev_vdata sevv1 = { ··· 361 365 }; 362 366 MODULE_DEVICE_TABLE(pci, sp_pci_table); 363 367 368 + static SIMPLE_DEV_PM_OPS(sp_pci_pm_ops, sp_pci_suspend, sp_pci_resume); 369 + 364 370 static struct pci_driver sp_pci_driver = { 365 371 .name = "ccp", 366 372 .id_table = sp_pci_table, 367 373 .probe = sp_pci_probe, 368 374 .remove = sp_pci_remove, 369 - #ifdef CONFIG_PM 370 - .suspend = sp_pci_suspend, 371 - .resume = sp_pci_resume, 372 - #endif 375 + .driver.pm = &sp_pci_pm_ops, 373 376 }; 374 377 375 378 int sp_pci_init(void)
+1 -1
drivers/crypto/ccp/sp-platform.c
··· 207 207 struct device *dev = &pdev->dev; 208 208 struct sp_device *sp = dev_get_drvdata(dev); 209 209 210 - return sp_suspend(sp, state); 210 + return sp_suspend(sp); 211 211 } 212 212 213 213 static int sp_platform_resume(struct platform_device *pdev)