Skip to content

Commit

Permalink
media: v4l: async: Return async sub-devices to subnotifier list
Browse files Browse the repository at this point in the history
[ Upstream commit 5276c9d ]

When an async notifier is unregistered, the async sub-devices in the
notifier's done list will disappear with the notifier. However this is
currently also done to the sub-notifiers that remain registered. Their
sub-devices only need to be unbound while the async sub-devices themselves
need to be returned to the sub-notifier's waiting list. Do this now.

Fixes: 2cab00b ("media: v4l: async: Allow binding notifiers to sub-devices")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Sakari Ailus authored and gregkh committed May 11, 2023
1 parent 48765ca commit f2b98b6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/media/v4l2-core/v4l2-async.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ static void v4l2_async_cleanup(struct v4l2_subdev *sd)

/* Unbind all sub-devices in the notifier tree. */
static void
v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier)
v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier,
bool readd)
{
struct v4l2_subdev *sd, *tmp;

Expand All @@ -425,9 +426,11 @@ v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier)
v4l2_async_find_subdev_notifier(sd);

if (subdev_notifier)
v4l2_async_nf_unbind_all_subdevs(subdev_notifier);
v4l2_async_nf_unbind_all_subdevs(subdev_notifier, true);

v4l2_async_nf_call_unbind(notifier, sd, sd->asd);
if (readd)
list_add_tail(&sd->asd->list, &notifier->waiting);
v4l2_async_cleanup(sd);

list_move(&sd->async_list, &subdev_list);
Expand Down Expand Up @@ -559,7 +562,7 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier)
/*
* On failure, unbind all sub-devices registered through this notifier.
*/
v4l2_async_nf_unbind_all_subdevs(notifier);
v4l2_async_nf_unbind_all_subdevs(notifier, false);

err_unlock:
mutex_unlock(&list_lock);
Expand Down Expand Up @@ -609,7 +612,7 @@ __v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier)
if (!notifier || (!notifier->v4l2_dev && !notifier->sd))
return;

v4l2_async_nf_unbind_all_subdevs(notifier);
v4l2_async_nf_unbind_all_subdevs(notifier, false);

notifier->sd = NULL;
notifier->v4l2_dev = NULL;
Expand Down Expand Up @@ -807,7 +810,7 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd)
*/
subdev_notifier = v4l2_async_find_subdev_notifier(sd);
if (subdev_notifier)
v4l2_async_nf_unbind_all_subdevs(subdev_notifier);
v4l2_async_nf_unbind_all_subdevs(subdev_notifier, false);

if (sd->asd)
v4l2_async_nf_call_unbind(notifier, sd, sd->asd);
Expand Down

0 comments on commit f2b98b6

Please sign in to comment.