linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Kent Gibson <warthog618@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v5] gpio: consumer: new virtual driver
Date: Thu, 17 Aug 2023 16:00:53 +0300	[thread overview]
Message-ID: <ZN4aBXX69m/YxWhZ@smile.fi.intel.com> (raw)
In-Reply-To: <CAMRc=Mds_PC8xO25HfjGbAP1LTqop4vkuz0OPHbcx9UO7QFF5A@mail.gmail.com>

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



      reply	other threads:[~2023-08-17 13:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 18:56 [PATCH v5] gpio: consumer: new virtual driver Bartosz Golaszewski
2023-08-17 10:03 ` Andy Shevchenko
2023-08-17 12:14   ` Bartosz Golaszewski
2023-08-17 12:38     ` Andy Shevchenko
2023-08-17 12:53       ` Bartosz Golaszewski
2023-08-17 13:00         ` Andy Shevchenko [this message]

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=ZN4aBXX69m/YxWhZ@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=corbet@lwn.net \
    --cc=linus.walleij@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=warthog618@gmail.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;
as well as URLs for NNTP newsgroup(s).