2020-04-18 09:29:41

by 赵军奎

[permalink] [raw]
Subject: [PATCH] amdgpu_connector_set_property, fix error branch not return errno

The "if(!encoder)" branch return the same value 0 of the success
branch, maybe return -EINVAL is more better.

Signed-off-by: Bernard Zhao <[email protected]>
w
---
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index f355d9a..1f8c6b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -474,12 +474,12 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

if (!amdgpu_encoder->enc_priv)
- return 0;
+ return -EINVAL;

dig = amdgpu_encoder->enc_priv;
new_coherent_mode = val ? true : false;
@@ -494,7 +494,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -509,7 +509,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -523,7 +523,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -537,7 +537,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -551,7 +551,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

--
2.7.4


2020-04-21 02:09:33

by 赵军奎

[permalink] [raw]
Subject: [PATCH v2] amdgpu: fixes error branch not return errno issue

The "if(!encoder)" branch return the same value 0 of the success
branch, maybe return -EINVAL is more better.

Signed-off-by: Bernard Zhao <[email protected]>

---
Changes since V1:
* commit message improve
---
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index f355d9a..1f8c6b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -474,12 +474,12 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

if (!amdgpu_encoder->enc_priv)
- return 0;
+ return -EINVAL;

dig = amdgpu_encoder->enc_priv;
new_coherent_mode = val ? true : false;
@@ -494,7 +494,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -509,7 +509,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -523,7 +523,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -537,7 +537,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

@@ -551,7 +551,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
/* need to find digital encoder on connector */
encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
if (!encoder)
- return 0;
+ return -EINVAL;

amdgpu_encoder = to_amdgpu_encoder(encoder);

--
2.7.4

2020-04-21 09:11:28

by 赵军奎

[permalink] [raw]
Subject: [add Markus.Elfring in mail list]Re:[PATCH v2] amdgpu: fixes error branch not return errno issue



From: Bernard Zhao <[email protected]>
Date: 2020-04-21 10:07:50
To: Alex Deucher <[email protected]>,"Christian König" <[email protected]>,"David (ChunMing) Zhou" <[email protected]>,David Airlie <[email protected]>,Daniel Vetter <[email protected]>,Lyude Paul <[email protected]>,Sam Ravnborg <[email protected]>,Bernard Zhao <[email protected]>,"José Roberto de Souza" <[email protected]>,Andrzej Pietrasiewicz <[email protected]>,[email protected],[email protected],[email protected]
Cc: [email protected]
Subject: [PATCH v2] amdgpu: fixes error branch not return errno issue>The "if(!encoder)" branch return the same value 0 of the success
>branch, maybe return -EINVAL is more better.
>
>Signed-off-by: Bernard Zhao <[email protected]>
>
>---
>Changes since V1:
>* commit message improve
>---
> drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
>index f355d9a..1f8c6b4 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
>@@ -474,12 +474,12 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
> /* need to find digital encoder on connector */
> encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
> if (!encoder)
>- return 0;
>+ return -EINVAL;
>
> amdgpu_encoder = to_amdgpu_encoder(encoder);
>
> if (!amdgpu_encoder->enc_priv)
>- return 0;
>+ return -EINVAL;
>
> dig = amdgpu_encoder->enc_priv;
> new_coherent_mode = val ? true : false;
>@@ -494,7 +494,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
> /* need to find digital encoder on connector */
> encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
> if (!encoder)
>- return 0;
>+ return -EINVAL;
>
> amdgpu_encoder = to_amdgpu_encoder(encoder);
>
>@@ -509,7 +509,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
> /* need to find digital encoder on connector */
> encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
> if (!encoder)
>- return 0;
>+ return -EINVAL;
>
> amdgpu_encoder = to_amdgpu_encoder(encoder);
>
>@@ -523,7 +523,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
> /* need to find digital encoder on connector */
> encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
> if (!encoder)
>- return 0;
>+ return -EINVAL;
>
> amdgpu_encoder = to_amdgpu_encoder(encoder);
>
>@@ -537,7 +537,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
> /* need to find digital encoder on connector */
> encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
> if (!encoder)
>- return 0;
>+ return -EINVAL;
>
> amdgpu_encoder = to_amdgpu_encoder(encoder);
>
>@@ -551,7 +551,7 @@ static int amdgpu_connector_set_property(struct drm_connector *connector,
> /* need to find digital encoder on connector */
> encoder = amdgpu_connector_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
> if (!encoder)
>- return 0;
>+ return -EINVAL;
>
> amdgpu_encoder = to_amdgpu_encoder(encoder);
>
>--
>2.7.4

>

add Markus.Elfring in mail list
Regards,
Bernard