public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Frank Li <Frank.Li@nxp.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Rui Miguel Silva <rmfrfs@gmail.com>,
	Martin Kepplinger-Novakovic <martink@posteo.de>,
	Purism Kernel Team <kernel@puri.sm>,
	linux-media@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] media: nxp: use devm_mutex_init() simple code
Date: Wed, 19 Nov 2025 13:22:47 +0900	[thread overview]
Message-ID: <20251119042247.GL10711@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20251117-cam_cleanup-v1-1-6cd42872db79@nxp.com>

Hi Frank,

Thank you for the patch.

On Mon, Nov 17, 2025 at 01:58:11PM -0500, Frank Li wrote:
> Use devm_mutex_init() simple code. No functional change.
> 
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>  drivers/media/platform/nxp/imx-pxp.c          |  5 ++++-
>  drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 11 +++++------
>  drivers/media/platform/nxp/mx2_emmaprp.c      |  7 +++----
>  3 files changed, 12 insertions(+), 11 deletions(-)

Given the diffstat, and the fact that devm_mutex_init() performs dynamic
memory allocation, I'm not convinced by this change. I won't block it
though, as I don't maintain the above drivers.

> 
> diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
> index 3f9a67a6bd4d268841f85f9b69af03138300d188..32d39c8013c7eef1f9629f971cc74afecd463ac7 100644
> --- a/drivers/media/platform/nxp/imx-pxp.c
> +++ b/drivers/media/platform/nxp/imx-pxp.c
> @@ -1805,6 +1805,10 @@ static int pxp_probe(struct platform_device *pdev)
>  
>  	spin_lock_init(&dev->irqlock);
>  
> +	ret = devm_mutex_init(&pdev->dev, &dev->dev_mutex);
> +	if (ret)
> +		return ret;
> +
>  	ret = devm_request_irq(&pdev->dev, irq, pxp_irq_handler, 0,
>  			       dev_name(&pdev->dev), dev);
>  	if (ret < 0) {
> @@ -1831,7 +1835,6 @@ static int pxp_probe(struct platform_device *pdev)
>  		goto err_clk;
>  
>  	atomic_set(&dev->num_inst, 0);
> -	mutex_init(&dev->dev_mutex);
>  
>  	dev->vfd = pxp_videodev;
>  	vfd = &dev->vfd;
> diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> index 371b4e81328c107269f89da23818ab0abd0179da..0851f4a9ae52d3096f454da643cfdc5017e000b1 100644
> --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
> @@ -1033,15 +1033,17 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, &state->sd);
>  
> -	mutex_init(&state->lock);
> +	ret = devm_mutex_init(dev, &state->lock);
> +	if (ret)
> +		return ret;
>  
>  	ret = imx8mq_mipi_csi_subdev_init(state);
>  	if (ret < 0)
> -		goto mutex;
> +		return ret;
>  
>  	ret = imx8mq_mipi_csi_init_icc(pdev);
>  	if (ret)
> -		goto mutex;
> +		return ret;
>  
>  	/* Enable runtime PM. */
>  	pm_runtime_enable(dev);
> @@ -1068,8 +1070,6 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev)
>  	v4l2_async_unregister_subdev(&state->sd);
>  icc:
>  	imx8mq_mipi_csi_release_icc(pdev);
> -mutex:
> -	mutex_destroy(&state->lock);
>  
>  	return ret;
>  }
> @@ -1087,7 +1087,6 @@ static void imx8mq_mipi_csi_remove(struct platform_device *pdev)
>  	imx8mq_mipi_csi_runtime_suspend(&pdev->dev);
>  	media_entity_cleanup(&state->sd.entity);
>  	v4l2_subdev_cleanup(&state->sd);
> -	mutex_destroy(&state->lock);
>  	pm_runtime_set_suspended(&pdev->dev);
>  	imx8mq_mipi_csi_release_icc(pdev);
>  }
> diff --git a/drivers/media/platform/nxp/mx2_emmaprp.c b/drivers/media/platform/nxp/mx2_emmaprp.c
> index 02d57229b9b3a600303cc0429e102139385071d6..384a2672884e96d17cca542ef51fbef62328b66a 100644
> --- a/drivers/media/platform/nxp/mx2_emmaprp.c
> +++ b/drivers/media/platform/nxp/mx2_emmaprp.c
> @@ -824,7 +824,9 @@ static int emmaprp_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	mutex_init(&pcdev->dev_mutex);
> +	ret = devm_mutex_init(&pdev->dev, &pcdev->dev_mutex);
> +	if (ret)
> +		return ret;
>  
>  	vfd = video_device_alloc();
>  	if (!vfd) {
> @@ -878,8 +880,6 @@ static int emmaprp_probe(struct platform_device *pdev)
>  unreg_dev:
>  	v4l2_device_unregister(&pcdev->v4l2_dev);
>  
> -	mutex_destroy(&pcdev->dev_mutex);
> -
>  	return ret;
>  }
>  
> @@ -892,7 +892,6 @@ static void emmaprp_remove(struct platform_device *pdev)
>  	video_unregister_device(pcdev->vfd);
>  	v4l2_m2m_release(pcdev->m2m_dev);
>  	v4l2_device_unregister(&pcdev->v4l2_dev);
> -	mutex_destroy(&pcdev->dev_mutex);
>  }
>  
>  static struct platform_driver emmaprp_pdrv = {

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2025-11-19  4:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-17 18:58 [PATCH 0/4] media: platform: nxp: Trivial cleanup pathces Frank Li
2025-11-17 18:58 ` [PATCH 1/4] media: nxp: use devm_mutex_init() simple code Frank Li
2025-11-19  4:22   ` Laurent Pinchart [this message]
2025-11-19 16:17     ` Frank Li
2025-11-17 18:58 ` [PATCH 2/4] media: nxp: use dev_err_probe() to simplify code Frank Li
2025-11-19  4:33   ` Laurent Pinchart
2025-11-17 18:58 ` [PATCH 3/4] media: nxp: imx8-isi: use devm_pm_runtime_enable() " Frank Li
2025-11-19  4:24   ` Laurent Pinchart
2025-11-17 18:58 ` [PATCH 4/4] media: nxp: use cleanup __free(fwnode_handle) " Frank Li
2025-11-19  4:25   ` Laurent Pinchart
2025-11-19  5:02     ` Laurent Pinchart
2025-12-03 21:31       ` Frank Li

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=20251119042247.GL10711@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=Frank.Li@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=kernel@puri.sm \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=martink@posteo.de \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rmfrfs@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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