* [PATCH 1/5] power: supply: max14577: remove unneeded variable initialization
@ 2021-04-19 16:33 Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 2/5] power: supply: max17040: handle device_property_read_u8_array() failure Krzysztof Kozlowski
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-19 16:33 UTC (permalink / raw)
To: Sebastian Reichel, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz, linux-pm, linux-kernel
The local 'current_bits' variable does not have to be initialized
because all cases in following switch() either return or initialize it.
Addresses-Coverity: Unused value
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
drivers/power/supply/max14577_charger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/max14577_charger.c b/drivers/power/supply/max14577_charger.c
index dcedae18d7be..f244cd902eb9 100644
--- a/drivers/power/supply/max14577_charger.c
+++ b/drivers/power/supply/max14577_charger.c
@@ -261,7 +261,7 @@ static int max14577_init_constant_voltage(struct max14577_charger *chg,
static int max14577_init_eoc(struct max14577_charger *chg,
unsigned int uamp)
{
- unsigned int current_bits = 0xf;
+ unsigned int current_bits;
u8 reg_data;
switch (chg->max14577->dev_type) {
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/5] power: supply: max17040: handle device_property_read_u8_array() failure
2021-04-19 16:33 [PATCH 1/5] power: supply: max14577: remove unneeded variable initialization Krzysztof Kozlowski
@ 2021-04-19 16:33 ` Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 3/5] power: supply: max17040: remove unneeded double cast Krzysztof Kozlowski
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-19 16:33 UTC (permalink / raw)
To: Sebastian Reichel, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz, linux-pm, linux-kernel
The device_property_read_u8_array() call should not fail because it is
preceded with device_property_count_u8() and check for number of
readable u8 values. However the code is more obvious and easier to read
if the return value of device_property_read_u8_array() is checked.
Otherwise reader needs to investigate whether really there is no risk of
using random stack values of 'rcomp' variable.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
drivers/power/supply/max17040_battery.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index d956c67d5155..d2053cd0bd13 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -268,11 +268,10 @@ static int max17040_get_of_data(struct max17040_chip *chip)
rcomp_len = device_property_count_u8(dev, "maxim,rcomp");
chip->rcomp = MAX17040_RCOMP_DEFAULT;
if (rcomp_len == data->rcomp_bytes) {
- device_property_read_u8_array(dev, "maxim,rcomp",
- rcomp, rcomp_len);
- chip->rcomp = rcomp_len == 2 ?
- rcomp[0] << 8 | rcomp[1] :
- rcomp[0] << 8;
+ if (!device_property_read_u8_array(dev, "maxim,rcomp",
+ rcomp, rcomp_len))
+ chip->rcomp = rcomp_len == 2 ? rcomp[0] << 8 | rcomp[1] :
+ rcomp[0] << 8;
} else if (rcomp_len > 0) {
dev_err(dev, "maxim,rcomp has incorrect length\n");
return -EINVAL;
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/5] power: supply: max17040: remove unneeded double cast
2021-04-19 16:33 [PATCH 1/5] power: supply: max14577: remove unneeded variable initialization Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 2/5] power: supply: max17040: handle device_property_read_u8_array() failure Krzysztof Kozlowski
@ 2021-04-19 16:33 ` Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 4/5] power: supply: act8945a: correct kerneldoc Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 5/5] power: supply: bq256xx: add kerneldoc for structure members Krzysztof Kozlowski
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-19 16:33 UTC (permalink / raw)
To: Sebastian Reichel, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz, linux-pm, linux-kernel
There is no need for double explicit cast from of_device_get_match_data()
(uintptr_t and then to target enum) because implicit conversion from
uintptr_t to enum is straightforward (uintptr_t is a integer type).
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
gcc v9.3.0 W=1 does not complain after removal of cast.
---
drivers/power/supply/max17040_battery.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
index d2053cd0bd13..1aab868adabf 100644
--- a/drivers/power/supply/max17040_battery.c
+++ b/drivers/power/supply/max17040_battery.c
@@ -486,8 +486,7 @@ static int max17040_probe(struct i2c_client *client,
ret = max17040_get_of_data(chip);
if (ret)
return ret;
- chip_id = (enum chip_id) (uintptr_t)
- of_device_get_match_data(&client->dev);
+ chip_id = (uintptr_t)of_device_get_match_data(&client->dev);
}
chip->data = max17040_family[chip_id];
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/5] power: supply: act8945a: correct kerneldoc
2021-04-19 16:33 [PATCH 1/5] power: supply: max14577: remove unneeded variable initialization Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 2/5] power: supply: max17040: handle device_property_read_u8_array() failure Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 3/5] power: supply: max17040: remove unneeded double cast Krzysztof Kozlowski
@ 2021-04-19 16:33 ` Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 5/5] power: supply: bq256xx: add kerneldoc for structure members Krzysztof Kozlowski
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-19 16:33 UTC (permalink / raw)
To: Sebastian Reichel, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz, linux-pm, linux-kernel
Remove incorrect kerneldoc marker to fix W=1 warning:
drivers/power/supply/act8945a_charger.c:22: warning:
This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
drivers/power/supply/act8945a_charger.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/power/supply/act8945a_charger.c b/drivers/power/supply/act8945a_charger.c
index 5f3eb6941d05..e9b5f4283772 100644
--- a/drivers/power/supply/act8945a_charger.c
+++ b/drivers/power/supply/act8945a_charger.c
@@ -18,7 +18,7 @@
static const char *act8945a_charger_model = "ACT8945A";
static const char *act8945a_charger_manufacturer = "Active-semi";
-/**
+/*
* ACT8945A Charger Register Map
*/
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 5/5] power: supply: bq256xx: add kerneldoc for structure members
2021-04-19 16:33 [PATCH 1/5] power: supply: max14577: remove unneeded variable initialization Krzysztof Kozlowski
` (2 preceding siblings ...)
2021-04-19 16:33 ` [PATCH 4/5] power: supply: act8945a: correct kerneldoc Krzysztof Kozlowski
@ 2021-04-19 16:33 ` Krzysztof Kozlowski
3 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2021-04-19 16:33 UTC (permalink / raw)
To: Sebastian Reichel, Krzysztof Kozlowski,
Bartlomiej Zolnierkiewicz, linux-pm, linux-kernel
Document members of structure to fix W=1 warnings like:
drivers/power/supply/bq256xx_charger.c:240: warning:
Function parameter or member 'charger' not described in 'bq256xx_device'
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
drivers/power/supply/bq256xx_charger.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/power/supply/bq256xx_charger.c b/drivers/power/supply/bq256xx_charger.c
index 2ab5ba4af92b..f501ecd49202 100644
--- a/drivers/power/supply/bq256xx_charger.c
+++ b/drivers/power/supply/bq256xx_charger.c
@@ -202,6 +202,8 @@ enum bq256xx_id {
* @client: i2c client structure
* @regmap: register map structure
* @dev: device structure
+ * @charger: power supply registered for the charger
+ * @battery: power supply registered for the battery
* @lock: mutex lock structure
*
* @usb2_phy: usb_phy identifier
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-19 16:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 16:33 [PATCH 1/5] power: supply: max14577: remove unneeded variable initialization Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 2/5] power: supply: max17040: handle device_property_read_u8_array() failure Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 3/5] power: supply: max17040: remove unneeded double cast Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 4/5] power: supply: act8945a: correct kerneldoc Krzysztof Kozlowski
2021-04-19 16:33 ` [PATCH 5/5] power: supply: bq256xx: add kerneldoc for structure members Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).