Re: [PATCH v2 07/10] pinctrl: baytrail: use gpiochip_dup_line_label()
From: Bartosz Golaszewski
Date: Thu Nov 30 2023 - 12:39:20 EST
On Thu, Nov 30, 2023 at 5:36 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Thu, Nov 30, 2023 at 02:46:27PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > Use the new gpiochip_dup_line_label() helper to safely retrieve the
> > descriptor label.
>
> ...
>
> > seq_printf(s,
> > " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s",
> > pin,
> > - label,
> > + label ?: "Unrequested",
>
> This already fourth (?) duplication among drivers.
> Perhaps you want a helper:
> gpiochip_dup_line_label_fallback() // naming is up to you
> which will return the same for everybody and we don't need to hunt for
> the different meaning of "Unrequested".
>
IMO the overhead here is very small in return for better readability
(IOW: `label ?: "Unrequested"` is more readable than some function
named `gpiochip_dup_line_label_fallback()`). Given the string is in
.rodata anyway, I wouldn't be surprised if adding a helper resulted in
bigger code.
> Also the word "Unrequested" is a bit doubtful as it can be a label, right?
> Something with special characters / spaces / etc would suit better?
> In any case it might require to add a warning (?) to the GPIO lib core
> when label gets assigned if it clashes with the "reserved" word.
>
Agreed but this is a functional change in debugfs output. I know
debugfs is not considered stable but I didn't write it, I don't know
who's using it and I prefer to leave it be.
Bart
> > val & BYT_INPUT_EN ? " " : "in",
> > val & BYT_OUTPUT_EN ? " " : "out",
> > str_hi_lo(val & BYT_LEVEL),
>
> --
> With Best Regards,
> Andy Shevchenko
>
>