Skip to contentSkip to conversation

gpiolib: cdev: relocate debounce_period_us from struct gpio_desc

PATCH Andy Shevchenko 1 participant 1 message Dec 18, 2023 GPIO

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Bartosz Golaszewski
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Kent Gibson
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

On Thu, Dec 14, 2023 at 05:58:11PM +0800, Kent Gibson wrote:

...

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+static void supinfo_init(void)
+{
+       supinfo.tree = RB_ROOT;
+       spin_lock_init(&supinfo.lock);
+}

Can it be done statically?

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

supinfo = {
.tree = RB_ROOT,
.lock = __SPIN_LOCK_UNLOCKED(supinfo.lock),

Double underscore typically means it's private and shouldn't be used.

Right, but when you have a struct you have no other means to initialize this directly.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

I even checked the current tree, we have 32 users of this pattern in drivers/.

See, there are users of the __ initializers.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Ah, that is what you meant. Yeah sure can - the supinfo_init() is another hangover from when I was trying to create the supinfo per chip, but now it is a global a static initialiser makes sense.

Yep, the DEFINE_MUTEX() / DEFINE_SPINLOCK() / etc looks better naturally than above.

Yeah, so maybe we should use non-struct, global variables after all.

At least this will allow to get rid of (questionable) initcall.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

And I still haven't received the email you quote there.

:-( I'm not sure we will get it, it most likely that I removed it already and it has disappeared due to problems with email server...

Signature · 2 lines
With Best Regards,
Andy Shevchenko