linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Yuehaibing <yuehaibing@huawei.com>, Sam Ravnborg <sam@ravnborg.org>
Cc: <a.hajda@samsung.com>, <narmstrong@baylibre.com>,
	<Laurent.pinchart@ideasonboard.com>, <jonas@kwiboo.se>,
	<jernej.skrabec@siol.net>, <airlied@linux.ie>, <daniel@ffwll.ch>,
	<sebastian.reichel@collabora.com>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
Date: Mon, 2 Nov 2020 11:42:10 +0200	[thread overview]
Message-ID: <bbf82393-0cbd-bb2c-6002-368486a1b900@ti.com> (raw)
In-Reply-To: <3d7fc2b4-8f8c-2ad3-34a5-7c48a6832df0@huawei.com>

On 02/11/2020 11:36, Yuehaibing wrote:
> On 2020/11/2 14:57, Tomi Valkeinen wrote:
>> On 31/10/2020 09:19, Sam Ravnborg wrote:
>>> Hi YueHaibing
>>>
>>> Thanks for the fix. Appreciated but please update as per comments below.
>>>
>>> On Sat, Oct 31, 2020 at 11:16:48AM +0800, YueHaibing wrote:
>>>> gpiod_to_irq() return negative value in case of error,
>>>> the existing code handle negative error codes wrongly.
>>>>
>>>> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter")
>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>> ---
>>>>  drivers/gpu/drm/bridge/ti-tpd12s015.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/ti-tpd12s015.c b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>>> index 514cbf0eac75..a18d5197c16c 100644
>>>> --- a/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>>> +++ b/drivers/gpu/drm/bridge/ti-tpd12s015.c
>>>> @@ -160,7 +160,7 @@ static int tpd12s015_probe(struct platform_device *pdev)
>>>>  
>>>>  	/* Register the IRQ if the HPD GPIO is IRQ-capable. */
>>>>  	tpd->hpd_irq = gpiod_to_irq(tpd->hpd_gpio);
>>>> -	if (tpd->hpd_irq) {
>>>> +	if (tpd->hpd_irq > 0) {
>>>>  		ret = devm_request_threaded_irq(&pdev->dev, tpd->hpd_irq, NULL,
>>>>  						tpd12s015_hpd_isr,
>>>>  						IRQF_TRIGGER_RISING |
>>>
>>> The current implmentation will skip devm_request_threaded_irq() in case
>>> or error - but continue with the rest of the function. So the
>>> driver fails to return an error code.
>>
>> That is intended. If the HPD gpio supports IRQs (gpiod_to_irq returns a valid number), we use the
>> IRQ. If it doesn't (gpiod_to_irq returns an error), it gets polled via detect(). Both are ok.
>>
>> I don't know if the gpiod_to_irq never returning 0 is something we should rely on. The docs say
>> gpiod_to_irq returns the irq number or an error, so I think checking for >= 0 matches the docs better.
>>
> 
> gpiod_to_irq() now never returns 0, see:
> https://elixir.bootlin.com/linux/v5.10-rc2/source/drivers/gpio/gpiolib.c#L3183
> 
> Also commit 4c37ce8608a8 ("gpio: make gpiod_to_irq() return negative for NO_IRQ") says:
> 
> commit 4c37ce8608a8c6521726d4cd1d4f54424e8d095f
> Author: Linus Walleij <linus.walleij@linaro.org>
> Date:   Mon May 2 13:13:10 2016 +0200
> 
>     gpio: make gpiod_to_irq() return negative for NO_IRQ
> 
>     If a translation returns zero, that means NO_IRQ, so we
>     should return an error since the function is documented to
>     return a negative code on error.
> 
> So checking for >0 is enough, my patch is correct.

Yes, but that is a gpiod_to_irq internal implementation detail. The documentation says it returns an
error code (negative) or a valid irq number. The documentation does not say gpiod_to_irq never
returns 0.

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2020-11-02  9:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31  3:16 [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe YueHaibing
2020-10-31  7:19 ` Sam Ravnborg
2020-10-31 12:32   ` Yuehaibing
2020-11-02  6:57   ` Tomi Valkeinen
2020-11-02  9:36     ` Yuehaibing
2020-11-02  9:42       ` Tomi Valkeinen [this message]
2020-11-02 14:30 ` [PATCH v2] " YueHaibing
2020-11-02 22:19   ` Laurent Pinchart
2020-11-03  6:49   ` Tomi Valkeinen
2020-11-05 21:10   ` Sam Ravnborg

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=bbf82393-0cbd-bb2c-6002-368486a1b900@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@siol.net \
    --cc=jonas@kwiboo.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=sam@ravnborg.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=yuehaibing@huawei.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;
as well as URLs for NNTP newsgroup(s).