aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/stm32/stm32-dcmi.c
diff options
context:
space:
mode:
authorSteve Longerbeam <slongerbeam@gmail.com>2018-09-29 15:54:18 -0400
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-10-04 15:55:38 -0400
commitd079f94c90469f413920b9f2b201537fac2ceb06 (patch)
tree81c01fba155425c957a7f827963b32efa9e0d872 /drivers/media/platform/stm32/stm32-dcmi.c
parentd5099f81803fc7a7831aa893097fab3cf8d15d3e (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/stm32/stm32-dcmi.c')
-rw-r--r--drivers/media/platform/stm32/stm32-dcmi.c24
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)
1590 1590
1591static int dcmi_graph_init(struct stm32_dcmi *dcmi) 1591static int dcmi_graph_init(struct stm32_dcmi *dcmi)
1592{ 1592{
1593 struct v4l2_async_subdev **subdevs = NULL;
1594 int ret; 1593 int ret;
1595 1594
1596 /* Parse the graph to extract a list of subdevice DT nodes. */ 1595 /* Parse the graph to extract a list of subdevice DT nodes. */
@@ -1600,23 +1599,21 @@ static int dcmi_graph_init(struct stm32_dcmi *dcmi)
1600 return ret; 1599 return ret;
1601 } 1600 }
1602 1601
1603 /* Register the subdevices notifier. */ 1602 v4l2_async_notifier_init(&dcmi->notifier);
1604 subdevs = devm_kzalloc(dcmi->dev, sizeof(*subdevs), GFP_KERNEL); 1603
1605 if (!subdevs) { 1604 ret = v4l2_async_notifier_add_subdev(&dcmi->notifier,
1605 &dcmi->entity.asd);
1606 if (ret) {
1606 of_node_put(dcmi->entity.node); 1607 of_node_put(dcmi->entity.node);
1607 return -ENOMEM; 1608 return ret;
1608 } 1609 }
1609 1610
1610 subdevs[0] = &dcmi->entity.asd;
1611
1612 dcmi->notifier.subdevs = subdevs;
1613 dcmi->notifier.num_subdevs = 1;
1614 dcmi->notifier.ops = &dcmi_graph_notify_ops; 1611 dcmi->notifier.ops = &dcmi_graph_notify_ops;
1615 1612
1616 ret = v4l2_async_notifier_register(&dcmi->v4l2_dev, &dcmi->notifier); 1613 ret = v4l2_async_notifier_register(&dcmi->v4l2_dev, &dcmi->notifier);
1617 if (ret < 0) { 1614 if (ret < 0) {
1618 dev_err(dcmi->dev, "Notifier registration failed\n"); 1615 dev_err(dcmi->dev, "Notifier registration failed\n");
1619 of_node_put(dcmi->entity.node); 1616 v4l2_async_notifier_cleanup(&dcmi->notifier);
1620 return ret; 1617 return ret;
1621 } 1618 }
1622 1619
@@ -1773,7 +1770,7 @@ static int dcmi_probe(struct platform_device *pdev)
1773 ret = reset_control_assert(dcmi->rstc); 1770 ret = reset_control_assert(dcmi->rstc);
1774 if (ret) { 1771 if (ret) {
1775 dev_err(&pdev->dev, "Failed to assert the reset line\n"); 1772 dev_err(&pdev->dev, "Failed to assert the reset line\n");
1776 goto err_device_release; 1773 goto err_cleanup;
1777 } 1774 }
1778 1775
1779 usleep_range(3000, 5000); 1776 usleep_range(3000, 5000);
@@ -1781,7 +1778,7 @@ static int dcmi_probe(struct platform_device *pdev)
1781 ret = reset_control_deassert(dcmi->rstc); 1778 ret = reset_control_deassert(dcmi->rstc);
1782 if (ret) { 1779 if (ret) {
1783 dev_err(&pdev->dev, "Failed to deassert the reset line\n"); 1780 dev_err(&pdev->dev, "Failed to deassert the reset line\n");
1784 goto err_device_release; 1781 goto err_cleanup;
1785 } 1782 }
1786 1783
1787 dev_info(&pdev->dev, "Probe done\n"); 1784 dev_info(&pdev->dev, "Probe done\n");
@@ -1792,6 +1789,8 @@ static int dcmi_probe(struct platform_device *pdev)
1792 1789
1793 return 0; 1790 return 0;
1794 1791
1792err_cleanup:
1793 v4l2_async_notifier_cleanup(&dcmi->notifier);
1795err_device_release: 1794err_device_release:
1796 video_device_release(dcmi->vdev); 1795 video_device_release(dcmi->vdev);
1797err_device_unregister: 1796err_device_unregister:
@@ -1809,6 +1808,7 @@ static int dcmi_remove(struct platform_device *pdev)
1809 pm_runtime_disable(&pdev->dev); 1808 pm_runtime_disable(&pdev->dev);
1810 1809
1811 v4l2_async_notifier_unregister(&dcmi->notifier); 1810 v4l2_async_notifier_unregister(&dcmi->notifier);
1811 v4l2_async_notifier_cleanup(&dcmi->notifier);
1812 v4l2_device_unregister(&dcmi->v4l2_dev); 1812 v4l2_device_unregister(&dcmi->v4l2_dev);
1813 1813
1814 dma_release_channel(dcmi->dma_chan); 1814 dma_release_channel(dcmi->dma_chan);