From d079f94c90469f413920b9f2b201537fac2ceb06 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Sat, 29 Sep 2018 15:54:18 -0400 Subject: 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 Signed-off-by: Steve Longerbeam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/cadence/cdns-csi2rx.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'drivers/media/platform/cadence') diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 43e43c7b3e98..da3eb349716f 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -399,18 +399,22 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx) csi2rx->asd.match_type = V4L2_ASYNC_MATCH_FWNODE; of_node_put(ep); - csi2rx->notifier.subdevs = devm_kzalloc(csi2rx->dev, - sizeof(*csi2rx->notifier.subdevs), - GFP_KERNEL); - if (!csi2rx->notifier.subdevs) - return -ENOMEM; + v4l2_async_notifier_init(&csi2rx->notifier); + + ret = v4l2_async_notifier_add_subdev(&csi2rx->notifier, &csi2rx->asd); + if (ret) { + fwnode_handle_put(csi2rx->asd.match.fwnode); + return ret; + } - csi2rx->notifier.subdevs[0] = &csi2rx->asd; - csi2rx->notifier.num_subdevs = 1; csi2rx->notifier.ops = &csi2rx_notifier_ops; - return v4l2_async_subdev_notifier_register(&csi2rx->subdev, - &csi2rx->notifier); + ret = v4l2_async_subdev_notifier_register(&csi2rx->subdev, + &csi2rx->notifier); + if (ret) + v4l2_async_notifier_cleanup(&csi2rx->notifier); + + return ret; } static int csi2rx_probe(struct platform_device *pdev) @@ -450,11 +454,11 @@ static int csi2rx_probe(struct platform_device *pdev) ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX, csi2rx->pads); if (ret) - goto err_free_priv; + goto err_cleanup; ret = v4l2_async_register_subdev(&csi2rx->subdev); if (ret < 0) - goto err_free_priv; + goto err_cleanup; dev_info(&pdev->dev, "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n", @@ -463,6 +467,8 @@ static int csi2rx_probe(struct platform_device *pdev) return 0; +err_cleanup: + v4l2_async_notifier_cleanup(&csi2rx->notifier); err_free_priv: kfree(csi2rx); return ret; -- cgit v1.2.3