Skip to contentSkip to conversation

GPU-DRM-TILCDC: Adjustments for seven function implementations

PATCH In review SF Markus Elfring 2 participants 5 messages Feb 6, 2018 – Feb 14, 2018

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

cover GPU-DRM-TILCDC: Adjustments for seven function implementations

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 22:17:44 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation in seven functions Use common error handling code in of_get_panel_info()

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c   |  4 +---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c    |  4 +---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  | 21 +++++++--------------
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c |  8 ++------
 4 files changed, 11 insertions(+), 26 deletions(-)
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/2 drm/tilcdc: Delete an error message for a failed memory allocation in seven functions

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 21:51:15 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c   | 4 +---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c    | 4 +---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  | 9 ++-------
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 8 ++------
 4 files changed, 6 insertions(+), 19 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +1 -3
index 8bf6bb93dc79..1b278a22c8b7 100644
@@ -994,10 +994,8 @@ int tilcdc_crtc_create(struct drm_device *dev)
 	int ret;
 
 	tilcdc_crtc = devm_kzalloc(dev->dev, sizeof(*tilcdc_crtc), GFP_KERNEL);
-	if (!tilcdc_crtc) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!tilcdc_crtc)
 		return -ENOMEM;
-	}
 
 	init_completion(&tilcdc_crtc->palette_loaded);
 	tilcdc_crtc->palette_base = dmam_alloc_coherent(dev->dev,
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -3
index 1afde61f1247..b8a5e4ed22e6 100644
@@ -233,10 +233,8 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
 	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		dev_err(dev, "failed to allocate private data\n");
+	if (!priv)
 		return -ENOMEM;
-	}
 
 	ddev = drm_dev_alloc(ddrv, dev);
 	if (IS_ERR(ddev))
drivers/gpu/drm/tilcdc/tilcdc_panel.c +2 -7
index 8eebb5f826a6..0b6aa95aec89 100644
@@ -101,10 +101,8 @@ static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
 
 	panel_encoder = devm_kzalloc(dev->dev, sizeof(*panel_encoder),
 				     GFP_KERNEL);
-	if (!panel_encoder) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!panel_encoder)
 		return NULL;
-	}
 
 	panel_encoder->mod = mod;
 
@@ -210,10 +208,8 @@ static struct drm_connector *panel_connector_create(struct drm_device *dev,
 
 	panel_connector = devm_kzalloc(dev->dev, sizeof(*panel_connector),
 				       GFP_KERNEL);
-	if (!panel_connector) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!panel_connector)
 		return NULL;
-	}
 
 	panel_connector->encoder = encoder;
 	panel_connector->mod = mod;
@@ -294,7 +290,6 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
 
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
-		pr_err("%s: allocation failed\n", __func__);
 		of_node_put(info_np);
 		return NULL;
 	}
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c +2 -6
index 7e3643462a08..c45cabb38db0 100644
@@ -111,10 +111,8 @@ static struct drm_encoder *tfp410_encoder_create(struct drm_device *dev,
 
 	tfp410_encoder = devm_kzalloc(dev->dev, sizeof(*tfp410_encoder),
 				      GFP_KERNEL);
-	if (!tfp410_encoder) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!tfp410_encoder)
 		return NULL;
-	}
 
 	tfp410_encoder->dpms = DRM_MODE_DPMS_OFF;
 	tfp410_encoder->mod = mod;
@@ -224,10 +222,8 @@ static struct drm_connector *tfp410_connector_create(struct drm_device *dev,
 
 	tfp410_connector = devm_kzalloc(dev->dev, sizeof(*tfp410_connector),
 					GFP_KERNEL);
-	if (!tfp410_connector) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!tfp410_connector)
 		return NULL;
-	}
 
 	tfp410_connector->encoder = encoder;
 	tfp410_connector->mod = mod;
Signature · 1 line
2.16.1
#2 lore raw

Re: [PATCH 1/2] drm/tilcdc: Delete an error message for a failed memory allocation in seven functions

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 21:51:15 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Thanks,
picked for the tilcdc next pull request.

Best regards,
Jyri

Quoted 104 lines
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c   | 4 +---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c    | 4 +---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  | 9 ++-------
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c | 8 ++------
 4 files changed, 6 insertions(+), 19 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_crtc.c +1 -3
index 8bf6bb93dc79..1b278a22c8b7 100644
@@ -994,10 +994,8 @@ int tilcdc_crtc_create(struct drm_device *dev)
 	int ret;
 
 	tilcdc_crtc = devm_kzalloc(dev->dev, sizeof(*tilcdc_crtc), GFP_KERNEL);
-	if (!tilcdc_crtc) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!tilcdc_crtc)
 		return -ENOMEM;
