From f18d6a4cb0561c322e284ed404f2ec97b1092396 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 13 Aug 2020 23:06:01 +0200 Subject: [PATCH] media: rcar-vin: Unconditionally unregister notifier on remove MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the VIN device is part of a group of VIN devices (all Gen3 boards) there is no reason to only unregister the group notifier if the VIN that registers the notifier is removed. The VIN that registers the notifier is always the last VIN device to be bound, so keeping the notifier around after any VIN is unbound creates an unbalanced state where no VIN in the group is operational. Fix this by unconditionally unregistering the notifier when any VIN device is unbound. Unregistering the notifier will lead to unbound() being called and all video devices exposed by any VIN instance to be removed. The lock was only needed to protect the check which VIN registers the notifier and is no longer needed. Signed-off-by: Niklas Söderlund Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/rcar-vin/rcar-core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 7440c8965d27..1cbbcc9008e3 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -1370,12 +1370,8 @@ static int rcar_vin_remove(struct platform_device *pdev) v4l2_async_notifier_cleanup(&vin->notifier); if (vin->info->use_mc) { - mutex_lock(&vin->group->lock); - if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) { - v4l2_async_notifier_unregister(&vin->group->notifier); - v4l2_async_notifier_cleanup(&vin->group->notifier); - } - mutex_unlock(&vin->group->lock); + v4l2_async_notifier_unregister(&vin->group->notifier); + v4l2_async_notifier_cleanup(&vin->group->notifier); rvin_group_put(vin); } -- 2.20.1