Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp67176ybg; Mon, 27 Jul 2020 23:39:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMMqsjc/m5R4rGtB4hs6e/6PN47e9xKStT5AJ+Y0+oT9fdYrAR5Vh8JMy/vdn4NU28Dkl9 X-Received: by 2002:aa7:c788:: with SMTP id n8mr4766462eds.146.1595918376331; Mon, 27 Jul 2020 23:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595918376; cv=none; d=google.com; s=arc-20160816; b=SJorLZkTCjUsU8sl9EMe2sQZ/49RT3xcSYmhGjAXJImKY6GR7Unl4qCn5AEPa/EJDu vfz+aGbmmBYPnKIr/RipE+qjL51KfUd3TxpmikVoF38PzI7FeoMrXHm7jZzB3Y3dDmhb 1ei6amkU2/2esMFcliuWxUBP3sBUOVsTnPApeCFhTeghopMjkCc/RDu3jJZwu2Li1rtN 5da4dSFZJzt2lbHXmEgwM27B3+HMmCzfrnJxMMgkpiNJFH7do9y6XaI9eUfSJy5VuUlJ hvx24M/kY8eAdnNiMhUEZIu1Q2SFvMslPQ/+0ykK5p3uaDz0ns/ysecB4zv7VGEBJBrZ D/pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ajyvh+tBMcwXmZAbVqtgESn3hRz8JO8E3SSTw659wtA=; b=0Db4TK1wpWh7f9qL8Tzfu7sAJCdTUPQdDP8zpd1GUUIl9EoiDzn973LmzsHRprzfqP sbeQIjfmxizXcIFrKir+A6ToaaEZ7Z8vSPVyn+nrJ8mnUBXlSZeWmnYzP4T3eFklkVnS rSJLqZGLEHWKXTE97mDx5qqyAGoU6Sgk4F2XLknt3BR+CnyzigGgXLAaSg7aPuw3Xl0l upOurE5tiZKIoci+HB5mwW7orwwl3CberEbHBMYGAvwToIcp3h63A6o5kmO9PgtLyyzf 8EocVrpmCwbvh+SAvdF4nTbctGVl3tGBa+8FcTJvsgS7jCpbHM27SW4nfPbe19doDC4O /olQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=ahwMcP16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si114006eda.329.2020.07.27.23.39.13; Mon, 27 Jul 2020 23:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=ahwMcP16; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbgG1Git (ORCPT + 99 others); Tue, 28 Jul 2020 02:38:49 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:11890 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726873AbgG1Gis (ORCPT ); Tue, 28 Jul 2020 02:38:48 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06S6R7RO020678; Tue, 28 Jul 2020 08:38:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=ajyvh+tBMcwXmZAbVqtgESn3hRz8JO8E3SSTw659wtA=; b=ahwMcP16A7T1FkUcl+gWZ2TQzBnE/8jtvvtmI4A2iwzWfxlSafWmVXyZGPnRFGMoc/0e OAW1VrxEgzNQLZR0sXpI28ZsNFAzaMUOAYnCfytXr6ErBQLizhStBOoP6/xDD3SB9PAC fIh1LrPi0ygrqh0tELHiNq+1qdrK+B8tZJ/AY2E5kw18pI5qVCn9wli5ei8p9SdafRL6 CxHVu5oYnJipMFKOoGY7F/ttcgaoL7RsbbkJ+Yx8SlQwRJGNyhioFPu/lqIjdmm9nDcj yhVdRPHj6ju4x8hCPAYojgTyG/mfoEzThVJmrFyO/T64pVmp8Us0J4zLBeOk6ujHxM/j Tg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32g9v9cu7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jul 2020 08:38:33 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2F7E9100034; Tue, 28 Jul 2020 08:38:33 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node3.st.com [10.75.127.9]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 22BB3210F96; Tue, 28 Jul 2020 08:38:33 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE3.st.com (10.75.127.9) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Tue, 28 Jul 2020 08:38:32 +0200 From: Alain Volmat To: , CC: , , , , , , , , Subject: [PATCH 1/2] media: stm32-dcmi: create video dev within notifier bound Date: Tue, 28 Jul 2020 08:37:57 +0200 Message-ID: <1595918278-9724-2-git-send-email-alain.volmat@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595918278-9724-1-git-send-email-alain.volmat@st.com> References: <1595918278-9724-1-git-send-email-alain.volmat@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE1.st.com (10.75.127.19) To SFHDAG3NODE3.st.com (10.75.127.9) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-28_01:2020-07-27,2020-07-28 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of an error during the initialization of the sensor, the video device is still available since created at the probe of the dcmi driver. Moreover the device wouldn't be released even when removing the module since the release is performed as part of the notifier unbind callback (not called if no sensor is properly initialized). This patch move the video device creation with the v4l2 notifier bound handler in order to avoid having a video device created when an error happen during the pipe (dcmi - sensor) initialization. This also makes the video device creation symmetric with the release which is already done within the notifier unbind handler. Fixes: 37404f91ef8b ("[media] stm32-dcmi: STM32 DCMI camera interface driver") Signed-off-by: Alain Volmat --- drivers/media/platform/stm32/stm32-dcmi.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index b8931490b83b..5e60d4c6eeeb 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -1747,6 +1747,15 @@ static int dcmi_graph_notify_bound(struct v4l2_async_notifier *notifier, dev_dbg(dcmi->dev, "Subdev \"%s\" bound\n", subdev->name); + ret = video_register_device(dcmi->vdev, VFL_TYPE_VIDEO, -1); + if (ret) { + dev_err(dcmi->dev, "Failed to register video device\n"); + return ret; + } + + dev_dbg(dcmi->dev, "Device registered as %s\n", + video_device_node_name(dcmi->vdev)); + /* * Link this sub-device to DCMI, it could be * a parallel camera sensor or a bridge @@ -1759,10 +1768,11 @@ static int dcmi_graph_notify_bound(struct v4l2_async_notifier *notifier, &dcmi->vdev->entity, 0, MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { dev_err(dcmi->dev, "Failed to create media pad link with subdev \"%s\"\n", subdev->name); - else + video_unregister_device(dcmi->vdev); + } else dev_dbg(dcmi->dev, "DCMI is now linked to \"%s\"\n", subdev->name); @@ -1974,15 +1984,6 @@ static int dcmi_probe(struct platform_device *pdev) } dcmi->vdev->entity.flags |= MEDIA_ENT_FL_DEFAULT; - ret = video_register_device(dcmi->vdev, VFL_TYPE_VIDEO, -1); - if (ret) { - dev_err(dcmi->dev, "Failed to register video device\n"); - goto err_media_entity_cleanup; - } - - dev_dbg(dcmi->dev, "Device registered as %s\n", - video_device_node_name(dcmi->vdev)); - /* Buffer queue */ q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->io_modes = VB2_MMAP | VB2_READ | VB2_DMABUF; -- 2.7.4