linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
@ 2020-10-31  3:16 YueHaibing
  2020-10-31  7:19 ` Sam Ravnborg
  2020-11-02 14:30 ` [PATCH v2] " YueHaibing
  0 siblings, 2 replies; 10+ messages in thread
From: YueHaibing @ 2020-10-31  3:16 UTC (permalink / raw)
  To: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, tomi.valkeinen, yuehaibing, sebastian.reichel,
	sam
  Cc: dri-devel, linux-kernel

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 |
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  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 14:30 ` [PATCH v2] " YueHaibing
  1 sibling, 2 replies; 10+ messages in thread
From: Sam Ravnborg @ 2020-10-31  7:19 UTC (permalink / raw)
  To: YueHaibing
  Cc: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, tomi.valkeinen, sebastian.reichel, dri-devel,
	linux-kernel

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.

In case of error (negative value) then return early with that error
value. If gpiod_to_irq() returns 0 assume this is a valid irq and let
the code continue.

Please fix and re-submit - or tell me if I am mistaken.

	Sam

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  2020-10-31  7:19 ` Sam Ravnborg
@ 2020-10-31 12:32   ` Yuehaibing
  2020-11-02  6:57   ` Tomi Valkeinen
  1 sibling, 0 replies; 10+ messages in thread
From: Yuehaibing @ 2020-10-31 12:32 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, tomi.valkeinen, sebastian.reichel, dri-devel,
	linux-kernel

On 2020/10/31 15: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.
> 
> In case of error (negative value) then return early with that error

Agree, will resubmit.

> value. If gpiod_to_irq() returns 0 assume this is a valid irq and let
> the code continue.

gpiod_to_irq() never returns 0, so no need check this.

> 
> Please fix and re-submit - or tell me if I am mistaken.
> 
> 	Sam
> .
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  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
  1 sibling, 1 reply; 10+ messages in thread
From: Tomi Valkeinen @ 2020-11-02  6:57 UTC (permalink / raw)
  To: Sam Ravnborg, YueHaibing
  Cc: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, sebastian.reichel, dri-devel, linux-kernel

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.

 Tomi

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  2020-11-02  6:57   ` Tomi Valkeinen
@ 2020-11-02  9:36     ` Yuehaibing
  2020-11-02  9:42       ` Tomi Valkeinen
  0 siblings, 1 reply; 10+ messages in thread
From: Yuehaibing @ 2020-11-02  9:36 UTC (permalink / raw)
  To: Tomi Valkeinen, Sam Ravnborg
  Cc: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, sebastian.reichel, dri-devel, linux-kernel

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.

>  Tomi
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  2020-11-02  9:36     ` Yuehaibing
@ 2020-11-02  9:42       ` Tomi Valkeinen
  0 siblings, 0 replies; 10+ messages in thread
From: Tomi Valkeinen @ 2020-11-02  9:42 UTC (permalink / raw)
  To: Yuehaibing, Sam Ravnborg
  Cc: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, sebastian.reichel, dri-devel, linux-kernel

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  2020-10-31  3:16 [PATCH] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe YueHaibing
  2020-10-31  7:19 ` Sam Ravnborg
@ 2020-11-02 14:30 ` YueHaibing
  2020-11-02 22:19   ` Laurent Pinchart
                     ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: YueHaibing @ 2020-11-02 14:30 UTC (permalink / raw)
  To: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, tomi.valkeinen, yuehaibing, sebastian.reichel,
	sam
  Cc: dri-devel, linux-kernel

gpiod_to_irq() return negative value in case of error,
the existing code doesn't handle negative error codes.
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(). 

Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: Add checking for >= 0 and update commit message
---
 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..e0e015243a60 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 |
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  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
  2 siblings, 0 replies; 10+ messages in thread
From: Laurent Pinchart @ 2020-11-02 22:19 UTC (permalink / raw)
  To: YueHaibing
  Cc: a.hajda, narmstrong, jonas, jernej.skrabec, airlied, daniel,
	tomi.valkeinen, sebastian.reichel, sam, dri-devel, linux-kernel

Hi Yue,

Thank you for the patch.

On Mon, Nov 02, 2020 at 10:30:24PM +0800, YueHaibing wrote:
> gpiod_to_irq() return negative value in case of error,
> the existing code doesn't handle negative error codes.
> 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(). 
> 
> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> v2: Add checking for >= 0 and update commit message
> ---
>  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..e0e015243a60 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 |

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  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
  2 siblings, 0 replies; 10+ messages in thread
From: Tomi Valkeinen @ 2020-11-03  6:49 UTC (permalink / raw)
  To: YueHaibing, a.hajda, narmstrong, Laurent.pinchart, jonas,
	jernej.skrabec, airlied, daniel, sebastian.reichel, sam
  Cc: dri-devel, linux-kernel

On 02/11/2020 16:30, YueHaibing wrote:
> gpiod_to_irq() return negative value in case of error,
> the existing code doesn't handle negative error codes.
> 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(). 
> 
> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: Add checking for >= 0 and update commit message
> ---
>  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..e0e015243a60 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 |
> 

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

 Tomi

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] drm/bridge: tpd12s015: Fix irq registering in tpd12s015_probe
  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
  2 siblings, 0 replies; 10+ messages in thread
From: Sam Ravnborg @ 2020-11-05 21:10 UTC (permalink / raw)
  To: YueHaibing
  Cc: a.hajda, narmstrong, Laurent.pinchart, jonas, jernej.skrabec,
	airlied, daniel, tomi.valkeinen, sebastian.reichel, linux-kernel,
	dri-devel

Hi YueHaibing

On Mon, Nov 02, 2020 at 10:30:24PM +0800, YueHaibing wrote:
> gpiod_to_irq() return negative value in case of error,
> the existing code doesn't handle negative error codes.
> 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(). 
> 
> Fixes: cff5e6f7e83f ("drm/bridge: Add driver for the TI TPD12S015 HDMI level shifter")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: Add checking for >= 0 and update commit message

Thanks, applied to drm-misc-next.

	Sam

> ---
>  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..e0e015243a60 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 |
> -- 
> 2.17.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-05 21:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).