Skip to contentSkip to conversation

linux-next: build warning after merge of the mfd tree

PATCH Applied Stephen Rothwell 6 participants 23 messages Nov 30, 2017 – Dec 1, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Lee,

After merging the mfd tree, today's linux-next build (x86_64 allmodconfig) produced this warning:

drivers/leds/leds-pm8058.c: In function 'pm8058_led_probe':
drivers/leds/leds-pm8058.c:109:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

  led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
                 ^

Exposed by commit

deed10c2d603 ("mfd: pm8xxx: Make elegible for COMPILE_TEST")

CONFIG_LEDS_PM8058 depends on CONFIG_MFD_PM8XXX which is now turned on by allmodconfig.

The actual problematic commit is:

7f866986e705 ("leds: add PM8058 LEDs driver")

from v4.9-rc1.

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw

PATCH 1/1 leds: pm8058: Make ledtype pointer sized type

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>
---
 drivers/leds/leds-pm8058.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-pm8058.c +2 -2
index a52674327857..cc2afe81720d 100644
@@ -29,7 +29,7 @@
 struct pm8058_led {
 	struct regmap *map;
 	u32 reg;
-	u32 ledtype;
+	unsigned long ledtype;
 	struct led_classdev cdev;
 };
 
@@ -106,7 +106,7 @@ static int pm8058_led_probe(struct platform_device *pdev)
 	if (!led)
 		return -ENOMEM;
 
-	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
+	led->ledtype = (unsigned long)of_device_get_match_data(&pdev->dev);
 
 	map = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!map) {
Signature · 1 line
2.15.0
#16 lore raw
In reply to Stephen Rothwell
Quoted 8 lines · Stephen Rothwell

Hi Lee,

After merging the mfd tree, today's linux-next build (x86_64 allmodconfig) produced this warning:

drivers/leds/leds-pm8058.c: In function 'pm8058_led_probe':
drivers/leds/leds-pm8058.c:109:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
led->ledtype = (u32)of_device_get_match_data(&pdev->dev);

Linuuuuusssssss ...

Please fix. I'm happy to squash.

Quoted 13 lines

Exposed by commit

deed10c2d603 ("mfd: pm8xxx: Make elegible for COMPILE_TEST")

CONFIG_LEDS_PM8058 depends on CONFIG_MFD_PM8XXX which is now turned on by allmodconfig.

The actual problematic commit is:

7f866986e705 ("leds: add PM8058 LEDs driver")

from v4.9-rc1.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#2 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Bjorn Andersson
Quoted 11 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>
---
 drivers/leds/leds-pm8058.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Hi Bjorn,

(Nice to see you) :)

I'm going to apply this *before* Linus' fix.

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

Quoted 14 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>
---
 drivers/leds/leds-pm8058.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines

Hi Bjorn,

(Nice to see you) :)

I'm going to apply this *before* Linus' fix.

Applied, thanks.

After I rx an Ack from Richard, Jacek or Pavel of course. :)

Will send a pull-request.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Reviewed-by on v1 1/1
#7 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Bjorn Andersson
Quoted 8 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Thanks for covering my ass.

Yours,
Linus Walleij

#9 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Bjorn Andersson
Quoted 8 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Ummm... no?

extern const void *of_device_get_match_data(const struct device *dev);

drivers/leds/leds-pm8058.c line 32

Quoted 10 lines
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..cc2afe81720d 100644
@@ -29,7 +29,7 @@
 struct pm8058_led {
 	struct regmap *map;
 	u32 reg;
-	u32 ledtype;
+	unsigned long ledtype;

Make it void *. u32 is buggy. unsigned long is merely ugly code. void
* is not nice, but certainly better than unsigned long.

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#8 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Linus Walleij
Quoted 8 lines · Linus Walleij
Quoted 5 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Quoted 5 lines
Quoted 3 lines
Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Thanks for covering my ass.

:D

Quoted 1 line

I still need a LED Ack if I'm going to take this.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#10 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Pavel Machek
Quoted 15 lines · Pavel Machek
Quoted 8 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Ummm... no?

extern const void *of_device_get_match_data(const struct device *dev);

Quoted 13 lines

drivers/leds/leds-pm8058.c line 32

Quoted 10 lines
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..cc2afe81720d 100644
@@ -29,7 +29,7 @@
 struct pm8058_led {
 	struct regmap *map;
 	u32 reg;
-	u32 ledtype;
+	unsigned long ledtype;

Make it void *. u32 is buggy. unsigned long is merely ugly code. void
* is not nice, but certainly better than unsigned long.

unsigned long is correct, see below:

static const struct of_device_id pm8058_leds_id_table[] = {
        {
                .compatible = "qcom,pm8058-led",
                .data = (void *)PM8058_LED_TYPE_COMMON
        },
        {
                .compatible = "qcom,pm8058-keypad-led",
                .data = (void *)PM8058_LED_TYPE_KEYPAD
        },
        {
                .compatible = "qcom,pm8058-flash-led",
                .data = (void *)PM8058_LED_TYPE_FLASH
        },
        { },
};

of_device_get_match_data will return PM8058_LED_TYPE_* which clearly is a led type identifier.

Thus unsigned long looks reasonable.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#4 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Lee Jones
Quoted 20 lines · Lee Jones
Quoted 18 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>
---
 drivers/leds/leds-pm8058.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Hi Bjorn,

(Nice to see you) :)

Quoted 7 lines
Quoted 3 lines

I'm going to apply this *before* Linus' fix.

Applied, thanks.

After I rx an Ack from Richard, Jacek or Pavel of course. :)

