Skip to content

Commit

Permalink
regulator: tps6586x: silence pointer-to-int-cast
Browse files Browse the repository at this point in the history
of_regulator_match.driver_data is (void *).  tps6586x uses it to store an
anonymous enum value (those TPS6586X_ID_ values).

Later, it tries to extract the ID by casting directly to an int, which is a
no-no ([-Wpointer-to-int-cast]):

drivers/regulator/tps6586x-regulator.c: In function 'tps6586x_parse_regulator_dt':
drivers/regulator/tps6586x-regulator.c:430:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   id = (int)tps6586x_matches[i].driver_data;
        ^

Instead of casting to int, uintptr_t is better suited for receiving and
comparing integers extracted from void *.  This is especially true on
64-bit systems where sizeof(void *) != sizeof(int).

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Daniel Kurtz authored and Mark Brown committed Jul 23, 2015
1 parent bc0195a commit a70f0d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/regulator/tps6586x-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
return NULL;

for (i = 0; i < num; i++) {
int id;
uintptr_t id;
if (!tps6586x_matches[i].init_data)
continue;

pdata->reg_init_data[i] = tps6586x_matches[i].init_data;
id = (int)tps6586x_matches[i].driver_data;
id = (uintptr_t)tps6586x_matches[i].driver_data;
if (id == TPS6586X_ID_SYS)
sys_rail = pdata->reg_init_data[i]->constraints.name;

Expand Down

0 comments on commit a70f0d0

Please sign in to comment.