lkml.org 
[lkml]   [2023]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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@linux.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@linux.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


\
 
 \ /
  Last update: 2023-08-17 15:03    [W:0.032 / U:1.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site