Skip to contentSkip to conversation

power: supply: max17040: Fix ptr to enum cast

PATCH In review Iskren Chernev 2 participants 2 messages Oct 5, 2020 – Oct 8, 2020

Subsystems (2)
lore
Share & tools
lore

Iskren Chernev

author reviewer
#0 lore raw

PATCH 1/1 power: supply: max17040: Fix ptr to enum cast

clang complains about casting pointers to smaller enum types.

---

P.S. I fixed a similar issue in v5, but it was in another patch, and the test robot only complains about the first issue, so I missed this one.

There is a similar warning in ltc2941-battery-gauge, let me know if I should submit a fix for it as well.

 drivers/power/supply/max17040_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/max17040_battery.c +1 -1
index 1d7510a59295d..d956c67d51558 100644
@@ -247,7 +247,7 @@ static int max17040_get_of_data(struct max17040_chip *chip)
 {
 	struct device *dev = &chip->client->dev;
 	struct chip_data *data = &max17040_family[
-		(enum chip_id) of_device_get_match_data(dev)];
+		(uintptr_t) of_device_get_match_data(dev)];
 	int rcomp_len;
 	u8 rcomp[2];
 

base-commit: f9d293364b452b651292ed3034dd06c57b1754d5 --
2.28.0

#1 lore raw

Hi,

Quoted 5 lines · Iskren Chernev

clang complains about casting pointers to smaller enum types.

---

Thanks, queued.

Quoted 5 lines

P.S. I fixed a similar issue in v5, but it was in another patch, and the test robot only complains about the first issue, so I missed this one.

There is a similar warning in ltc2941-battery-gauge, let me know if I should submit a fix for it as well.

Sure.

-- Sebastian

Quoted 21 lines
 drivers/power/supply/max17040_battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/max17040_battery.c +1 -1
index 1d7510a59295d..d956c67d51558 100644
@@ -247,7 +247,7 @@ static int max17040_get_of_data(struct max17040_chip *chip)
 {
 	struct device *dev = &chip->client->dev;
 	struct chip_data *data = &max17040_family[
-		(enum chip_id) of_device_get_match_data(dev)];
+		(uintptr_t) of_device_get_match_data(dev)];
 	int rcomp_len;
 	u8 rcomp[2];
 

base-commit: f9d293364b452b651292ed3034dd06c57b1754d5 --
2.28.0