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]>
---
.../media/platform/marvell-ccic/cafe-driver.c | 31 +++++--------------
.../media/platform/marvell-ccic/mcam-core.c | 3 --
2 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 9a09a10a3631..58b9915ac7a4 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -604,44 +604,28 @@ static void cafe_pci_remove(struct pci_dev *pdev)
}
-#ifdef CONFIG_PM
/*
* Basic power management.
*/
-static int cafe_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused cafe_pci_suspend(struct device *dev)
{
- struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
- int ret;
- ret = pci_save_state(pdev);
- if (ret)
- return ret;
mccic_suspend(&cam->mcam);
- pci_disable_device(pdev);
return 0;
}
-static int cafe_pci_resume(struct pci_dev *pdev)
+static int __maybe_unused cafe_pci_resume(struct device *dev)
{
- struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
- int ret = 0;
- pci_restore_state(pdev);
- ret = pci_enable_device(pdev);
-
- if (ret) {
- cam_warn(cam, "Unable to re-enable device on resume!\n");
- return ret;
- }
cafe_ctlr_init(&cam->mcam);
return mccic_resume(&cam->mcam);
}
-#endif /* CONFIG_PM */
-
static const struct pci_device_id cafe_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL,
PCI_DEVICE_ID_MARVELL_88ALP01_CCIC) },
@@ -650,15 +634,14 @@ static const struct pci_device_id cafe_ids[] = {
MODULE_DEVICE_TABLE(pci, cafe_ids);
+static SIMPLE_DEV_PM_OPS(cafe_pci_pm_ops, cafe_pci_suspend, cafe_pci_resume);
+
static struct pci_driver cafe_pci_driver = {
.name = "cafe1000-ccic",
.id_table = cafe_ids,
.probe = cafe_pci_probe,
.remove = cafe_pci_remove,
-#ifdef CONFIG_PM
- .suspend = cafe_pci_suspend,
- .resume = cafe_pci_resume,
-#endif
+ .driver.pm = &cafe_pci_pm_ops,
};
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 09775b6624c6..d81d0c130e3c 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1967,8 +1967,6 @@ EXPORT_SYMBOL_GPL(mccic_shutdown);
/*
* Power management
*/
-#ifdef CONFIG_PM
-
void mccic_suspend(struct mcam_camera *cam)
{
mutex_lock(&cam->s_mutex);
@@ -2015,7 +2013,6 @@ int mccic_resume(struct mcam_camera *cam)
return ret;
}
EXPORT_SYMBOL_GPL(mccic_resume);
-#endif /* CONFIG_PM */
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Jonathan Corbet <[email protected]>");
--
2.27.0
Hi Vaibhav,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v5.8-rc6 next-20200720]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Vaibhav-Gupta/media-cafe-driver-use-generic-power-management/20200721-015153
base: git://linuxtv.org/media_tree.git master
config: alpha-allmodconfig (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All error/warnings (new ones prefixed by >>):
drivers/media/platform/marvell-ccic/cafe-driver.c: In function 'cafe_pci_suspend':
>> drivers/media/platform/marvell-ccic/cafe-driver.c:615:2: error: implicit declaration of function 'mccic_suspend' [-Werror=implicit-function-declaration]
615 | mccic_suspend(&cam->mcam);
| ^~~~~~~~~~~~~
drivers/media/platform/marvell-ccic/cafe-driver.c: In function 'cafe_pci_resume':
>> drivers/media/platform/marvell-ccic/cafe-driver.c:626:9: error: implicit declaration of function 'mccic_resume'; did you mean 'mccic_register'? [-Werror=implicit-function-declaration]
626 | return mccic_resume(&cam->mcam);
| ^~~~~~~~~~~~
| mccic_register
cc1: some warnings being treated as errors
--
>> drivers/media/platform/marvell-ccic/mcam-core.c:1972:6: warning: no previous prototype for 'mccic_suspend' [-Wmissing-prototypes]
1972 | void mccic_suspend(struct mcam_camera *cam)
| ^~~~~~~~~~~~~
>> drivers/media/platform/marvell-ccic/mcam-core.c:1987:5: warning: no previous prototype for 'mccic_resume' [-Wmissing-prototypes]
1987 | int mccic_resume(struct mcam_camera *cam)
| ^~~~~~~~~~~~
vim +/mccic_suspend +615 drivers/media/platform/marvell-ccic/cafe-driver.c
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 605
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 606
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 607 /*
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 608 * Basic power management.
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 609 */
0ad4543b81ce3b drivers/media/platform/marvell-ccic/cafe-driver.c Vaibhav Gupta 2020-07-20 610 static int __maybe_unused cafe_pci_suspend(struct device *dev)
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 611 {
0ad4543b81ce3b drivers/media/platform/marvell-ccic/cafe-driver.c Vaibhav Gupta 2020-07-20 612 struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 613 struct cafe_camera *cam = to_cam(v4l2_dev);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 614
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 @615 mccic_suspend(&cam->mcam);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 616 return 0;
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 617 }
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 618
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 619
0ad4543b81ce3b drivers/media/platform/marvell-ccic/cafe-driver.c Vaibhav Gupta 2020-07-20 620 static int __maybe_unused cafe_pci_resume(struct device *dev)
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 621 {
0ad4543b81ce3b drivers/media/platform/marvell-ccic/cafe-driver.c Vaibhav Gupta 2020-07-20 622 struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 623 struct cafe_camera *cam = to_cam(v4l2_dev);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 624
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 625 cafe_ctlr_init(&cam->mcam);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 @626 return mccic_resume(&cam->mcam);
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 627 }
abfa3df36c01a3 drivers/media/video/marvell-ccic/cafe-driver.c Jonathan Corbet 2011-06-11 628
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
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]>
---
.../media/platform/marvell-ccic/cafe-driver.c | 31 +++++--------------
.../media/platform/marvell-ccic/mcam-core.c | 3 --
.../media/platform/marvell-ccic/mcam-core.h | 2 --
3 files changed, 7 insertions(+), 29 deletions(-)
diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 9a09a10a3631..58b9915ac7a4 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -604,44 +604,28 @@ static void cafe_pci_remove(struct pci_dev *pdev)
}
-#ifdef CONFIG_PM
/*
* Basic power management.
*/
-static int cafe_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused cafe_pci_suspend(struct device *dev)
{
- struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
- int ret;
- ret = pci_save_state(pdev);
- if (ret)
- return ret;
mccic_suspend(&cam->mcam);
- pci_disable_device(pdev);
return 0;
}
-static int cafe_pci_resume(struct pci_dev *pdev)
+static int __maybe_unused cafe_pci_resume(struct device *dev)
{
- struct v4l2_device *v4l2_dev = dev_get_drvdata(&pdev->dev);
+ struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
struct cafe_camera *cam = to_cam(v4l2_dev);
- int ret = 0;
- pci_restore_state(pdev);
- ret = pci_enable_device(pdev);
-
- if (ret) {
- cam_warn(cam, "Unable to re-enable device on resume!\n");
- return ret;
- }
cafe_ctlr_init(&cam->mcam);
return mccic_resume(&cam->mcam);
}
-#endif /* CONFIG_PM */
-
static const struct pci_device_id cafe_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL,
PCI_DEVICE_ID_MARVELL_88ALP01_CCIC) },
@@ -650,15 +634,14 @@ static const struct pci_device_id cafe_ids[] = {
MODULE_DEVICE_TABLE(pci, cafe_ids);
+static SIMPLE_DEV_PM_OPS(cafe_pci_pm_ops, cafe_pci_suspend, cafe_pci_resume);
+
static struct pci_driver cafe_pci_driver = {
.name = "cafe1000-ccic",
.id_table = cafe_ids,
.probe = cafe_pci_probe,
.remove = cafe_pci_remove,
-#ifdef CONFIG_PM
- .suspend = cafe_pci_suspend,
- .resume = cafe_pci_resume,
-#endif
+ .driver.pm = &cafe_pci_pm_ops,
};
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.c b/drivers/media/platform/marvell-ccic/mcam-core.c
index 09775b6624c6..d81d0c130e3c 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.c
+++ b/drivers/media/platform/marvell-ccic/mcam-core.c
@@ -1967,8 +1967,6 @@ EXPORT_SYMBOL_GPL(mccic_shutdown);
/*
* Power management
*/
-#ifdef CONFIG_PM
-
void mccic_suspend(struct mcam_camera *cam)
{
mutex_lock(&cam->s_mutex);
@@ -2015,7 +2013,6 @@ int mccic_resume(struct mcam_camera *cam)
return ret;
}
EXPORT_SYMBOL_GPL(mccic_resume);
-#endif /* CONFIG_PM */
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Jonathan Corbet <[email protected]>");
diff --git a/drivers/media/platform/marvell-ccic/mcam-core.h b/drivers/media/platform/marvell-ccic/mcam-core.h
index 2e3a7567a76a..b55545822fd2 100644
--- a/drivers/media/platform/marvell-ccic/mcam-core.h
+++ b/drivers/media/platform/marvell-ccic/mcam-core.h
@@ -236,10 +236,8 @@ static inline void mcam_reg_set_bit(struct mcam_camera *cam,
int mccic_register(struct mcam_camera *cam);
int mccic_irq(struct mcam_camera *cam, unsigned int irqs);
void mccic_shutdown(struct mcam_camera *cam);
-#ifdef CONFIG_PM
void mccic_suspend(struct mcam_camera *cam);
int mccic_resume(struct mcam_camera *cam);
-#endif
/*
* Register definitions for the m88alp01 camera interface. Offsets in bytes
--
2.27.0