mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 16:41:58 +00:00
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 <vaibhavgupta40@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
7aa87db5b8
commit
e3083c3f36
@ -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,
|
||||
};
|
||||
|
||||
|
||||
|
@ -1969,8 +1969,6 @@ EXPORT_SYMBOL_GPL(mccic_shutdown);
|
||||
/*
|
||||
* Power management
|
||||
*/
|
||||
#ifdef CONFIG_PM
|
||||
|
||||
void mccic_suspend(struct mcam_camera *cam)
|
||||
{
|
||||
mutex_lock(&cam->s_mutex);
|
||||
@ -2017,7 +2015,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 <corbet@lwn.net>");
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user