From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Lee Jones <lee@kernel.org>, Jingoo Han <jingoohan1@gmail.com>,
Helge Deller <deller@gmx.de>,
dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] backlight: hx8357: switch to using gpiod API
Date: Mon, 6 Feb 2023 20:15:56 -0800 [thread overview]
Message-ID: <Y+HQfDtiqUso7e9k@google.com> (raw)
In-Reply-To: <Y+DmBGiq9kvRBHLY@aspen.lan>
On Mon, Feb 06, 2023 at 11:35:32AM +0000, Daniel Thompson wrote:
> On Tue, Jan 31, 2023 at 02:57:06PM -0800, Dmitry Torokhov wrote:
> > Switch the driver from legacy gpio API that is deprecated to the newer
> > gpiod API that respects line polarities described in ACPI/DT.
> >
> > This makes driver use standard property name for the reset gpio
> > ("reset-gpios" vs "gpios-reset"), however there is a quirk in gpiolib
> > to also recognize the legacy name and keep compatibility with older
> > DTSes.
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >
> > All preparation gpiolib work to handle legacy names and polarity quirks
> > has landed in mainline...
> >
> > drivers/video/backlight/hx8357.c | 82 ++++++++++++++------------------
> > 1 file changed, 37 insertions(+), 45 deletions(-)
> >
> > diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
> > index 9b50bc96e00f..a93e14adb846 100644
> > --- a/drivers/video/backlight/hx8357.c
> > +++ b/drivers/video/backlight/hx8357.c
> > [snip]
> > - if (of_find_property(spi->dev.of_node, "im-gpios", NULL)) {
> > - lcd->use_im_pins = 1;
> > -
> > - for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
> > - lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node,
> > - "im-gpios", i);
> > - if (lcd->im_pins[i] == -EPROBE_DEFER) {
> > - dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n");
> > - return -EPROBE_DEFER;
> > - }
> > - if (!gpio_is_valid(lcd->im_pins[i])) {
> > - dev_err(&spi->dev, "Missing dt property: im-gpios\n");
> > - return -EINVAL;
> > + gpiod_set_consumer_name(lcd->reset, "hx8357-reset");
> > +
> > + for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
> > + lcd->im_pins[i] = devm_gpiod_get_index(&spi->dev,
> > + "im", i, GPIOD_OUT_LOW);
> > + ret = PTR_ERR_OR_ZERO(lcd->im_pins[i]);
> > + if (ret) {
> > + if (ret == -ENOENT) {
> > + if (i == 0)
> > + break;
> > + dev_err(&spi->dev, "Missing im gpios[%d]\n", i);
> > + ret = -EINVAL;
> > + } if (ret == -EPROBE_DEFER) {
I see I miss "else" here...
> > + dev_info(&spi->dev, "im gpio[%d] is not here yet, deferring the probe\n",
> > + i);
> > + } else {
> > + dev_err(&spi->dev, "failed to request im gpio[%d]: %d\n",
> > + i, ret);
> > }
>
> These last two clauses should be updated to return dev_err_probe(...)
> instead.
>
> With that change:
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
So you want to actually suppress the deferral message unless debug
printks are enabled? So you want this to read:
if (ret) {
if (ret == -ENOENT) {
if (i == 0)
break;
dev_err(&spi->dev, "Missing im gpios[%d]\n", i);
return -EINVAL;
}
return dev_err_probe(&spi->dev, ret,
"failed to request im gpio[%d]\n", i);
}
Did I get it right?
Thanks.
--
Dmitry
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Daniel Thompson <daniel.thompson@linaro.org>
Cc: linux-fbdev@vger.kernel.org, Jingoo Han <jingoohan1@gmail.com>,
Helge Deller <deller@gmx.de>, Lee Jones <lee@kernel.org>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] backlight: hx8357: switch to using gpiod API
Date: Mon, 6 Feb 2023 20:15:56 -0800 [thread overview]
Message-ID: <Y+HQfDtiqUso7e9k@google.com> (raw)
In-Reply-To: <Y+DmBGiq9kvRBHLY@aspen.lan>
On Mon, Feb 06, 2023 at 11:35:32AM +0000, Daniel Thompson wrote:
> On Tue, Jan 31, 2023 at 02:57:06PM -0800, Dmitry Torokhov wrote:
> > Switch the driver from legacy gpio API that is deprecated to the newer
> > gpiod API that respects line polarities described in ACPI/DT.
> >
> > This makes driver use standard property name for the reset gpio
> > ("reset-gpios" vs "gpios-reset"), however there is a quirk in gpiolib
> > to also recognize the legacy name and keep compatibility with older
> > DTSes.
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >
> > All preparation gpiolib work to handle legacy names and polarity quirks
> > has landed in mainline...
> >
> > drivers/video/backlight/hx8357.c | 82 ++++++++++++++------------------
> > 1 file changed, 37 insertions(+), 45 deletions(-)
> >
> > diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
> > index 9b50bc96e00f..a93e14adb846 100644
> > --- a/drivers/video/backlight/hx8357.c
> > +++ b/drivers/video/backlight/hx8357.c
> > [snip]
> > - if (of_find_property(spi->dev.of_node, "im-gpios", NULL)) {
> > - lcd->use_im_pins = 1;
> > -
> > - for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
> > - lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node,
> > - "im-gpios", i);
> > - if (lcd->im_pins[i] == -EPROBE_DEFER) {
> > - dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n");
> > - return -EPROBE_DEFER;
> > - }
> > - if (!gpio_is_valid(lcd->im_pins[i])) {
> > - dev_err(&spi->dev, "Missing dt property: im-gpios\n");
> > - return -EINVAL;
> > + gpiod_set_consumer_name(lcd->reset, "hx8357-reset");
> > +
> > + for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
> > + lcd->im_pins[i] = devm_gpiod_get_index(&spi->dev,
> > + "im", i, GPIOD_OUT_LOW);
> > + ret = PTR_ERR_OR_ZERO(lcd->im_pins[i]);
> > + if (ret) {
> > + if (ret == -ENOENT) {
> > + if (i == 0)
> > + break;
> > + dev_err(&spi->dev, "Missing im gpios[%d]\n", i);
> > + ret = -EINVAL;
> > + } if (ret == -EPROBE_DEFER) {
I see I miss "else" here...
> > + dev_info(&spi->dev, "im gpio[%d] is not here yet, deferring the probe\n",
> > + i);
> > + } else {
> > + dev_err(&spi->dev, "failed to request im gpio[%d]: %d\n",
> > + i, ret);
> > }
>
> These last two clauses should be updated to return dev_err_probe(...)
> instead.
>
> With that change:
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
So you want to actually suppress the deferral message unless debug
printks are enabled? So you want this to read:
if (ret) {
if (ret == -ENOENT) {
if (i == 0)
break;
dev_err(&spi->dev, "Missing im gpios[%d]\n", i);
return -EINVAL;
}
return dev_err_probe(&spi->dev, ret,
"failed to request im gpio[%d]\n", i);
}
Did I get it right?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2023-02-07 4:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-31 22:57 [PATCH 1/2] backlight: hx8357: switch to using gpiod API Dmitry Torokhov
2023-01-31 22:57 ` Dmitry Torokhov
2023-01-31 22:57 ` [PATCH 2/2] backlight: hx8357: stop using of-specific APIs Dmitry Torokhov
2023-01-31 22:57 ` Dmitry Torokhov
2023-02-06 11:42 ` Daniel Thompson
2023-02-06 11:42 ` Daniel Thompson
2023-02-06 11:35 ` [PATCH 1/2] backlight: hx8357: switch to using gpiod API Daniel Thompson
2023-02-06 11:35 ` Daniel Thompson
2023-02-07 4:15 ` Dmitry Torokhov [this message]
2023-02-07 4:15 ` Dmitry Torokhov
2023-02-07 16:04 ` Daniel Thompson
2023-02-07 16:04 ` Daniel Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+HQfDtiqUso7e9k@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=daniel.thompson@linaro.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=lee@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.