Will send a pull-request.

Huh? This is for LED subsystem AFAICS.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#15 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Pavel Machek
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Quoted 8 lines
Quoted 3 lines
Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Ummm... no?

extern const void *of_device_get_match_data(const struct device *dev);

Right, this returns a pointer, which is of architecture dependent size.

Quoted 15 lines

drivers/leds/leds-pm8058.c line 32

Quoted 11 lines
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..cc2afe81720d 100644
@@ -29,7 +29,7 @@
 struct pm8058_led {
 	struct regmap *map;
 	u32 reg;
-	u32 ledtype;
+	unsigned long ledtype;

Make it void *. u32 is buggy. unsigned long is merely ugly code. void
* is not nice, but certainly better than unsigned long.

unsigned long is the integer type in the kernel that has the same size as a pointer, similar to the C-standard's intptr_t. So this is the idiomatic way to pass an integer data type via a pointer variable in the kernel.

Regards,
Bjorn

#11 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Jacek Anaszewski
Quoted 48 lines · Jacek Anaszewski
Quoted 15 lines · Pavel Machek
Quoted 8 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Ummm... no?

extern const void *of_device_get_match_data(const struct device *dev);

Quoted 13 lines

drivers/leds/leds-pm8058.c line 32

Quoted 10 lines
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..cc2afe81720d 100644
@@ -29,7 +29,7 @@
 struct pm8058_led {
 	struct regmap *map;
 	u32 reg;
-	u32 ledtype;
+	unsigned long ledtype;

Make it void *. u32 is buggy. unsigned long is merely ugly code. void
* is not nice, but certainly better than unsigned long.

unsigned long is correct, see below:

static const struct of_device_id pm8058_leds_id_table[] = {
        {
                .compatible = "qcom,pm8058-led",
                .data = (void *)PM8058_LED_TYPE_COMMON
        },
        {
                .compatible = "qcom,pm8058-keypad-led",
                .data = (void *)PM8058_LED_TYPE_KEYPAD
        },
        {
                .compatible = "qcom,pm8058-flash-led",
                .data = (void *)PM8058_LED_TYPE_FLASH
        },
        { },
};
Quoted 4 lines

of_device_get_match_data will return PM8058_LED_TYPE_* which clearly is a led type identifier.

Thus unsigned long looks reasonable.

Hmm. Ok. So u32 would actually make even more sense there (because PM8058_LED_TYPE_* does not really need to be 64-bit), but it would cause a warning.

I don't like this. This fix actually makes code waste memory and is uglier.

...but we get a warning fix. So I don't like the patch, but it is an improvement...

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#12 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

Hi Pavel,

Quoted 59 lines · On Thu, 30 Nov 2017 23:34:07 +0100 Pavel Machek <[email protected]> wrote:
Quoted 48 lines · Jacek Anaszewski
Quoted 15 lines · Pavel Machek
Quoted 8 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>

Ummm... no?

extern const void *of_device_get_match_data(const struct device *dev);

Quoted 13 lines

drivers/leds/leds-pm8058.c line 32

Quoted 10 lines
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..cc2afe81720d 100644
@@ -29,7 +29,7 @@
 struct pm8058_led {
 	struct regmap *map;
 	u32 reg;
-	u32 ledtype;
+	unsigned long ledtype;  

Make it void *. u32 is buggy. unsigned long is merely ugly code. void
* is not nice, but certainly better than unsigned long.

unsigned long is correct, see below:

static const struct of_device_id pm8058_leds_id_table[] = {
        {
                .compatible = "qcom,pm8058-led",
                .data = (void *)PM8058_LED_TYPE_COMMON
        },
        {
                .compatible = "qcom,pm8058-keypad-led",
                .data = (void *)PM8058_LED_TYPE_KEYPAD
        },
        {
                .compatible = "qcom,pm8058-flash-led",
                .data = (void *)PM8058_LED_TYPE_FLASH
        },
        { },
};
Quoted 4 lines

of_device_get_match_data will return PM8058_LED_TYPE_* which clearly is a led type identifier.

Thus unsigned long looks reasonable.

Hmm. Ok. So u32 would actually make even more sense there (because PM8058_LED_TYPE_* does not really need to be 64-bit), but it would cause a warning.

Quoted 5 lines

I don't like this. This fix actually makes code waste memory and is uglier.

...but we get a warning fix. So I don't like the patch, but it is an improvement...

I *think* you can get away with (u32)(unsigned long)ptr ...

Signature · 2 lines
Cheers,
Stephen Rothwell
#13 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

Hi!

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

of_device_get_match_data will return PM8058_LED_TYPE_* which clearly is a led type identifier.

Thus unsigned long looks reasonable.

Hmm. Ok. So u32 would actually make even more sense there (because PM8058_LED_TYPE_* does not really need to be 64-bit), but it would cause a warning.

Quoted 7 lines
Quoted 5 lines

I don't like this. This fix actually makes code waste memory and is uglier.

...but we get a warning fix. So I don't like the patch, but it is an improvement...

I *think* you can get away with (u32)(unsigned long)ptr ...

Yes, that should work. It would actually be my preferred solution.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

Quoted 14 lines · Pavel Machek

Hi!

Quoted 12 lines
Quoted 12 lines
Quoted 4 lines

of_device_get_match_data will return PM8058_LED_TYPE_* which clearly is a led type identifier.

Thus unsigned long looks reasonable.

Hmm. Ok. So u32 would actually make even more sense there (because PM8058_LED_TYPE_* does not really need to be 64-bit), but it would cause a warning.

I don't like this. This fix actually makes code waste memory and is uglier.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

...but we get a warning fix. So I don't like the patch, but it is an improvement...

I *think* you can get away with (u32)(unsigned long)ptr ...

Yes, that should work. It would actually be my preferred solution.

I'm fine with this suggestion, and it silence the warning. I will update and resend the patch.

Regards,
Bjorn

#17 lore raw

PATCH v2 1/1 leds: pm8058: Silence pointer to integer size warning

In reply to Stephen Rothwell

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing a compile warning when compile-testing the driver on such platform.

Cast the return value of of_device_get_match_data() to unsigned long and then to u32 to silence this warning.

Cc Linus Walleij <[email protected]>
Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
---
 drivers/leds/leds-pm8058.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..8988ba3b2d65 100644
@@ -106,7 +106,7 @@ static int pm8058_led_probe(struct platform_device *pdev)
 	if (!led)
 		return -ENOMEM;
 
-	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
+	led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);
 
 	map = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!map) {
Signature · 1 line
2.15.0
#5 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Jacek Anaszewski
Quoted 23 lines · Jacek Anaszewski
Quoted 22 lines · Lee Jones
Quoted 20 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>
---
 drivers/leds/leds-pm8058.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Hi Bjorn,

(Nice to see you) :)

I'm going to apply this *before* Linus' fix.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Applied, thanks.

After I rx an Ack from Richard, Jacek or Pavel of course. :)

