Skip to content

Commit f892a21

Browse files
VARoDeKherbertx
authored andcommitted
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 <[email protected]> Acked-by: John Allen <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 958ea4e commit f892a21

File tree

5 files changed

+13
-22
lines changed

5 files changed

+13
-22
lines changed

drivers/crypto/ccp/ccp-dev.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait)
531531
return len;
532532
}
533533

534-
#ifdef CONFIG_PM
535534
bool ccp_queues_suspended(struct ccp_device *ccp)
536535
{
537536
unsigned int suspended = 0;
@@ -549,7 +548,7 @@ bool ccp_queues_suspended(struct ccp_device *ccp)
549548
return ccp->cmd_q_count == suspended;
550549
}
551550

552-
int ccp_dev_suspend(struct sp_device *sp, pm_message_t state)
551+
int ccp_dev_suspend(struct sp_device *sp)
553552
{
554553
struct ccp_device *ccp = sp->ccp_data;
555554
unsigned long flags;
@@ -601,7 +600,6 @@ int ccp_dev_resume(struct sp_device *sp)
601600

602601
return 0;
603602
}
604-
#endif
605603

606604
int ccp_dev_init(struct sp_device *sp)
607605
{

drivers/crypto/ccp/sp-dev.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,12 @@ void sp_destroy(struct sp_device *sp)
211211
sp_del_device(sp);
212212
}
213213

214-
#ifdef CONFIG_PM
215-
int sp_suspend(struct sp_device *sp, pm_message_t state)
214+
int sp_suspend(struct sp_device *sp)
216215
{
217216
int ret;
218217

219218
if (sp->dev_vdata->ccp_vdata) {
220-
ret = ccp_dev_suspend(sp, state);
219+
ret = ccp_dev_suspend(sp);
221220
if (ret)
222221
return ret;
223222
}
@@ -237,7 +236,6 @@ int sp_resume(struct sp_device *sp)
237236

238237
return 0;
239238
}
240-
#endif
241239

242240
struct sp_device *sp_get_psp_master_device(void)
243241
{

drivers/crypto/ccp/sp-dev.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ int sp_init(struct sp_device *sp);
119119
void sp_destroy(struct sp_device *sp);
120120
struct sp_device *sp_get_master(void);
121121

122-
int sp_suspend(struct sp_device *sp, pm_message_t state);
122+
int sp_suspend(struct sp_device *sp);
123123
int sp_resume(struct sp_device *sp);
124124
int sp_request_ccp_irq(struct sp_device *sp, irq_handler_t handler,
125125
const char *name, void *data);
@@ -134,7 +134,7 @@ struct sp_device *sp_get_psp_master_device(void);
134134
int ccp_dev_init(struct sp_device *sp);
135135
void ccp_dev_destroy(struct sp_device *sp);
136136

137-
int ccp_dev_suspend(struct sp_device *sp, pm_message_t state);
137+
int ccp_dev_suspend(struct sp_device *sp);
138138
int ccp_dev_resume(struct sp_device *sp);
139139

140140
#else /* !CONFIG_CRYPTO_DEV_SP_CCP */
@@ -145,7 +145,7 @@ static inline int ccp_dev_init(struct sp_device *sp)
145145
}
146146
static inline void ccp_dev_destroy(struct sp_device *sp) { }
147147

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)
149149
{
150150
return 0;
151151
}

drivers/crypto/ccp/sp-pci.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,19 @@ static void sp_pci_remove(struct pci_dev *pdev)
252252
sp_free_irqs(sp);
253253
}
254254

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)
257256
{
258-
struct device *dev = &pdev->dev;
259257
struct sp_device *sp = dev_get_drvdata(dev);
260258

261-
return sp_suspend(sp, state);
259+
return sp_suspend(sp);
262260
}
263261

264-
static int sp_pci_resume(struct pci_dev *pdev)
262+
static int __maybe_unused sp_pci_resume(struct device *dev)
265263
{
266-
struct device *dev = &pdev->dev;
267264
struct sp_device *sp = dev_get_drvdata(dev);
268265

269266
return sp_resume(sp);
270267
}
271-
#endif
272268

273269
#ifdef CONFIG_CRYPTO_DEV_SP_PSP
274270
static const struct sev_vdata sevv1 = {
@@ -365,15 +361,14 @@ static const struct pci_device_id sp_pci_table[] = {
365361
};
366362
MODULE_DEVICE_TABLE(pci, sp_pci_table);
367363

364+
static SIMPLE_DEV_PM_OPS(sp_pci_pm_ops, sp_pci_suspend, sp_pci_resume);
365+
368366
static struct pci_driver sp_pci_driver = {
369367
.name = "ccp",
370368
.id_table = sp_pci_table,
371369
.probe = sp_pci_probe,
372370
.remove = sp_pci_remove,
373-
#ifdef CONFIG_PM
374-
.suspend = sp_pci_suspend,
375-
.resume = sp_pci_resume,
376-
#endif
371+
.driver.pm = &sp_pci_pm_ops,
377372
};
378373

379374
int sp_pci_init(void)

drivers/crypto/ccp/sp-platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int sp_platform_suspend(struct platform_device *pdev,
207207
struct device *dev = &pdev->dev;
208208
struct sp_device *sp = dev_get_drvdata(dev);
209209

210-
return sp_suspend(sp, state);
210+
return sp_suspend(sp);
211211
}
212212

213213
static int sp_platform_resume(struct platform_device *pdev)

0 commit comments

Comments
 (0)