Skip to content

Commit

Permalink
media: v4l: async: Allow async notifier register call succeed with no…
Browse files Browse the repository at this point in the history
… subdevs

The information on how many async sub-devices would be bindable to a
notifier is typically dependent on information from platform firmware and
it's not driver's business to be aware of that.

Many V4L2 main drivers are perfectly usable (and useful) without async
sub-devices and so if there aren't any around, just proceed call the
notifier's complete callback immediately without registering the notifier
itself.

If a driver needs to check whether there are async sub-devices available,
it can be done by inspecting the notifier's num_subdevs field which tells
the number of async sub-devices.

Signed-off-by: Sakari Ailus <[email protected]>
Acked-by: Hans Verkuil <[email protected]>
Acked-by: Niklas Söderlund <[email protected]>
Reviewed-by: Sebastian Reichel <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
Sakari Ailus authored and mchehab committed Oct 31, 2017
1 parent 24def9b commit 479bc5a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/media/v4l2-core/v4l2-async.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,22 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
int ret;
int i;

if (!v4l2_dev || !notifier->num_subdevs ||
notifier->num_subdevs > V4L2_MAX_SUBDEVS)
if (!v4l2_dev || notifier->num_subdevs > V4L2_MAX_SUBDEVS)
return -EINVAL;

notifier->v4l2_dev = v4l2_dev;
INIT_LIST_HEAD(&notifier->waiting);
INIT_LIST_HEAD(&notifier->done);

if (!notifier->num_subdevs) {
int ret;

ret = v4l2_async_notifier_call_complete(notifier);
notifier->v4l2_dev = NULL;

return ret;
}

for (i = 0; i < notifier->num_subdevs; i++) {
asd = notifier->subdevs[i];

Expand Down

0 comments on commit 479bc5a

Please sign in to comment.