diff mbox series

gpio: amd-fch: Drop const from resource

Message ID 20190225125500.20571-1-linus.walleij@linaro.org
State Accepted
Commit c0162a49e0a0651625f0c22fd45ece4573143a67
Headers show
Series gpio: amd-fch: Drop const from resource | expand

Commit Message

Linus Walleij Feb. 25, 2019, 12:55 p.m. UTC
The build servers and linux-next are complaining like this:

drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':
drivers/gpio/gpio-amd-fch.c:164:49: warning: passing argument 2 of
'devm_ioremap_resource' discards 'const' qualifier from pointer
target type [-Wdiscarded-qualifiers]
priv->base = devm_ioremap_resource(&pdev->dev, &amd_fch_gpio_iores);
                                               ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/platform_device.h:14, from
drivers/gpio/gpio-amd-fch.c:15:
include/linux/device.h:709:15: note: expected 'struct resource *'
but argument is of type 'const struct resource *'
 void __iomem *devm_ioremap_resource(struct device *dev,struct resource *res);
               ^~~~~~~~~~~~~~~~~~~~~

Let's just remove "const" for now.

It is possible that devm_ioremap_resource() should rather
be constified so we can pass const resources as arguments.
But right now I just want to get rid of this build warning.

Fixes: e09d168f13f0 ("gpio: AMD G-Series PCH gpio driver")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reported-by: kbuild test robot <lkp@intel.com>
Cc: Enrico Weigelt <info@metux.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/gpio/gpio-amd-fch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.20.1

Comments

Enrico Weigelt, metux IT consult March 4, 2019, 11:45 a.m. UTC | #1
On 25.02.19 13:55, Linus Walleij wrote:
> The build servers and linux-next are complaining like this:

> 

> drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':

> drivers/gpio/gpio-amd-fch.c:164:49: warning: passing argument 2 of

> 'devm_ioremap_resource' discards 'const' qualifier from pointer

> target type [-Wdiscarded-qualifiers]

> priv->base = devm_ioremap_resource(&pdev->dev, &amd_fch_gpio_iores);


hmm, strange that it doesn't come up on my builds.
Do did you pass some extra cflags ?

Maybe we should talk to kbuild maintainer on adding
-Wdiscarded-qualifiers per default ?

> Let's just remove "const" for now.


ACK.

> It is possible that devm_ioremap_resource() should rather

> be constified so we can pass const resources as arguments.


Indeed. Actually, we could even make it initconst, as it doesn't
keep any pointer - instead if just reads out the size and start
fields and then forgets about the struct.

Maybe we could even pass the struct directly (instead of ptr),
as it's very small anyways.


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
index 3b4fdce325c1..4fd66444ea33 100644
--- a/drivers/gpio/gpio-amd-fch.c
+++ b/drivers/gpio/gpio-amd-fch.c
@@ -25,7 +25,7 @@ 
 #define AMD_FCH_GPIO_FLAG_WRITE		BIT(22)
 #define AMD_FCH_GPIO_FLAG_READ		BIT(16)
 
-static const struct resource amd_fch_gpio_iores =
+static struct resource amd_fch_gpio_iores =
 	DEFINE_RES_MEM_NAMED(
 		AMD_FCH_MMIO_BASE + AMD_FCH_GPIO_BANK0_BASE,
 		AMD_FCH_GPIO_SIZE,