2022-04-22 19:30:32

by CGEL

[permalink] [raw]
Subject: [PATCH] drm/msm/dp: fix error check return value of irq_of_parse_and_map()

From: Lv Ruyi <[email protected]>

The irq_of_parse_and_map() function returns 0 on failure, and does not
return an negative value.

Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Lv Ruyi <[email protected]>
---
drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index a42732b67349..3926d2ac107d 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -1239,7 +1239,7 @@ int dp_display_request_irq(struct msm_dp *dp_display)
dp = container_of(dp_display, struct dp_display_private, dp_display);

dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);
- if (dp->irq < 0) {
+ if (!dp->irq) {
rc = dp->irq;
DRM_ERROR("failed to get irq: %d\n", rc);
return rc;
--
2.25.1


2022-04-22 22:47:35

by Stephen Boyd

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/dp: fix error check return value of irq_of_parse_and_map()

Quoting [email protected] (2022-04-22 01:49:51)
> From: Lv Ruyi <[email protected]>
>
> The irq_of_parse_and_map() function returns 0 on failure, and does not
> return an negative value.
>
> Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Lv Ruyi <[email protected]>
> ---
> drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index a42732b67349..3926d2ac107d 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1239,7 +1239,7 @@ int dp_display_request_irq(struct msm_dp *dp_display)
> dp = container_of(dp_display, struct dp_display_private, dp_display);
>
> dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);

Why can't platform_get_irq() be used?

> - if (dp->irq < 0) {
> + if (!dp->irq) {
> rc = dp->irq;

zero as an error return value is an error?

> DRM_ERROR("failed to get irq: %d\n", rc);
> return rc;

2022-04-22 23:39:11

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/dp: fix error check return value of irq_of_parse_and_map()

On 22/04/2022 21:39, Stephen Boyd wrote:
> Quoting [email protected] (2022-04-22 01:49:51)
>> From: Lv Ruyi <[email protected]>
>>
>> The irq_of_parse_and_map() function returns 0 on failure, and does not
>> return an negative value.
>>
>> Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
>> Reported-by: Zeal Robot <[email protected]>
>> Signed-off-by: Lv Ruyi <[email protected]>
>> ---
>> drivers/gpu/drm/msm/dp/dp_display.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
>> index a42732b67349..3926d2ac107d 100644
>> --- a/drivers/gpu/drm/msm/dp/dp_display.c
>> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
>> @@ -1239,7 +1239,7 @@ int dp_display_request_irq(struct msm_dp *dp_display)
>> dp = container_of(dp_display, struct dp_display_private, dp_display);
>>
>> dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);
>
> Why can't platform_get_irq() be used?
>
>> - if (dp->irq < 0) {
>> + if (!dp->irq) {
>> rc = dp->irq;
>
> zero as an error return value is an error?

Hmm, nice catch. Please fix it. And the other patch too.

>
>> DRM_ERROR("failed to get irq: %d\n", rc);
>> return rc;


--
With best wishes
Dmitry

2022-04-24 03:27:27

by CGEL

[permalink] [raw]
Subject: [PATCH v2] drm/msm/dp: fix error check return value of irq_of_parse_and_map()

From: Lv Ruyi <[email protected]>

The irq_of_parse_and_map() function returns 0 on failure, and does not
return an negative value.

Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Lv Ruyi <[email protected]>
---
v2: don't print rc, and return -EINVAL rather than 0
---
drivers/gpu/drm/msm/dp/dp_display.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index a42732b67349..c3566e6564b1 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -1239,10 +1239,9 @@ int dp_display_request_irq(struct msm_dp *dp_display)
dp = container_of(dp_display, struct dp_display_private, dp_display);

dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);
- if (dp->irq < 0) {
- rc = dp->irq;
- DRM_ERROR("failed to get irq: %d\n", rc);
- return rc;
+ if (!dp->irq) {
+ DRM_ERROR("failed to get irq\n");
+ return -EINVAL;
}

rc = devm_request_irq(&dp->pdev->dev, dp->irq,
--
2.25.1

2022-04-26 07:02:56

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH v2] drm/msm/dp: fix error check return value of irq_of_parse_and_map()

On 24/04/2022 06:24, [email protected] wrote:
> From: Lv Ruyi <[email protected]>
>
> The irq_of_parse_and_map() function returns 0 on failure, and does not
> return an negative value.
>
> Fixes: 8ede2ecc3e5e ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Lv Ruyi <[email protected]>

Reviewed-by: Dmitry Baryshkov <[email protected]>

> ---
> v2: don't print rc, and return -EINVAL rather than 0
> ---
> drivers/gpu/drm/msm/dp/dp_display.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index a42732b67349..c3566e6564b1 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -1239,10 +1239,9 @@ int dp_display_request_irq(struct msm_dp *dp_display)
> dp = container_of(dp_display, struct dp_display_private, dp_display);
>
> dp->irq = irq_of_parse_and_map(dp->pdev->dev.of_node, 0);
> - if (dp->irq < 0) {
> - rc = dp->irq;
> - DRM_ERROR("failed to get irq: %d\n", rc);
> - return rc;
> + if (!dp->irq) {
> + DRM_ERROR("failed to get irq\n");
> + return -EINVAL;
> }
>
> rc = devm_request_irq(&dp->pdev->dev, dp->irq,


--
With best wishes
Dmitry