Skip to contentSkip to conversation

mfd: dm355evm_msp: Refactoring for add_child()

PATCH Superseded SF Markus Elfring 2 participants 6 messages Jul 1, 2016 – Aug 9, 2016

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 mfd: dm355evm_msp: Refactoring for add_child()

From: Markus Elfring <[email protected]>

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

---
v4: Further feedback was integrated into this message.
v3: Deletion of another blank line
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.0
#1 lore raw
Quoted 1 line · SF Markus Elfring

From: Markus Elfring <[email protected]>

Please use git send-email to submit your patches.

Quoted 6 lines

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

---
v4: Further feedback was integrated into this message.

This is not a good change-log. What actually changed?

Quoted 11 lines

v3: Deletion of another blank line
v2: Rebasing

 drivers/mfd/dm355evm_msp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +0 -0
index 270e19c..86eca61 100644

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

Quoted 3 lines
drivers/mfd/dm355evm_msp.c +0 -0
@@ -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");

Please take the opportunity to convert these to dev_err()s.

Quoted 19 lines
drivers/mfd/dm355evm_msp.c +4 -3
-			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:

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

Quoted 10 lines
drivers/mfd/dm355evm_msp.c +4 -5
-	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);

... and remove this line.

Quoted 4 lines
drivers/mfd/dm355evm_msp.c +1 -0
+	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
#2 lore raw
Quoted 3 lines
Quoted 1 line

v4: Further feedback was integrated into this message.

This is not a good change-log. What actually changed?

Which kind of information would you find more useful in this case?

Quoted 13 lines
Quoted 13 lines
drivers/mfd/dm355evm_msp.c +3 -1
@@ -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;
 
Quoted 13 lines

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

Quoted 11 lines
drivers/mfd/dm355evm_msp.c +4 -6
-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);

... and remove this line.

Do you really want that this error message should be deleted?

How does this response fit to your request to introduce such a message for the function "add_numbered_child" (on 2016-06-08)?
https://www.mail-archive.com/[email protected]/msg1162299.html
https://lkml.org/lkml/2016/6/8/467

Regards,
Markus

#3 lore raw
Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line

v4: Further feedback was integrated into this message.

This is not a good change-log. What actually changed?

Which kind of information would you find more useful in this case?

That's for you to tell me surely?

If I wanted to know what changed, I would normally look at the patch change-log. But the change-log in this patch says "I did some stuff". What stuff did you change? Which review comments did you tend to?

Quoted 28 lines
Quoted 14 lines
Quoted 14 lines
drivers/mfd/dm355evm_msp.c +3 -1
@@ -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;
 
Quoted 13 lines

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

Quoted 11 lines
drivers/mfd/dm355evm_msp.c +4 -6
-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);

... and remove this line.

Quoted 6 lines

-Do you really want that this error message should be deleted?

How does this response fit to your request to introduce such a message for the function "add_numbered_child" (on 2016-06-08)?
https://www.mail-archive.com/[email protected]/msg1162299.html
https://lkml.org/lkml/2016/6/8/467

You've lost the context. The "..." is meant to intimate that it follows on from a previous comment. In this case:

Quoted 5 lines
Quoted 3 lines

status = platform_device_add_data(pdev, pdata, pdata_len);

if (status < 0) {
	dev_dbg(&pdev->dev, "can't add platform_data\n");

Please take the opportunity to convert these to dev_err()s.

So, convert the specific dev_dbg() calls to dev_err() and remove the contentless one at the bottom.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw
Quoted 3 lines

But the change-log in this patch says "I did some stuff". What stuff did you change? Which review comments did you tend to?

I imagine that I could increase the description granularity to a detail level which you might also not like.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

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

Quoted 3 lines
drivers/mfd/dm355evm_msp.c +3 -0
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);

... and remove this line.

Quoted 8 lines
Quoted 6 lines

Do you really want that this error message should be deleted?

How does this response fit to your request to introduce such a message for the function "add_numbered_child" (on 2016-06-08)?
https://www.mail-archive.com/[email protected]/msg1162299.html
https://lkml.org/lkml/2016/6/8/467

You've lost the context.

I interpreted the suggested message adjustments as separate changes. So I wondered about a different handling for the Linux modules "dm355evm_msp" and "twl-core".

Quoted 11 lines

The "..." is meant to intimate that it follows on from a previous comment. In this case:

Quoted 5 lines
Quoted 3 lines

status = platform_device_add_data(pdev, pdata, pdata_len);

if (status < 0) {
	dev_dbg(&pdev->dev, "can't add platform_data\n");

Please take the opportunity to convert these to dev_err()s.

So, convert the specific dev_dbg() calls to dev_err() and remove the contentless one at the bottom.

It seems then that you would like to get rid of an error message at the end while increasing the importance of a related information.

Regards,
Markus

#5 lore raw
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines

But the change-log in this patch says "I did some stuff". What stuff did you change? Which review comments did you tend to?

I imagine that I could increase the description granularity to a detail level which you might also not like.

Right. A certain level of common sense needs to be exercised.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 5 lines

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

Quoted 3 lines
drivers/mfd/dm355evm_msp.c +3 -0
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);

... and remove this line.

Do you really want that this error message should be deleted?

How does this response fit to your request to introduce such a message for the function "add_numbered_child" (on 2016-06-08)?
https://www.mail-archive.com/[email protected]/msg1162299.html
https://lkml.org/lkml/2016/6/8/467

Quoted 5 lines
Quoted 1 line

You've lost the context.

I interpreted the suggested message adjustments as separate changes. So I wondered about a different handling for the Linux modules "dm355evm_msp" and "twl-core".

In what way? The coding standards should be the same.

Quoted 7 lines
Quoted 7 lines

The "..." is meant to intimate that it follows on from a previous comment. In this case:

Quoted 4 lines
Quoted 3 lines

status = platform_device_add_data(pdev, pdata, pdata_len);

if (status < 0) {
	dev_dbg(&pdev->dev, "can't add platform_data\n");
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Please take the opportunity to convert these to dev_err()s.

So, convert the specific dev_dbg() calls to dev_err() and remove the contentless one at the bottom.

It seems then that you would like to get rid of an error message at the end while increasing the importance of a related information.

Yes. Remove the pointless error message at the bottom and provide an informative one, describing why things went wrong. Remember; common sense often prevails.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog