Skip to contentSkip to conversation

pm2301-charger: Adjustments for two function implementations

PATCH New SF Markus Elfring 1 participant 4 messages Dec 16, 2017

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

cover pm2301-charger: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
Date: Sat, 16 Dec 2017 21:06:54 +0100

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

Markus Elfring (3):
Delete an error message for a failed memory allocation
in pm2xxx_wall_charger_probe()
Improve a size determination in pm2xxx_wall_charger_probe() Combine substrings for three messages

 drivers/power/supply/pm2301_charger.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/3 pm2301-charger: Delete an error message for a failed memory allocation in pm2xxx_wall_charger_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 16 Dec 2017 20:30:26 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/power/supply/pm2301_charger.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/power/supply/pm2301_charger.c +1 -3
index 78561b6884fc..0a0c2da936cf 100644
@@ -991,10 +991,8 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
 	}
 
 	pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL);
-	if (!pm2) {
-		dev_err(&i2c_client->dev, "pm2xxx_charger allocation failed\n");
+	if (!pm2)
 		return -ENOMEM;
-	}
 
 	/* get parent data */
 	pm2->dev = &i2c_client->dev;
Signature · 1 line
2.15.1
#2 lore raw

PATCH 2/3 pm2301-charger: Improve a size determination in pm2xxx_wall_charger_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 16 Dec 2017 20:33:37 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/power/supply/pm2301_charger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/pm2301_charger.c +1 -1
index 0a0c2da936cf..99a9892f0f68 100644
@@ -990,7 +990,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
 		return -EINVAL;
 	}
 
-	pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL);
+	pm2 = kzalloc(sizeof(*pm2), GFP_KERNEL);
 	if (!pm2)
 		return -ENOMEM;
 
Signature · 1 line
2.15.1
#3 lore raw

PATCH 3/3 pm2301-charger: Combine substrings for three messages

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 16 Dec 2017 20:51:10 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

---
 drivers/power/supply/pm2301_charger.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/power/supply/pm2301_charger.c +5 -6
index 99a9892f0f68..fa37144d9638 100644
@@ -742,8 +742,7 @@ static int pm2xxx_charger_ac_en(struct ux500_charger *charger,
 
 		if (volt_index < 0 || curr_index < 0) {
 			dev_err(pm2->dev,
-				"Charger voltage or current too high, "
-				"charging not started\n");
+				"Charger voltage or current too high, charging not started\n");
 			return -ENXIO;
 		}
 
@@ -791,8 +790,8 @@ static int pm2xxx_charger_ac_en(struct ux500_charger *charger,
 
 		ret = pm2xxx_charging_enable_mngt(pm2);
 		if (ret < 0) {
-			dev_err(pm2->dev, "Failed to enable"
-						"pm2xxx ac charger\n");
+			dev_err(pm2->dev,
+				"Failed to enable pm2xxx ac charger\n");
 			goto error_occured;
 		}
 
@@ -809,8 +808,8 @@ static int pm2xxx_charger_ac_en(struct ux500_charger *charger,
 
 		ret = pm2xxx_charging_disable_mngt(pm2);
 		if (ret < 0) {
-			dev_err(pm2->dev, "failed to disable"
-						"pm2xxx ac charger\n");
+			dev_err(pm2->dev,
+				"failed to disable pm2xxx ac charger\n");
 			goto error_occured;
 		}
 
Signature · 1 line
2.15.1