diff options
author | Steve Longerbeam | 2018-09-29 15:54:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab | 2018-10-04 15:55:38 -0400 |
commit | d079f94c90469f413920b9f2b201537fac2ceb06 (patch) | |
tree | 81c01fba155425c957a7f827963b32efa9e0d872 /drivers/media/platform/pxa_camera.c | |
parent | d5099f81803fc7a7831aa893097fab3cf8d15d3e (diff) |
media: platform: Switch to v4l2_async_notifier_add_subdev
Switch all media platform drivers to call v4l2_async_notifier_add_subdev()
to add asd's to a notifier, in place of referencing the notifier->subdevs[]
array. These drivers also must now call v4l2_async_notifier_init() before
adding asd's to their notifiers.
There may still be cases where a platform driver maintains a list of
asd's that is a duplicate of the notifier asd_list, in which case its
possible the platform driver list can be removed, and can reference the
notifier asd_list instead. One example of where a duplicate list has
been removed in this patch is xilinx-vipp.c. If there are such cases
remaining, those drivers should be optimized to remove the duplicate
platform driver asd lists.
None of the changes to the platform drivers in this patch have been
tested. Verify that the async subdevices needed by the platform are
bound at load time, and that the driver unloads and reloads correctly
with no memory leaking of asd objects.
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/platform/pxa_camera.c')
-rw-r--r-- | drivers/media/platform/pxa_camera.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c index 6717834e8041..2f083acdd269 100644 --- a/drivers/media/platform/pxa_camera.c +++ b/drivers/media/platform/pxa_camera.c @@ -697,7 +697,6 @@ struct pxa_camera_dev { struct v4l2_pix_format current_pix; struct v4l2_async_subdev asd; - struct v4l2_async_subdev *asds[1]; /* * PXA27x is only supposed to handle one camera on its Quick Capture @@ -2352,12 +2351,10 @@ static int pxa_camera_pdata_from_dt(struct device *dev, asd->match_type = V4L2_ASYNC_MATCH_FWNODE; remote = of_graph_get_remote_port(np); - if (remote) { + if (remote) asd->match.fwnode = of_fwnode_handle(remote); - of_node_put(remote); - } else { + else dev_notice(dev, "no remote for %pOF\n", np); - } out: of_node_put(np); @@ -2495,9 +2492,14 @@ static int pxa_camera_probe(struct platform_device *pdev) if (err) goto exit_deactivate; - pcdev->asds[0] = &pcdev->asd; - pcdev->notifier.subdevs = pcdev->asds; - pcdev->notifier.num_subdevs = 1; + v4l2_async_notifier_init(&pcdev->notifier); + + err = v4l2_async_notifier_add_subdev(&pcdev->notifier, &pcdev->asd); + if (err) { + fwnode_handle_put(pcdev->asd.match.fwnode); + goto exit_free_v4l2dev; + } + pcdev->notifier.ops = &pxa_camera_sensor_ops; if (!of_have_populated_dt()) @@ -2505,7 +2507,7 @@ static int pxa_camera_probe(struct platform_device *pdev) err = pxa_camera_init_videobuf2(pcdev); if (err) - goto exit_free_v4l2dev; + goto exit_notifier_cleanup; if (pcdev->mclk) { v4l2_clk_name_i2c(clk_name, sizeof(clk_name), @@ -2516,7 +2518,7 @@ static int pxa_camera_probe(struct platform_device *pdev) clk_name, NULL); if (IS_ERR(pcdev->mclk_clk)) { err = PTR_ERR(pcdev->mclk_clk); - goto exit_free_v4l2dev; + goto exit_notifier_cleanup; } } @@ -2527,6 +2529,8 @@ static int pxa_camera_probe(struct platform_device *pdev) return 0; exit_free_clk: v4l2_clk_unregister(pcdev->mclk_clk); +exit_notifier_cleanup: + v4l2_async_notifier_cleanup(&pcdev->notifier); exit_free_v4l2dev: v4l2_device_unregister(&pcdev->v4l2_dev); exit_deactivate: @@ -2550,6 +2554,7 @@ static int pxa_camera_remove(struct platform_device *pdev) dma_release_channel(pcdev->dma_chans[2]); v4l2_async_notifier_unregister(&pcdev->notifier); + v4l2_async_notifier_cleanup(&pcdev->notifier); if (pcdev->mclk_clk) { v4l2_clk_unregister(pcdev->mclk_clk); |