Skip to content

Commit 68e966a

Browse files
VARoDeKmchehab
authored andcommitted
media: tw68: use generic power management
With legacy PM, drivers themselves were responsible for managing the device's power states and takes care of register states. After upgrading to the generic structure, PCI core will take care of required tasks and drivers should do only device-specific operations. The driver was invoking PCI helper functions like pci_save/restore_state() which is not recommended. Compile-Tested only. Signed-off-by: Vaibhav Gupta <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 9c4a848 commit 68e966a

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

drivers/media/pci/tw68/tw68-core.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,9 @@ static void tw68_finidev(struct pci_dev *pci_dev)
359359
v4l2_device_unregister(&dev->v4l2_dev);
360360
}
361361

362-
#ifdef CONFIG_PM
363-
364-
static int tw68_suspend(struct pci_dev *pci_dev , pm_message_t state)
362+
static int __maybe_unused tw68_suspend(struct device *dev_d)
365363
{
364+
struct pci_dev *pci_dev = to_pci_dev(dev_d);
366365
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
367366
struct tw68_dev *dev = container_of(v4l2_dev,
368367
struct tw68_dev, v4l2_dev);
@@ -373,24 +372,19 @@ static int tw68_suspend(struct pci_dev *pci_dev , pm_message_t state)
373372

374373
synchronize_irq(pci_dev->irq);
375374

376-
pci_save_state(pci_dev);
377-
pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
378375
vb2_discard_done(&dev->vidq);
379376

380377
return 0;
381378
}
382379

383-
static int tw68_resume(struct pci_dev *pci_dev)
380+
static int __maybe_unused tw68_resume(struct device *dev_d)
384381
{
385-
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
382+
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev_d);
386383
struct tw68_dev *dev = container_of(v4l2_dev,
387384
struct tw68_dev, v4l2_dev);
388385
struct tw68_buf *buf;
389386
unsigned long flags;
390387

391-
pci_set_power_state(pci_dev, PCI_D0);
392-
pci_restore_state(pci_dev);
393-
394388
/* Do things that are done in tw68_initdev ,
395389
except of initializing memory structures.*/
396390

@@ -408,19 +402,17 @@ static int tw68_resume(struct pci_dev *pci_dev)
408402

409403
return 0;
410404
}
411-
#endif
412405

413406
/* ----------------------------------------------------------- */
414407

408+
static SIMPLE_DEV_PM_OPS(tw68_pm_ops, tw68_suspend, tw68_resume);
409+
415410
static struct pci_driver tw68_pci_driver = {
416-
.name = "tw68",
417-
.id_table = tw68_pci_tbl,
418-
.probe = tw68_initdev,
419-
.remove = tw68_finidev,
420-
#ifdef CONFIG_PM
421-
.suspend = tw68_suspend,
422-
.resume = tw68_resume
423-
#endif
411+
.name = "tw68",
412+
.id_table = tw68_pci_tbl,
413+
.probe = tw68_initdev,
414+
.remove = tw68_finidev,
415+
.driver.pm = &tw68_pm_ops,
424416
};
425417

426418
module_pci_driver(tw68_pci_driver);

0 commit comments

Comments
 (0)