Re: [PATCH v3] media: v4l2-flash: Enter LED off state after file handle closed
From: ChiYuan Huang
Date: Sun Feb 22 2026 - 20:03:08 EST
On Mon, Feb 23, 2026 at 08:18:50AM +0800, ChiYuan Huang wrote:
> On Sat, Feb 21, 2026 at 04:48:48PM +0100, Jacek Anaszewski wrote:
> Hi, Jacek:
>
> > Hi ChiYuan,
> >
> ...
> > On 1/12/26 10:20, cy_huang@xxxxxxxxxxx wrote:
> > > drivers/media/v4l2-core/v4l2-flash-led-class.c | 6 ++++++
> > > 1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c
> > > index 355595a0fefa..46606f5cc192 100644
> > > --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c
> > > +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c
> > > @@ -623,6 +623,12 @@ static int v4l2_flash_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
> > > return 0;
> > > if (led_cdev) {
> > > + /* If file handle is released, make sure LED enter off state */
> > > + ret = v4l2_ctrl_s_ctrl(v4l2_flash->ctrls[LED_MODE],
> > > + V4L2_FLASH_LED_MODE_NONE);
> > > + if (ret)
> > > + return ret;
> > > +
> > > mutex_lock(&led_cdev->led_access);
> > > if (v4l2_flash->ctrls[STROBE_SOURCE])
> > >
> > > base-commit: 8ac28a6642d1cc8bac0632222e66add800b027fa
> >
> > The patch itself looks good, but while at it I started wondering
> > if we shouldn't move below STROBE_SOURCE access before the lock.
> > I don't see now, why we placed it there.
> >
> My assumption is LED should already be called 'led_sysfs_enable(false)',
> no other APIs except V4L2 singular handle. But your guess is right. If we
> put the change after the lock, should be more safe.
>
> Thanks for the reviewing, if the common is to put after the lock, then
> I can send v4 patch to fix it.
Aha, I remember the another thing is the 'return'.
To put after the lock, the lock problem need to be handled.
Should rewrite the lock using 'scoped_guard' and move all into the scope.
> > Adding Sakari.
> >
> > --
> > Best regards,
> > Jacek Anaszewski
> >