diff options
author | Steve Longerbeam <slongerbeam@gmail.com> | 2018-09-29 15:54:19 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-10-04 15:59:21 -0400 |
commit | 66beb323e4a0cef0e1ee1277b609e3e242490bf1 (patch) | |
tree | 4a106c145fb4ea7eb9beaa31e37c611be6d43cdd /drivers/media | |
parent | d079f94c90469f413920b9f2b201537fac2ceb06 (diff) |
media: v4l2: async: Remove notifier subdevs array
All platform drivers have been converted to use
v4l2_async_notifier_add_subdev(), in place of adding
asd's to the notifier subdevs array. So the subdevs
array can now be removed from struct v4l2_async_notifier,
and remove the backward compatibility support for that
array in v4l2-async.c.
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')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-async.c | 114 |
1 files changed, 25 insertions, 89 deletions
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index b0eb31efcbfe..70adbd9a01a2 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -359,32 +359,24 @@ __v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier, /* * Find out whether an async sub-device was set up already or * whether it exists in a given notifier before @this_index. + * If @this_index < 0, search the notifier's entire @asd_list. */ static bool v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd, - unsigned int this_index) + int this_index) { struct v4l2_async_subdev *asd_y; - unsigned int j; + int j = 0; lockdep_assert_held(&list_lock); /* Check that an asd is not being added more than once. */ - if (notifier->subdevs) { - for (j = 0; j < this_index; j++) { - asd_y = notifier->subdevs[j]; - if (asd_equal(asd, asd_y)) - return true; - } - } else { - j = 0; - list_for_each_entry(asd_y, ¬ifier->asd_list, asd_list) { - if (j++ >= this_index) - break; - if (asd_equal(asd, asd_y)) - return true; - } + list_for_each_entry(asd_y, ¬ifier->asd_list, asd_list) { + if (this_index >= 0 && j++ >= this_index) + break; + if (asd_equal(asd, asd_y)) + return true; } /* Check that an asd does not exist in other notifiers. */ @@ -397,7 +389,7 @@ v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier, static int v4l2_async_notifier_asd_valid(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd, - unsigned int this_index) + int this_index) { struct device *dev = notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL; @@ -438,36 +430,19 @@ EXPORT_SYMBOL(v4l2_async_notifier_init); static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier) { struct v4l2_async_subdev *asd; - int ret; - int i; - - if (notifier->num_subdevs > V4L2_MAX_SUBDEVS) - return -EINVAL; + int ret, i = 0; INIT_LIST_HEAD(¬ifier->waiting); INIT_LIST_HEAD(¬ifier->done); mutex_lock(&list_lock); - if (notifier->subdevs) { - for (i = 0; i < notifier->num_subdevs; i++) { - asd = notifier->subdevs[i]; - - ret = v4l2_async_notifier_asd_valid(notifier, asd, i); - if (ret) - goto err_unlock; + list_for_each_entry(asd, ¬ifier->asd_list, asd_list) { + ret = v4l2_async_notifier_asd_valid(notifier, asd, i++); + if (ret) + goto err_unlock; - list_add_tail(&asd->list, ¬ifier->waiting); - } - } else { - i = 0; - list_for_each_entry(asd, ¬ifier->asd_list, asd_list) { - ret = v4l2_async_notifier_asd_valid(notifier, asd, i++); - if (ret) - goto err_unlock; - - list_add_tail(&asd->list, ¬ifier->waiting); - } + list_add_tail(&asd->list, ¬ifier->waiting); } ret = v4l2_async_notifier_try_all_subdevs(notifier); @@ -560,45 +535,22 @@ EXPORT_SYMBOL(v4l2_async_notifier_unregister); static void __v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier) { struct v4l2_async_subdev *asd, *tmp; - unsigned int i; if (!notifier) return; - if (notifier->subdevs) { - for (i = 0; i < notifier->num_subdevs; i++) { - asd = notifier->subdevs[i]; - - switch (asd->match_type) { - case V4L2_ASYNC_MATCH_FWNODE: - fwnode_handle_put(asd->match.fwnode); - break; - default: - break; - } - - kfree(asd); + list_for_each_entry_safe(asd, tmp, ¬ifier->asd_list, asd_list) { + switch (asd->match_type) { + case V4L2_ASYNC_MATCH_FWNODE: + fwnode_handle_put(asd->match.fwnode); + break; + default: + break; } - kvfree(notifier->subdevs); - notifier->subdevs = NULL; - } else { - list_for_each_entry_safe(asd, tmp, - ¬ifier->asd_list, asd_list) { - switch (asd->match_type) { - case V4L2_ASYNC_MATCH_FWNODE: - fwnode_handle_put(asd->match.fwnode); - break; - default: - break; - } - - list_del(&asd->asd_list); - kfree(asd); - } + list_del(&asd->asd_list); + kfree(asd); } - - notifier->num_subdevs = 0; } void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier) @@ -618,27 +570,11 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, mutex_lock(&list_lock); - if (notifier->num_subdevs >= V4L2_MAX_SUBDEVS) { - ret = -EINVAL; - goto unlock; - } - - /* - * If caller uses this function, it cannot also allocate and - * place asd's in the notifier->subdevs array. - */ - if (WARN_ON(notifier->subdevs)) { - ret = -EINVAL; - goto unlock; - } - - ret = v4l2_async_notifier_asd_valid(notifier, asd, - notifier->num_subdevs); + ret = v4l2_async_notifier_asd_valid(notifier, asd, -1); if (ret) goto unlock; list_add_tail(&asd->asd_list, ¬ifier->asd_list); - notifier->num_subdevs++; unlock: mutex_unlock(&list_lock); |