Skip to contentSkip to conversation

devres: allow const resource arguments

PATCH In review Arnd Bergmann 4 participants 4 messages Jun 28, 2019 – Jul 3, 2019

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

PATCH 1/1 devres: allow const resource arguments

devm_ioremap_resource() does not currently take 'const' arguments, which results in a warning from the first driver trying to do it anyway:

drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':
drivers/gpio/gpio-amd-fch.c:171:49: error: passing argument 2 of 'devm_ioremap_resource' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

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

Change the prototype to allow it, as there is no real reason not to.

Fixes 9bb2e0452508 ("gpio: amd: Make resource struct const")

---
The warning is currently in Linus Walleij's gpio tree, so I would suggest he can queue up this fix as well, if Greg (or whoever feels responsible for devres) agrees.

---
 include/linux/device.h | 3 ++-
 lib/devres.c           | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
include/linux/device.h +2 -1
index 4f65c424e5fd..f4ff92a6a56e 100644
@@ -705,7 +705,8 @@ extern unsigned long devm_get_free_pages(struct device *dev,
 					 gfp_t gfp_mask, unsigned int order);
 extern void devm_free_pages(struct device *dev, unsigned long addr);
 
-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
+void __iomem *devm_ioremap_resource(struct device *dev,
+				    const struct resource *res);
 
 void __iomem *devm_of_iomap(struct device *dev,
 			    struct device_node *node, int index,
lib/devres.c +2 -1
index 69bed2f38306..6a0e9bd6524a 100644
@@ -131,7 +131,8 @@ EXPORT_SYMBOL(devm_iounmap);
  *	if (IS_ERR(base))
  *		return PTR_ERR(base);
  */
-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
+void __iomem *devm_ioremap_resource(struct device *dev,
+				    const struct resource *res)
 {
 	resource_size_t size;
 	void __iomem *dest_ptr;
Signature · 1 line
2.20.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

devm_ioremap_resource() does not currently take 'const' arguments, which results in a warning from the first driver trying to do it anyway:

drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':
drivers/gpio/gpio-amd-fch.c:171:49: error: passing argument 2 of 'devm_ioremap_resource' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

  priv->base = devm_ioremap_resource(&pdev->dev, &amd_fch_gpio_iores);
                                                 ^~~~~~~~~~~~~~~~~~~
Quoted 8 lines

Change the prototype to allow it, as there is no real reason not to.

Fixes 9bb2e0452508 ("gpio: amd: Make resource struct const")

---
The warning is currently in Linus Walleij's gpio tree, so I would suggest he can queue up this fix as well, if Greg (or whoever feels responsible for devres) agrees.

That's fine with me if Linus takes it:

#2 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

devm_ioremap_resource() does not currently take 'const' arguments, which results in a warning from the first driver trying to do it anyway:

drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':
drivers/gpio/gpio-amd-fch.c:171:49: error: passing argument 2 of 'devm_ioremap_resource' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

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

<snip>

I've posted quite the same some time ago - no idea why it got no response.

--mtx

Signature · 3 lines
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
[email protected] -- +49-151-27565287
#3 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

devm_ioremap_resource() does not currently take 'const' arguments, which results in a warning from the first driver trying to do it anyway:

drivers/gpio/gpio-amd-fch.c: In function 'amd_fch_gpio_probe':
drivers/gpio/gpio-amd-fch.c:171:49: error: passing argument 2 of 'devm_ioremap_resource' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

Quoted 7 lines
  priv->base = devm_ioremap_resource(&pdev->dev, &amd_fch_gpio_iores);
                                                 ^~~~~~~~~~~~~~~~~~~

Change the prototype to allow it, as there is no real reason not to.

Fixes 9bb2e0452508 ("gpio: amd: Make resource struct const")

Patch applied with Greg's and Enrico's ACKs.

Yours,
Linus Walleij