Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label()
  2026-11-26  8:42 [PATCH] gpiolib: Use srcu_barrier() instead of synchronize_srcu() in gpiodev_release() Zqiang
@ 2026-11-26  8:42 ` Zqiang
  2026-11-26 14:59   ` Bartosz Golaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Zqiang @ 2026-11-26  8:42 UTC (permalink / raw)
  To: linusw, brgl, paulmck; +Cc: linux-gpio, linux-kernel, qiang.zhang

The srcu_dereference_check() already evaluates 'srcu_read_lock_held(ssp)'
internally, so passing srcu_read_lock_held() as the extra condition is
redundant. all callers of gpiod_get_label() hold the desc_srcu read lock,
so replace it with srcu_dereference(), which provides identical lockdep
coverage.

No functional changes.

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 drivers/gpio/gpiolib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5dd4d142cf52..47ce89bfb578 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -124,8 +124,7 @@ const char *gpiod_get_label(struct gpio_desc *desc)
 
 	flags = READ_ONCE(desc->flags);
 
-	label = srcu_dereference_check(desc->label, &desc->gdev->desc_srcu,
-				srcu_read_lock_held(&desc->gdev->desc_srcu));
+	label = srcu_dereference(desc->label, &desc->gdev->desc_srcu);
 
 	if (test_bit(GPIOD_FLAG_USED_AS_IRQ, &flags))
 		return label ? label->str : "interrupt";
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label()
  2026-11-26  8:42 ` [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label() Zqiang
@ 2026-11-26 14:59   ` Bartosz Golaszewski
  2026-11-26 23:11     ` Zqiang
  0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-11-26 14:59 UTC (permalink / raw)
  To: Zqiang; +Cc: linusw, paulmck, linux-gpio, linux-kernel

On Thu, Nov 26, 2026 at 04:42:33PM +0800, Zqiang wrote:
> The srcu_dereference_check() already evaluates 'srcu_read_lock_held(ssp)'
> internally, so passing srcu_read_lock_held() as the extra condition is
> redundant. all callers of gpiod_get_label() hold the desc_srcu read lock,
> so replace it with srcu_dereference(), which provides identical lockdep
> coverage.
> 
> No functional changes.
> 
> Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> ---
>  drivers/gpio/gpiolib.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 5dd4d142cf52..47ce89bfb578 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -124,8 +124,7 @@ const char *gpiod_get_label(struct gpio_desc *desc)
>  
>  	flags = READ_ONCE(desc->flags);
>  
> -	label = srcu_dereference_check(desc->label, &desc->gdev->desc_srcu,
> -				srcu_read_lock_held(&desc->gdev->desc_srcu));
> +	label = srcu_dereference(desc->label, &desc->gdev->desc_srcu);
>  
>  	if (test_bit(GPIOD_FLAG_USED_AS_IRQ, &flags))
>  		return label ? label->str : "interrupt";
> -- 
> 2.17.1
>

What is this patch? A v2 to the one it's replying to? A separate change
(in which case it should be a new thread, not a reply)?

I'm confused by this thread.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label()
  2026-11-26 14:59   ` Bartosz Golaszewski
@ 2026-11-26 23:11     ` Zqiang
  0 siblings, 0 replies; 4+ messages in thread
From: Zqiang @ 2026-11-26 23:11 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: linusw, paulmck, linux-gpio, linux-kernel

> 
> On Thu, Nov 26, 2026 at 04:42:33PM +0800, Zqiang wrote:
> 
> > 
> > The srcu_dereference_check() already evaluates 'srcu_read_lock_held(ssp)'
> >  internally, so passing srcu_read_lock_held() as the extra condition is
> >  redundant. all callers of gpiod_get_label() hold the desc_srcu read lock,
> >  so replace it with srcu_dereference(), which provides identical lockdep
> >  coverage.
> >  
> >  No functional changes.
> >  
> >  Signed-off-by: Zqiang <qiang.zhang@linux.dev>
> >  ---
> >  drivers/gpio/gpiolib.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >  
> >  diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> >  index 5dd4d142cf52..47ce89bfb578 100644
> >  --- a/drivers/gpio/gpiolib.c
> >  +++ b/drivers/gpio/gpiolib.c
> >  @@ -124,8 +124,7 @@ const char *gpiod_get_label(struct gpio_desc *desc)
> >  
> >  flags = READ_ONCE(desc->flags);
> >  
> >  - label = srcu_dereference_check(desc->label, &desc->gdev->desc_srcu,
> >  - srcu_read_lock_held(&desc->gdev->desc_srcu));
> >  + label = srcu_dereference(desc->label, &desc->gdev->desc_srcu);
> >  
> >  if (test_bit(GPIOD_FLAG_USED_AS_IRQ, &flags))
> >  return label ? label->str : "interrupt";
> >  -- 
> >  2.17.1
> > 
> What is this patch? A v2 to the one it's replying to? A separate change
> (in which case it should be a new thread, not a reply)?
> 
> I'm confused by this thread.

This are two separate thread, I sent them together at the time, but it seems
that the title was lost, sorry, I caused your misunderstanding, I will resend it.

Thanks
Zqiang


> 
> Bart
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label()
@ 2026-11-27  2:31 Zqiang
  0 siblings, 0 replies; 4+ messages in thread
From: Zqiang @ 2026-11-27  2:31 UTC (permalink / raw)
  To: linusw, brgl, paulmck; +Cc: linux-gpio, linux-kernel, qiang.zhang

The srcu_dereference_check() already evaluates 'srcu_read_lock_held(ssp)'
internally, so passing srcu_read_lock_held() as the extra condition is
redundant. all callers of gpiod_get_label() hold the desc_srcu read lock,
so replace it with srcu_dereference(), which provides identical lockdep
coverage.

No functional changes.

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 drivers/gpio/gpiolib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5dd4d142cf52..47ce89bfb578 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -124,8 +124,7 @@ const char *gpiod_get_label(struct gpio_desc *desc)
 
 	flags = READ_ONCE(desc->flags);
 
-	label = srcu_dereference_check(desc->label, &desc->gdev->desc_srcu,
-				srcu_read_lock_held(&desc->gdev->desc_srcu));
+	label = srcu_dereference(desc->label, &desc->gdev->desc_srcu);
 
 	if (test_bit(GPIOD_FLAG_USED_AS_IRQ, &flags))
 		return label ? label->str : "interrupt";
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-27  2:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  2:31 [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label() Zqiang
  -- strict thread matches above, loose matches on Subject: below --
2026-11-26  8:42 [PATCH] gpiolib: Use srcu_barrier() instead of synchronize_srcu() in gpiodev_release() Zqiang
2026-11-26  8:42 ` [PATCH] gpiolib: Use srcu_dereference() in gpiod_get_label() Zqiang
2026-11-26 14:59   ` Bartosz Golaszewski
2026-11-26 23:11     ` Zqiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox