Commit f287e3ec authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Mauro Carvalho Chehab

media: rcar-vin: Register media device when all sub-devices bound

The media device is not usable by userspace before all devices involved
in capture are present in the system. Move registering of the media
device to the async complete callback.
Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent f18d6a4c
...@@ -243,7 +243,6 @@ static struct rvin_group *rvin_group_data; ...@@ -243,7 +243,6 @@ static struct rvin_group *rvin_group_data;
static void rvin_group_cleanup(struct rvin_group *group) static void rvin_group_cleanup(struct rvin_group *group)
{ {
media_device_unregister(&group->mdev);
media_device_cleanup(&group->mdev); media_device_cleanup(&group->mdev);
mutex_destroy(&group->lock); mutex_destroy(&group->lock);
} }
...@@ -253,7 +252,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin) ...@@ -253,7 +252,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin)
struct media_device *mdev = &group->mdev; struct media_device *mdev = &group->mdev;
const struct of_device_id *match; const struct of_device_id *match;
struct device_node *np; struct device_node *np;
int ret;
mutex_init(&group->lock); mutex_init(&group->lock);
...@@ -278,11 +276,7 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin) ...@@ -278,11 +276,7 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin)
media_device_init(mdev); media_device_init(mdev);
ret = media_device_register(&group->mdev); return 0;
if (ret)
rvin_group_cleanup(group);
return ret;
} }
static void rvin_group_release(struct kref *kref) static void rvin_group_release(struct kref *kref)
...@@ -682,6 +676,10 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier) ...@@ -682,6 +676,10 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier)
unsigned int i; unsigned int i;
int ret; int ret;
ret = media_device_register(&vin->group->mdev);
if (ret)
return ret;
ret = v4l2_device_register_subdev_nodes(&vin->v4l2_dev); ret = v4l2_device_register_subdev_nodes(&vin->v4l2_dev);
if (ret) { if (ret) {
vin_err(vin, "Failed to register subdev nodes\n"); vin_err(vin, "Failed to register subdev nodes\n");
...@@ -762,6 +760,8 @@ static void rvin_group_notify_unbind(struct v4l2_async_notifier *notifier, ...@@ -762,6 +760,8 @@ static void rvin_group_notify_unbind(struct v4l2_async_notifier *notifier,
} }
mutex_unlock(&vin->group->lock); mutex_unlock(&vin->group->lock);
media_device_unregister(&vin->group->mdev);
} }
static int rvin_group_notify_bound(struct v4l2_async_notifier *notifier, static int rvin_group_notify_bound(struct v4l2_async_notifier *notifier,
......
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