mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugues FRUCHET <hugues.fruchet@st.com>
To: Alain VOLMAT <alain.volmat@st.com>,
	"mchehab@kernel.org" <mchehab@kernel.org>
Cc: "mcoquelin.stm32@gmail.com" <mcoquelin.stm32@gmail.com>,
	Alexandre TORGUE <alexandre.torgue@st.com>,
	Yannick FERTRE <yannick.fertre@st.com>,
	"hans.verkuil@cisco.com" <hans.verkuil@cisco.com>,
	"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	"linux-stm32@st-md-mailman.stormreply.com" 
	<linux-stm32@st-md-mailman.stormreply.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] media: stm32-dcmi: create video dev within notifier bound
Date: Tue, 28 Jul 2020 07:48:11 +0000	[thread overview]
Message-ID: <5650a872-3352-64cb-2f35-94e2be3b187f@st.com> (raw)
In-Reply-To: <1595918278-9724-2-git-send-email-alain.volmat@st.com>

Reviewed-by: Hugues Fruchet <hugues.fruchet@st.com>

On 7/28/20 8:37 AM, Alain Volmat wrote:
> 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 <alain.volmat@st.com>
> ---
>   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;
> 

  reply	other threads:[~2020-07-28  7:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28  6:37 [PATCH 0/2] Error handling fixes in stm32-dcmi driver Alain Volmat
2020-07-28  6:37 ` [PATCH 1/2] media: stm32-dcmi: create video dev within notifier bound Alain Volmat
2020-07-28  7:48   ` Hugues FRUCHET [this message]
2020-08-19 13:52   ` Hans Verkuil
2020-07-28  6:37 ` [PATCH 2/2] media: stm32-dcmi: fix probe error path & module remove Alain Volmat
2020-07-28  7:48   ` Hugues FRUCHET
2020-08-19 13:58   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5650a872-3352-64cb-2f35-94e2be3b187f@st.com \
    --to=hugues.fruchet@st.com \
    --cc=alain.volmat@st.com \
    --cc=alexandre.torgue@st.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mchehab@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=yannick.fertre@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®