diff mbox series

[1/5] drm/sun4i: Use PTR_ERR_OR_ZERO() to simplify code in sun4i_hdmi_init_regmap_fields

Message ID 1574080484-48744-2-git-send-email-zhengbin13@huawei.com (mailing list archive)
State New, archived
Headers show
Series drm/sun4i: Use PTR_ERR_OR_ZERO() to simplify code | expand

Commit Message

Zheng Bin Nov. 18, 2019, 12:34 p.m. UTC
Fixes coccicheck warning:

drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c:281:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--
2.7.4

Comments

Maxime Ripard Nov. 18, 2019, 1 p.m. UTC | #1
On Mon, Nov 18, 2019 at 08:34:40PM +0800, zhengbin wrote:
> Fixes coccicheck warning:
>
> drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c:281:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c
> index b66fa27..ac435e5 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c
> @@ -278,10 +278,7 @@ static int sun4i_hdmi_init_regmap_fields(struct sun4i_hdmi *hdmi)
>  	hdmi->field_ddc_sck_en =
>  		devm_regmap_field_alloc(hdmi->dev, hdmi->regmap,
>  					hdmi->variant->field_ddc_sck_en);
> -	if (IS_ERR(hdmi->field_ddc_sck_en))
> -		return PTR_ERR(hdmi->field_ddc_sck_en);
> -
> -	return 0;
> +	return PTR_ERR_OR_ZERO(hdmi->field_ddc_sck_en);

These 5 patches are not clearer and just make it more difficult to
maintain. I guess we should just get rid of the coccinelle rule here,
there's a lot of false positive with it.

Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c
index b66fa27..ac435e5 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c
@@ -278,10 +278,7 @@  static int sun4i_hdmi_init_regmap_fields(struct sun4i_hdmi *hdmi)
 	hdmi->field_ddc_sck_en =
 		devm_regmap_field_alloc(hdmi->dev, hdmi->regmap,
 					hdmi->variant->field_ddc_sck_en);
-	if (IS_ERR(hdmi->field_ddc_sck_en))
-		return PTR_ERR(hdmi->field_ddc_sck_en);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(hdmi->field_ddc_sck_en);
 }

 int sun4i_hdmi_i2c_create(struct device *dev, struct sun4i_hdmi *hdmi)