From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
andy@kernel.org
Subject: Re: [PATCH 4/4] gpiolib: cdev: replace locking wrappers for gpio_device with guards
Date: Wed, 20 Dec 2023 20:23:41 +0800 [thread overview]
Message-ID: <ZYLczeiVDjd2cWQF@rigel> (raw)
In-Reply-To: <CAMRc=MfyCBpZ07SYfxMtug6FVYiKA0MRgvjMTOAzKiVLGdPM+w@mail.gmail.com>
On Wed, Dec 20, 2023 at 01:16:00PM +0100, Bartosz Golaszewski wrote:
> On Wed, Dec 20, 2023 at 1:13 PM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > On Wed, Dec 20, 2023 at 01:05:35PM +0100, Bartosz Golaszewski wrote:
> > > On Wed, Dec 20, 2023 at 12:56 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> > > >
> > > > (+PeterZ)
> > > >
> > > > On Wed, Dec 20, 2023 at 2:52 AM Kent Gibson <warthog618@gmail.com> wrote:
> > > >
> > > > > Replace the wrapping functions that inhibit removal of the gpio_device
> > > > > with equivalent guard macros.
> > > > >
> > > > > Signed-off-by: Kent Gibson <warthog618@gmail.com>
> > > > (...)
> > > > > +DEFINE_CLASS(_read_sem_guard,
> > > > > + struct rw_semaphore *,
> > > > > + up_read(_T),
> > > > > + ({
> > > > > + down_read(sem);
> > > > > + sem;
> > > > > + }),
> > > > > + struct rw_semaphore *sem);
> > > >
> > > > Isn't this so generic that it should be in <linux/cleanup.h>?
> > > >
> > > > Otherwise all the patches look good to me.
> > > >
> > >
> > > We already have this:
> > >
> > > DEFINE_GUARD(rwsem_read, struct rw_semaphore *, down_read(_T), up_read(_T))
> > > DEFINE_GUARD(rwsem_write, struct rw_semaphore *, down_write(_T), up_write(_T))
> > >
> > > DEFINE_FREE(up_read, struct rw_semaphore *, if (_T) up_read(_T))
> > > DEFINE_FREE(up_write, struct rw_semaphore *, if (_T) up_write(_T))
> > >
> >
> > Ah - in rwsem.h - I missed that.
> >
> > > This can surely be used here, right?
> > >
> >
> > Don't see why not.
> >
> > I would still like to move the gpio_device specific macros to gpiolib.h,
> > as they apply to the struct gpio_device defined there.
>
> Which ones? Because I'd rather use guard(rwsem_read)(&gdev->sem); than
> some custom wrapper as this one's purpose is clearer.
>
It would be read and write guards for the gpio_device.
cdev would only be using the read flavour.
And possibly named something other than read/write as the purpose is to
prevent (read) or allow (write) object removal.
I though that would be clearer than having to reference gpiolib.h to see
what gdev->sem covers, and allow you to change the locking
mechanism later and not have to update cdev.
Cheers,
Kent.
next prev parent reply other threads:[~2023-12-20 12:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 1:51 [PATCH 0/4] gpiolib: cdev: guard tidying Kent Gibson
2023-12-20 1:51 ` [PATCH 1/4] gpiolib: cdev: include overflow.h Kent Gibson
2023-12-20 1:51 ` [PATCH 2/4] gpiolib: cdev: allocate linereq using kvzalloc() Kent Gibson
2023-12-20 14:30 ` Andy Shevchenko
2023-12-20 14:53 ` Kent Gibson
2023-12-20 14:58 ` Andy Shevchenko
2023-12-20 1:51 ` [PATCH 3/4] gpiolib: cdev: replace locking wrappers for config_mutex with guards Kent Gibson
2023-12-20 1:51 ` [PATCH 4/4] gpiolib: cdev: replace locking wrappers for gpio_device " Kent Gibson
2023-12-20 11:55 ` Linus Walleij
2023-12-20 12:05 ` Bartosz Golaszewski
2023-12-20 12:13 ` Kent Gibson
2023-12-20 12:16 ` Bartosz Golaszewski
2023-12-20 12:23 ` Kent Gibson [this message]
2023-12-20 12:30 ` Bartosz Golaszewski
2023-12-20 12:53 ` Kent Gibson
2023-12-20 13:19 ` Bartosz Golaszewski
2023-12-20 13:28 ` Kent Gibson
2023-12-20 13:47 ` Bartosz Golaszewski
2023-12-20 13:53 ` Kent Gibson
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=ZYLczeiVDjd2cWQF@rigel \
--to=warthog618@gmail.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
/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).