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/atmel | |
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/atmel')
-rw-r--r-- | drivers/media/platform/atmel/atmel-isc.c | 15 | ||||
-rw-r--r-- | drivers/media/platform/atmel/atmel-isi.c | 17 |
2 files changed, 19 insertions, 13 deletions
diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index dc637bffe63c..334de0f2e36a 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -1983,8 +1983,10 @@ static void isc_subdev_cleanup(struct isc_device *isc) { struct isc_subdev_entity *subdev_entity; - list_for_each_entry(subdev_entity, &isc->subdev_entities, list) + list_for_each_entry(subdev_entity, &isc->subdev_entities, list) { v4l2_async_notifier_unregister(&subdev_entity->notifier); + v4l2_async_notifier_cleanup(&subdev_entity->notifier); + } INIT_LIST_HEAD(&isc->subdev_entities); } @@ -2201,8 +2203,15 @@ static int atmel_isc_probe(struct platform_device *pdev) } list_for_each_entry(subdev_entity, &isc->subdev_entities, list) { - subdev_entity->notifier.subdevs = &subdev_entity->asd; - subdev_entity->notifier.num_subdevs = 1; + v4l2_async_notifier_init(&subdev_entity->notifier); + + ret = v4l2_async_notifier_add_subdev(&subdev_entity->notifier, + subdev_entity->asd); + if (ret) { + fwnode_handle_put(subdev_entity->asd->match.fwnode); + goto cleanup_subdev; + } + subdev_entity->notifier.ops = &isc_async_ops; ret = v4l2_async_notifier_register(&isc->v4l2_dev, diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c index 26874575d381..c4d5f05786e8 100644 --- a/drivers/media/platform/atmel/atmel-isi.c +++ b/drivers/media/platform/atmel/atmel-isi.c @@ -1124,7 +1124,6 @@ static int isi_graph_parse(struct atmel_isi *isi, struct device_node *node) static int isi_graph_init(struct atmel_isi *isi) { - struct v4l2_async_subdev **subdevs = NULL; int ret; /* Parse the graph to extract a list of subdevice DT nodes. */ @@ -1134,23 +1133,20 @@ static int isi_graph_init(struct atmel_isi *isi) return ret; } - /* Register the subdevices notifier. */ - subdevs = devm_kzalloc(isi->dev, sizeof(*subdevs), GFP_KERNEL); - if (!subdevs) { + v4l2_async_notifier_init(&isi->notifier); + + ret = v4l2_async_notifier_add_subdev(&isi->notifier, &isi->entity.asd); + if (ret) { of_node_put(isi->entity.node); - return -ENOMEM; + return ret; } - subdevs[0] = &isi->entity.asd; - - isi->notifier.subdevs = subdevs; - isi->notifier.num_subdevs = 1; isi->notifier.ops = &isi_graph_notify_ops; ret = v4l2_async_notifier_register(&isi->v4l2_dev, &isi->notifier); if (ret < 0) { dev_err(isi->dev, "Notifier registration failed\n"); - of_node_put(isi->entity.node); + v4l2_async_notifier_cleanup(&isi->notifier); return ret; } @@ -1303,6 +1299,7 @@ static int atmel_isi_remove(struct platform_device *pdev) isi->fb_descriptors_phys); pm_runtime_disable(&pdev->dev); v4l2_async_notifier_unregister(&isi->notifier); + v4l2_async_notifier_cleanup(&isi->notifier); v4l2_device_unregister(&isi->v4l2_dev); return 0; |