From: Frank Li <Frank.li@nxp.com>
To: "Ming Qian(OSS)" <ming.qian@oss.nxp.com>
Cc: mchehab@kernel.org, hverkuil-cisco@xs4all.nl,
mirela.rabulea@oss.nxp.com, nicolas@ndufresne.ca,
shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com, xiahong.bao@nxp.com,
eagle.zhou@nxp.com, linux-imx@nxp.com, imx@lists.linux.dev,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 2/4] media: imx-jpeg: Use devm_pm_runtime_enable() helper
Date: Wed, 4 Feb 2026 10:42:53 -0500 [thread overview]
Message-ID: <aYNo_XjfrXA6tKX-@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <0f2cc5d0-9abe-47c6-abdc-42ebe5fb5b35@oss.nxp.com>
On Wed, Feb 04, 2026 at 09:36:06AM +0800, Ming Qian(OSS) wrote:
> Hi Frank,
>
> On 2/4/2026 12:56 AM, Frank Li wrote:
> > On Tue, Feb 03, 2026 at 04:23:39PM +0800, ming.qian@oss.nxp.com wrote:
> > > From: Ming Qian <ming.qian@oss.nxp.com>
> > >
> > > Use devm_pm_runtime_enable() to simplify probe and exit paths.
> > >
> > > No functional change.
> > >
> > > Signed-off-by: Ming Qian <ming.qian@oss.nxp.com>
> > > ---
> > > drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 15 ++++++++++++---
> > > 1 file changed, 12 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> > > index 39022c1bf36d..877e6c4f7406 100644
> > > --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> > > +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
> > > @@ -2971,12 +2971,22 @@ static int mxc_jpeg_probe(struct platform_device *pdev)
> > > jpeg->dec_vdev->minor);
> > >
> > > platform_set_drvdata(pdev, jpeg);
> > > - pm_runtime_enable(dev);
> > > + ret = devm_pm_runtime_enable(dev);
> > > + if (ret) {
> > > + dev_err(dev, "Failed to enable runtime PM: %d\n", ret);
> > > + goto err_pm;
> > > + }
> > >
> > > return 0;
> > >
> > > +err_pm:
> > > + video_unregister_device(jpeg->dec_vdev);
> > > + /* set NULL to prevent double-free */
> > > + jpeg->dec_vdev = NULL;
> >
> > code have not simplied, you add addtional goto label. You can use
> > devm_add_action_or_reset().
> >
> > Frank
> >
>
> I don't quite understand the difference compared to directly using
> devm_pm_runtime_enable.
>
> int devm_pm_runtime_enable(struct device *dev)
> {
> pm_runtime_enable(dev);
>
> return devm_add_action_or_reset(dev, pm_runtime_disable_action, dev);
> }
>
> We still need to check the return value of devm_add_action_or_reset and
> perform the corresponding error handling.
> We may still add the goto label.
Sorry, my means put video_device_release() to devm_add_action_or_reset() to
avoid goto.
If it is complex, you can keep original one.
Frank
>
> Regards,
> Ming
>
> > > err_vdev_register:
> > > - video_device_release(jpeg->dec_vdev);
> > > + /* Only release if allocation succeeded but registration failed */
> > > + if (jpeg->dec_vdev)
> > > + video_device_release(jpeg->dec_vdev);
> > >
> > > err_vdev_alloc:
> > > v4l2_m2m_release(jpeg->m2m_dev);
> > > @@ -3047,7 +3057,6 @@ static void mxc_jpeg_remove(struct platform_device *pdev)
> > >
> > > mxc_jpeg_free_slot_data(jpeg);
> > >
> > > - pm_runtime_disable(&pdev->dev);
> > > video_unregister_device(jpeg->dec_vdev);
> > > v4l2_m2m_release(jpeg->m2m_dev);
> > > v4l2_device_unregister(&jpeg->v4l2_dev);
> > > --
> > > 2.52.0
> > >
next prev parent reply other threads:[~2026-02-04 15:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-03 8:23 [PATCH v4 0/4] media: imx-jpeg: Add v1 hardware encoder support for i.MX952 ming.qian
2026-02-03 8:23 ` [PATCH v4 1/4] media: imx-jpeg: Simplify descriptor initialization with memset ming.qian
2026-02-03 8:23 ` [PATCH v4 2/4] media: imx-jpeg: Use devm_pm_runtime_enable() helper ming.qian
2026-02-03 16:56 ` Frank Li
2026-02-04 1:36 ` Ming Qian(OSS)
2026-02-04 15:42 ` Frank Li [this message]
2026-02-05 1:45 ` Ming Qian(OSS)
2026-03-19 19:53 ` Nicolas Dufresne
2026-02-03 8:23 ` [PATCH v4 3/4] media: imx-jpeg: Add encoder ops layer for hardware abstraction ming.qian
2026-02-03 8:23 ` [PATCH v4 4/4] media: imx-jpeg: Add support for encoder v1 descriptor configuration ming.qian
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=aYNo_XjfrXA6tKX-@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=eagle.zhou@nxp.com \
--cc=festevam@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ming.qian@oss.nxp.com \
--cc=mirela.rabulea@oss.nxp.com \
--cc=nicolas@ndufresne.ca \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=xiahong.bao@nxp.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