Skip to contentSkip to conversation

drm/sun4i: fix warning PTR_ERR_OR_ZERO can be used

PATCH In review Hariprasad Kelam 2 participants 2 messages May 25, 2019 – May 26, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/sun4i: fix warning PTR_ERR_OR_ZERO can be used

fix below warnings reported by coccicheck

./drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c:174:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c:236:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c:285:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c:142:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_dotclock.c:198:1-3: WARNING:
PTR_ERR_OR_ZERO can be used

---
 drivers/gpu/drm/sun4i/sun4i_dotclock.c      | 4 +---
 drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c  | 4 +---
 drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c      | 4 +---
 drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 4 +---
 drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c  | 4 +---
 5 files changed, 5 insertions(+), 15 deletions(-)
drivers/gpu/drm/sun4i/sun4i_dotclock.c +1 -3
index 2a15f2f..e0fd19d 100644
@@ -195,10 +195,8 @@ int sun4i_dclk_create(struct device *dev, struct sun4i_tcon *tcon)
 	dclk->hw.init = &init;
 
 	tcon->dclk = clk_register(dev, &dclk->hw);
-	if (IS_ERR(tcon->dclk))
-		return PTR_ERR(tcon->dclk);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(tcon->dclk);
 }
 EXPORT_SYMBOL(sun4i_dclk_create);
 
drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c +1 -3
index e826da3..1e74040 100644
@@ -139,8 +139,6 @@ int sun4i_ddc_create(struct sun4i_hdmi *hdmi, struct clk *parent)
 	ddc->m_offset = hdmi->variant->ddc_clk_m_offset;
 
 	hdmi->ddc_clk = devm_clk_register(hdmi->dev, &ddc->hw);
-	if (IS_ERR(hdmi->ddc_clk))
-		return PTR_ERR(hdmi->ddc_clk);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(hdmi->ddc_clk);
 }
drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c +1 -3
index 58e9d37..b72f9c7 100644
@@ -282,10 +282,8 @@ 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)
drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +1 -3
index 2598741..389c1c5 100644
@@ -233,8 +233,6 @@ int sun4i_tmds_create(struct sun4i_hdmi *hdmi)
 	tmds->div_offset = hdmi->variant->tmds_clk_div_offset;
 
 	hdmi->tmds_clk = devm_clk_register(hdmi->dev, &tmds->hw);
-	if (IS_ERR(hdmi->tmds_clk))
-		return PTR_ERR(hdmi->tmds_clk);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(hdmi->tmds_clk);
 }
drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c +1 -3
index a4d31fe..d52f581 100644
@@ -171,8 +171,6 @@ int sun8i_phy_clk_create(struct sun8i_hdmi_phy *phy, struct device *dev,
 	priv->hw.init = &init;
 
 	phy->clk_phy = devm_clk_register(dev, &priv->hw);
-	if (IS_ERR(phy->clk_phy))
-		return PTR_ERR(phy->clk_phy);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(phy->clk_phy);
 }
Signature · 1 line
2.7.4
#1 lore raw

Hi!

Quoted 27 lines · Hariprasad Kelam

fix below warnings reported by coccicheck

./drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c:174:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c:236:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c:285:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c:142:1-3: WARNING:
PTR_ERR_OR_ZERO can be used ./drivers/gpu/drm/sun4i/sun4i_dotclock.c:198:1-3: WARNING:
PTR_ERR_OR_ZERO can be used

---
 drivers/gpu/drm/sun4i/sun4i_dotclock.c      | 4 +---
 drivers/gpu/drm/sun4i/sun4i_hdmi_ddc_clk.c  | 4 +---
 drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c      | 4 +---
 drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 4 +---
 drivers/gpu/drm/sun4i/sun8i_hdmi_phy_clk.c  | 4 +---
 5 files changed, 5 insertions(+), 15 deletions(-)
drivers/gpu/drm/sun4i/sun4i_dotclock.c +0 -0
index 2a15f2f..e0fd19d 100644

drivers/gpu/drm/sun4i/sun4i_dotclock.c int sun4i_dclk_create(struct device *dev, struct sun4i_tcon *tcon) · line 199

Quoted 8 lines
drivers/gpu/drm/sun4i/sun4i_dotclock.c +1 -3
@@ -195,10 +195,8 @@ int sun4i_dclk_create(struct device *dev, struct sun4i_tcon *tcon)
 	dclk->hw.init = &init;
 
 	tcon->dclk = clk_register(dev, &dclk->hw);
-	if (IS_ERR(tcon->dclk))
-		return PTR_ERR(tcon->dclk);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(tcon->dclk);

Unfortunately, that was on purpose. It's much easier to extend if we ever need to change anything there.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel