Commit 66beb323 authored by Steve Longerbeam's avatar Steve Longerbeam Committed by Mauro Carvalho Chehab

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: default avatarSteve Longerbeam <slongerbeam@gmail.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent d079f94c
...@@ -359,32 +359,24 @@ __v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier, ...@@ -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 * Find out whether an async sub-device was set up already or
* whether it exists in a given notifier before @this_index. * whether it exists in a given notifier before @this_index.
* If @this_index < 0, search the notifier's entire @asd_list.
*/ */
static bool static bool
v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier, v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier,
struct v4l2_async_subdev *asd, struct v4l2_async_subdev *asd,
unsigned int this_index) int this_index)
{ {
struct v4l2_async_subdev *asd_y; struct v4l2_async_subdev *asd_y;
unsigned int j; int j = 0;
lockdep_assert_held(&list_lock); lockdep_assert_held(&list_lock);
/* Check that an asd is not being added more than once. */ /* Check that an asd is not being added more than once. */
if (notifier->subdevs) { list_for_each_entry(asd_y, &notifier->asd_list, asd_list) {
for (j = 0; j < this_index; j++) { if (this_index >= 0 && j++ >= this_index)
asd_y = notifier->subdevs[j]; break;
if (asd_equal(asd, asd_y)) if (asd_equal(asd, asd_y))
return true; return true;
}
} else {
j = 0;
list_for_each_entry(asd_y, &notifier->asd_list, asd_list) {
if (j++ >= this_index)
break;
if (asd_equal(asd, asd_y))
return true;
}
} }
/* Check that an asd does not exist in other notifiers. */ /* 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, ...@@ -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, static int v4l2_async_notifier_asd_valid(struct v4l2_async_notifier *notifier,
struct v4l2_async_subdev *asd, struct v4l2_async_subdev *asd,
unsigned int this_index) int this_index)
{ {
struct device *dev = struct device *dev =
notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL; notifier->v4l2_dev ? notifier->v4l2_dev->dev : NULL;
...@@ -438,36 +430,19 @@ EXPORT_SYMBOL(v4l2_async_notifier_init); ...@@ -438,36 +430,19 @@ EXPORT_SYMBOL(v4l2_async_notifier_init);
static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier) static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier)
{ {
struct v4l2_async_subdev *asd; struct v4l2_async_subdev *asd;
int ret; int ret, i = 0;
int i;
if (notifier->num_subdevs > V4L2_MAX_SUBDEVS)
return -EINVAL;
INIT_LIST_HEAD(&notifier->waiting); INIT_LIST_HEAD(&notifier->waiting);
INIT_LIST_HEAD(&notifier->done); INIT_LIST_HEAD(&notifier->done);
mutex_lock(&list_lock); mutex_lock(&list_lock);
if (notifier->subdevs) { list_for_each_entry(asd, &notifier->asd_list, asd_list) {
for (i = 0; i < notifier->num_subdevs; i++) { ret = v4l2_async_notifier_asd_valid(notifier, asd, i++);
asd = notifier->subdevs[i]; if (ret)
goto err_unlock;
ret = v4l2_async_notifier_asd_valid(notifier, asd, i);
if (ret)
goto err_unlock;
list_add_tail(&asd->list, &notifier->waiting); list_add_tail(&asd->list, &notifier->waiting);
}
} else {
i = 0;
list_for_each_entry(asd, &notifier->asd_list, asd_list) {
ret = v4l2_async_notifier_asd_valid(notifier, asd, i++);
if (ret)
goto err_unlock;
list_add_tail(&asd->list, &notifier->waiting);
}
} }
ret = v4l2_async_notifier_try_all_subdevs(notifier); ret = v4l2_async_notifier_try_all_subdevs(notifier);
...@@ -560,45 +535,22 @@ EXPORT_SYMBOL(v4l2_async_notifier_unregister); ...@@ -560,45 +535,22 @@ EXPORT_SYMBOL(v4l2_async_notifier_unregister);
static void __v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier) static void __v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
{ {
struct v4l2_async_subdev *asd, *tmp; struct v4l2_async_subdev *asd, *tmp;
unsigned int i;
if (!notifier) if (!notifier)
return; return;
if (notifier->subdevs) { list_for_each_entry_safe(asd, tmp, &notifier->asd_list, asd_list) {
for (i = 0; i < notifier->num_subdevs; i++) { switch (asd->match_type) {
asd = notifier->subdevs[i]; case V4L2_ASYNC_MATCH_FWNODE:
fwnode_handle_put(asd->match.fwnode);
switch (asd->match_type) { break;
case V4L2_ASYNC_MATCH_FWNODE: default:
fwnode_handle_put(asd->match.fwnode); break;
break;
default:
break;
}
kfree(asd);
} }
kvfree(notifier->subdevs); list_del(&asd->asd_list);
notifier->subdevs = NULL; kfree(asd);
} else {
list_for_each_entry_safe(asd, tmp,
&notifier->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);
}
} }
notifier->num_subdevs = 0;
} }
void v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier) 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, ...@@ -618,27 +570,11 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier,
mutex_lock(&list_lock); mutex_lock(&list_lock);
if (notifier->num_subdevs >= V4L2_MAX_SUBDEVS) { ret = v4l2_async_notifier_asd_valid(notifier, asd, -1);
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);
if (ret) if (ret)
goto unlock; goto unlock;
list_add_tail(&asd->asd_list, &notifier->asd_list); list_add_tail(&asd->asd_list, &notifier->asd_list);
notifier->num_subdevs++;
unlock: unlock:
mutex_unlock(&list_lock); mutex_unlock(&list_lock);
......
...@@ -20,9 +20,6 @@ struct v4l2_device; ...@@ -20,9 +20,6 @@ struct v4l2_device;
struct v4l2_subdev; struct v4l2_subdev;
struct v4l2_async_notifier; struct v4l2_async_notifier;
/* A random max subdevice number, used to allocate an array on stack */
#define V4L2_MAX_SUBDEVS 128U
/** /**
* enum v4l2_async_match_type - type of asynchronous subdevice logic to be used * enum v4l2_async_match_type - type of asynchronous subdevice logic to be used
* in order to identify a match * in order to identify a match
...@@ -124,20 +121,16 @@ struct v4l2_async_notifier_operations { ...@@ -124,20 +121,16 @@ struct v4l2_async_notifier_operations {
* struct v4l2_async_notifier - v4l2_device notifier data * struct v4l2_async_notifier - v4l2_device notifier data
* *
* @ops: notifier operations * @ops: notifier operations
* @num_subdevs: number of subdevices used in the subdevs array
* @subdevs: array of pointers to subdevice descriptors
* @v4l2_dev: v4l2_device of the root notifier, NULL otherwise * @v4l2_dev: v4l2_device of the root notifier, NULL otherwise
* @sd: sub-device that registered the notifier, NULL otherwise * @sd: sub-device that registered the notifier, NULL otherwise
* @parent: parent notifier * @parent: parent notifier
* @asd_list: master list of struct v4l2_async_subdev, replaces @subdevs * @asd_list: master list of struct v4l2_async_subdev
* @waiting: list of struct v4l2_async_subdev, waiting for their drivers * @waiting: list of struct v4l2_async_subdev, waiting for their drivers
* @done: list of struct v4l2_subdev, already probed * @done: list of struct v4l2_subdev, already probed
* @list: member in a global list of notifiers * @list: member in a global list of notifiers
*/ */
struct v4l2_async_notifier { struct v4l2_async_notifier {
const struct v4l2_async_notifier_operations *ops; const struct v4l2_async_notifier_operations *ops;
unsigned int num_subdevs;
struct v4l2_async_subdev **subdevs;
struct v4l2_device *v4l2_dev; struct v4l2_device *v4l2_dev;
struct v4l2_subdev *sd; struct v4l2_subdev *sd;
struct v4l2_async_notifier *parent; struct v4l2_async_notifier *parent;
...@@ -164,10 +157,8 @@ void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier); ...@@ -164,10 +157,8 @@ void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier);
* @notifier: pointer to &struct v4l2_async_notifier * @notifier: pointer to &struct v4l2_async_notifier
* @asd: pointer to &struct v4l2_async_subdev * @asd: pointer to &struct v4l2_async_subdev
* *
* This can be used before registering a notifier to add an * Call this function before registering a notifier to link the
* asd to the notifiers @asd_list. If the caller uses this * provided asd to the notifiers master @asd_list.
* method to compose an asd list, it must never allocate
* or place asd's in the @subdevs array.
*/ */
int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier,
struct v4l2_async_subdev *asd); struct v4l2_async_subdev *asd);
...@@ -184,10 +175,8 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, ...@@ -184,10 +175,8 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier,
* the driver's async sub-device struct, i.e. both * the driver's async sub-device struct, i.e. both
* begin at the same memory address. * begin at the same memory address.
* *
* This can be used before registering a notifier to add a * Allocate a fwnode-matched asd of size asd_struct_size, and add it
* fwnode-matched asd to the notifiers master asd_list. If the caller * to the notifiers @asd_list.
* uses this method to compose an asd list, it must never allocate
* or place asd's in the @subdevs array.
*/ */
struct v4l2_async_subdev * struct v4l2_async_subdev *
v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier, v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier,
......
...@@ -259,12 +259,6 @@ typedef int (*parse_endpoint_func)(struct device *dev, ...@@ -259,12 +259,6 @@ typedef int (*parse_endpoint_func)(struct device *dev,
* This function may not be called on a registered notifier and may be called on * This function may not be called on a registered notifier and may be called on
* a notifier only once. * a notifier only once.
* *
* Do not allocate the notifier's subdevs array, or change the notifier's
* num_subdevs field. This is because this function uses
* @v4l2_async_notifier_add_subdev to populate the notifier's asd_list,
* which is in-place-of the subdevs array which must remain unallocated
* and unused.
*
* The &struct v4l2_fwnode_endpoint passed to the callback function * The &struct v4l2_fwnode_endpoint passed to the callback function
* @parse_endpoint is released once the function is finished. If there is a need * @parse_endpoint is released once the function is finished. If there is a need
* to retain that configuration, the user needs to allocate memory for it. * to retain that configuration, the user needs to allocate memory for it.
...@@ -316,12 +310,6 @@ int v4l2_async_notifier_parse_fwnode_endpoints( ...@@ -316,12 +310,6 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
* This function may not be called on a registered notifier and may be called on * This function may not be called on a registered notifier and may be called on
* a notifier only once per port. * a notifier only once per port.
* *
* Do not allocate the notifier's subdevs array, or change the notifier's
* num_subdevs field. This is because this function uses
* @v4l2_async_notifier_add_subdev to populate the notifier's asd_list,
* which is in-place-of the subdevs array which must remain unallocated
* and unused.
*
* The &struct v4l2_fwnode_endpoint passed to the callback function * The &struct v4l2_fwnode_endpoint passed to the callback function
* @parse_endpoint is released once the function is finished. If there is a need * @parse_endpoint is released once the function is finished. If there is a need
* to retain that configuration, the user needs to allocate memory for it. * to retain that configuration, the user needs to allocate memory for it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment