gpiolib: Return label, if set, for IRQ only line
PATCH 1/1 gpiolib: Return label, if set, for IRQ only line
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib.c +6 -6
@@ -105,16 +105,16 @@ const char *gpiod_get_label(struct gpio_desc *desc)unsigned long flags; flags =READ_ONCE (desc->flags); -if (test_bit (FLAG_USED_AS_IRQ , &flags) && - !test_bit (FLAG_REQUESTED , &flags)) -return "interrupt" ; - -if (!test_bit (FLAG_REQUESTED , &flags)) -return NULL ; label =srcu_dereference_check (desc->label, &desc->srcu,srcu_read_lock_held (&desc->srcu)); +if (test_bit (FLAG_USED_AS_IRQ , &flags)) +return label->str ?:"interrupt" ; + +if (!test_bit (FLAG_REQUESTED , &flags)) +return NULL ; +return label->str; }
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Quoted 37 lines · Andy Shevchenko
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +6
-7@@ -105,16 +105,16 @@ const char *gpiod_get_label(struct gpio_desc *desc)unsigned long flags; flags =READ_ONCE (desc->flags); -if (test_bit (FLAG_USED_AS_IRQ , &flags) && - !test_bit (FLAG_REQUESTED , &flags)) -return "interrupt" ; - -if (!test_bit (FLAG_REQUESTED , &flags)) -return NULL ; label =srcu_dereference_check (desc->label, &desc->srcu,srcu_read_lock_held (&desc->srcu)); +if (test_bit (FLAG_USED_AS_IRQ , &flags)) +return label->str ?:"interrupt" ; + +if (!test_bit (FLAG_REQUESTED , &flags)) +return NULL ; +return label->str; } --
Quoted 2 lines
2.43.0.rc1.1336.g36b5255a03ac
What good would it be if gpiochip_dup_line_label() returns NULL for unrequested lines anyway?
Bart
Thu, May 09, 2024 at 03:15:05PM +0200, Bartosz Golaszewski kirjoitti:
Quoted 29 lines
Quoted 27 lines · Andy Shevchenko
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +0
-6@@ -105,16 +105,16 @@ const char *gpiod_get_label(struct gpio_desc *desc)unsigned long flags; flags =READ_ONCE (desc->flags); -if (test_bit (FLAG_USED_AS_IRQ , &flags) && - !test_bit (FLAG_REQUESTED , &flags)) -return "interrupt" ; - -if (!test_bit (FLAG_REQUESTED , &flags)) -return NULL ; label =srcu_dereference_check (desc->label, &desc->srcu,srcu_read_lock_held (&desc->srcu));
Quoted 11 lines
drivers/gpio/gpiolib.c const char *gpiod_get_label(struct gpio_desc *desc) · line 119
Quoted 8 lines
drivers/gpio/gpiolib.c +6
-0+if (test_bit (FLAG_USED_AS_IRQ , &flags)) +return label->str ?:"interrupt" ; + +if (!test_bit (FLAG_REQUESTED , &flags)) +return NULL ; +return label->str; }What good would it be if
gpiochip_dup_line_label()returns NULL for unrequested lines anyway?
Then it should be handled differently in those cases. So, consider it as a preparatory patch which doesn't change current behaviour.
(Yes, I have some hack patches locally which do something useful, but they are not ready. In any case this one looks to me as a good cleanup on its own for the sake of readability of the code and reduced amount of checks.)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 43 lines · Andy Shevchenko
Thu, May 09, 2024 at 03:15:05PM +0200, Bartosz Golaszewski kirjoitti:
Quoted 29 lines
Quoted 27 lines · Andy Shevchenko
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +0
-6@@ -105,16 +105,16 @@ const char *gpiod_get_label(struct gpio_desc *desc)unsigned long flags; flags =READ_ONCE (desc->flags); -if (test_bit (FLAG_USED_AS_IRQ , &flags) && - !test_bit (FLAG_REQUESTED , &flags)) -return "interrupt" ; - -if (!test_bit (FLAG_REQUESTED , &flags)) -return NULL ; label =srcu_dereference_check (desc->label, &desc->srcu,srcu_read_lock_held (&desc->srcu));Quoted 11 lines
drivers/gpio/gpiolib.c const char *gpiod_get_label(struct gpio_desc *desc) · line 119
Quoted 8 lines
drivers/gpio/gpiolib.c +6
-0+if (test_bit (FLAG_USED_AS_IRQ , &flags)) +return label->str ?:"interrupt" ; + +if (!test_bit (FLAG_REQUESTED , &flags)) +return NULL ; +return label->str; }What good would it be if
gpiochip_dup_line_label()returns NULL for unrequested lines anyway?
Quoted 7 lines
Then it should be handled differently in those cases. So, consider it as a preparatory patch which doesn't change current behaviour.
(Yes, I have some hack patches locally which do something useful, but they are not ready. In any case this one looks to me as a good cleanup on its own for the sake of readability of the code and reduced amount of checks.)
Fair enough but I would like to know what your bigger plan is before picking this up.
Bart
Quoted 47 lines · Bartosz Golaszewski
Quoted 45 lines · Andy Shevchenko
Thu, May 09, 2024 at 03:15:05PM +0200, Bartosz Golaszewski kirjoitti:
Quoted 29 lines
Quoted 27 lines · Andy Shevchenko
If line has been locked as IRQ without requesting, still check its label and return it, if not NULL.
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +0
-6@@ -105,16 +105,16 @@ const char *gpiod_get_label(struct gpio_desc *desc)unsigned long flags; flags =READ_ONCE (desc->flags); -if (test_bit (FLAG_USED_AS_IRQ , &flags) && - !test_bit (FLAG_REQUESTED , &flags)) -return "interrupt" ; - -if (!test_bit (FLAG_REQUESTED , &flags)) -return NULL ; label =srcu_dereference_check (desc->label, &desc->srcu,srcu_read_lock_held (&desc->srcu));Quoted 11 lines
drivers/gpio/gpiolib.c const char *gpiod_get_label(struct gpio_desc *desc) · line 119
Quoted 8 lines
drivers/gpio/gpiolib.c +6
-0+if (test_bit (FLAG_USED_AS_IRQ , &flags)) +return label->str ?:"interrupt" ; + +if (!test_bit (FLAG_REQUESTED , &flags)) +return NULL ; +return label->str; }What good would it be if
gpiochip_dup_line_label()returns NULL for unrequested lines anyway?Then it should be handled differently in those cases. So, consider it as a preparatory patch which doesn't change current behaviour.
Quoted 7 lines
Quoted 4 lines
(Yes, I have some hack patches locally which do something useful, but they are not ready. In any case this one looks to me as a good cleanup on its own for the sake of readability of the code and reduced amount of checks.)
Fair enough but I would like to know what your bigger plan is before picking this up.
I stand corrected, this patch has an immediate effect on the generic gpiolib_dbg_show() which does *not* use the above mentioned call..
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Bartosz Golaszewski
On Thu, May 9, 2024 at 3:58 PM Andy Shevchenko
<[email protected]> wrote:
...
Quoted 5 lines
Quoted 2 lines
Fair enough but I would like to know what your bigger plan is before picking this up.
I stand corrected, this patch has an immediate effect on the generic
gpiolib_dbg_show()which does *not* use the above mentioned call..
Ah, but it doesn't use gpiod_get_label() in the else branch either...
I want to amend the else branch there to print similar or reuse the main one. For the latter I have locally a patch to modify gpiolib_dbg_show() to show the interrupt lines as well even if they are not requested.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Bartosz Golaszewski
On Thu, May 9, 2024 at 3:58 PM Andy Shevchenko
<[email protected]> wrote:
...
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
Fair enough but I would like to know what your bigger plan is before picking this up.
I stand corrected, this patch has an immediate effect on the generic
gpiolib_dbg_show()which does *not* use the above mentioned call..Ah, but it doesn't use
gpiod_get_label()in the else branch either...I want to amend the else branch there to print similar or reuse the main one. For the latter I have locally a patch to modify
gpiolib_dbg_show()to show the interrupt lines as well even if they are not requested.
I just shared that patch, if you are okay with both, it would be nice to have them applied.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Bartosz Golaszewski
On Thu, May 9, 2024 at 3:58 PM Andy Shevchenko
<[email protected]> wrote:...
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Fair enough but I would like to know what your bigger plan is before picking this up.
I stand corrected, this patch has an immediate effect on the generic
gpiolib_dbg_show()which does *not* use the above mentioned call..
Quoted 9 lines
Quoted 5 lines
Ah, but it doesn't use
gpiod_get_label()in the else branch either...I want to amend the else branch there to print similar or reuse the main one. For the latter I have locally a patch to modify
gpiolib_dbg_show()to show the interrupt lines as well even if they are not requested.I just shared that patch, if you are okay with both, it would be nice to have them applied.
Not for this merge window, we'll see in two weeks.
Bart
Quoted 7 lines · Bartosz Golaszewski
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Bartosz Golaszewski
On Thu, May 9, 2024 at 3:58 PM Andy Shevchenko
<[email protected]> wrote:
...
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Fair enough but I would like to know what your bigger plan is before picking this up.
I stand corrected, this patch has an immediate effect on the generic
gpiolib_dbg_show()which does *not* use the above mentioned call..Ah, but it doesn't use
gpiod_get_label()in the else branch either...
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I want to amend the else branch there to print similar or reuse the main one. For the latter I have locally a patch to modify
gpiolib_dbg_show()to show the interrupt lines as well even if they are not requested.I just shared that patch, if you are okay with both, it would be nice to have them applied.
Not for this merge window, we'll see in two weeks.
No hurry, I'm fine with your schedule.
Signature · 2 lines
With Best Regards, Andy Shevchenko