Will send a pull-request.

Huh? This is for LED subsystem AFAICS.

Right, hence why I said I'd sent out a pull-request.

The problem, however, arose due to a change in its parent driver's Kconfig entry, which has been applied to the MFD tree. We need to ensure this patch is applied *before* the other 'fix' to quash the warning before it starts, so to speak.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#18 lore raw

Re: [PATCH v2] leds: pm8058: Silence pointer to integer size warning

In reply to Bjorn Andersson
Quoted 19 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing a compile warning when compile-testing the driver on such platform.

Cast the return value of of_device_get_match_data() to unsigned long and then to u32 to silence this warning.

Cc Linus Walleij <[email protected]>
Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
---
 drivers/leds/leds-pm8058.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pm8058.c +0 -0
index a52674327857..8988ba3b2d65 100644

drivers/leds/leds-pm8058.c static int pm8058_led_probe(struct platform_device *pdev) · line 109

Quoted 5 lines
drivers/leds/leds-pm8058.c +1 -1
@@ -106,7 +106,7 @@ static int pm8058_led_probe(struct platform_device *pdev)
 	if (!led)
 		return -ENOMEM;
 
-	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
+	led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);

Wouldn't (u32)(void *) be even more correct?

... if the compiler will let you get away with it.

Quoted 2 lines
drivers/leds/leds-pm8058.c +0 -0
 	map = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!map) {
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by
#19 lore raw

Re: [PATCH v2] leds: pm8058: Silence pointer to integer size warning

Quoted 6 lines · Lee Jones
Quoted 4 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing a compile warning when compile-testing the driver on such platform.

Quoted 6 lines
Quoted 6 lines

Cast the return value of of_device_get_match_data() to unsigned long and then to u32 to silence this warning.

Cc Linus Walleij <[email protected]>
Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")

Thanks!

Quoted 8 lines
Quoted 8 lines
drivers/leds/leds-pm8058.c +0 -0
index a52674327857..8988ba3b2d65 100644
@@ -106,7 +106,7 @@ static int pm8058_led_probe(struct platform_device *pdev)
 	if (!led)
 		return -ENOMEM;
 
Quoted 6 lines

drivers/leds/leds-pm8058.c static int pm8058_led_probe(struct platform_device *pdev) · line 109

Quoted 2 lines
drivers/leds/leds-pm8058.c +1 -1
-	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
+	led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);

