* Re: [PATCH] gpiolib: Add some warn print for easier to debug
[not found] <5f049035.1c69fb81.15cb1.53fdSMTPIN_ADDED_MISSING@mx.google.com>
@ 2020-07-09 13:26 ` Bartosz Golaszewski
2020-07-09 15:40 ` Andy Shevchenko
0 siblings, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2020-07-09 13:26 UTC (permalink / raw)
To: mnlife; +Cc: Linus Walleij, linux-gpio
On Tue, Jul 7, 2020 at 5:09 PM mnlife <mnlife@foxmail.com> wrote:
>
> when I get gpiod optional failed, I am confused for a long time.
> finally I find out that because of the string con_id is too long,
> prop_name is truncated.
>
> Signed-off-by: mnlife <mnlife@foxmail.com>
> ---
> drivers/gpio/gpiolib-of.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index ccc449df3792..11740f292420 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -467,15 +467,20 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
> enum of_gpio_flags of_flags;
> struct gpio_desc *desc;
> unsigned int i;
> + int size;
>
> /* Try GPIO property "foo-gpios" and "foo-gpio" */
> for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
> if (con_id)
> - snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
> - gpio_suffixes[i]);
> + size = snprintf(prop_name, sizeof(prop_name), "%s-%s",
> + con_id, gpio_suffixes[i]);
> else
> - snprintf(prop_name, sizeof(prop_name), "%s",
> - gpio_suffixes[i]);
> + size = snprintf(prop_name, sizeof(prop_name), "%s",
> + gpio_suffixes[i]);
> +
> + if (size >= sizeof(prop_name))
> + dev_warn(dev, "prop_name %s is truncated with size %d\n",
> + prop_name, size);
>
> desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
> &of_flags);
> --
> 2.17.1
>
To me this isn't a reason for a warning. If anything, this should
simply be documented (if it's not already).
Bart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpiolib: Add some warn print for easier to debug
2020-07-09 13:26 ` [PATCH] gpiolib: Add some warn print for easier to debug Bartosz Golaszewski
@ 2020-07-09 15:40 ` Andy Shevchenko
[not found] ` <BY5PR12MB41141291F53618E098239A73F9650@BY5PR12MB4114.namprd12.prod.outlook.com>
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-07-09 15:40 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: mnlife, Linus Walleij, linux-gpio
On Thu, Jul 9, 2020 at 4:27 PM Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:
> On Tue, Jul 7, 2020 at 5:09 PM mnlife <mnlife@foxmail.com> wrote:
...
> > + if (size >= sizeof(prop_name))
> > + dev_warn(dev, "prop_name %s is truncated with size %d\n",
> > + prop_name, size);
> To me this isn't a reason for a warning. If anything, this should
> simply be documented (if it's not already).
+1. This can only be useful in the development cycle.
CONFIG_DEBUG_GPIO easily catches this as well.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpiolib: Add some warn print for easier to debug
[not found] ` <BY5PR12MB41141291F53618E098239A73F9650@BY5PR12MB4114.namprd12.prod.outlook.com>
@ 2020-07-10 13:38 ` Andy Shevchenko
[not found] ` <DM6PR12MB41226F148D9D3F64A2C1EE19F9650@DM6PR12MB4122.namprd12.prod.outlook.com>
0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-07-10 13:38 UTC (permalink / raw)
To: qiao mnlife; +Cc: Bartosz Golaszewski, mnlife, Linus Walleij, linux-gpio
On Fri, Jul 10, 2020 at 6:11 AM qiao mnlife <mnlife.qiao@gmail.com> wrote:
>
> However, in development, it is not easy to know that this problem is caused, just looking at the documentation is not enough, I need to read the gpiolib source code more attentive
Have you tried to enable CONFIG_GPIO_DEBUG?
> From: linux-gpio-owner@vger.kernel.org <linux-gpio-owner@vger.kernel.org> on behalf of Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Thursday, July 9, 2020 11:40:52 PM
> To: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> Cc: mnlife <mnlife@foxmail.com>; Linus Walleij <linus.walleij@linaro.org>; linux-gpio <linux-gpio@vger.kernel.org>
> Subject: Re: [PATCH] gpiolib: Add some warn print for easier to debug
>
> On Thu, Jul 9, 2020 at 4:27 PM Bartosz Golaszewski
> <bgolaszewski@baylibre.com> wrote:
> > On Tue, Jul 7, 2020 at 5:09 PM mnlife <mnlife@foxmail.com> wrote:
>
> ...
>
> > > + if (size >= sizeof(prop_name))
> > > + dev_warn(dev, "prop_name %s is truncated with size %d\n",
> > > + prop_name, size);
>
> > To me this isn't a reason for a warning. If anything, this should
> > simply be documented (if it's not already).
>
> +1. This can only be useful in the development cycle.
>
> CONFIG_DEBUG_GPIO easily catches this as well.
>
>
> --
> With Best Regards,
> Andy Shevchenko
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpiolib: Add some warn print for easier to debug
[not found] ` <DM6PR12MB41226F148D9D3F64A2C1EE19F9650@DM6PR12MB4122.namprd12.prod.outlook.com>
@ 2020-07-10 14:09 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2020-07-10 14:09 UTC (permalink / raw)
To: qiao mnlife; +Cc: Bartosz Golaszewski, mnlife, Linus Walleij, linux-gpio
On Fri, Jul 10, 2020 at 4:54 PM qiao mnlife <mnlife.qiao@gmail.com> wrote:
>
> It will print the truncated name in gpiolib-of.c line 246, but I think this is not straightforward, and I feel its printing level is wrong
So, it does its job:
- it's for development
- it gives developer and information when debugging feature is enabled
- it does show the issue
> From: Andy Shevchenko <andy.shevchenko@gmail.com>> On Fri, Jul 10, 2020 at 6:11 AM qiao mnlife <mnlife.qiao@gmail.com> wrote:
> >
> > However, in development, it is not easy to know that this problem is caused, just looking at the documentation is not enough, I need to read the gpiolib source code more attentive
>
> Have you tried to enable CONFIG_GPIO_DEBUG?
>
> > From: linux-gpio-owner@vger.kernel.org <linux-gpio-owner@vger.kernel.org> on behalf of Andy Shevchenko <andy.shevchenko@gmail.com>
> > Sent: Thursday, July 9, 2020 11:40:52 PM
> > To: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > Cc: mnlife <mnlife@foxmail.com>; Linus Walleij <linus.walleij@linaro.org>; linux-gpio <linux-gpio@vger.kernel.org>
> > Subject: Re: [PATCH] gpiolib: Add some warn print for easier to debug
> >
> > On Thu, Jul 9, 2020 at 4:27 PM Bartosz Golaszewski
> > <bgolaszewski@baylibre.com> wrote:
> > > On Tue, Jul 7, 2020 at 5:09 PM mnlife <mnlife@foxmail.com> wrote:
> >
> > ...
> >
> > > > + if (size >= sizeof(prop_name))
> > > > + dev_warn(dev, "prop_name %s is truncated with size %d\n",
> > > > + prop_name, size);
> >
> > > To me this isn't a reason for a warning. If anything, this should
> > > simply be documented (if it's not already).
> >
> > +1. This can only be useful in the development cycle.
> >
> > CONFIG_DEBUG_GPIO easily catches this as well.
> >
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-10 14:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <5f049035.1c69fb81.15cb1.53fdSMTPIN_ADDED_MISSING@mx.google.com>
2020-07-09 13:26 ` [PATCH] gpiolib: Add some warn print for easier to debug Bartosz Golaszewski
2020-07-09 15:40 ` Andy Shevchenko
[not found] ` <BY5PR12MB41141291F53618E098239A73F9650@BY5PR12MB4114.namprd12.prod.outlook.com>
2020-07-10 13:38 ` Andy Shevchenko
[not found] ` <DM6PR12MB41226F148D9D3F64A2C1EE19F9650@DM6PR12MB4122.namprd12.prod.outlook.com>
2020-07-10 14:09 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.