[PATCH] regulator: da9121: Fix Wvoid-pointer-to-enum-cast warning

From: Krzysztof Kozlowski
Date: Fri May 09 2025 - 10:25:03 EST


'subvariant_id' is an enum, thus cast of pointer on 64-bit compile test
with clang and W=1 causes:

da9121-regulator.c:1132:24: error: cast to smaller integer type 'enum da9121_subvariant' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>

---

One of the discussions in 2023 on LKML suggested warning is not suitable
for kernel, however other points were that we actually want these to be
fixed (IIUC):
https://lore.kernel.org/all/20230814160457.GA2836@dev-arch.thelio-3990X/

Nothing changed in disabling the warning for more than a year, so assume
the warning will stay and we really want to have warnings-free builds.
---
drivers/regulator/da9121-regulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/da9121-regulator.c b/drivers/regulator/da9121-regulator.c
index 17527a3f53b4..ef161eb0ca27 100644
--- a/drivers/regulator/da9121-regulator.c
+++ b/drivers/regulator/da9121-regulator.c
@@ -1129,7 +1129,7 @@ static int da9121_i2c_probe(struct i2c_client *i2c)
}

chip->pdata = i2c->dev.platform_data;
- chip->subvariant_id = (enum da9121_subvariant)i2c_get_match_data(i2c);
+ chip->subvariant_id = (kernel_ulong_t)i2c_get_match_data(i2c);

ret = da9121_assign_chip_model(i2c, chip);
if (ret < 0)
--
2.45.2