linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andy@kernel.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	linus.walleij@linaro.org
Subject: Re: [PATCH 1/4] gpiolib: cdev: relocate debounce_period_us from struct gpio_desc
Date: Thu, 14 Dec 2023 08:18:01 +0800	[thread overview]
Message-ID: <ZXpJueTnmtUIecCd@rigel> (raw)
In-Reply-To: <ZXoO8B0N3S49GnvX@smile.fi.intel.com>

On Wed, Dec 13, 2023 at 10:07:12PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 13, 2023 at 08:03:44PM +0100, Bartosz Golaszewski wrote:
>
> ...
>
> > > > > > > > > > +static struct supinfo supinfo;
> > > > > > > > >
> > > > > > > > > Why supinfo should be a struct to begin with? Seems to me as an unneeded
> > > > > > > > > complication.
> > > > > > >
> > > > > > > I think we should keep it as a struct but defined the following way:
> > > > > > >
> > > > > > > struct {
> > > > > > >     spinlock_t lock;
> > > > > > >     struct rb_root tree;
> > > > > > > } supinfo;
> > > > > >
> > > > > > That is what I meant be merging the struct definition with the variable
> > > > > > definition.  Or is there some other way to completely do away with the
> > > > > > struct that I'm missing?
> > > > >
> > > > > Look at the top of gpiolib.c:
> > > > >
> > > > > static DEFINE_MUTEX(gpio_lookup_lock);
> > > > > static LIST_HEAD(gpio_lookup_list);
> > > > >
> > > > > In the similar way you can simply do
> > > > >
> > > > > static DEFINE_SPINLOCK(gpio_sup_lock);
> > > > > static struct rb_root gpio_sup_tree;
> > > >
> > > > The fact that this has been like this, doesn't mean it's the only
> > > > right way. IMO putting these into the same structure makes logical
> > > > sense.
> > >
> > > I disagree on the struct like this on the grounds:
> > > - it's global

I dislike having the global at all - and now you want two :-(.

> > > - it's one time use

Its not about how many times it is instanciated, it is about
maintainability.

> > > - it adds complications for no benefit

It provides a placeholder for collective documentation and clarifies
scope for the reader.
How is it more complicated?

> > > - it makes code uglier and longer
> > >

What, swapping an underscore for a period?

And you would hope the generated code is essentially the same.

> >
> > It boils down to supinfo.lock vs supinfo_lock. I do prefer the former
> > but it's a weak opinion, I won't die on that hill.
>
> Me neither, just showing rationale from my side.
>

I can't recall the last time I intentionally used separate globals over a
struct, so if there are no strong opinions otherwise I'll leave it as a
struct.

Cheers,
Kent.


  reply	other threads:[~2023-12-14  0:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12  5:42 [PATCH 0/4] gpiolib: cdev: relocate debounce_period_us Kent Gibson
2023-12-12  5:42 ` [PATCH 1/4] gpiolib: cdev: relocate debounce_period_us from struct gpio_desc Kent Gibson
2023-12-13 13:54   ` Andy Shevchenko
2023-12-13 14:27     ` Kent Gibson
2023-12-13 15:40       ` Bartosz Golaszewski
2023-12-13 15:59         ` Kent Gibson
2023-12-13 16:12           ` Andy Shevchenko
2023-12-13 16:15             ` Bartosz Golaszewski
2023-12-13 16:29               ` Andy Shevchenko
2023-12-13 19:03                 ` Bartosz Golaszewski
2023-12-13 20:07                   ` Andy Shevchenko
2023-12-14  0:18                     ` Kent Gibson [this message]
2023-12-14  2:15                       ` Kent Gibson
2023-12-14  9:40                         ` Bartosz Golaszewski
2023-12-14 14:35                           ` Andy Shevchenko
2023-12-14 14:47                             ` Kent Gibson
2023-12-13 16:14           ` Bartosz Golaszewski
2023-12-13 16:15         ` Kent Gibson
2023-12-13 16:16           ` Bartosz Golaszewski
2023-12-13 16:27           ` Andy Shevchenko
2023-12-12  5:42 ` [PATCH 2/4] gpiolib: remove " Kent Gibson
2023-12-12  5:42 ` [PATCH 3/4] gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo() Kent Gibson
2023-12-13 13:56   ` Andy Shevchenko
2023-12-13 14:07     ` Kent Gibson
2023-12-13 15:05       ` Andy Shevchenko
2023-12-13 15:11       ` Kent Gibson
2023-12-13 15:28         ` Andy Shevchenko
2023-12-12  5:42 ` [PATCH 4/4] gpiolib: cdev: improve documentation of get/set values Kent Gibson
2023-12-12 17:09 ` [PATCH 0/4] gpiolib: cdev: relocate debounce_period_us Bartosz Golaszewski
2023-12-12 23:58   ` Kent Gibson
2023-12-13 10:03     ` Bartosz Golaszewski
2023-12-13 13:17       ` 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=ZXpJueTnmtUIecCd@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 \
    /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).