Wouldn't (u32)(void *) be even more correct?

... if the compiler will let you get away with it.

Afaict that would still produce the warning. of_device_get_match_data already returns void *.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#20 lore raw

Re: [PATCH v2] leds: pm8058: Silence pointer to integer size warning

Quoted 11 lines · Pavel Machek
Quoted 7 lines · Lee Jones

drivers/leds/leds-pm8058.c static int pm8058_led_probe(struct platform_device *pdev) · line 109

Quoted 2 lines · Bjorn Andersson
drivers/leds/leds-pm8058.c +1 -1
-	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
+	led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);

Wouldn't (u32)(void *) be even more correct?

... if the compiler will let you get away with it.

Afaict that would still produce the warning. of_device_get_match_data already returns void *.

Just tested. It actually still suffers from the original error.

warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#21 lore raw

Re: [PATCH v2] leds: pm8058: Silence pointer to integer size warning

In reply to Bjorn Andersson
Quoted 7 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing a compile warning when compile-testing the driver on such platform.

Cast the return value of of_device_get_match_data() to unsigned long and then to u32 to silence this warning.

Quoted 6 lines
Cc Linus Walleij <[email protected]>
Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
---
 drivers/leds/leds-pm8058.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied with Pavel's Ack thanks.

Will send out a pull-request shortly.

Quoted 13 lines
drivers/leds/leds-pm8058.c +1 -1
index a52674327857..8988ba3b2d65 100644
@@ -106,7 +106,7 @@ static int pm8058_led_probe(struct platform_device *pdev)
 	if (!led)
 		return -ENOMEM;
 
-	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
+	led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);
 
 	map = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!map) {
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#22 lore raw

[GIT PULL] Immutable branch between MFD and LED due for the v4.16 merge window

In reply to Bjorn Andersson

Enjoy!

The following changes since commit 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323:

Linux 4.15-rc1 (2017-11-26 16:01:47 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-leds-v4.16

for you to fetch changes up to 8f52df50d9366f770a894d14ef724e5e04574e98:

leds: pm8058: Silence pointer to integer size warning (2017-12-01 08:57:42 +0000)

----------------------------------------------------------------
Immutable branch between MFD and LED due for the v4.16 merge window

----------------------------------------------------------------
Bjorn Andersson (1):
leds: pm8058: Silence pointer to integer size warning

 drivers/leds/leds-pm8058.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

Re: [PATCH] leds: pm8058: Make ledtype pointer sized type

In reply to Lee Jones
Quoted 31 lines · Lee Jones
Quoted 29 lines · Jacek Anaszewski
Quoted 27 lines · Lee Jones
Quoted 14 lines · Lee Jones
Quoted 11 lines · Bjorn Andersson

The pointer returned by of_device_get_match_data() doesn't have the same size as u32 on 64-bit architectures, causing issues when compile testing the driver on such platform. Make ledtype unsigned long instead, to solve this problem.

Fixes 7f866986e705 ("leds: add PM8058 LEDs driver")
Cc Linus Walleij <[email protected]>
---
 drivers/leds/leds-pm8058.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 7 lines

Hi Bjorn,

(Nice to see you) :)

I'm going to apply this *before* Linus' fix.

Applied, thanks.

After I rx an Ack from Richard, Jacek or Pavel of course. :)

Will send a pull-request.

Quoted 8 lines
Quoted 1 line

Huh? This is for LED subsystem AFAICS.

Right, hence why I said I'd sent out a pull-request.

The problem, however, arose due to a change in its parent driver's Kconfig entry, which has been applied to the MFD tree. We need to ensure this patch is applied *before* the other 'fix' to quash the warning before it starts, so to speak.

Ah, I hadn't seen the MFD patch and understood that you was talking about pull request for 4.15-rc2, which looked a bit strange out of context.

For v2:

Signature · 2 lines
Best regards,
Jacek Anaszewski