diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2020-08-18 01:08:48 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-08-29 09:09:16 +0300 |
commit | 9a8a45f81d3433fa9feeff5983e71a06b0fdc506 (patch) | |
tree | 947e0861afea7b11f954d777b8424e66e7b11274 /drivers/media/platform/marvell-ccic/mmp-driver.c | |
parent | 953e41153a16620f675eda6e7022fd5b3eb58fce (diff) | |
download | linux-9a8a45f81d3433fa9feeff5983e71a06b0fdc506.tar.xz |
media: marvell-ccic: mmp: get rid of mmpcam_devices list
The sole reason for this was so that it would be possible to get a
mmp_camera from a platform_device in suspend/resume/remove hooks, because
drvdata used to be used by the v4l core.
Since commit 95db3a60e065 ("[media] v4l: Add a media_device pointer to the
v4l2_device structure") it is no longer case and thus we can make things
a great deal simpler.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/platform/marvell-ccic/mmp-driver.c')
-rw-r--r-- | drivers/media/platform/marvell-ccic/mmp-driver.c | 78 |
1 files changed, 8 insertions, 70 deletions
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c index 92b92255dac6..f04c01bced2f 100644 --- a/drivers/media/platform/marvell-ccic/mmp-driver.c +++ b/drivers/media/platform/marvell-ccic/mmp-driver.c @@ -47,49 +47,6 @@ static inline struct mmp_camera *mcam_to_cam(struct mcam_camera *mcam) } /* - * A silly little infrastructure so we can keep track of our devices. - * Chances are that we will never have more than one of them, but - * the Armada 610 *does* have two controllers... - */ - -static LIST_HEAD(mmpcam_devices); -static struct mutex mmpcam_devices_lock; - -static void mmpcam_add_device(struct mmp_camera *cam) -{ - mutex_lock(&mmpcam_devices_lock); - list_add(&cam->devlist, &mmpcam_devices); - mutex_unlock(&mmpcam_devices_lock); -} - -static void mmpcam_remove_device(struct mmp_camera *cam) -{ - mutex_lock(&mmpcam_devices_lock); - list_del(&cam->devlist); - mutex_unlock(&mmpcam_devices_lock); -} - -/* - * Platform dev remove passes us a platform_device, and there's - * no handy unused drvdata to stash a backpointer in. So just - * dig it out of our list. - */ -static struct mmp_camera *mmpcam_find_device(struct platform_device *pdev) -{ - struct mmp_camera *cam; - - mutex_lock(&mmpcam_devices_lock); - list_for_each_entry(cam, &mmpcam_devices, devlist) { - if (cam->pdev == pdev) { - mutex_unlock(&mmpcam_devices_lock); - return cam; - } - } - mutex_unlock(&mmpcam_devices_lock); - return NULL; -} - -/* * calc the dphy register values * There are three dphy registers being used. * dphy[0] - CSI2_DPHY3 @@ -227,6 +184,7 @@ static int mmpcam_probe(struct platform_device *pdev) cam = devm_kzalloc(&pdev->dev, sizeof(*cam), GFP_KERNEL); if (cam == NULL) return -ENOMEM; + platform_set_drvdata(pdev, cam); cam->pdev = pdev; INIT_LIST_HEAD(&cam->devlist); @@ -313,11 +271,10 @@ static int mmpcam_probe(struct platform_device *pdev) cam->irq = res->start; ret = devm_request_irq(&pdev->dev, cam->irq, mmpcam_irq, IRQF_SHARED, "mmp-camera", mcam); - if (ret == 0) { - mmpcam_add_device(cam); - return 0; - } + if (ret) + goto out; + return 0; out: fwnode_handle_put(mcam->asd.match.fwnode); mccic_shutdown(mcam); @@ -330,14 +287,13 @@ static int mmpcam_remove(struct mmp_camera *cam) { struct mcam_camera *mcam = &cam->mcam; - mmpcam_remove_device(cam); mccic_shutdown(mcam); return 0; } static int mmpcam_platform_remove(struct platform_device *pdev) { - struct mmp_camera *cam = mmpcam_find_device(pdev); + struct mmp_camera *cam = platform_get_drvdata(pdev); if (cam == NULL) return -ENODEV; @@ -351,7 +307,7 @@ static int mmpcam_platform_remove(struct platform_device *pdev) static int mmpcam_suspend(struct platform_device *pdev, pm_message_t state) { - struct mmp_camera *cam = mmpcam_find_device(pdev); + struct mmp_camera *cam = platform_get_drvdata(pdev); if (state.event != PM_EVENT_SUSPEND) return 0; @@ -361,7 +317,7 @@ static int mmpcam_suspend(struct platform_device *pdev, pm_message_t state) static int mmpcam_resume(struct platform_device *pdev) { - struct mmp_camera *cam = mmpcam_find_device(pdev); + struct mmp_camera *cam = platform_get_drvdata(pdev); return mccic_resume(&cam->mcam); } @@ -387,22 +343,4 @@ static struct platform_driver mmpcam_driver = { } }; - -static int __init mmpcam_init_module(void) -{ - mutex_init(&mmpcam_devices_lock); - return platform_driver_register(&mmpcam_driver); -} - -static void __exit mmpcam_exit_module(void) -{ - platform_driver_unregister(&mmpcam_driver); - /* - * platform_driver_unregister() should have emptied the list - */ - if (!list_empty(&mmpcam_devices)) - printk(KERN_ERR "mmp_camera leaving devices behind\n"); -} - -module_init(mmpcam_init_module); -module_exit(mmpcam_exit_module); +module_platform_driver(mmpcam_driver); |