On Wed, Dec 13, 2023 at 5:29 PM Andy Shevchenko <andy@xxxxxxxxxx> wrote: > > On Wed, Dec 13, 2023 at 05:15:38PM +0100, Bartosz Golaszewski wrote: > > On Wed, Dec 13, 2023 at 5:12 PM Andy Shevchenko <andy@xxxxxxxxxx> wrote: > > > On Wed, Dec 13, 2023 at 11:59:26PM +0800, Kent Gibson wrote: > > > > On Wed, Dec 13, 2023 at 04:40:12PM +0100, Bartosz Golaszewski wrote: > > > > > On Wed, Dec 13, 2023 at 3:27 PM Kent Gibson <warthog618@xxxxxxxxx> wrote: > > > > > > On Wed, Dec 13, 2023 at 03:54:53PM +0200, Andy Shevchenko wrote: > > > > > > > On Tue, Dec 12, 2023 at 01:42:50PM +0800, Kent Gibson 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 > - it's one time use > - it adds complications for no benefit > - it makes code uglier and longer > 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. Bart > What we probably want to have is a singleton objects in C language or at least > inside Linux kernel project. But I'm not sure it's feasible. > > > > > > > Yeah, that is a hangover from an earlier iteration where supinfo was > > > > > > contained in other object rather than being a global. > > > > > > Could merge the struct definition into the variable now. > > -- > With Best Regards, > Andy Shevchenko > >