Skip to contentSkip to conversation

mfd: dm355evm_msp: Improve implementation of add_child()

PATCH Applied SF Markus Elfring 3 participants 5 messages Aug 11, 2016 – Aug 30, 2016

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

v5 cover mfd: dm355evm_msp: Improve implementation of add_child()

From: Markus Elfring <[email protected]>

Adjust jump targets together with three error messages.

Markus Elfring (2):
Refactoring
Change error messages

 drivers/mfd/dm355evm_msp.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.9.2
#1 lore raw

PATCH v5 1/2 mfd: dm355evm_msp: Refactoring for add_child()

From: Markus Elfring <[email protected]>
Date: Thu, 11 Aug 2016 13:30:32 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---

v5: Rebased on the source files from Linux next-20160809.

v4: Adjustment of an error message at the end

See also a change request for the module "twl-core" on 2016-06-08:
https://lkml.kernel.org/g/<20160608111442.GB14888@dell>

v3: Deletion of another blank line as requested by Lee Jones

v2: Rebasing

 drivers/mfd/dm355evm_msp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +9 -8
index 270e19c..86eca61 100644
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -222,19 +222,20 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
+	if (status)
+		goto put_device;
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 1 line
2.9.2
#3 lore raw

PATCH v5 2/2 mfd: dm355evm_msp: Change error messages in add_child()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 11 Aug 2016 14:00:43 +0200

Delete an error message at the end while increasing the importance of related information.

---

v5: Rebased on the source files from Linux next-20160809.

Requested changes were applied.

 drivers/mfd/dm355evm_msp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/dm355evm_msp.c +2 -3
index 86eca61..463f9e2e 100644
@@ -208,7 +208,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 	if (pdata) {
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
-			dev_dbg(&pdev->dev, "can't add platform_data\n");
+			dev_err(&pdev->dev, "can't add platform_data\n");
 			goto put_device;
 		}
 	}
@@ -221,7 +221,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
-			dev_dbg(&pdev->dev, "can't add irq\n");
+			dev_err(&pdev->dev, "can't add irq\n");
 			goto put_device;
 		}
 	}
@@ -234,7 +234,6 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 
 put_device:
 	platform_device_put(pdev);
-	dev_err(&client->dev, "failed to add device %s\n", name);
 	return ERR_PTR(status);
 }
 
Signature · 1 line
2.9.2
#4 lore raw

Re: [PATCH v5 2/2] mfd: dm355evm_msp: Change error messages in add_child()

Quoted 23 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 11 Aug 2016 14:00:43 +0200

Delete an error message at the end while increasing the importance of related information.

---

v5: Rebased on the source files from Linux next-20160809.

Requested changes were applied.

 drivers/mfd/dm355evm_msp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/dm355evm_msp.c +0 -0
index 86eca61..463f9e2e 100644

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 211

Quoted 5 lines
drivers/mfd/dm355evm_msp.c +1 -1
@@ -208,7 +208,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 	if (pdata) {
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
-			dev_dbg(&pdev->dev, "can't add platform_data\n");
+			dev_err(&pdev->dev, "can't add platform_data\n");

Isn't this message unnecessary? platform_device_add_data only fails on failure of kmemdup, which I assume ends up in kmalloc eventually and prints a backtrace on failure.

The same is true of platform_device_add_resources below.

julia

Quoted 28 lines
drivers/mfd/dm355evm_msp.c +1 -3
 			goto put_device;
 		}
 	}
@@ -221,7 +221,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
-			dev_dbg(&pdev->dev, "can't add irq\n");
+			dev_err(&pdev->dev, "can't add irq\n");
 			goto put_device;
 		}
 	}
@@ -234,7 +234,6 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 
 put_device:
 	platform_device_put(pdev);
-	dev_err(&client->dev, "failed to add device %s\n", name);
 	return ERR_PTR(status);
 }
 
--

2.9.2

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#2 lore raw

Re: [PATCH v5 1/2] mfd: dm355evm_msp: Refactoring for add_child()

In reply to SF Markus Elfring
Quoted 17 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 11 Aug 2016 13:30:32 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---

v5: Rebased on the source files from Linux next-20160809.

v4: Adjustment of an error message at the end

See also a change request for the module "twl-core" on 2016-06-08:
https://lkml.kernel.org/g/<20160608111442.GB14888@dell>

Quoted 6 lines

v3: Deletion of another blank line as requested by Lee Jones

v2: Rebasing

 drivers/mfd/dm355evm_msp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Applied, thanks.

Quoted 41 lines
drivers/mfd/dm355evm_msp.c +9 -8
index 270e19c..86eca61 100644
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -222,19 +222,20 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
+	if (status)
+		goto put_device;
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog