2024-05-11 12:43:03

by Sui Jingfeng

[permalink] [raw]
Subject: [PATCH] drm/bridge: Remove a small useless code snippet

Because the check on the non-existence (encoder == NULL) has already been
done in the implementation of drm_bridge_attach() function, and
drm_bridge_attach() is called earlier. The driver won't get to check point
even if drm_bridge_attach() fails for some reasons, as it will clear the
bridge->encoder to NULL and return a negective error code.

Therefore, there is no need to check another again. Remove the redundant
codes at the later.

Signed-off-by: Sui Jingfeng <[email protected]>
---
drivers/gpu/drm/bridge/simple-bridge.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 28376d0ecd09..3caa918ac2e0 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -116,11 +116,6 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
return 0;

- if (!bridge->encoder) {
- DRM_ERROR("Missing encoder\n");
- return -ENODEV;
- }
-
drm_connector_helper_add(&sbridge->connector,
&simple_bridge_con_helper_funcs);
ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
--
2.43.0



2024-05-12 21:09:27

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: Remove a small useless code snippet

Hi Sui,

Thank you for the patch.

On Sat, May 11, 2024 at 08:42:38PM +0800, Sui Jingfeng wrote:
> Because the check on the non-existence (encoder == NULL) has already been
> done in the implementation of drm_bridge_attach() function, and
> drm_bridge_attach() is called earlier. The driver won't get to check point
> even if drm_bridge_attach() fails for some reasons, as it will clear the
> bridge->encoder to NULL and return a negective error code.

s/negective/negative/

>
> Therefore, there is no need to check another again. Remove the redundant
> codes at the later.
>
> Signed-off-by: Sui Jingfeng <[email protected]>

Reviewed-by: Laurent Pinchart <[email protected]>

If you end up sending a second version of this patch, please include all
similar patches you have sent at the same time in a patch series,
instead of sending them separately.

> ---
> drivers/gpu/drm/bridge/simple-bridge.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
> index 28376d0ecd09..3caa918ac2e0 100644
> --- a/drivers/gpu/drm/bridge/simple-bridge.c
> +++ b/drivers/gpu/drm/bridge/simple-bridge.c
> @@ -116,11 +116,6 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
> if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
> return 0;
>
> - if (!bridge->encoder) {
> - DRM_ERROR("Missing encoder\n");
> - return -ENODEV;
> - }
> -
> drm_connector_helper_add(&sbridge->connector,
> &simple_bridge_con_helper_funcs);
> ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,

--
Regards,

Laurent Pinchart

2024-05-13 00:32:51

by Sui Jingfeng

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: Remove a small useless code snippet

Hi,


On 2024/5/13 05:09, Laurent Pinchart wrote:
> Hi Sui,
>
> Thank you for the patch.
>
> On Sat, May 11, 2024 at 08:42:38PM +0800, Sui Jingfeng wrote:
>> Because the check on the non-existence (encoder == NULL) has already been
>> done in the implementation of drm_bridge_attach() function, and
>> drm_bridge_attach() is called earlier. The driver won't get to check point
>> even if drm_bridge_attach() fails for some reasons, as it will clear the
>> bridge->encoder to NULL and return a negective error code.
> s/negective/negative/
>

Sorry, my bad.


>> Therefore, there is no need to check another again. Remove the redundant
>> codes at the later.
>>
>> Signed-off-by: Sui Jingfeng <[email protected]>
> Reviewed-by: Laurent Pinchart <[email protected]>
>
> If you end up sending a second version of this patch, please include all
> similar patches you have sent at the same time in a patch series,
> instead of sending them separately.

I will send a second version to correct spell error and collect and fold them into a series.

By the way, thanks a lot for you time review my patch and thanks a lot for the generous.

So happy be reviewed and its my pleasure to have opportunities to talk with you. Thanks a lot!


>> ---
>> drivers/gpu/drm/bridge/simple-bridge.c | 5 -----
>> 1 file changed, 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
>> index 28376d0ecd09..3caa918ac2e0 100644
>> --- a/drivers/gpu/drm/bridge/simple-bridge.c
>> +++ b/drivers/gpu/drm/bridge/simple-bridge.c
>> @@ -116,11 +116,6 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
>> if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
>> return 0;
>>
>> - if (!bridge->encoder) {
>> - DRM_ERROR("Missing encoder\n");
>> - return -ENODEV;
>> - }
>> -
>> drm_connector_helper_add(&sbridge->connector,
>> &simple_bridge_con_helper_funcs);
>> ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,

--
Best regards,
Sui