-	}
 
 	init_completion(&tilcdc_crtc->palette_loaded);
 	tilcdc_crtc->palette_base = dmam_alloc_coherent(dev->dev,
drivers/gpu/drm/tilcdc/tilcdc_drv.c +1 -3
index 1afde61f1247..b8a5e4ed22e6 100644
@@ -233,10 +233,8 @@ static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
 	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		dev_err(dev, "failed to allocate private data\n");
+	if (!priv)
 		return -ENOMEM;
-	}
 
 	ddev = drm_dev_alloc(ddrv, dev);
 	if (IS_ERR(ddev))
drivers/gpu/drm/tilcdc/tilcdc_panel.c +2 -7
index 8eebb5f826a6..0b6aa95aec89 100644
@@ -101,10 +101,8 @@ static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
 
 	panel_encoder = devm_kzalloc(dev->dev, sizeof(*panel_encoder),
 				     GFP_KERNEL);
-	if (!panel_encoder) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!panel_encoder)
 		return NULL;
-	}
 
 	panel_encoder->mod = mod;
 
@@ -210,10 +208,8 @@ static struct drm_connector *panel_connector_create(struct drm_device *dev,
 
 	panel_connector = devm_kzalloc(dev->dev, sizeof(*panel_connector),
 				       GFP_KERNEL);
-	if (!panel_connector) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!panel_connector)
 		return NULL;
-	}
 
 	panel_connector->encoder = encoder;
 	panel_connector->mod = mod;
@@ -294,7 +290,6 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
 
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
-		pr_err("%s: allocation failed\n", __func__);
 		of_node_put(info_np);
 		return NULL;
 	}
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c +2 -6
index 7e3643462a08..c45cabb38db0 100644
@@ -111,10 +111,8 @@ static struct drm_encoder *tfp410_encoder_create(struct drm_device *dev,
 
 	tfp410_encoder = devm_kzalloc(dev->dev, sizeof(*tfp410_encoder),
 				      GFP_KERNEL);
-	if (!tfp410_encoder) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!tfp410_encoder)
 		return NULL;
-	}
 
 	tfp410_encoder->dpms = DRM_MODE_DPMS_OFF;
 	tfp410_encoder->mod = mod;
@@ -224,10 +222,8 @@ static struct drm_connector *tfp410_connector_create(struct drm_device *dev,
 
 	tfp410_connector = devm_kzalloc(dev->dev, sizeof(*tfp410_connector),
 					GFP_KERNEL);
-	if (!tfp410_connector) {
-		dev_err(dev->dev, "allocation failed\n");
+	if (!tfp410_connector)
 		return NULL;
-	}
 
 	tfp410_connector->encoder = encoder;
 	tfp410_connector->mod = mod;
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#3 lore raw

PATCH 2/2 drm/tilcdc: panel: Use common error handling code in of_get_panel_info()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 22:10:11 +0100

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_panel.c +5 -7
index 0b6aa95aec89..cf9ca16fee81 100644
@@ -289,10 +289,8 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
 	}
 
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
-	if (!info) {
-		of_node_put(info_np);
-		return NULL;
-	}
+	if (!info)
+		goto put_node;
 
 	ret |= of_property_read_u32(info_np, "ac-bias", &info->ac_bias);
 	ret |= of_property_read_u32(info_np, "ac-bias-intrpt", &info->ac_bias_intrpt);
@@ -311,11 +309,11 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
 	if (ret) {
 		pr_err("%s: error reading panel-info properties\n", __func__);
 		kfree(info);
-		of_node_put(info_np);
-		return NULL;
+		info = NULL;
 	}
-	of_node_put(info_np);
 
+put_node:
+	of_node_put(info_np);
 	return info;
 }
 
Signature · 1 line
2.16.1
#4 lore raw

Re: [PATCH 2/2] drm/tilcdc: panel: Use common error handling code in of_get_panel_info()

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 6 Feb 2018 22:10:11 +0100

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

Well, it is couple of lines less. If I would just have couple weeks time to implement proper drm panel support for tilcdc and get rid of this driver all together...

Picked for the next tilcdc pullrequest.

Thanks,
Jyri

Quoted 37 lines
---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/tilcdc/tilcdc_panel.c +5 -7
index 0b6aa95aec89..cf9ca16fee81 100644
@@ -289,10 +289,8 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
 	}
 
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
-	if (!info) {
-		of_node_put(info_np);
-		return NULL;
-	}
+	if (!info)
+		goto put_node;
 
 	ret |= of_property_read_u32(info_np, "ac-bias", &info->ac_bias);
 	ret |= of_property_read_u32(info_np, "ac-bias-intrpt", &info->ac_bias_intrpt);
@@ -311,11 +309,11 @@ static struct tilcdc_panel_info *of_get_panel_info(struct device_node *np)
 	if (ret) {
 		pr_err("%s: error reading panel-info properties\n", __func__);
 		kfree(info);
-		of_node_put(info_np);
-		return NULL;
+		info = NULL;
 	}
-	of_node_put(info_np);
 
+put_node:
+	of_node_put(info_np);
 	return info;
 }
 
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki