Message ID | 20171201051656.31694-1-bjorn.andersson@linaro.org |
---|---|
State | New |
Headers | show |
Series | [v2] leds: pm8058: Silence pointer to integer size warning | expand |
On Thu, 30 Nov 2017, Bjorn Andersson wrote: > 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 <linus.walleij@linaro.org> > Fixes: 7f866986e705 ("leds: add PM8058 LEDs driver") > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > drivers/leds/leds-pm8058.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c > index a52674327857..8988ba3b2d65 100644 > --- a/drivers/leds/leds-pm8058.c > +++ b/drivers/leds/leds-pm8058.c > @@ -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. > map = dev_get_regmap(pdev->dev.parent, NULL); > if (!map) { -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
On Fri 2017-12-01 07:57:15, Lee Jones wrote: > On Thu, 30 Nov 2017, Bjorn Andersson wrote: > > > 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 <linus.walleij@linaro.org> > > Fixes: 7f866986e705 ("leds: add PM8058 LEDs driver") > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Thanks! Acked-by: Pavel Machek <pavel@ucw.cz> > > diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c > > index a52674327857..8988ba3b2d65 100644 > > --- a/drivers/leds/leds-pm8058.c > > +++ b/drivers/leds/leds-pm8058.c > > @@ -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. Afaict that would still produce the warning. of_device_get_match_data already returns void *. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
On Thu, 30 Nov 2017, Bjorn Andersson wrote: > 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 <linus.walleij@linaro.org> > Fixes: 7f866986e705 ("leds: add PM8058 LEDs driver") > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> > --- > 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. > diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c > index a52674327857..8988ba3b2d65 100644 > --- a/drivers/leds/leds-pm8058.c > +++ b/drivers/leds/leds-pm8058.c > @@ -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) { -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
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(-) -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
diff --git a/drivers/leds/leds-pm8058.c b/drivers/leds/leds-pm8058.c index a52674327857..8988ba3b2d65 100644 --- a/drivers/leds/leds-pm8058.c +++ b/drivers/leds/leds-pm8058.c @@ -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) {
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 <linus.walleij@linaro.org> Fixes: 7f866986e705 ("leds: add PM8058 LEDs driver") Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- drivers/leds/leds-pm8058.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.15.0