From: Xin Ji <xji@analogixsemi.com>
To: Tzung-Bi Shih <tzungbi@google.com>
Cc: narmstrong@baylibre.com, dan.carpenter@oracle.com,
robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com,
jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@linux.ie,
daniel@ffwll.ch, sam@ravnborg.org, pihsun@chromium.org,
maxime@cerno.tech, drinkcat@google.com, hsinyi@chromium.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
bliang@analogixsemi.com, qwen@analogixsemi.com
Subject: Re: [PATCH] drm/bridge: anx7625: Check GPIO description to avoid crash
Date: Thu, 18 Nov 2021 13:43:46 +0800 [thread overview]
Message-ID: <20211118054346.GA3796880@anxtwsw-Precision-3640-Tower> (raw)
In-Reply-To: <CA+Px+wUc8+5HtkS8y4b9aw7m+wLS+zC1em6VKRNog1QKnJrZ=Q@mail.gmail.com>
On Thu, Nov 18, 2021 at 12:52:14PM +0800, Tzung-Bi Shih wrote:
> On Thu, Nov 18, 2021 at 11:11 AM Xin Ji <xji@analogixsemi.com> wrote:
> > @@ -1098,9 +1098,18 @@ static void anx7625_init_gpio(struct anx7625_data *platform)
> > /* Gpio for chip power enable */
> > platform->pdata.gpio_p_on =
> > devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
> > + if (IS_ERR(platform->pdata.gpio_p_on)) {
> > + DRM_DEV_DEBUG_DRIVER(dev, "no enable gpio found\n");
> > + platform->pdata.gpio_p_on = NULL;
> > + }
> > +
> > /* Gpio for chip reset */
> > platform->pdata.gpio_reset =
> > devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> > + if (IS_ERR(platform->pdata.gpio_reset)) {
> > + DRM_DEV_DEBUG_DRIVER(dev, "no reset gpio found\n");
> > + platform->pdata.gpio_p_on = NULL;
> > + }
> >
> > if (platform->pdata.gpio_p_on && platform->pdata.gpio_reset) {
> > platform->pdata.low_power_mode = 1;
>
> devm_gpiod_get_optional() is possible to return NULL (see
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.15.2%2Fsource%2Fdrivers%2Fgpio%2Fgpiolib-devres.c%23L250&data=04%7C01%7Cxji%40analogixsemi.com%7C40e84a44676149c2544a08d9aa4f37f0%7Cb099b0b4f26c4cf59a0fd5be9acab205%7C0%7C0%7C637728079481953910%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=2UPuAadtM%2FObwkwE6fLhJr7uCfWN%2Fr29o4t8uqUU2Ls%3D&reserved=0).
> Thus, we should use IS_ERR_OR_NULL for checking the return value.
Hi Tzung-Bi Shih, IS_ERR_OR_NULL is better, I'll use it.
Thanks,
Xin
>
> The cases here would work fine except it will skip to print some
> informative messages.
>
> Acked-by: Tzung-Bi Shih <tzungbi@google.com>
prev parent reply other threads:[~2021-11-18 5:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 3:11 Xin Ji
2021-11-18 4:52 ` Tzung-Bi Shih
2021-11-18 5:43 ` Xin Ji [this message]
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=20211118054346.GA3796880@anxtwsw-Precision-3640-Tower \
--to=xji@analogixsemi.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@linux.ie \
--cc=bliang@analogixsemi.com \
--cc=dan.carpenter@oracle.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@google.com \
--cc=hsinyi@chromium.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime@cerno.tech \
--cc=narmstrong@baylibre.com \
--cc=pihsun@chromium.org \
--cc=qwen@analogixsemi.com \
--cc=robert.foss@linaro.org \
--cc=sam@ravnborg.org \
--cc=tzungbi@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®