From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from bin-mail-out-05.binero.net ([195.74.38.228]:52921 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbeDNL7R (ORCPT ); Sat, 14 Apr 2018 07:59:17 -0400 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= To: Laurent Pinchart , Hans Verkuil , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Kieran Bingham , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v14 05/33] rcar-vin: unregister video device on driver removal Date: Sat, 14 Apr 2018 13:56:58 +0200 Message-Id: <20180414115726.5075-6-niklas.soderlund+renesas@ragnatech.se> In-Reply-To: <20180414115726.5075-1-niklas.soderlund+renesas@ragnatech.se> References: <20180414115726.5075-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-media-owner@vger.kernel.org List-ID: If the video device was registered by the complete() callback it should be unregistered when a device is unbound from the driver. Protect from printing an uninitialized video device node name by adding a check in rvin_v4l2_unregister() to identify that the video device is registered. Signed-off-by: Niklas Söderlund Reviewed-by: Kieran Bingham Reviewed-by: Hans Verkuil Acked-by: Laurent Pinchart --- drivers/media/platform/rcar-vin/rcar-core.c | 2 ++ drivers/media/platform/rcar-vin/rcar-v4l2.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 2bedf20abcf3ca07..47f06acde2e698f2 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -272,6 +272,8 @@ static int rcar_vin_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); + rvin_v4l2_unregister(vin); + v4l2_async_notifier_unregister(&vin->notifier); v4l2_async_notifier_cleanup(&vin->notifier); diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 178aecc94962abe2..32a658214f48fa49 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -841,6 +841,9 @@ static const struct v4l2_file_operations rvin_fops = { void rvin_v4l2_unregister(struct rvin_dev *vin) { + if (!video_is_registered(&vin->vdev)) + return; + v4l2_info(&vin->v4l2_dev, "Removing %s\n", video_device_node_name(&vin->vdev)); -- 2.16.2