pm2301-charger: Adjustments for two function implementations
Subsystems (2)
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
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
@@ -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
PATCH 2/3 pm2301-charger: Improve a size determination in pm2xxx_wall_charger_probe()
In reply to SF Markus ElfringFrom: 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
@@ -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
PATCH 3/3 pm2301-charger: Combine substrings for three messages
In reply to SF Markus ElfringFrom: 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
@@ -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