media: v4l: async: Register sub-devices before calling bound callback
authorSakari Ailus <sakari.ailus@linux.intel.com>
Mon, 17 Jul 2017 14:04:20 +0000 (10:04 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 31 Oct 2017 17:53:18 +0000 (13:53 -0400)
Register the sub-device before calling the notifier's bound callback.
Doing this the other way around is problematic as the struct v4l2_device
has not assigned for the sub-device yet and may be required by the bound
callback.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/v4l2-core/v4l2-async.c

index e170682dae788bd9da311d31364f8d42b53a98de..46db856858949e5b17019efd60e16b4e497bdab1 100644 (file)
@@ -130,13 +130,13 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier,
 {
        int ret;
 
-       ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
+       ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
        if (ret < 0)
                return ret;
 
-       ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
+       ret = v4l2_async_notifier_call_bound(notifier, sd, asd);
        if (ret < 0) {
-               v4l2_async_notifier_call_unbind(notifier, sd, asd);
+               v4l2_device_unregister_subdev(sd);
                return ret;
        }