diff options
author | Steve Longerbeam <slongerbeam@gmail.com> | 2018-09-29 15:54:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-10-04 15:55:38 -0400 |
commit | d079f94c90469f413920b9f2b201537fac2ceb06 (patch) | |
tree | 81c01fba155425c957a7f827963b32efa9e0d872 /drivers/media/platform/stm32 | |
parent | d5099f81803fc7a7831aa893097fab3cf8d15d3e (diff) | |
download | linux-d079f94c90469f413920b9f2b201537fac2ceb06.tar.bz2 |
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/stm32')
-rw-r--r-- | drivers/media/platform/stm32/stm32-dcmi.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index d6b00eda6b9b..48f514d7e34f 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -1590,7 +1590,6 @@ static int dcmi_graph_parse(struct stm32_dcmi *dcmi, struct device_node *node) static int dcmi_graph_init(struct stm32_dcmi *dcmi) { - struct v4l2_async_subdev **subdevs = NULL; int ret; /* Parse the graph to extract a list of subdevice DT nodes. */ @@ -1600,23 +1599,21 @@ static int dcmi_graph_init(struct stm32_dcmi *dcmi) return ret; } - /* Register the subdevices notifier. */ - subdevs = devm_kzalloc(dcmi->dev, sizeof(*subdevs), GFP_KERNEL); - if (!subdevs) { + v4l2_async_notifier_init(&dcmi->notifier); + + ret = v4l2_async_notifier_add_subdev(&dcmi->notifier, + &dcmi->entity.asd); + if (ret) { of_node_put(dcmi->entity.node); - return -ENOMEM; + return ret; } - subdevs[0] = &dcmi->entity.asd; - - dcmi->notifier.subdevs = subdevs; - dcmi->notifier.num_subdevs = 1; dcmi->notifier.ops = &dcmi_graph_notify_ops; ret = v4l2_async_notifier_register(&dcmi->v4l2_dev, &dcmi->notifier); if (ret < 0) { dev_err(dcmi->dev, "Notifier registration failed\n"); - of_node_put(dcmi->entity.node); + v4l2_async_notifier_cleanup(&dcmi->notifier); return ret; } @@ -1773,7 +1770,7 @@ static int dcmi_probe(struct platform_device *pdev) ret = reset_control_assert(dcmi->rstc); if (ret) { dev_err(&pdev->dev, "Failed to assert the reset line\n"); - goto err_device_release; + goto err_cleanup; } usleep_range(3000, 5000); @@ -1781,7 +1778,7 @@ static int dcmi_probe(struct platform_device *pdev) ret = reset_control_deassert(dcmi->rstc); if (ret) { dev_err(&pdev->dev, "Failed to deassert the reset line\n"); - goto err_device_release; + goto err_cleanup; } dev_info(&pdev->dev, "Probe done\n"); @@ -1792,6 +1789,8 @@ static int dcmi_probe(struct platform_device *pdev) return 0; +err_cleanup: + v4l2_async_notifier_cleanup(&dcmi->notifier); err_device_release: video_device_release(dcmi->vdev); err_device_unregister: @@ -1809,6 +1808,7 @@ static int dcmi_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); v4l2_async_notifier_unregister(&dcmi->notifier); + v4l2_async_notifier_cleanup(&dcmi->notifier); v4l2_device_unregister(&dcmi->v4l2_dev); dma_release_channel(dcmi->dma_chan); |