mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator/tps6586x: silence pointer-to-int-cast
@ 2015-07-22 10:23 Daniel Kurtz
  2015-07-23 15:01 ` Mark Brown
  2015-07-23 15:04 ` Applied "regulator: tps6586x: silence pointer-to-int-cast" to the regulator tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Kurtz @ 2015-07-22 10:23 UTC (permalink / raw)
  Cc: Daniel Kurtz, Liam Girdwood, Mark Brown,
	open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK

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>
---
 drivers/regulator/tps6586x-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 2852de0..9e9d220 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -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;
 
-- 
2.4.3.573.g4eafbef


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] regulator/tps6586x: silence pointer-to-int-cast
  2015-07-22 10:23 [PATCH] regulator/tps6586x: silence pointer-to-int-cast Daniel Kurtz
@ 2015-07-23 15:01 ` Mark Brown
  2015-07-23 15:04 ` Applied "regulator: tps6586x: silence pointer-to-int-cast" to the regulator tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2015-07-23 15:01 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: Liam Girdwood, open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

On Wed, Jul 22, 2015 at 06:23:26PM +0800, Daniel Kurtz wrote:
> of_regulator_match.driver_data is (void *).  tps6586x uses it to store an
> anonymous enum value (those TPS6586X_ID_ values).

Applied, but please use subject lines matching the style for the
subsystem and you might want to look at your script - it seems to have
corrupted things and put eveything in Cc with an empty to.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "regulator: tps6586x: silence pointer-to-int-cast" to the regulator tree
  2015-07-22 10:23 [PATCH] regulator/tps6586x: silence pointer-to-int-cast Daniel Kurtz
  2015-07-23 15:01 ` Mark Brown
@ 2015-07-23 15:04 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2015-07-23 15:04 UTC (permalink / raw)
  To: Daniel Kurtz, Mark Brown; +Cc: linux-kernel

The patch

   regulator: tps6586x: silence pointer-to-int-cast

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From a70f0d027c83350ad46ca3e86e4c781bfed7fcc2 Mon Sep 17 00:00:00 2001
From: Daniel Kurtz <djkurtz@chromium.org>
Date: Wed, 22 Jul 2015 18:23:26 +0800
Subject: [PATCH] regulator: tps6586x: silence pointer-to-int-cast

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>
---
 drivers/regulator/tps6586x-regulator.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 2852de05d64d..9e9d22038017 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -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;
 
-- 
2.1.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-23 15:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-22 10:23 [PATCH] regulator/tps6586x: silence pointer-to-int-cast Daniel Kurtz
2015-07-23 15:01 ` Mark Brown
2015-07-23 15:04 ` Applied "regulator: tps6586x: silence pointer-to-int-cast" to the regulator tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®