* [PATCH 0/2] max8997_charger: Fine-tuning for max8997_battery_probe()
@ 2017-10-30 21:34 ` SF Markus Elfring
0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-30 21:34 UTC (permalink / raw)
To: linux-pm, Sebastian Reichel; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 22:30:22 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use common error handling code
Improve a size determination
drivers/power/supply/max8997_charger.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/2] max8997_charger: Fine-tuning for max8997_battery_probe()
@ 2017-10-30 21:34 ` SF Markus Elfring
0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-30 21:34 UTC (permalink / raw)
To: linux-pm, Sebastian Reichel; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 22:30:22 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use common error handling code
Improve a size determination
drivers/power/supply/max8997_charger.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] max8997_charger: Use common error handling code in max8997_battery_probe()
2017-10-30 21:34 ` SF Markus Elfring
@ 2017-10-30 21:35 ` SF Markus Elfring
-1 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-30 21:35 UTC (permalink / raw)
To: linux-pm, Sebastian Reichel; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 22:14:52 +0100
Add a jump target so that a specific error message is stored only once
at the end of this function implementation.
Replace two calls of the function "dev_err" by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/power/supply/max8997_charger.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index fa861003fece..38a01706a56b 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/max8997_charger.c
@@ -113,10 +113,8 @@ static int max8997_battery_probe(struct platform_device *pdev)
ret = max8997_update_reg(iodev->i2c,
MAX8997_REG_MBCCTRL5, val, 0xf);
- if (ret < 0) {
- dev_err(&pdev->dev, "Cannot use i2c bus.\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_bus_failure;
}
switch (pdata->timeout) {
@@ -141,10 +139,8 @@ static int max8997_battery_probe(struct platform_device *pdev)
pdata->timeout);
return -EINVAL;
}
- if (ret < 0) {
- dev_err(&pdev->dev, "Cannot use i2c bus.\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_bus_failure;
charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data),
GFP_KERNEL);
@@ -168,6 +164,10 @@ static int max8997_battery_probe(struct platform_device *pdev)
}
return 0;
+
+report_bus_failure:
+ dev_err(&pdev->dev, "Cannot use i2c bus.\n");
+ return ret;
}
static const struct platform_device_id max8997_battery_id[] = {
--
2.14.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] max8997_charger: Use common error handling code in max8997_battery_probe()
@ 2017-10-30 21:35 ` SF Markus Elfring
0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-30 21:35 UTC (permalink / raw)
To: linux-pm, Sebastian Reichel; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 22:14:52 +0100
Add a jump target so that a specific error message is stored only once
at the end of this function implementation.
Replace two calls of the function "dev_err" by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/power/supply/max8997_charger.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index fa861003fece..38a01706a56b 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/max8997_charger.c
@@ -113,10 +113,8 @@ static int max8997_battery_probe(struct platform_device *pdev)
ret = max8997_update_reg(iodev->i2c,
MAX8997_REG_MBCCTRL5, val, 0xf);
- if (ret < 0) {
- dev_err(&pdev->dev, "Cannot use i2c bus.\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_bus_failure;
}
switch (pdata->timeout) {
@@ -141,10 +139,8 @@ static int max8997_battery_probe(struct platform_device *pdev)
pdata->timeout);
return -EINVAL;
}
- if (ret < 0) {
- dev_err(&pdev->dev, "Cannot use i2c bus.\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_bus_failure;
charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data),
GFP_KERNEL);
@@ -168,6 +164,10 @@ static int max8997_battery_probe(struct platform_device *pdev)
}
return 0;
+
+report_bus_failure:
+ dev_err(&pdev->dev, "Cannot use i2c bus.\n");
+ return ret;
}
static const struct platform_device_id max8997_battery_id[] = {
--
2.14.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] max8997_charger: Improve a size determination in max8997_battery_probe()
2017-10-30 21:34 ` SF Markus Elfring
@ 2017-10-30 21:36 ` SF Markus Elfring
-1 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-30 21:36 UTC (permalink / raw)
To: linux-pm, Sebastian Reichel; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 22:22:54 +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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/power/supply/max8997_charger.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index 38a01706a56b..1de0e74b7dea 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/max8997_charger.c
@@ -142,8 +142,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
if (ret < 0)
goto report_bus_failure;
- charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data),
- GFP_KERNEL);
+ charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
if (!charger)
return -ENOMEM;
--
2.14.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] max8997_charger: Improve a size determination in max8997_battery_probe()
@ 2017-10-30 21:36 ` SF Markus Elfring
0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-30 21:36 UTC (permalink / raw)
To: linux-pm, Sebastian Reichel; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 30 Oct 2017 22:22:54 +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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/power/supply/max8997_charger.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c
index 38a01706a56b..1de0e74b7dea 100644
--- a/drivers/power/supply/max8997_charger.c
+++ b/drivers/power/supply/max8997_charger.c
@@ -142,8 +142,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
if (ret < 0)
goto report_bus_failure;
- charger = devm_kzalloc(&pdev->dev, sizeof(struct charger_data),
- GFP_KERNEL);
+ charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
if (!charger)
return -ENOMEM;
--
2.14.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-30 21:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30 21:34 [PATCH 0/2] max8997_charger: Fine-tuning for max8997_battery_probe() SF Markus Elfring
2017-10-30 21:34 ` SF Markus Elfring
2017-10-30 21:35 ` [PATCH 1/2] max8997_charger: Use common error handling code in max8997_battery_probe() SF Markus Elfring
2017-10-30 21:35 ` SF Markus Elfring
2017-10-30 21:36 ` [PATCH 2/2] max8997_charger: Improve a size determination " SF Markus Elfring
2017-10-30 21:36 ` SF Markus Elfring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.