[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZN4aBXX69m/YxWhZ@smile.fi.intel.com>
Date: Thu, 17 Aug 2023 16:00:53 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Kent Gibson <warthog618@...il.com>,
Jonathan Corbet <corbet@....net>, linux-gpio@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v5] gpio: consumer: new virtual driver
On Thu, Aug 17, 2023 at 02:53:04PM +0200, Bartosz Golaszewski wrote:
> On Thu, Aug 17, 2023 at 2:38 PM Andy Shevchenko
> <andriy.shevchenko@...ux.intel.com> wrote:
> > On Thu, Aug 17, 2023 at 02:14:04PM +0200, Bartosz Golaszewski wrote:
> > > On Thu, Aug 17, 2023 at 12:03 PM Andy Shevchenko
> > > <andriy.shevchenko@...ux.intel.com> wrote:
> > > > On Tue, Aug 15, 2023 at 08:56:50PM +0200, Bartosz Golaszewski wrote:
...
> > > > > + struct gpio_consumer_device *dev = lookup->parent;
> > > > > +
> > > > > + guard(mutex)(&dev->lock);
> > > > > +
> > > > > + return sprintf(page, "%s\n", lookup->key);
> >
> > (1)
...
> > So the 1) has to be amended then.
>
> No! lookup->key is a string stored in the lookup struct BUT protected
> by the consumer device's lock (it must be or else the lookup could get
> removed while it's being modified). Unless you want to duplicate the
> string in order to release the mutex earlier, it has to be locked
> until sprintf() returns.
Ah, good point, otherwise we would need a copy...
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists