Skip to content

Commit e3083c3

Browse files
VARoDeKmchehab
authored andcommitted
media: cafe-driver: use generic power management
Drivers using legacy PM have to manage PCI states and device's PM states themselves. They also need to take care of configuration registers. With improved and powerful support of generic PM, PCI Core takes care of above mentioned, device-independent, jobs. This driver makes use of PCI helper functions like pci_save/restore_state() and pci_enable/disable_device() to do required operations. In generic mode, they are no longer needed. Change function parameter in both .suspend() and .resume() to "struct device*" type. 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 7aa87db commit e3083c3

File tree

3 files changed

+7
-29
lines changed

3 files changed

+7
-29
lines changed

drivers/media/platform/marvell-ccic/cafe-driver.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -604,44 +604,28 @@ static void cafe_pci_remove(struct pci_dev *pdev)
604604
}
605605

606606

607-
#ifdef CONFIG_PM
608607
/*
609608
* Basic power management.
610609
*/
611-
static int cafe_pci_suspend(struct pci_dev *pdev, pm_message_t state)
610+
static int __maybe_unused cafe_pci_suspend(struct device *dev)
612611
{
613-
struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
612+
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
614613
struct cafe_camera *cam = to_cam(v4l2_dev);
615-
int ret;
616614

617-
ret = pci_save_state(pdev);
618-
if (ret)
619-
return ret;
620615
mccic_suspend(&cam->mcam);
621-
pci_disable_device(pdev);
622616
return 0;
623617
}
624618

625619

626-
static int cafe_pci_resume(struct pci_dev *pdev)
620+
static int __maybe_unused cafe_pci_resume(struct device *dev)
627621
{
628-
struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
622+
struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
629623
struct cafe_camera *cam = to_cam(v4l2_dev);
630-
int ret = 0;
631624

632-
pci_restore_state(pdev);
633-
ret = pci_enable_device(pdev);
634-
635-
if (ret) {
636-
cam_warn(cam, "Unable to re-enable device on resume!\n");
637-
return ret;
638-
}
639625
cafe_ctlr_init(&cam->mcam);
640626
return mccic_resume(&cam->mcam);
641627
}
642628

643-
#endif /* CONFIG_PM */
644-
645629
static const struct pci_device_id cafe_ids[] = {
646630
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL,
647631
PCI_DEVICE_ID_MARVELL_88ALP01_CCIC) },
@@ -650,15 +634,14 @@ static const struct pci_device_id cafe_ids[] = {
650634

651635
MODULE_DEVICE_TABLE(pci, cafe_ids);
652636

637+
static SIMPLE_DEV_PM_OPS(cafe_pci_pm_ops, cafe_pci_suspend, cafe_pci_resume);
638+
653639
static struct pci_driver cafe_pci_driver = {
654640
.name = "cafe1000-ccic",
655641
.id_table = cafe_ids,
656642
.probe = cafe_pci_probe,
657643
.remove = cafe_pci_remove,
658-
#ifdef CONFIG_PM
659-
.suspend = cafe_pci_suspend,
660-
.resume = cafe_pci_resume,
661-
#endif
644+
.driver.pm = &cafe_pci_pm_ops,
662645
};
663646

664647

drivers/media/platform/marvell-ccic/mcam-core.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,8 +1969,6 @@ EXPORT_SYMBOL_GPL(mccic_shutdown);
19691969
/*
19701970
* Power management
19711971
*/
1972-
#ifdef CONFIG_PM
1973-
19741972
void mccic_suspend(struct mcam_camera *cam)
19751973
{
19761974
mutex_lock(&cam->s_mutex);
@@ -2017,7 +2015,6 @@ int mccic_resume(struct mcam_camera *cam)
20172015
return ret;
20182016
}
20192017
EXPORT_SYMBOL_GPL(mccic_resume);
2020-
#endif /* CONFIG_PM */
20212018

20222019
MODULE_LICENSE("GPL v2");
20232020
MODULE_AUTHOR("Jonathan Corbet <[email protected]>");

drivers/media/platform/marvell-ccic/mcam-core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,8 @@ static inline void mcam_reg_set_bit(struct mcam_camera *cam,
236236
int mccic_register(struct mcam_camera *cam);
237237
int mccic_irq(struct mcam_camera *cam, unsigned int irqs);
238238
void mccic_shutdown(struct mcam_camera *cam);
239-
#ifdef CONFIG_PM
240239
void mccic_suspend(struct mcam_camera *cam);
241240
int mccic_resume(struct mcam_camera *cam);
242-
#endif
243241

244242
/*
245243
* Register definitions for the m88alp01 camera interface. Offsets in bytes

0 commit comments

Comments
 (0)