* [PATCH] power_supply: bq25890: make chip_id int
@ 2015-06-02 10:36 Laurentiu Palcu
2015-06-02 13:12 ` Krzysztof Kozlowski
2015-06-02 19:28 ` Sebastian Reichel
0 siblings, 2 replies; 3+ messages in thread
From: Laurentiu Palcu @ 2015-06-02 10:36 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
Krzysztof Kozlowski
Cc: Dan Carpenter, Laurentiu Palcu, linux-pm, linux-kernel
Smatch static checker correctly detected an impossible condition because
chip_id was declared as u8, instead of int:
drivers/power/bq25890_charger.c:843 bq25890_probe()
warn: impossible condition '(bq->chip_id < 0) => (0-255 < 0)'
Also, while at it, fix the return value too.
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/power/bq25890_charger.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/bq25890_charger.c b/drivers/power/bq25890_charger.c
index c7b4903..16b7c7bc 100644
--- a/drivers/power/bq25890_charger.c
+++ b/drivers/power/bq25890_charger.c
@@ -99,7 +99,7 @@ struct bq25890_device {
struct regmap *rmap;
struct regmap_field *rmap_fields[F_MAX_FIELDS];
- u8 chip_id;
+ int chip_id;
struct bq25890_init_data init_data;
struct bq25890_state state;
@@ -842,7 +842,7 @@ static int bq25890_probe(struct i2c_client *client,
bq->chip_id = bq25890_field_read(bq, F_PN);
if (bq->chip_id < 0) {
dev_err(dev, "Cannot read chip ID.\n");
- return ret;
+ return bq->chip_id;
}
if (bq->chip_id != BQ25890_ID) {
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power_supply: bq25890: make chip_id int
2015-06-02 10:36 [PATCH] power_supply: bq25890: make chip_id int Laurentiu Palcu
@ 2015-06-02 13:12 ` Krzysztof Kozlowski
2015-06-02 19:28 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2015-06-02 13:12 UTC (permalink / raw)
To: Laurentiu Palcu, Sebastian Reichel, Dmitry Eremin-Solenikov,
David Woodhouse
Cc: Dan Carpenter, linux-pm, linux-kernel
W dniu 02.06.2015 o 19:36, Laurentiu Palcu pisze:
> Smatch static checker correctly detected an impossible condition because
> chip_id was declared as u8, instead of int:
>
> drivers/power/bq25890_charger.c:843 bq25890_probe()
> warn: impossible condition '(bq->chip_id < 0) => (0-255 < 0)'
>
> Also, while at it, fix the return value too.
I wondered whether this should be split into two commits... but actually
returning uninitialized value is not possible now because of the cast, so:
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power_supply: bq25890: make chip_id int
2015-06-02 10:36 [PATCH] power_supply: bq25890: make chip_id int Laurentiu Palcu
2015-06-02 13:12 ` Krzysztof Kozlowski
@ 2015-06-02 19:28 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2015-06-02 19:28 UTC (permalink / raw)
To: Laurentiu Palcu
Cc: Dmitry Eremin-Solenikov, David Woodhouse, Krzysztof Kozlowski,
Dan Carpenter, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 425 bytes --]
Hi Laurentiu,
On Tue, Jun 02, 2015 at 01:36:51PM +0300, Laurentiu Palcu wrote:
> Smatch static checker correctly detected an impossible condition because
> chip_id was declared as u8, instead of int:
>
> drivers/power/bq25890_charger.c:843 bq25890_probe()
> warn: impossible condition '(bq->chip_id < 0) => (0-255 < 0)'
>
> Also, while at it, fix the return value too.
Thanks, queued for 4.2.
-- Sebastian
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-02 19:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-02 10:36 [PATCH] power_supply: bq25890: make chip_id int Laurentiu Palcu
2015-06-02 13:12 ` Krzysztof Kozlowski
2015-06-02 19:28 ` Sebastian Reichel
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).