Commit 393cfcc0 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: v4l: async: Drop duplicate handling when adding connections

The connections are checked for duplicates already when the notifier is
registered. This is effectively a sanity check for driver (and possibly
obscure firmware) bugs. Don't do this when adding the connection.

Retain the int return type for now. It'll be needed very soon again.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Philipp Zabel <p.zabel@pengutronix.de> # imx6qp
Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> # rcar + adv746x
Tested-by: Aishwarya Kothari <aishwarya.kothari@toradex.com> # Apalis i.MX6Q with TC358743
Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> # Renesas RZ/G2L SMARC
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ed59bbe1
......@@ -471,14 +471,11 @@ v4l2_async_nf_has_async_match_entry(struct v4l2_async_notifier *notifier,
/*
* Find out whether an async sub-device was set up already or whether it exists
* in a given notifier. The skip_self argument is used to skip testing the same
* sub-device in the notifier in case the sub-device has been already added to
* the notifier.
* in a given notifier.
*/
static bool
v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier,
struct v4l2_async_match_desc *match,
bool skip_self)
struct v4l2_async_match_desc *match)
{
struct v4l2_async_connection *asc;
......@@ -486,7 +483,7 @@ v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier,
/* Check that an asd is not being added more than once. */
list_for_each_entry(asc, &notifier->asc_list, asc_entry) {
if (skip_self && &asc->match == match)
if (&asc->match == match)
continue;
if (v4l2_async_match_equal(&asc->match, match))
return true;
......@@ -501,16 +498,14 @@ v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier,
}
static int v4l2_async_nf_match_valid(struct v4l2_async_notifier *notifier,
struct v4l2_async_match_desc *match,
bool skip_self)
struct v4l2_async_match_desc *match)
{
struct device *dev = notifier_dev(notifier);
switch (match->type) {
case V4L2_ASYNC_MATCH_TYPE_I2C:
case V4L2_ASYNC_MATCH_TYPE_FWNODE:
if (v4l2_async_nf_has_async_match(notifier, match,
skip_self)) {
if (v4l2_async_nf_has_async_match(notifier, match)) {
dev_dbg(dev, "v4l2-async: match descriptor already listed in a notifier\n");
return -EEXIST;
}
......@@ -541,7 +536,7 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier)
mutex_lock(&list_lock);
list_for_each_entry(asc, &notifier->asc_list, asc_entry) {
ret = v4l2_async_nf_match_valid(notifier, &asc->match, true);
ret = v4l2_async_nf_match_valid(notifier, &asc->match);
if (ret)
goto err_unlock;
......@@ -670,19 +665,13 @@ EXPORT_SYMBOL_GPL(v4l2_async_nf_cleanup);
static int __v4l2_async_nf_add_connection(struct v4l2_async_notifier *notifier,
struct v4l2_async_connection *asc)
{
int ret;
mutex_lock(&list_lock);
ret = v4l2_async_nf_match_valid(notifier, &asc->match, false);
if (ret)
goto unlock;
list_add_tail(&asc->asc_entry, &notifier->asc_list);
unlock:
mutex_unlock(&list_lock);
return ret;
return 0;
}
struct v4l2_async_connection *
......
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