Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power_supply: bq25890: make chip_id int

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>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>

authored by

Laurentiu Palcu and committed by
Sebastian Reichel
23fa43a2 e86d69dd

+2 -2
+2 -2
drivers/power/bq25890_charger.c
··· 99 99 struct regmap *rmap; 100 100 struct regmap_field *rmap_fields[F_MAX_FIELDS]; 101 101 102 - u8 chip_id; 102 + int chip_id; 103 103 struct bq25890_init_data init_data; 104 104 struct bq25890_state state; 105 105 ··· 842 842 bq->chip_id = bq25890_field_read(bq, F_PN); 843 843 if (bq->chip_id < 0) { 844 844 dev_err(dev, "Cannot read chip ID.\n"); 845 - return ret; 845 + return bq->chip_id; 846 846 } 847 847 848 848 if (bq->chip_id != BQ25890_ID) {