Skip to contentSkip to conversation

Sanitize devm_request_and_ioremap()

PATCH Applied Thierry Reding 21 participants 86 messages Jan 21, 2013 – Feb 11, 2013

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

cover Sanitize devm_request_and_ioremap()

Recent discussions about the lack of a meaningful error code returned by devm_request_and_ioremap() have triggered this patch series. One common issue is that the function returns NULL in all failure cases, making it impossible to determine what went wrong exactly. Another problem is that people can't seem to agree on what error code to return in case where the function fails. Both of these problems lead to inconsistent usage.

This series attempts to fix this by providing a replacement function, devm_ioremap_resource(), which returns a pointer to the remapped memory region on success and an ERR_PTR()-encoded error code on failure. Users can check for failure using the IS_ERR() macro and determine the exact cause by extracting the error code using PTR_ERR().

Patch 1 adds the new devm_ioremap_resource() function, which is really just a renamed version of devm_request_and_ioremap() that returns ERR_PTR()-encoded error codes on failure and makes the old function a wrapper around it, returning NULL in case of devm_ioremap_resource() failure. Furthermore the patch marks devm_request_and_ioremap() as a deprecated function to make it clear that it should no longer be used. A semantic patch is included that was used to convert the bulk of the existing calls to devm_request_and_ioremap() to the new API. The patch is far from perfect and a few occurrences had to be converted or fixed up manually.

The remaining patches convert each subsystem separately to use the new API.

Thierry

Cc Greg Kroah-Hartman <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Wolfram Sang <[email protected]>

Thierry Reding (33):
lib: devres: Introduce devm_ioremap_resource()
ARM: Convert to devm_ioremap_resource()
MIPS: Convert to devm_ioremap_resource()
amba: Convert to devm_ioremap_resource()
ata: Convert to devm_ioremap_resource()
char: Convert to devm_ioremap_resource()
dma: Convert to devm_ioremap_resource()
gpio: Convert to devm_ioremap_resource()
drm: Convert to devm_ioremap_resource()
i2c: Convert to devm_ioremap_resource()
iio: Convert to devm_ioremap_resource()
Input: Convert to devm_ioremap_resource()
iommu: Convert to devm_ioremap_resource()
media: Convert to devm_ioremap_resource()
memory: Convert to devm_ioremap_resource()
mfd: Convert to devm_ioremap_resource()
misc: Convert to devm_ioremap_resource()
mmc: Convert to devm_ioremap_resource()
mtd: Convert to devm_ioremap_resource()
net: Convert to devm_ioremap_resource()
pinctrl: Convert to devm_ioremap_resource()
power: Convert to devm_ioremap_resource()
pwm: Convert to devm_ioremap_resource()
rtc: Convert to devm_ioremap_resource()
spi: Convert to devm_ioremap_resource()
staging: Convert to devm_ioremap_resource()
thermal: Convert to devm_ioremap_resource()
serial: Convert to devm_ioremap_resource()
usb: Convert to devm_ioremap_resource()
video: Convert to devm_ioremap_resource()
w1: Convert to devm_ioremap_resource()
watchdog: Convert to devm_ioremap_resource()
ASoC: Convert to devm_ioremap_resource()

 Documentation/driver-model/devres.txt              |  3 +-
 arch/arm/mach-omap2/gpmc.c                         |  8 +-
 arch/arm/mach-tegra/tegra2_emc.c                   |  8 +-
 arch/arm/plat-omap/dmtimer.c                       |  8 +-
 arch/arm/plat-samsung/adc.c                        |  8 +-
 arch/mips/lantiq/xway/dma.c                        |  5 +-
 arch/mips/lantiq/xway/gptu.c                       |  8 +-
 arch/mips/pci/pci-lantiq.c                         | 12 +--
 drivers/amba/tegra-ahb.c                           |  7 +-
 drivers/ata/pata_ep93xx.c                          |  7 +-
 drivers/char/hw_random/exynos-rng.c                |  9 ++-
 drivers/char/hw_random/omap-rng.c                  |  6 +-
 drivers/char/hw_random/tx4939-rng.c                |  7 +-
 drivers/dma/dw_dmac.c                              |  7 +-
 drivers/dma/imx-dma.c                              |  7 +-
 drivers/dma/mmp_pdma.c                             |  7 +-
 drivers/dma/mmp_tdma.c                             |  7 +-
 drivers/dma/tegra20-apb-dma.c                      | 10 +--
 drivers/gpio/gpio-mvebu.c                          | 16 ++--
 drivers/gpio/gpio-mxs.c                            |  9 ++-
 drivers/gpio/gpio-spear-spics.c                    |  8 +-
 drivers/gpio/gpio-stp-xway.c                       |  9 +--
 drivers/gpio/gpio-tegra.c                          |  9 +--
 drivers/gpu/drm/exynos/exynos_drm_fimc.c           |  8 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c           |  8 +-
 drivers/gpu/drm/exynos/exynos_drm_g2d.c            |  7 +-
 drivers/gpu/drm/exynos/exynos_drm_gsc.c            |  8 +-
 drivers/gpu/drm/exynos/exynos_drm_rotator.c        |  8 +-
 drivers/gpu/drm/exynos/exynos_hdmi.c               |  8 +-
 drivers/gpu/drm/tegra/dc.c                         |  8 +-
 drivers/gpu/drm/tegra/hdmi.c                       |  6 +-
 drivers/gpu/drm/tegra/host1x.c                     |  6 +-
 drivers/i2c/busses/i2c-at91.c                      |  6 +-
 drivers/i2c/busses/i2c-imx.c                       |  6 +-
 drivers/i2c/busses/i2c-ocores.c                    |  7 +-
 drivers/i2c/busses/i2c-omap.c                      |  8 +-
 drivers/i2c/busses/i2c-rcar.c                      |  8 +-
 drivers/i2c/busses/i2c-s3c2410.c                   |  7 +-
 drivers/i2c/busses/i2c-sirf.c                      |  7 +-
 drivers/i2c/busses/i2c-stu300.c                    |  6 +-
 drivers/i2c/busses/i2c-tegra.c                     |  8 +-
 drivers/i2c/busses/i2c-xlr.c                       |  9 +--
 drivers/iio/adc/at91_adc.c                         |  6 +-
 drivers/input/keyboard/spear-keyboard.c            |  8 +-
 drivers/input/serio/arc_ps2.c                      |  7 +-
 drivers/iommu/tegra-smmu.c                         |  7 +-
 drivers/media/platform/exynos-gsc/gsc-core.c       |  8 +-
 drivers/media/platform/mx2_emmaprp.c               |  6 +-
 drivers/media/platform/s3c-camif/camif-core.c      |  8 +-
 drivers/media/platform/s5p-fimc/fimc-core.c        |  8 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c        |  8 +-
 drivers/media/platform/s5p-fimc/mipi-csis.c        |  8 +-
 drivers/media/platform/s5p-g2d/g2d.c               |  8 +-
 drivers/media/platform/s5p-jpeg/jpeg-core.c        |  8 +-
 drivers/media/platform/s5p-mfc/s5p_mfc.c           |  8 +-
 drivers/media/platform/soc_camera/mx2_camera.c     | 12 +--
 drivers/memory/emif.c                              |  8 +-
 drivers/memory/tegra20-mc.c                        |  7 +-
 drivers/memory/tegra30-mc.c                        |  7 +-
 drivers/mfd/intel_msic.c                           |  9 +--
 drivers/misc/atmel-ssc.c                           |  8 +-
 drivers/mmc/host/dw_mmc-pltfm.c                    |  7 +-
 drivers/mmc/host/mxs-mmc.c                         |  6 +-
 drivers/mmc/host/sdhci-s3c.c                       |  7 +-
 drivers/mtd/devices/spear_smi.c                    |  7 +-
 drivers/mtd/maps/autcpu12-nvram.c                  |  9 +--
 drivers/mtd/maps/lantiq-flash.c                    |  8 +-
 drivers/mtd/nand/fsmc_nand.c                       | 33 ++++----
 drivers/mtd/nand/lpc32xx_mlc.c                     |  9 +--
 drivers/mtd/nand/lpc32xx_slc.c                     |  8 +-
 drivers/mtd/nand/mxc_nand.c                        | 12 +--
 drivers/mtd/nand/s3c2410.c                         |  7 +-
 drivers/mtd/nand/txx9ndfmc.c                       |  7 +-
 drivers/net/can/grcan.c                            |  8 +-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  9 +--
 drivers/pinctrl/pinctrl-at91.c                     |  7 +-
 drivers/pinctrl/pinctrl-bcm2835.c                  |  6 +-
 drivers/pinctrl/pinctrl-coh901.c                   |  8 +-
 drivers/pinctrl/pinctrl-exynos5440.c               |  8 +-
 drivers/pinctrl/pinctrl-falcon.c                   | 13 ++--
 drivers/pinctrl/pinctrl-imx.c                      |  6 +-
 drivers/pinctrl/pinctrl-nomadik.c                  |  6 +-
 drivers/pinctrl/pinctrl-pxa3xx.c                   |  7 +-
 drivers/pinctrl/pinctrl-samsung.c                  |  8 +-
 drivers/pinctrl/pinctrl-u300.c                     |  6 +-
 drivers/pinctrl/pinctrl-xway.c                     |  9 +--
 drivers/pinctrl/spear/pinctrl-plgpio.c             |  8 +-
 drivers/power/jz4740-battery.c                     |  7 +-
 drivers/pwm/pwm-imx.c                              |  6 +-
 drivers/pwm/pwm-lpc32xx.c                          |  6 +-
 drivers/pwm/pwm-mxs.c                              |  6 +-
 drivers/pwm/pwm-puv3.c                             |  6 +-
 drivers/pwm/pwm-pxa.c                              |  6 +-
 drivers/pwm/pwm-spear.c                            |  6 +-
 drivers/pwm/pwm-tegra.c                            |  6 +-
 drivers/pwm/pwm-tiecap.c                           |  6 +-
 drivers/pwm/pwm-tiehrpwm.c                         |  6 +-
 drivers/pwm/pwm-tipwmss.c                          |  6 +-
 drivers/pwm/pwm-vt8500.c                           |  6 +-
 drivers/rtc/rtc-s3c.c                              |  8 +-
 drivers/rtc/rtc-snvs.c                             |  6 +-
 drivers/rtc/rtc-spear.c                            |  8 +-
 drivers/rtc/rtc-tegra.c                            |  8 +-
 drivers/spi/spi-ep93xx.c                           |  7 +-
 drivers/spi/spi-mxs.c                              |  6 +-
 drivers/spi/spi-omap2-mcspi.c                      |  7 +-
 drivers/spi/spi-s3c64xx.c                          |  7 +-
 drivers/spi/spi-sirf.c                             |  7 +-
 drivers/spi/spi-tegra20-sflash.c                   |  8 +-
 drivers/spi/spi-tegra20-slink.c                    |  8 +-
 drivers/staging/iio/adc/mxs-lradc.c                |  7 +-
 drivers/staging/nvec/nvec.c                        |  8 +-
 drivers/staging/omap-thermal/omap-bandgap.c        | 11 +--
 drivers/thermal/exynos_thermal.c                   |  8 +-
 drivers/tty/serial/sccnxp.c                        |  8 +-
 drivers/usb/chipidea/usbmisc_imx6q.c               |  6 +-
 drivers/usb/gadget/bcm63xx_udc.c                   | 13 ++--
 drivers/usb/gadget/s3c-hsotg.c                     |  7 +-
 drivers/usb/gadget/s3c-hsudc.c                     |  7 +-
 drivers/usb/host/ehci-atmel.c                      |  7 +-
 drivers/usb/host/ehci-grlib.c                      |  9 +--
 drivers/usb/host/ehci-mxc.c                        |  7 +-
 drivers/usb/host/ehci-platform.c                   |  7 +-
 drivers/usb/host/ehci-ppc-of.c                     |  8 +-
 drivers/usb/host/ehci-sead3.c                      |  8 +-
 drivers/usb/host/ehci-sh.c                         |  7 +-
 drivers/usb/host/ehci-vt8500.c                     |  8 +-
 drivers/usb/host/ehci-xilinx-of.c                  |  8 +-
 drivers/usb/host/ohci-nxp.c                        |  7 +-
 drivers/usb/host/ohci-platform.c                   |  7 +-
 drivers/usb/host/ohci-s3c2410.c                    |  7 +-
 drivers/usb/musb/musb_dsps.c                       |  7 +-
 drivers/usb/musb/omap2430.c                        |  4 +-
 drivers/usb/otg/mxs-phy.c                          |  6 +-
 drivers/usb/phy/mv_u3d_phy.c                       |  8 +-
 drivers/usb/phy/omap-usb2.c                        |  8 +-
 drivers/usb/renesas_usbhs/common.c                 |  9 +--
 drivers/video/exynos/exynos_dp_core.c              |  8 +-
 drivers/video/jz4740_fb.c                          |  6 +-
 drivers/video/omap2/dss/hdmi.c                     |  8 +-
 drivers/video/omap2/vrfb.c                         |  9 +--
 drivers/video/s3c-fb.c                             |  7 +-
 drivers/w1/masters/omap_hdq.c                      |  8 +-
 drivers/watchdog/ar7_wdt.c                         |  8 +-
 drivers/watchdog/dw_wdt.c                          |  6 +-
 drivers/watchdog/imx2_wdt.c                        |  8 +-
 drivers/watchdog/jz4740_wdt.c                      |  6 +-
 drivers/watchdog/lantiq_wdt.c                      |  8 +-
 drivers/watchdog/max63xx_wdt.c                     |  7 +-
 drivers/watchdog/pnx4008_wdt.c                     |  6 +-
 drivers/watchdog/txx9wdt.c                         |  6 +-
 include/linux/device.h                             |  3 +-
 lib/devres.c                                       | 57 ++++++++++----
 scripts/coccinelle/api/devm_ioremap_resource.cocci | 90 ++++++++++++++++++++++
 sound/soc/cirrus/ep93xx-ac97.c                     |  7 +-
 sound/soc/cirrus/ep93xx-i2s.c                      |  6 +-
 sound/soc/codecs/jz4740.c                          |  6 +-
 sound/soc/fsl/imx-audmux.c                         |  6 +-
 sound/soc/fsl/imx-ssi.c                            |  7 +-
 sound/soc/kirkwood/kirkwood-i2s.c                  |  8 +-
 sound/soc/mxs/mxs-saif.c                           |  8 +-
 sound/soc/pxa/mmp-sspa.c                           |  6 +-
 162 files changed, 686 insertions(+), 681 deletions(-)
 create mode 100644 scripts/coccinelle/api/devm_ioremap_resource.cocci
Signature · 1 line
1.8.1
#1 lore raw

PATCH 1/33 lib: devres: Introduce devm_ioremap_resource()

The devm_request_and_ioremap() function is very useful and helps avoid a whole lot of boilerplate. However, one issue that keeps popping up is its lack of a specific error code to determine which of the steps that it performs failed. Furthermore, while the function gives an example and suggests what error code to return on failure, a wide variety of error codes are used throughout the tree.

In an attempt to fix these problems, this patch adds a new function that drivers can transition to. The devm_ioremap_resource() returns a pointer to the remapped I/O memory on success or an ERR_PTR() encoded error code on failure. Callers can check for failure using IS_ERR() and determine its cause by extracting the error code using PTR_ERR().

devm_request_and_ioremap() is implemented as a wrapper around the new API and return NULL on failure as before. This ensures that backwards compatibility is maintained until all users have been converted to the new API, at which point the old devm_request_and_ioremap() function should be removed. To help prevent new users from being added in the meantime, devm_request_and_ioremap() is marked __deprecated.

A semantic patch is included which can be used to convert from the old devm_request_and_ioremap() API to the new devm_ioremap_resource() API. Some non-trivial cases may require manual intervention, though.

Cc Greg Kroah-Hartman <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 Documentation/driver-model/devres.txt              |  3 +-
 include/linux/device.h                             |  3 +-
 lib/devres.c                                       | 57 ++++++++++----
 scripts/coccinelle/api/devm_ioremap_resource.cocci | 90 ++++++++++++++++++++++
 4 files changed, 138 insertions(+), 15 deletions(-)
 create mode 100644 scripts/coccinelle/api/devm_ioremap_resource.cocci
Documentation/driver-model/devres.txt +2 -1
index 43cff70..25240fc 100644
@@ -266,7 +266,8 @@ IOMAP
   devm_ioremap()
   devm_ioremap_nocache()
   devm_iounmap()
-  devm_request_and_ioremap() : checks resource, requests region, ioremaps
+  devm_ioremap_resource() : checks resource, requests memory region, ioremaps
+  devm_request_and_ioremap() : obsoleted by devm_ioremap_resource()
   pcim_iomap()
   pcim_iounmap()
   pcim_iomap_table()	: array of mapped addresses indexed by BAR
include/linux/device.h +2 -1
index 43dcda9..558c405 100644
@@ -573,8 +573,9 @@ extern int devres_release_group(struct device *dev, void *id);
 extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
 extern void devm_kfree(struct device *dev, void *p);
 
+void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
 void __iomem *devm_request_and_ioremap(struct device *dev,
-			struct resource *res);
+			struct resource *res) __deprecated;
 
 struct device_dma_parameters {
 	/*
lib/devres.c +44 -13

90 lines not on this page · raw message

scripts/coccinelle/api/devm_ioremap_resource.cocci new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.8.1.1
maintainer Acked-by on v1 1/33
#2 lore raw

Re: [PATCH 01/33] lib: devres: Introduce devm_ioremap_resource()

Quoted 20 lines · Thierry Reding

The devm_request_and_ioremap() function is very useful and helps avoid a whole lot of boilerplate. However, one issue that keeps popping up is its lack of a specific error code to determine which of the steps that it performs failed. Furthermore, while the function gives an example and suggests what error code to return on failure, a wide variety of error codes are used throughout the tree.

In an attempt to fix these problems, this patch adds a new function that drivers can transition to. The devm_ioremap_resource() returns a pointer to the remapped I/O memory on success or an ERR_PTR() encoded error code on failure. Callers can check for failure using IS_ERR() and determine its cause by extracting the error code using PTR_ERR().

devm_request_and_ioremap() is implemented as a wrapper around the new API and return NULL on failure as before. This ensures that backwards compatibility is maintained until all users have been converted to the new API, at which point the old devm_request_and_ioremap() function should be removed. To help prevent new users from being added in the meantime, devm_request_and_ioremap() is marked __deprecated.

Quoted 7 lines

A semantic patch is included which can be used to convert from the old devm_request_and_ioremap() API to the new devm_ioremap_resource() API. Some non-trivial cases may require manual intervention, though.

Cc Greg Kroah-Hartman <[email protected]>
Cc Dmitry Torokhov <[email protected]>

This looks good to me.

Quoted 235 lines
Cc Arnd Bergmann <[email protected]>
---
 Documentation/driver-model/devres.txt              |  3 +-
 include/linux/device.h                             |  3 +-
 lib/devres.c                                       | 57 ++++++++++----
 scripts/coccinelle/api/devm_ioremap_resource.cocci | 90 ++++++++++++++++++++++
 4 files changed, 138 insertions(+), 15 deletions(-)
 create mode 100644 scripts/coccinelle/api/devm_ioremap_resource.cocci
Documentation/driver-model/devres.txt +2 -1
index 43cff70..25240fc 100644
@@ -266,7 +266,8 @@ IOMAP
   devm_ioremap()
   devm_ioremap_nocache()
   devm_iounmap()
-  devm_request_and_ioremap() : checks resource, requests region, ioremaps
+  devm_ioremap_resource() : checks resource, requests memory region, ioremaps
+  devm_request_and_ioremap() : obsoleted by devm_ioremap_resource()
   pcim_iomap()
   pcim_iounmap()
   pcim_iomap_table()	: array of mapped addresses indexed by BAR
include/linux/device.h +2 -1
index 43dcda9..558c405 100644
@@ -573,8 +573,9 @@ extern int devres_release_group(struct device *dev, void *id);
 extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
 extern void devm_kfree(struct device *dev, void *p);
 
+void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
 void __iomem *devm_request_and_ioremap(struct device *dev,
-			struct resource *res);
+			struct resource *res) __deprecated;
 
 struct device_dma_parameters {
 	/*
lib/devres.c +44 -13
index 80b9c76..9c76b3a 100644
@@ -86,22 +86,24 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
 EXPORT_SYMBOL(devm_iounmap);
 
 /**
- * devm_request_and_ioremap() - Check, request region, and ioremap resource
- * @dev: Generic device to handle the resource for
+ * devm_ioremap_resource() - check, request region, and ioremap resource
+ * @dev: generic device to handle the resource for
  * @res: resource to be handled
  *
- * Takes all necessary steps to ioremap a mem resource. Uses managed device, so
- * everything is undone on driver detach. Checks arguments, so you can feed
- * it the result from e.g. platform_get_resource() directly. Returns the
- * remapped pointer or NULL on error. Usage example:
+ * Checks that a resource is a valid memory region, requests the memory region
+ * and ioremaps it either as cacheable or as non-cacheable memory depending on
+ * the resource's flags. All operations are managed and will be undone on
+ * driver detach.
+ *
+ * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
+ * on failure. Usage example:
  *
  *	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- *	base = devm_request_and_ioremap(&pdev->dev, res);
- *	if (!base)
- *		return -EADDRNOTAVAIL;
+ *	base = devm_ioremap_resource(&pdev->dev, res);
+ *	if (IS_ERR(base))
+ *		return PTR_ERR(base);
  */
-void __iomem *devm_request_and_ioremap(struct device *dev,
-			struct resource *res)
+void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
 {
 	resource_size_t size;
 	const char *name;
@@ -111,7 +113,7 @@ void __iomem *devm_request_and_ioremap(struct device *dev,
 
 	if (!res || resource_type(res) != IORESOURCE_MEM) {
 		dev_err(dev, "invalid resource\n");
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	size = resource_size(res);
@@ -119,7 +121,7 @@ void __iomem *devm_request_and_ioremap(struct device *dev,
 
 	if (!devm_request_mem_region(dev, res->start, size, name)) {
 		dev_err(dev, "can't request region for resource %pR\n", res);
-		return NULL;
+		return ERR_PTR(-EBUSY);
 	}
 
 	if (res->flags & IORESOURCE_CACHEABLE)
@@ -130,10 +132,39 @@ void __iomem *devm_request_and_ioremap(struct device *dev,
 	if (!dest_ptr) {
 		dev_err(dev, "ioremap failed for resource %pR\n", res);
 		devm_release_mem_region(dev, res->start, size);
+		dest_ptr = ERR_PTR(-ENOMEM);
 	}
 
 	return dest_ptr;
 }
+EXPORT_SYMBOL(devm_ioremap_resource);
+
+/**
+ * devm_request_and_ioremap() - Check, request region, and ioremap resource
+ * @dev: Generic device to handle the resource for
+ * @res: resource to be handled
+ *
+ * Takes all necessary steps to ioremap a mem resource. Uses managed device, so
+ * everything is undone on driver detach. Checks arguments, so you can feed
+ * it the result from e.g. platform_get_resource() directly. Returns the
+ * remapped pointer or NULL on error. Usage example:
+ *
+ *	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ *	base = devm_request_and_ioremap(&pdev->dev, res);
+ *	if (!base)
+ *		return -EADDRNOTAVAIL;
+ */
+void __iomem *devm_request_and_ioremap(struct device *device,
+				       struct resource *res)
+{
+	void __iomem *dest_ptr;
+
+	dest_ptr = devm_ioremap_resource(device, res);
+	if (IS_ERR(dest_ptr))
+		return NULL;
+
+	return dest_ptr;
+}
 EXPORT_SYMBOL(devm_request_and_ioremap);
 
 #ifdef CONFIG_HAS_IOPORT
scripts/coccinelle/api/devm_ioremap_resource.cocci new file +90 -0
new file mode 100644
index 0000000..495daa3
@@ -0,0 +1,90 @@
+virtual patch
+virtual report
+
+@depends on patch@
+expression base, dev, res;
+@@
+
+-base = devm_request_and_ioremap(dev, res);
++base = devm_ioremap_resource(dev, res);
+ ...
+ if (
+-base == NULL
++IS_ERR(base)
+ || ...) {
+<...
+-	return ...;
++	return PTR_ERR(base);
+...>
+ }
+
+@depends on patch@
+expression e, E, ret;
+identifier l;
+@@
+
+ e = devm_ioremap_resource(...);
+ ...
+ if (IS_ERR(e) || ...) {
+ 	... when any
+-	ret = E;
++	ret = PTR_ERR(e);
+ 	...
+(
+ 	return ret;
+|
+ 	goto l;
+)
+ }
+
+@depends on patch@
+expression e;
+@@
+
+ e = devm_ioremap_resource(...);
+ ...
+ if (IS_ERR(e) || ...) {
+ 	...
+-	\(dev_dbg\|dev_err\|pr_debug\|pr_err\|DRM_ERROR\)(...);
+ 	...
+ }
+
+@depends on patch@
+expression e;
+identifier l;
+@@
+
+ e = devm_ioremap_resource(...);
+ ...
+ if (IS_ERR(e) || ...)
+-{
+(
+ 	return ...;
+|
+ 	goto l;
+)
+-}
+
+@r depends on report@
+expression e;
+identifier l;
+position p1;
+@@
+
+*e = devm_request_and_ioremap@p1(...);
+ ...
+ if (e == NULL || ...) {
+ 	...
+(
+ 	return ...;
+|
+ 	goto l;
+)
+ }
+
+@script:python depends on r@
+p1 << r.p1;
+@@
+
+msg = "ERROR: deprecated devm_request_and_ioremap() API used on line %s" % (p1[0].line)
+coccilib.report.print_report(p1[0], msg)
Signature · 1 line
1.8.1.1
Signature · 1 line
Dmitry
#3 lore raw

Re: [PATCH 01/33] lib: devres: Introduce devm_ioremap_resource()

In reply to Thierry Reding
Quoted 13 lines · Thierry Reding

The devm_request_and_ioremap() function is very useful and helps avoid a whole lot of boilerplate. However, one issue that keeps popping up is its lack of a specific error code to determine which of the steps that it performs failed. Furthermore, while the function gives an example and suggests what error code to return on failure, a wide variety of error codes are used throughout the tree.

In an attempt to fix these problems, this patch adds a new function that drivers can transition to. The devm_ioremap_resource() returns a pointer to the remapped I/O memory on success or an ERR_PTR() encoded error code on failure. Callers can check for failure using IS_ERR() and determine its cause by extracting the error code using PTR_ERR().

Quoted 6 lines

devm_request_and_ioremap() is implemented as a wrapper around the new API and return NULL on failure as before. This ensures that backwards compatibility is maintained until all users have been converted to the new API, at which point the old devm_request_and_ioremap() function should be removed. To help prevent new users from being added in the meantime, devm_request_and_ioremap() is marked __deprecated.

I've edited the patch and removed the __depreciated line as that's just going to cause a whole lot of noise in the kernel. I'd recommend just watching to ensure that we catch all users of the current function and convert them to the new one, and then we can drop it, no need to use __deprecated at all.

thanks,

greg k-h

#4 lore raw

Re: [PATCH 01/33] lib: devres: Introduce devm_ioremap_resource()

Quoted 21 lines · Greg Kroah-Hartman
Quoted 13 lines · Thierry Reding

The devm_request_and_ioremap() function is very useful and helps avoid a whole lot of boilerplate. However, one issue that keeps popping up is its lack of a specific error code to determine which of the steps that it performs failed. Furthermore, while the function gives an example and suggests what error code to return on failure, a wide variety of error codes are used throughout the tree.

In an attempt to fix these problems, this patch adds a new function that drivers can transition to. The devm_ioremap_resource() returns a pointer to the remapped I/O memory on success or an ERR_PTR() encoded error code on failure. Callers can check for failure using IS_ERR() and determine its cause by extracting the error code using PTR_ERR().

Quoted 6 lines

devm_request_and_ioremap() is implemented as a wrapper around the new API and return NULL on failure as before. This ensures that backwards compatibility is maintained until all users have been converted to the new API, at which point the old devm_request_and_ioremap() function should be removed. To help prevent new users from being added in the meantime, devm_request_and_ioremap() is marked __deprecated.

Quoted 5 lines

I've edited the patch and removed the __depreciated line as that's just going to cause a whole lot of noise in the kernel. I'd recommend just watching to ensure that we catch all users of the current function and convert them to the new one, and then we can drop it, no need to use __deprecated at all.

Okay, works for me. Both grep and the semantic patch can easily find users of the current function.

Thierry

#5 lore raw

PATCH 2/33 ARM: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
---
 arch/arm/mach-omap2/gpmc.c       | 8 +++-----
 arch/arm/mach-tegra/tegra2_emc.c | 8 +++-----
 arch/arm/plat-omap/dmtimer.c     | 8 +++-----
 arch/arm/plat-samsung/adc.c      | 8 +++-----
 4 files changed, 12 insertions(+), 20 deletions(-)
arch/arm/mach-omap2/gpmc.c +3 -5
index 8033cb7..64bac53 100644
@@ -1134,11 +1134,9 @@ static int gpmc_probe(struct platform_device *pdev)
 	phys_base = res->start;
 	mem_size = resource_size(res);
 
-	gpmc_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!gpmc_base) {
-		dev_err(&pdev->dev, "error: request memory / ioremap\n");
-		return -EADDRNOTAVAIL;
-	}
+	gpmc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(gpmc_base))
+		return PTR_ERR(gpmc_base);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res == NULL)
arch/arm/mach-tegra/tegra2_emc.c +3 -5
index e18aa2f..ce7ce42 100644
@@ -312,11 +312,9 @@ static int tegra_emc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	emc_regbase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!emc_regbase) {
-		dev_err(&pdev->dev, "failed to remap registers\n");
-		return -ENOMEM;
-	}
+	emc_regbase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(emc_regbase))
+		return PTR_ERR(emc_regbase);
 
 	pdata = pdev->dev.platform_data;
 
arch/arm/plat-omap/dmtimer.c +3 -5
index 7b433f3..a0daa2f 100644
@@ -808,11 +808,9 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
 		return  -ENOMEM;
 	}
 
-	timer->io_base = devm_request_and_ioremap(dev, mem);
-	if (!timer->io_base) {
-		dev_err(dev, "%s: region already claimed.\n", __func__);
-		return -ENOMEM;
-	}
+	timer->io_base = devm_ioremap_resource(dev, mem);
+	if (IS_ERR(timer->io_base))
+		return PTR_ERR(timer->io_base);
 
 	if (dev->of_node) {
 		if (of_find_property(dev->of_node, "ti,timer-alwon", NULL))
arch/arm/plat-samsung/adc.c +3 -5
index 2d676ab..ca07cb1 100644
@@ -386,11 +386,9 @@ static int s3c_adc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	adc->regs = devm_request_and_ioremap(dev, regs);
-	if (!adc->regs) {
-		dev_err(dev, "failed to map registers\n");
-		return -ENXIO;
-	}
+	adc->regs = devm_ioremap_resource(dev, regs);
+	if (IS_ERR(adc->regs))
+		return PTR_ERR(adc->regs);
 
 	ret = regulator_enable(adc->vdd);
 	if (ret)
Signature · 1 line
1.8.1.1
#6 lore raw

Re: [PATCH 02/33] ARM: Convert to devm_ioremap_resource()

Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Does this include the resource part of the handling too?

#7 lore raw

Re: [PATCH 02/33] ARM: Convert to devm_ioremap_resource()

Quoted 5 lines · Russell King - ARM Linux
Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Does this include the resource part of the handling too?

I'm not sure I understand your question. devm_ioremap_resource() does a devm_request_mem_region() internally if that's what you were asking.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130121/b1ffe047/attachment.sig>

#8 lore raw

Re: [PATCH 02/33] ARM: Convert to devm_ioremap_resource()

Quoted 9 lines · Thierry Reding
Quoted 5 lines · Russell King - ARM Linux
Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Does this include the resource part of the handling too?

I'm not sure I understand your question. devm_ioremap_resource() does a devm_request_mem_region() internally if that's what you were asking.

Ah, that's fine then. The function name is a little misleading, and as it doesn't exist in mainline at present, it is not something I know about.

maintainer
#9 lore raw

Re: [PATCH 02/33] ARM: Convert to devm_ioremap_resource()

Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Thierry Reding
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Does this include the resource part of the handling too?

I'm not sure I understand your question. devm_ioremap_resource() does a devm_request_mem_region() internally if that's what you were asking.

Ah, that's fine then. The function name is a little misleading, and as it doesn't exist in mainline at present, it is not something I know about.

The usual problem with long patch series like this: The introductory mail PATCH 0/xx explains this nicely, but it's not possible to put everyone on Cc because then it gets rejected by vger for overly long mail headers.

We had a discussion about the function name earlier, but could not come up with one that isn't too bulky but still carries the same meaning as devm_request_and_ioremap() with a different symbol.

Arnd

#10 lore raw

Re: [PATCH 02/33] ARM: Convert to devm_ioremap_resource()

In reply to Russell King - ARM Linux
Quoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Thierry Reding
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Does this include the resource part of the handling too?

I'm not sure I understand your question. devm_ioremap_resource() does a devm_request_mem_region() internally if that's what you were asking.

Ah, that's fine then. The function name is a little misleading, and as it doesn't exist in mainline at present, it is not something I know about.

Can I assume this is an Acked-by: from you for this patch so that I can take this through my driver-core tree?

thanks,

greg k-h

#11 lore raw

PATCH 3/33 MIPS: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 arch/mips/lantiq/xway/dma.c  |  5 +++--
 arch/mips/lantiq/xway/gptu.c |  8 +++-----
 arch/mips/pci/pci-lantiq.c   | 12 ++++++------
 3 files changed, 12 insertions(+), 13 deletions(-)
arch/mips/lantiq/xway/dma.c +3 -2
index e44a186..08f7ebd 100644
@@ -21,6 +21,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/clk.h>
+#include <linux/err.h>
 
 #include <lantiq_soc.h>
 #include <xway_dma.h>
@@ -223,8 +224,8 @@ ltq_dma_init(struct platform_device *pdev)
 		panic("Failed to get dma resource");
 
 	/* remap dma register range */
-	ltq_dma_membase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!ltq_dma_membase)
+	ltq_dma_membase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ltq_dma_membase))
 		panic("Failed to remap dma resource");
 
 	/* power up and reset the dma engine */
arch/mips/lantiq/xway/gptu.c +3 -5
index e30b1ed..9861c86 100644
@@ -150,11 +150,9 @@ static int gptu_probe(struct platform_device *pdev)
 	}
 
 	/* remap gptu register range */
-	gptu_membase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!gptu_membase) {
-		dev_err(&pdev->dev, "Failed to remap resource\n");
-		return -ENOMEM;
-	}
+	gptu_membase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(gptu_membase))
+		return PTR_ERR(gptu_membase);
 
 	/* enable our clock */
 	clk = clk_get(&pdev->dev, NULL);
arch/mips/pci/pci-lantiq.c +6 -6
index 9568178..910fb4c 100644
@@ -214,13 +214,13 @@ static int ltq_pci_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ltq_pci_membase = devm_request_and_ioremap(&pdev->dev, res_bridge);
-	ltq_pci_mapped_cfg = devm_request_and_ioremap(&pdev->dev, res_cfg);
+	ltq_pci_membase = devm_ioremap_resource(&pdev->dev, res_bridge);
+	if (IS_ERR(ltq_pci_membase))
+		return PTR_ERR(ltq_pci_membase);
 
-	if (!ltq_pci_membase || !ltq_pci_mapped_cfg) {
-		dev_err(&pdev->dev, "failed to remap resources\n");
-		return -ENOMEM;
-	}
+	ltq_pci_mapped_cfg = devm_ioremap_resource(&pdev->dev, res_cfg);
+	if (IS_ERR(ltq_pci_mapped_cfg))
+		return PTR_ERR(ltq_pci_mapped_cfg);
 
 	ltq_pci_startup(pdev);
 
Signature · 1 line
1.8.1.1
#12 lore raw

PATCH 4/33 amba: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/amba/tegra-ahb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/amba/tegra-ahb.c +4 -3
index 536c166..ab92785 100644
@@ -20,6 +20,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -257,9 +258,9 @@ static int tegra_ahb_probe(struct platform_device *pdev)
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENODEV;
-	ahb->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!ahb->regs)
-		return -EBUSY;
+	ahb->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ahb->regs))
+		return PTR_ERR(ahb->regs);
 
 	ahb->dev = &pdev->dev;
 	platform_set_drvdata(pdev, ahb);
Signature · 1 line
1.8.1.1
#13 lore raw

PATCH 5/33 ata: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

---
 drivers/ata/pata_ep93xx.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/ata/pata_ep93xx.c +4 -3
index 556222f..c1bfaf4 100644
@@ -31,6 +31,7 @@
  *   Copyright (C) 2006 Tower Technologies
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -937,9 +938,9 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
 		goto err_rel_gpio;
 	}
 
-	ide_base = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (!ide_base) {
-		err = -ENXIO;
+	ide_base = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(ide_base)) {
+		err = PTR_ERR(ide_base);
 		goto err_rel_gpio;
 	}
 
Signature · 1 line
1.8.1.1
#14 lore raw

PATCH 6/33 char: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Cc Greg Kroah-Hartman <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 drivers/char/hw_random/exynos-rng.c | 9 +++++----
 drivers/char/hw_random/omap-rng.c   | 6 +++---
 drivers/char/hw_random/tx4939-rng.c | 7 ++++---
 3 files changed, 12 insertions(+), 10 deletions(-)
drivers/char/hw_random/exynos-rng.c +5 -4
index 48bbfec..4673fc4 100644
@@ -104,6 +104,7 @@ static int exynos_read(struct hwrng *rng, void *buf,
 static int exynos_rng_probe(struct platform_device *pdev)
 {
 	struct exynos_rng *exynos_rng;
+	struct resource *res;
 
 	exynos_rng = devm_kzalloc(&pdev->dev, sizeof(struct exynos_rng),
 					GFP_KERNEL);
@@ -120,10 +121,10 @@ static int exynos_rng_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	exynos_rng->mem = devm_request_and_ioremap(&pdev->dev,
-			platform_get_resource(pdev, IORESOURCE_MEM, 0));
-	if (!exynos_rng->mem)
-		return -EBUSY;
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	exynos_rng->mem = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(exynos_rng->mem))
+		return PTR_ERR(exynos_rng->mem);
 
 	platform_set_drvdata(pdev, exynos_rng);
 
drivers/char/hw_random/omap-rng.c +3 -3
index d8c54e2..749dc16 100644
@@ -124,9 +124,9 @@ static int omap_rng_probe(struct platform_device *pdev)
 		goto err_ioremap;
 	}
 
-	priv->base = devm_request_and_ioremap(&pdev->dev, priv->mem_res);
-	if (!priv->base) {
-		ret = -ENOMEM;
+	priv->base = devm_ioremap_resource(&pdev->dev, priv->mem_res);
+	if (IS_ERR(priv->base)) {
+		ret = PTR_ERR(priv->base);
 		goto err_ioremap;
 	}
 	dev_set_drvdata(&pdev->dev, priv);
drivers/char/hw_random/tx4939-rng.c +4 -3
index de473ef..3099198 100644
@@ -7,6 +7,7 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  */
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -115,9 +116,9 @@ static int __init tx4939_rng_probe(struct platform_device *dev)
 	rngdev = devm_kzalloc(&dev->dev, sizeof(*rngdev), GFP_KERNEL);
 	if (!rngdev)
 		return -ENOMEM;
-	rngdev->base = devm_request_and_ioremap(&dev->dev, r);
-	if (!rngdev->base)
-		return -EBUSY;
+	rngdev->base = devm_ioremap_resource(&dev->dev, r);
+	if (IS_ERR(rngdev->base))
+		return PTR_ERR(rngdev->base);
 
 	rngdev->rng.name = dev_name(&dev->dev);
 	rngdev->rng.data_present = tx4939_rng_data_present;
Signature · 1 line
1.8.1.1
#15 lore raw

PATCH 7/33 dma: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/dma/dw_dmac.c         |  7 ++++---
 drivers/dma/imx-dma.c         |  7 ++++---
 drivers/dma/mmp_pdma.c        |  7 ++++---
 drivers/dma/mmp_tdma.c        |  7 ++++---
 drivers/dma/tegra20-apb-dma.c | 10 ++++------
 5 files changed, 20 insertions(+), 18 deletions(-)
drivers/dma/dw_dmac.c +4 -3
index 3e8ba02..b33d1f6 100644
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -1489,9 +1490,9 @@ static int dw_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	regs = devm_request_and_ioremap(&pdev->dev, io);
-	if (!regs)
-		return -EBUSY;
+	regs = devm_ioremap_resource(&pdev->dev, io);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	dw_params = dma_read_byaddr(regs, DW_PARAMS);
 	autocfg = dw_params >> DW_PARAMS_EN & 0x1;
drivers/dma/imx-dma.c +4 -3
index dbf0e6f..84ae491 100644
@@ -14,6 +14,7 @@
  * http://www.opensource.org/licenses/gpl-license.html
  * http://www.gnu.org/copyleft/gpl.html
  */
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/mm.h>
@@ -1011,9 +1012,9 @@ static int __init imxdma_probe(struct platform_device *pdev)
 	imxdma->devtype = pdev->id_entry->driver_data;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	imxdma->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!imxdma->base)
-		return -EADDRNOTAVAIL;
+	imxdma->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(imxdma->base))
+		return PTR_ERR(imxdma->base);
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
drivers/dma/mmp_pdma.c +4 -3
index c6d98c0..dc74665 100644
@@ -5,6 +5,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -782,9 +783,9 @@ static int mmp_pdma_probe(struct platform_device *op)
 	if (!iores)
 		return -EINVAL;
 
-	pdev->base = devm_request_and_ioremap(pdev->dev, iores);
-	if (!pdev->base)
-		return -EADDRNOTAVAIL;
+	pdev->base = devm_ioremap_resource(pdev->dev, iores);
+	if (IS_ERR(pdev->base))
+		return PTR_ERR(pdev->base);
 
 	of_id = of_match_device(mmp_pdma_dt_ids, pdev->dev);
 	if (of_id)
drivers/dma/mmp_tdma.c +4 -3
index a9f1cd5..43d5a6c 100644
@@ -9,6 +9,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -547,9 +548,9 @@ static int mmp_tdma_probe(struct platform_device *pdev)
 	if (!iores)
 		return -EINVAL;
 
-	tdev->base = devm_request_and_ioremap(&pdev->dev, iores);
-	if (!tdev->base)
-		return -EADDRNOTAVAIL;
+	tdev->base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(tdev->base))
+		return PTR_ERR(tdev->base);
 
 	INIT_LIST_HEAD(&tdev->device.channels);
 
drivers/dma/tegra20-apb-dma.c +4 -6
index c39e61b..7d6d8b4 100644
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -1236,12 +1237,9 @@ static int tegra_dma_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	tdma->base_addr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!tdma->base_addr) {
-		dev_err(&pdev->dev,
-			"Cannot request memregion/iomap dma address\n");
-		return -EADDRNOTAVAIL;
-	}
+	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(tdma->base_addr))
+		return PTR_ERR(tdma->base_addr);
 
 	tdma->dma_clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(tdma->dma_clk)) {
Signature · 1 line
1.8.1.1
#16 lore raw

Re: [PATCH 07/33] dma: Convert to devm_ioremap_resource()

Quoted 5 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Where is this symbol, applying this results in build failures for me?

Quoted 142 lines
---
 drivers/dma/dw_dmac.c         |  7 ++++---
 drivers/dma/imx-dma.c         |  7 ++++---
 drivers/dma/mmp_pdma.c        |  7 ++++---
 drivers/dma/mmp_tdma.c        |  7 ++++---
 drivers/dma/tegra20-apb-dma.c | 10 ++++------
 5 files changed, 20 insertions(+), 18 deletions(-)
drivers/dma/dw_dmac.c +4 -3
index 3e8ba02..b33d1f6 100644
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -1489,9 +1490,9 @@ static int dw_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	regs = devm_request_and_ioremap(&pdev->dev, io);
-	if (!regs)
-		return -EBUSY;
+	regs = devm_ioremap_resource(&pdev->dev, io);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	dw_params = dma_read_byaddr(regs, DW_PARAMS);
 	autocfg = dw_params >> DW_PARAMS_EN & 0x1;
drivers/dma/imx-dma.c +4 -3
index dbf0e6f..84ae491 100644
@@ -14,6 +14,7 @@
  * http://www.opensource.org/licenses/gpl-license.html
  * http://www.gnu.org/copyleft/gpl.html
  */
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/mm.h>
@@ -1011,9 +1012,9 @@ static int __init imxdma_probe(struct platform_device *pdev)
 	imxdma->devtype = pdev->id_entry->driver_data;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	imxdma->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!imxdma->base)
-		return -EADDRNOTAVAIL;
+	imxdma->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(imxdma->base))
+		return PTR_ERR(imxdma->base);
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
drivers/dma/mmp_pdma.c +4 -3
index c6d98c0..dc74665 100644
@@ -5,6 +5,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -782,9 +783,9 @@ static int mmp_pdma_probe(struct platform_device *op)
 	if (!iores)
 		return -EINVAL;
 
-	pdev->base = devm_request_and_ioremap(pdev->dev, iores);
-	if (!pdev->base)
-		return -EADDRNOTAVAIL;
+	pdev->base = devm_ioremap_resource(pdev->dev, iores);
+	if (IS_ERR(pdev->base))
+		return PTR_ERR(pdev->base);
 
 	of_id = of_match_device(mmp_pdma_dt_ids, pdev->dev);
 	if (of_id)
drivers/dma/mmp_tdma.c +4 -3
index a9f1cd5..43d5a6c 100644
@@ -9,6 +9,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/types.h>
@@ -547,9 +548,9 @@ static int mmp_tdma_probe(struct platform_device *pdev)
 	if (!iores)
 		return -EINVAL;
 
-	tdev->base = devm_request_and_ioremap(&pdev->dev, iores);
-	if (!tdev->base)
-		return -EADDRNOTAVAIL;
+	tdev->base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(tdev->base))
+		return PTR_ERR(tdev->base);
 
 	INIT_LIST_HEAD(&tdev->device.channels);
 
drivers/dma/tegra20-apb-dma.c +4 -6
index c39e61b..7d6d8b4 100644
@@ -21,6 +21,7 @@
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -1236,12 +1237,9 @@ static int tegra_dma_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	tdma->base_addr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!tdma->base_addr) {
-		dev_err(&pdev->dev,
-			"Cannot request memregion/iomap dma address\n");
-		return -EADDRNOTAVAIL;
-	}
+	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(tdma->base_addr))
+		return PTR_ERR(tdma->base_addr);
 
 	tdma->dma_clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(tdma->dma_clk)) {
Signature · 1 line
1.8.1.1
#17 lore raw

Re: [PATCH 07/33] dma: Convert to devm_ioremap_resource()

Quoted 7 lines · Vinod Koul
Quoted 5 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Where is this symbol, applying this results in build failures for me?

I was introduced in the first patch of this series, which I failed to send to everyone concerned. Greg agreed to take this series through the driver-core tree given the dependency on the first patch. AFAICT he's already applied this patch to the driver-core-next branch.

Thierry

#18 lore raw

Re: [PATCH 07/33] dma: Convert to devm_ioremap_resource()

In reply to Thierry Reding
Quoted 29 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/dma/dw_dmac.c         |  7 ++++---
 drivers/dma/imx-dma.c         |  7 ++++---
 drivers/dma/mmp_pdma.c        |  7 ++++---
 drivers/dma/mmp_tdma.c        |  7 ++++---
 drivers/dma/tegra20-apb-dma.c | 10 ++++------
 5 files changed, 20 insertions(+), 18 deletions(-)
drivers/dma/dw_dmac.c +1 -0
index 3e8ba02..b33d1f6 100644
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>

drivers/dma/dw_dmac.c static int dw_probe(struct platform_device *pdev) · line 1495

Quoted 9 lines
drivers/dma/dw_dmac.c +3 -3
@@ -1489,9 +1490,9 @@ static int dw_probe(struct platform_device *pdev)
        if (irq < 0)
                return irq;
 
-       regs = devm_request_and_ioremap(&pdev->dev, io);
-       if (!regs)
-               return -EBUSY;
+       regs = devm_ioremap_resource(&pdev->dev, io);
+       if (IS_ERR(regs))
+               return PTR_ERR(regs);

Do you concern that change makes sparse crazy?

drivers/dma/dw_dmac.c:1690:20: warning: incorrect type in argument 1 (different address spaces)
drivers/dma/dw_dmac.c:1690:20: expected void const *ptr
drivers/dma/dw_dmac.c:1690:20: got void [noderef] <asn:2>*[assigned] regs
drivers/dma/dw_dmac.c:1691:32: warning: incorrect type in argument 1 (different address spaces)
drivers/dma/dw_dmac.c:1691:32: expected void const *ptr
drivers/dma/dw_dmac.c:1691:32: got void [noderef] <asn:2>*[assigned] regs

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#19 lore raw

Re: [PATCH 07/33] dma: Convert to devm_ioremap_resource()

Quoted 43 lines · Andy Shevchenko
Quoted 29 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/dma/dw_dmac.c         |  7 ++++---
 drivers/dma/imx-dma.c         |  7 ++++---
 drivers/dma/mmp_pdma.c        |  7 ++++---
 drivers/dma/mmp_tdma.c        |  7 ++++---
 drivers/dma/tegra20-apb-dma.c | 10 ++++------
 5 files changed, 20 insertions(+), 18 deletions(-)
drivers/dma/dw_dmac.c +1 -0
index 3e8ba02..b33d1f6 100644
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>

drivers/dma/dw_dmac.c static int dw_probe(struct platform_device *pdev) · line 1495

Quoted 9 lines
drivers/dma/dw_dmac.c +3 -3
@@ -1489,9 +1490,9 @@ static int dw_probe(struct platform_device *pdev)
        if (irq < 0)
                return irq;
 
-       regs = devm_request_and_ioremap(&pdev->dev, io);
-       if (!regs)
-               return -EBUSY;
+       regs = devm_ioremap_resource(&pdev->dev, io);
+       if (IS_ERR(regs))
+               return PTR_ERR(regs);

Do you concern that change makes sparse crazy?

Quoted 8 lines

drivers/dma/dw_dmac.c:1690:20: warning: incorrect type in argument 1 (different address spaces)
drivers/dma/dw_dmac.c:1690:20: expected void const *ptr
drivers/dma/dw_dmac.c:1690:20: got void [noderef] <asn:2>*[assigned] regs
drivers/dma/dw_dmac.c:1691:32: warning: incorrect type in argument 1 (different address spaces)
drivers/dma/dw_dmac.c:1691:32: expected void const *ptr
drivers/dma/dw_dmac.c:1691:32: got void [noderef] <asn:2>*[assigned] regs

Yeah, Thierry has been emailing me about this and it's a false-positive that I don't know how we are going to make sparse handle properly.

greg k-h

#20 lore raw

PATCH 8/33 gpio: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>
---
 drivers/gpio/gpio-mvebu.c       | 16 ++++++++--------
 drivers/gpio/gpio-mxs.c         |  9 ++++++---
 drivers/gpio/gpio-spear-spics.c |  8 +++-----
 drivers/gpio/gpio-stp-xway.c    |  9 ++++-----
 drivers/gpio/gpio-tegra.c       |  9 ++++-----
 5 files changed, 25 insertions(+), 26 deletions(-)
drivers/gpio/gpio-mvebu.c +8 -8
index 7d9bd94..bf6c7c9 100644
@@ -33,6 +33,7 @@
  *   interrupts.
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
 #include <linux/irq.h>
@@ -544,11 +545,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	mvchip->chip.of_node = np;
 
 	spin_lock_init(&mvchip->lock);
-	mvchip->membase = devm_request_and_ioremap(&pdev->dev, res);
-	if (! mvchip->membase) {
-		dev_err(&pdev->dev, "Cannot ioremap\n");
+	mvchip->membase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(mvchip->membase)) {
 		kfree(mvchip->chip.label);
-		return -ENOMEM;
+		return PTR_ERR(mvchip->membase);
 	}
 
 	/* The Armada XP has a second range of registers for the
@@ -561,11 +561,11 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 			return -ENODEV;
 		}
 
-		mvchip->percpu_membase = devm_request_and_ioremap(&pdev->dev, res);
-		if (! mvchip->percpu_membase) {
-			dev_err(&pdev->dev, "Cannot ioremap\n");
+		mvchip->percpu_membase = devm_ioremap_resource(&pdev->dev,
+							       res);
+		if (IS_ERR(mvchip->percpu_membase)) {
 			kfree(mvchip->chip.label);
-			return -ENOMEM;
+			return PTR_ERR(mvchip->percpu_membase);
 		}
 	}
 
drivers/gpio/gpio-mxs.c +6 -3
index fa2a63c..45d97c4 100644
@@ -20,6 +20,7 @@
  * MA  02110-1301, USA.
  */
 
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -253,12 +254,14 @@ static int mxs_gpio_probe(struct platform_device *pdev)
 			parent = of_get_parent(np);
 			base = of_iomap(parent, 0);
 			of_node_put(parent);
+			if (!base)
+				return -EADDRNOTAVAIL;
 		} else {
 			iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-			base = devm_request_and_ioremap(&pdev->dev, iores);
+			base = devm_ioremap_resource(&pdev->dev, iores);
+			if (IS_ERR(base))
+				return PTR_ERR(base);
 		}
-		if (!base)
-			return -EADDRNOTAVAIL;
 	}
 	port->base = base;
 
drivers/gpio/gpio-spear-spics.c +3 -5
index 5f45fc4..7a4bf7c 100644
@@ -140,11 +140,9 @@ static int spics_gpio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	spics->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!spics->base) {
-		dev_err(&pdev->dev, "request and ioremap fail\n");
-		return -ENOMEM;
-	}
+	spics->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(spics->base))
+		return PTR_ERR(spics->base);
 
 	if (of_property_read_u32(np, "st-spics,peripcfg-reg",
 				&spics->perip_cfg))
drivers/gpio/gpio-stp-xway.c +4 -5
index 85841ee7..c20e051 100644
@@ -214,11 +214,10 @@ static int xway_stp_probe(struct platform_device *pdev)
 	if (!chip)
 		return -ENOMEM;
 
-	chip->virt = devm_request_and_ioremap(&pdev->dev, res);
-	if (!chip->virt) {
-		dev_err(&pdev->dev, "failed to remap STP memory\n");
-		return -ENOMEM;
-	}
+	chip->virt = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(chip->virt))
+		return PTR_ERR(chip->virt);
+	
 	chip->gc.dev = &pdev->dev;
 	chip->gc.label = "stp-xway";
 	chip->gc.direction_output = xway_stp_dir_out;
drivers/gpio/gpio-tegra.c +4 -5
index 63cb643..414ad91 100644
@@ -17,6 +17,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
@@ -450,11 +451,9 @@ static int tegra_gpio_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!regs) {
-		dev_err(&pdev->dev, "Couldn't ioremap regs\n");
-		return -ENODEV;
-	}
+	regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	for (i = 0; i < tegra_gpio_bank_count; i++) {
 		for (j = 0; j < 4; j++) {
Signature · 1 line
1.8.1.1
Acked-by on v1 8/33
#21 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

drivers/gpio/gpio-spear-spics.c static int spics_gpio_probe(struct platform_device *pdev) · line 145

Quoted 11 lines · Thierry Reding
drivers/gpio/gpio-spear-spics.c +0 -3
index 5f45fc4..7a4bf7c 100644
@@ -140,11 +140,9 @@ static int spics_gpio_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       spics->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!spics->base) {
-               dev_err(&pdev->dev, "request and ioremap fail\n");

can we keep it as is?

drivers/gpio/gpio-spear-spics.c static int spics_gpio_probe(struct platform_device *pdev) · line 146

Quoted 6 lines
drivers/gpio/gpio-spear-spics.c +3 -2
-               return -ENOMEM;
-       }
+       spics->base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(spics->base))
+               return PTR_ERR(spics->base);
 
#22 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 10 lines · Viresh Kumar
Quoted 8 lines · Thierry Reding
drivers/gpio/gpio-spear-spics.c +0 -0
index 5f45fc4..7a4bf7c 100644
@@ -140,11 +140,9 @@ static int spics_gpio_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
Quoted 5 lines

drivers/gpio/gpio-spear-spics.c static int spics_gpio_probe(struct platform_device *pdev) · line 145

Quoted 3 lines
drivers/gpio/gpio-spear-spics.c +0 -3
-       spics->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!spics->base) {
-               dev_err(&pdev->dev, "request and ioremap fail\n");

can we keep it as is?

And this is why I dislike the ERR_PTR pattern so much. It goes against every instinct about what is and is not a valid pointer.

I know people want error codes, but I think hoping that all users will remember to do 'if (IS_ERR(ptr))' instead of 'if (!ptr)' makes things worse not better.

g.

#23 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 6 lines · Grant Likely
Quoted 4 lines · Viresh Kumar
Quoted 3 lines
drivers/gpio/gpio-spear-spics.c +0 -3
-       spics->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!spics->base) {
-               dev_err(&pdev->dev, "request and ioremap fail\n");
Quoted 8 lines
Quoted 1 line

can we keep it as is?

And this is why I dislike the ERR_PTR pattern so much. It goes against every instinct about what is and is not a valid pointer.

I know people want error codes, but I think hoping that all users will remember to do 'if (IS_ERR(ptr))' instead of 'if (!ptr)' makes things worse not better.

NB: among the error codes people want to propagate from consumer interfaces such as say, clk_get(), regulator_get() and pinctrl_get() is -EPROBE_DEFER. So just "something failed" (return NULL) isn't enough.

We then obviously need to return an int as error code instead and pass the pointer as argument, so do you mean we should refactor all the *_get() things from e.g.:

struct clk *clk_get(struct device *dev, const char *id);

into something like:

int clk_get(struct clk **clk, struct device *dev, const char *id);

across the entire kernel?

Yours,
Linus Walleij

#24 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 9 lines · Linus Walleij

NB: among the error codes people want to propagate from consumer interfaces such as say, clk_get(), regulator_get() and pinctrl_get() is -EPROBE_DEFER. So just "something failed" (return NULL) isn't enough.

We then obviously need to return an int as error code instead and pass the pointer as argument, so do you mean we should refactor all the *_get() things from e.g.:

Quoted 7 lines

struct clk *clk_get(struct device *dev, const char *id);

into something like:

int clk_get(struct clk **clk, struct device *dev, const char *id);

across the entire kernel?

I really don't want to do that. What we have today I think is far better than having to munge things like that - you just get a different set of problems through doing that, such as what happens if people ignore the returned error code, etc.

We _should_ really be able to get Sparse to deal with this. Sparse really should be taught about a pointer attribute that says "this is fine to dereference, but it should also have the magic IS_ERR() check done on it too." As IS_ERR() is a function, we can surely mark the passed pointer in some way to tell sparse "this has been appropraitely checked".

Practically, we don't end up with that many problems though with people failing to check the returned pointer (I've seen relatively few of these in the bigger scheme of things). What I have seen through is repeated confusion between IS_ERR() and IS_ERR_OR_NULL() since the second one was introduced - which then leads people into coding their error paths such that they return zero should NULL be returned.

I've said before - almost every usage of IS_ERR_OR_NULL() appears to be a bug... and I've been mooting its removal. I have acks against a patch which deprecates it - but we can't deprecate it until we've removed most of the existing users of it (otherwise akpm will hunt down those who added the deprecated marker.)

#25 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

In reply to Thierry Reding
Quoted 9 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

Yours,
Linus Walleij

#26 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 9 lines · Linus Walleij
Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 6 lines
Quoted 3 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

It is part of this series, so your Acked-by would be great. Other maintainers have done the same. Initially I had thought that it might be easier if the patches went in through individual trees, but since the first patch is a dependency, maybe it'd be better to take them all through a single tree.

Greg, any comments? Would you be willing to take the series through your driver-core tree once all Acked-bys are there? Alternatively I guess we could take the first patch into linux-next, at which point maintainers could take this through the individual trees.

Thierry

#27 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 23 lines · Thierry Reding
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 6 lines
Quoted 3 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

It is part of this series, so your Acked-by would be great. Other maintainers have done the same. Initially I had thought that it might be easier if the patches went in through individual trees, but since the first patch is a dependency, maybe it'd be better to take them all through a single tree.

Quoted 4 lines

Greg, any comments? Would you be willing to take the series through your driver-core tree once all Acked-bys are there? Alternatively I guess we could take the first patch into linux-next, at which point maintainers could take this through the individual trees.

Yes, I'll take the first patch through my driver-core tree, and add all of the patches that the subsystem maintainers have acked as well.

As subsystem trees can't depend on linux-next, it makes it easier that way.

thanks,

greg k-h

#28 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 29 lines · Greg Kroah-Hartman
Quoted 23 lines · Thierry Reding
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 6 lines
Quoted 3 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

It is part of this series, so your Acked-by would be great. Other maintainers have done the same. Initially I had thought that it might be easier if the patches went in through individual trees, but since the first patch is a dependency, maybe it'd be better to take them all through a single tree.

Quoted 4 lines

Greg, any comments? Would you be willing to take the series through your driver-core tree once all Acked-bys are there? Alternatively I guess we could take the first patch into linux-next, at which point maintainers could take this through the individual trees.

Quoted 5 lines

Yes, I'll take the first patch through my driver-core tree, and add all of the patches that the subsystem maintainers have acked as well.

As subsystem trees can't depend on linux-next, it makes it easier that way.

Most excellent. Thanks!

Thierry

Acked-by
#29 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

In reply to Thierry Reding
Quoted 10 lines · Thierry Reding
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

It is part of this series, so your Acked-by would be great.

Fair enough,

Yours,
Linus Walleij

Tested-by Acked-by
#30 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

In reply to Linus Walleij
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 6 lines
Quoted 3 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

I don't know if I was really the one you were looking for (either you wanted to send it to an other Greg(ory) or to Thomas Petazzoni who wrote the gpio-mvebu.c driver). However, that's fortunate because Thomas is currently in on vacations, so I apply this patch and the first of the series, I built, compiled and tested it on an Aramda XP DB board. Everything is OK for me.

So for sure you can have my

and as the code looks good, so for what it's worth, you can even get my

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#31 lore raw

Re: [PATCH 08/33] gpio: Convert to devm_ioremap_resource()

Quoted 24 lines · Gregory CLEMENT
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 6 lines
Quoted 3 lines
Cc Grant Likely <[email protected]>
Cc Linus Walleij <[email protected]>

Is the interface already in-kernel so I should apply this or is it added as part of this series so you're searching an ACK?

I don't know if I was really the one you were looking for (either you wanted to send it to an other Greg(ory) or to Thomas Petazzoni who wrote the gpio-mvebu.c driver). However, that's fortunate because Thomas is currently in on vacations, so I apply this patch and the first of the series, I built, compiled and tested it on an Aramda XP DB board. Everything is OK for me.

Quoted 5 lines

So for sure you can have my

and as the code looks good, so for what it's worth, you can even get my

Great! Thanks for testing!

Thierry

#32 lore raw

PATCH 9/33 drm: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/gpu/drm/exynos/exynos_drm_fimc.c    | 8 +++-----
 drivers/gpu/drm/exynos/exynos_drm_fimd.c    | 8 +++-----
 drivers/gpu/drm/exynos/exynos_drm_g2d.c     | 7 +++----
 drivers/gpu/drm/exynos/exynos_drm_gsc.c     | 8 +++-----
 drivers/gpu/drm/exynos/exynos_drm_rotator.c | 8 +++-----
 drivers/gpu/drm/exynos/exynos_hdmi.c        | 8 +++-----
 drivers/gpu/drm/tegra/dc.c                  | 8 +++-----
 drivers/gpu/drm/tegra/hdmi.c                | 6 +++---
 drivers/gpu/drm/tegra/host1x.c              | 6 +++---
 9 files changed, 27 insertions(+), 40 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_fimc.c +3 -5
index 67a83e6..411f69b7 100644
@@ -1785,11 +1785,9 @@ static int fimc_probe(struct platform_device *pdev)
 
 	/* resource memory */
 	ctx->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ctx->regs = devm_request_and_ioremap(dev, ctx->regs_res);
-	if (!ctx->regs) {
-		dev_err(dev, "failed to map registers.\n");
-		return -ENXIO;
-	}
+	ctx->regs = devm_ioremap_resource(dev, ctx->regs_res);
+	if (IS_ERR(ctx->regs))
+		return PTR_ERR(ctx->regs);
 
 	/* resource irq */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
drivers/gpu/drm/exynos/exynos_drm_fimd.c +3 -5
index 9537761..36493ce 100644
@@ -913,11 +913,9 @@ static int fimd_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	ctx->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!ctx->regs) {
-		dev_err(dev, "failed to map registers\n");
-		return -ENXIO;
-	}
+	ctx->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ctx->regs))
+		return PTR_ERR(ctx->regs);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
drivers/gpu/drm/exynos/exynos_drm_g2d.c +3 -4
index 36c3905..7329abd 100644
@@ -1136,10 +1136,9 @@ static int g2d_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	g2d->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!g2d->regs) {
-		dev_err(dev, "failed to remap I/O memory\n");
-		ret = -ENXIO;
+	g2d->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(g2d->regs)) {
+		ret = PTR_ERR(g2d->regs);
 		goto err_put_clk;
 	}
 
drivers/gpu/drm/exynos/exynos_drm_gsc.c +3 -5
index 8140753..7841c3b 100644
@@ -1692,11 +1692,9 @@ static int gsc_probe(struct platform_device *pdev)
 
 	/* resource memory */
 	ctx->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ctx->regs = devm_request_and_ioremap(dev, ctx->regs_res);
-	if (!ctx->regs) {
-		dev_err(dev, "failed to map registers.\n");
-		return -ENXIO;
-	}
+	ctx->regs = devm_ioremap_resource(dev, ctx->regs_res);
+	if (IS_ERR(ctx->regs))
+		return PTR_ERR(ctx->regs);
 
 	/* resource irq */
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
drivers/gpu/drm/exynos/exynos_drm_rotator.c +3 -5
index e9e83ef..a6da774 100644
@@ -656,11 +656,9 @@ static int rotator_probe(struct platform_device *pdev)
 				platform_get_device_id(pdev)->driver_data;
 
 	rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	rot->regs = devm_request_and_ioremap(dev, rot->regs_res);
-	if (!rot->regs) {
-		dev_err(dev, "failed to map register\n");
-		return -ENXIO;
-	}
+	rot->regs = devm_ioremap_resource(dev, rot->regs_res);
+	if (IS_ERR(rot->regs))
+		return PTR_ERR(rot->regs);
 
 	rot->irq = platform_get_irq(pdev, 0);
 	if (rot->irq < 0) {
drivers/gpu/drm/exynos/exynos_hdmi.c +3 -5
index 41ff79d..d4c3f3d 100644
@@ -2526,11 +2526,9 @@ static int hdmi_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	hdata->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hdata->regs) {
-		DRM_ERROR("failed to map registers\n");
-		return -ENXIO;
-	}
+	hdata->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hdata->regs))
+		return PTR_ERR(hdata->regs);
 
 	ret = devm_gpio_request(&pdev->dev, hdata->hpd_gpio, "HPD");
 	if (ret) {
drivers/gpu/drm/tegra/dc.c +3 -5
index 656b2e3..d365c6d 100644
@@ -764,11 +764,9 @@ static int tegra_dc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	dc->regs = devm_request_and_ioremap(&pdev->dev, regs);
-	if (!dc->regs) {
-		dev_err(&pdev->dev, "failed to remap registers\n");
-		return -ENXIO;
-	}
+	dc->regs = devm_ioremap_resource(&pdev->dev, regs);
+	if (IS_ERR(dc->regs))
+		return PTR_ERR(dc->regs);
 
 	dc->irq = platform_get_irq(pdev, 0);
 	if (dc->irq < 0) {
drivers/gpu/drm/tegra/hdmi.c +3 -3
index e060c7e..266af78 100644
@@ -1259,9 +1259,9 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
 	if (!regs)
 		return -ENXIO;
 
-	hdmi->regs = devm_request_and_ioremap(&pdev->dev, regs);
-	if (!hdmi->regs)
-		return -EADDRNOTAVAIL;
+	hdmi->regs = devm_ioremap_resource(&pdev->dev, regs);
+	if (IS_ERR(hdmi->regs))
+		return PTR_ERR(hdmi->regs);
 
 	err = platform_get_irq(pdev, 0);
 	if (err < 0)
drivers/gpu/drm/tegra/host1x.c +3 -3
index 5d17b11..92e25a7 100644
@@ -139,9 +139,9 @@ static int tegra_host1x_probe(struct platform_device *pdev)
 
 	host1x->irq = err;
 
-	host1x->regs = devm_request_and_ioremap(&pdev->dev, regs);
-	if (!host1x->regs) {
-		err = -EADDRNOTAVAIL;
+	host1x->regs = devm_ioremap_resource(&pdev->dev, regs);
+	if (IS_ERR(host1x->regs)) {
+		err = PTR_ERR(host1x->regs);
 		goto err;
 	}
 
Signature · 1 line
1.8.1.1
#33 lore raw

PATCH 10/33 i2c: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/i2c/busses/i2c-at91.c    | 6 +++---
 drivers/i2c/busses/i2c-imx.c     | 6 +++---
 drivers/i2c/busses/i2c-ocores.c  | 7 ++++---
 drivers/i2c/busses/i2c-omap.c    | 8 +++-----
 drivers/i2c/busses/i2c-rcar.c    | 8 +++-----
 drivers/i2c/busses/i2c-s3c2410.c | 7 +++----
 drivers/i2c/busses/i2c-sirf.c    | 7 +++----
 drivers/i2c/busses/i2c-stu300.c  | 6 +++---
 drivers/i2c/busses/i2c-tegra.c   | 8 +++-----
 drivers/i2c/busses/i2c-xlr.c     | 9 ++++-----
 10 files changed, 32 insertions(+), 40 deletions(-)
drivers/i2c/busses/i2c-at91.c +3 -3
index 2bfc04d..ebc2241 100644
@@ -723,9 +723,9 @@ static int at91_twi_probe(struct platform_device *pdev)
 	if (!dev->pdata)
 		return -ENODEV;
 
-	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!dev->base)
-		return -EBUSY;
+	dev->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(dev->base))
+		return PTR_ERR(dev->base);
 
 	dev->irq = platform_get_irq(pdev, 0);
 	if (dev->irq < 0)
drivers/i2c/busses/i2c-imx.c +3 -3
index b973474..a71ece6 100644
@@ -511,9 +511,9 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!base)
-		return -EBUSY;
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	i2c_imx = devm_kzalloc(&pdev->dev, sizeof(struct imx_i2c_struct),
 				GFP_KERNEL);
drivers/i2c/busses/i2c-ocores.c +4 -3
index a873d0a..a337d08 100644
@@ -12,6 +12,7 @@
  * kind, whether express or implied.
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -364,9 +365,9 @@ static int ocores_i2c_probe(struct platform_device *pdev)
 	if (!i2c)
 		return -ENOMEM;
 
-	i2c->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!i2c->base)
-		return -EADDRNOTAVAIL;
+	i2c->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(i2c->base))
+		return PTR_ERR(i2c->base);
 
 	pdata = pdev->dev.platform_data;
 	if (pdata) {
drivers/i2c/busses/i2c-omap.c +3 -5
index 20d41bf..a9bf4ca 100644
@@ -1103,11 +1103,9 @@ omap_i2c_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	dev->base = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!dev->base) {
-		dev_err(&pdev->dev, "I2C region already claimed\n");
-		return -ENOMEM;
-	}
+	dev->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(dev->base))
+		return PTR_ERR(dev->base);
 
 	match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev);
 	if (match) {
drivers/i2c/busses/i2c-rcar.c +3 -5
index 9bd4d73..4ba4a95 100644
@@ -642,11 +642,9 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
-	priv->io = devm_request_and_ioremap(dev, res);
-	if (!priv->io) {
-		dev_err(dev, "cannot ioremap\n");
-		return -ENODEV;
-	}
+	priv->io = devm_ioremap_resource(dev, res);
+	if (IS_ERR(priv->io))
+		return PTR_ERR(priv->io);
 
 	priv->irq = platform_get_irq(pdev, 0);
 	init_waitqueue_head(&priv->wait);
drivers/i2c/busses/i2c-s3c2410.c +3 -4
index a290d08..c807a6d 100644
@@ -1042,11 +1042,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	i2c->regs = devm_request_and_ioremap(&pdev->dev, res);
+	i2c->regs = devm_ioremap_resource(&pdev->dev, res);
 
-	if (i2c->regs == NULL) {
-		dev_err(&pdev->dev, "cannot map IO\n");
-		ret = -ENXIO;
+	if (IS_ERR(i2c->regs)) {
+		ret = PTR_ERR(i2c->regs);
 		goto err_clk;
 	}
 
drivers/i2c/busses/i2c-sirf.c +3 -4
index 3f1818b..183cf05 100644
@@ -308,10 +308,9 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	siic->base = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (siic->base == NULL) {
-		dev_err(&pdev->dev, "IO remap failed!\n");
-		err = -ENOMEM;
+	siic->base = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(siic->base)) {
+		err = PTR_ERR(siic->base);
 		goto out;
 	}
 
drivers/i2c/busses/i2c-stu300.c +3 -3
index 580a0c0..60195b5 100644
@@ -888,11 +888,11 @@ stu300_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENOENT;
 
-	dev->virtbase = devm_request_and_ioremap(&pdev->dev, res);
+	dev->virtbase = devm_ioremap_resource(&pdev->dev, res);
 	dev_dbg(&pdev->dev, "initialize bus device I2C%d on virtual "
 		"base %p\n", bus_nr, dev->virtbase);
-	if (!dev->virtbase)
-		return -ENOMEM;
+	if (IS_ERR(dev->virtbase))
+		return PTR_ERR(dev->virtbase);
 
 	dev->irq = platform_get_irq(pdev, 0);
 	ret = devm_request_irq(&pdev->dev, dev->irq, stu300_irh, 0, NAME, dev);
drivers/i2c/busses/i2c-tegra.c +3 -5
index 7b38877..1fb3009 100644
@@ -669,11 +669,9 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!base) {
-		dev_err(&pdev->dev, "Cannot request/ioremap I2C registers\n");
-		return -EADDRNOTAVAIL;
-	}
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
drivers/i2c/busses/i2c-xlr.c +4 -5
index a005265..93f029e 100644
@@ -7,6 +7,7 @@
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -225,11 +226,9 @@ static int xlr_i2c_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	priv->iobase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->iobase) {
-		dev_err(&pdev->dev, "devm_request_and_ioremap failed\n");
-		return -EBUSY;
-	}
+	priv->iobase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->iobase))
+		return PTR_ERR(priv->iobase);
 
 	priv->adap.dev.parent = &pdev->dev;
 	priv->adap.owner	= THIS_MODULE;
Signature · 1 line
1.8.1.1
Acked-by on v1 10/33
#34 lore raw

Re: [PATCH 10/33] i2c: Convert to devm_ioremap_resource()

Quoted 10 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

I still have the concerns I mentioned in the previous discussion but the series seems to have enough momentum that we could also just try it.

So, for I2C:

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#35 lore raw

PATCH 11/33 iio: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

---
 drivers/iio/adc/at91_adc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/adc/at91_adc.c +3 -3
index a526c0e..83c836b 100644
@@ -557,9 +557,9 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	st->reg_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!st->reg_base) {
-		ret = -ENOMEM;
+	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(st->reg_base)) {
+		ret = PTR_ERR(st->reg_base);
 		goto error_free_device;
 	}
 
Signature · 1 line
1.8.1.1
maintainer Acked-by on v1 11/33
#36 lore raw

Re: [PATCH 11/33] iio: Convert to devm_ioremap_resource()

Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Looks fine to me.

Quoted 22 lines
---
 drivers/iio/adc/at91_adc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/adc/at91_adc.c +3 -3
index a526c0e..83c836b 100644
@@ -557,9 +557,9 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	st->reg_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!st->reg_base) {
-		ret = -ENOMEM;
+	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(st->reg_base)) {
+		ret = PTR_ERR(st->reg_base);
 		goto error_free_device;
 	}
 
#37 lore raw

PATCH 12/33 Input: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/input/keyboard/spear-keyboard.c | 8 +++-----
 drivers/input/serio/arc_ps2.c           | 7 ++++---
 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/input/keyboard/spear-keyboard.c +3 -5
index 695d237..cb1e8f6 100644
@@ -228,11 +228,9 @@ static int spear_kbd_probe(struct platform_device *pdev)
 		kbd->suspended_rate = pdata->suspended_rate;
 	}
 
-	kbd->io_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!kbd->io_base) {
-		dev_err(&pdev->dev, "request-ioremap failed for kbd_region\n");
-		return -ENOMEM;
-	}
+	kbd->io_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(kbd->io_base))
+		return PTR_ERR(kbd->io_base);
 
 	kbd->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(kbd->clk))
drivers/input/serio/arc_ps2.c +4 -3
index b571eb3..c52e3e5 100644
@@ -8,6 +8,7 @@
  * Driver is originally developed by Pavel Sokolov <[email protected]>
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
@@ -206,9 +207,9 @@ static int arc_ps2_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	arc_ps2->addr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!arc_ps2->addr)
-		return -EBUSY;
+	arc_ps2->addr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(arc_ps2->addr))
+		return PTR_ERR(arc_ps2->addr);
 
 	dev_info(&pdev->dev, "irq = %d, address = 0x%p, ports = %i\n",
 		 irq, arc_ps2->addr, ARC_PS2_PORTS);
Signature · 1 line
1.8.1.1
maintainer Acked-by on v1 12/33
#38 lore raw

Re: [PATCH 12/33] Input: Convert to devm_ioremap_resource()

Quoted 8 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 53 lines
---
 drivers/input/keyboard/spear-keyboard.c | 8 +++-----
 drivers/input/serio/arc_ps2.c           | 7 ++++---
 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/input/keyboard/spear-keyboard.c +3 -5
index 695d237..cb1e8f6 100644
@@ -228,11 +228,9 @@ static int spear_kbd_probe(struct platform_device *pdev)
 		kbd->suspended_rate = pdata->suspended_rate;
 	}
 
-	kbd->io_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!kbd->io_base) {
-		dev_err(&pdev->dev, "request-ioremap failed for kbd_region\n");
-		return -ENOMEM;
-	}
+	kbd->io_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(kbd->io_base))
+		return PTR_ERR(kbd->io_base);
 
 	kbd->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(kbd->clk))
drivers/input/serio/arc_ps2.c +4 -3
index b571eb3..c52e3e5 100644
@@ -8,6 +8,7 @@
  * Driver is originally developed by Pavel Sokolov <[email protected]>
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/input.h>
@@ -206,9 +207,9 @@ static int arc_ps2_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	arc_ps2->addr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!arc_ps2->addr)
-		return -EBUSY;
+	arc_ps2->addr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(arc_ps2->addr))
+		return PTR_ERR(arc_ps2->addr);
 
 	dev_info(&pdev->dev, "irq = %d, address = 0x%p, ports = %i\n",
 		 irq, arc_ps2->addr, ARC_PS2_PORTS);
Signature · 1 line
1.8.1.1
Signature · 1 line
Dmitry
Acked-by on v1 12/33
#39 lore raw

Re: [PATCH 12/33] Input: Convert to devm_ioremap_resource()

In reply to Thierry Reding

drivers/input/keyboard/spear-keyboard.c static int spear_kbd_probe(struct platform_device *pdev) · line 233

Quoted 8 lines · Thierry Reding
drivers/input/keyboard/spear-keyboard.c +0 -3
@@ -228,11 +228,9 @@ static int spear_kbd_probe(struct platform_device *pdev)
                kbd->suspended_rate = pdata->suspended_rate;
        }
 
-       kbd->io_base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!kbd->io_base) {
-               dev_err(&pdev->dev, "request-ioremap failed for kbd_region\n");

I would like to keep this error message as is.

drivers/input/keyboard/spear-keyboard.c static int spear_kbd_probe(struct platform_device *pdev) · line 233

Quoted 5 lines
drivers/input/keyboard/spear-keyboard.c +3 -2
-               return -ENOMEM;
-       }
+       kbd->io_base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(kbd->io_base))
+               return PTR_ERR(kbd->io_base);

apart from that, for SPEAr

#40 lore raw

Re: [PATCH 12/33] Input: Convert to devm_ioremap_resource()

Quoted 7 lines · Viresh Kumar
Quoted 5 lines · Thierry Reding
drivers/input/keyboard/spear-keyboard.c +0 -0
@@ -228,11 +228,9 @@ static int spear_kbd_probe(struct platform_device *pdev)
                kbd->suspended_rate = pdata->suspended_rate;
        }
 
Quoted 5 lines

drivers/input/keyboard/spear-keyboard.c static int spear_kbd_probe(struct platform_device *pdev) · line 233

Quoted 3 lines
drivers/input/keyboard/spear-keyboard.c +0 -3
-       kbd->io_base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!kbd->io_base) {
-               dev_err(&pdev->dev, "request-ioremap failed for kbd_region\n");

I would like to keep this error message as is.

Can you specify why? devm_request_and_ioremap() and the new devm_ioremap_resource() both already output an error message if they can't request or ioremap the memory region, so all this does is output a duplicate error message.

Thierry

#41 lore raw

Re: [PATCH 12/33] Input: Convert to devm_ioremap_resource()

Quoted 4 lines · Thierry Reding

Can you specify why? devm_request_and_ioremap() and the new devm_ioremap_resource() both already output an error message if they can't request or ioremap the memory region, so all this does is output a duplicate error message.

because i missed implementations of these routines.. Ignore this comment wherever i gave it :)

#42 lore raw

Re: [PATCH 12/33] Input: Convert to devm_ioremap_resource()

Quoted 9 lines · Viresh Kumar
Quoted 4 lines · Thierry Reding

Can you specify why? devm_request_and_ioremap() and the new devm_ioremap_resource() both already output an error message if they can't request or ioremap the memory region, so all this does is output a duplicate error message.

because i missed implementations of these routines.. Ignore this comment wherever i gave it :)

Done. =)

#43 lore raw

PATCH 13/33 iommu: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Joerg Roedel <[email protected]>
Cc iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
---
 drivers/iommu/tegra-smmu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/iommu/tegra-smmu.c +4 -3
index fc17889..f08dbcd 100644
@@ -19,6 +19,7 @@
 
 #define pr_fmt(fmt)	"%s(): " fmt, __func__
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
@@ -1176,9 +1177,9 @@ static int tegra_smmu_probe(struct platform_device *pdev)
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
 		if (!res)
 			return -ENODEV;
-		smmu->regs[i] = devm_request_and_ioremap(&pdev->dev, res);
-		if (!smmu->regs[i])
-			return -EBUSY;
+		smmu->regs[i] = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(smmu->regs[i]))
+			return PTR_ERR(smmu->regs[i]);
 	}
 
 	err = of_get_dma_window(dev->of_node, NULL, 0, NULL, &base, &size);
Signature · 1 line
1.8.1.1
#44 lore raw

PATCH 14/33 media: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/media/platform/exynos-gsc/gsc-core.c   |  8 +++-----
 drivers/media/platform/mx2_emmaprp.c           |  6 +++---
 drivers/media/platform/s3c-camif/camif-core.c  |  8 +++-----
 drivers/media/platform/s5p-fimc/fimc-core.c    |  8 +++-----
 drivers/media/platform/s5p-fimc/fimc-lite.c    |  8 +++-----
 drivers/media/platform/s5p-fimc/mipi-csis.c    |  8 +++-----
 drivers/media/platform/s5p-g2d/g2d.c           |  8 +++-----
 drivers/media/platform/s5p-jpeg/jpeg-core.c    |  8 +++-----
 drivers/media/platform/s5p-mfc/s5p_mfc.c       |  8 +++-----
 drivers/media/platform/soc_camera/mx2_camera.c | 12 ++++++------
 10 files changed, 33 insertions(+), 49 deletions(-)
drivers/media/platform/exynos-gsc/gsc-core.c +3 -5
index 2b1b9f3..c1a0713 100644
@@ -1098,11 +1098,9 @@ static int gsc_probe(struct platform_device *pdev)
 	mutex_init(&gsc->lock);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	gsc->regs = devm_request_and_ioremap(dev, res);
-	if (!gsc->regs) {
-		dev_err(dev, "failed to map registers\n");
-		return -ENOENT;
-	}
+	gsc->regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(gsc->regs))
+		return PTR_ERR(gsc->regs);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
drivers/media/platform/mx2_emmaprp.c +3 -3
index 6b155d7..4b9e0a2 100644
@@ -941,9 +941,9 @@ static int emmaprp_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pcdev);
 
-	pcdev->base_emma = devm_request_and_ioremap(&pdev->dev, res_emma);
-	if (!pcdev->base_emma) {
-		ret = -ENXIO;
+	pcdev->base_emma = devm_ioremap_resource(&pdev->dev, res_emma);
+	if (IS_ERR(pcdev->base_emma)) {
+		ret = PTR_ERR(pcdev->base_emma);
 		goto rel_vdev;
 	}
 
drivers/media/platform/s3c-camif/camif-core.c +3 -5
index e2716c3..09a8c9c 100644
@@ -433,11 +433,9 @@ static int s3c_camif_probe(struct platform_device *pdev)
 
 	mres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	camif->io_base = devm_request_and_ioremap(dev, mres);
-	if (!camif->io_base) {
-		dev_err(dev, "failed to obtain I/O memory\n");
-		return -ENOENT;
-	}
+	camif->io_base = devm_ioremap_resource(dev, mres);
+	if (IS_ERR(camif->io_base))
+		return PTR_ERR(camif->io_base);
 
 	ret = camif_request_irqs(pdev, camif);
 	if (ret < 0)
drivers/media/platform/s5p-fimc/fimc-core.c +3 -5
index 545b46a..acc0f84 100644
@@ -909,11 +909,9 @@ static int fimc_probe(struct platform_device *pdev)
 	mutex_init(&fimc->lock);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	fimc->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (fimc->regs == NULL) {
-		dev_err(&pdev->dev, "Failed to obtain io memory\n");
-		return -ENOENT;
-	}
+	fimc->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(fimc->regs))
+		return PTR_ERR(fimc->regs);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res == NULL) {
drivers/media/platform/s5p-fimc/fimc-lite.c +3 -5
index ed67220..67db9f8 100644
@@ -1426,11 +1426,9 @@ static int fimc_lite_probe(struct platform_device *pdev)
 	mutex_init(&fimc->lock);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	fimc->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (fimc->regs == NULL) {
-		dev_err(&pdev->dev, "Failed to obtain io memory\n");
-		return -ENOENT;
-	}
+	fimc->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(fimc->regs))
+		return PTR_ERR(fimc->regs);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res == NULL) {
drivers/media/platform/s5p-fimc/mipi-csis.c +3 -5
index ec3fa7d..7abae01 100644
@@ -686,11 +686,9 @@ static int s5pcsis_probe(struct platform_device *pdev)
 	}
 
 	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	state->regs = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (state->regs == NULL) {
-		dev_err(&pdev->dev, "Failed to request and remap io memory\n");
-		return -ENXIO;
-	}
+	state->regs = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(state->regs))
+		return PTR_ERR(state->regs);
 
 	state->irq = platform_get_irq(pdev, 0);
 	if (state->irq < 0) {
drivers/media/platform/s5p-g2d/g2d.c +3 -5
index 1bfbc32..6ed259f 100644
@@ -708,11 +708,9 @@ static int g2d_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	dev->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (dev->regs == NULL) {
-			dev_err(&pdev->dev, "Failed to obtain io memory\n");
-			return -ENOENT;
-	}
+	dev->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(dev->regs))
+		return PTR_ERR(dev->regs);
 
 	dev->clk = clk_get(&pdev->dev, "sclk_fimg2d");
 	if (IS_ERR_OR_NULL(dev->clk)) {
drivers/media/platform/s5p-jpeg/jpeg-core.c +3 -5
index 17983c4..3b02375 100644
@@ -1325,11 +1325,9 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
 	/* memory-mapped registers */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	jpeg->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (jpeg->regs == NULL) {
-		dev_err(&pdev->dev, "Failed to obtain io memory\n");
-		return -ENOENT;
-	}
+	jpeg->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(jpeg->regs))
+		return PTR_ERR(jpeg->regs);
 
 	/* interrupt service routine registration */
 	jpeg->irq = ret = platform_get_irq(pdev, 0);
drivers/media/platform/s5p-mfc/s5p_mfc.c +3 -5
index 379f574..b2e9e1a 100644
@@ -1061,11 +1061,9 @@ static int s5p_mfc_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	dev->regs_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (dev->regs_base == NULL) {
-		dev_err(&pdev->dev, "Failed to obtain io memory\n");
-		return -ENOENT;
-	}
+	dev->regs_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(dev->regs_base))
+		return PTR_ERR(dev->regs_base);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res == NULL) {
drivers/media/platform/soc_camera/mx2_camera.c +6 -6
index 8bda2c9..1abdc7d 100644
@@ -1707,9 +1707,9 @@ static int mx27_camera_emma_init(struct platform_device *pdev)
 		goto out;
 	}
 
-	pcdev->base_emma = devm_request_and_ioremap(pcdev->dev, res_emma);
-	if (!pcdev->base_emma) {
-		err = -EADDRNOTAVAIL;
+	pcdev->base_emma = devm_ioremap_resource(pcdev->dev, res_emma);
+	if (IS_ERR(pcdev->base_emma)) {
+		err = PTR_ERR(pcdev->base_emma);
 		goto out;
 	}
 
@@ -1824,9 +1824,9 @@ static int mx2_camera_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&pcdev->discard);
 	spin_lock_init(&pcdev->lock);
 
-	pcdev->base_csi = devm_request_and_ioremap(&pdev->dev, res_csi);
-	if (!pcdev->base_csi) {
-		err = -EADDRNOTAVAIL;
+	pcdev->base_csi = devm_ioremap_resource(&pdev->dev, res_csi);
+	if (IS_ERR(pcdev->base_csi)) {
+		err = PTR_ERR(pcdev->base_csi);
 		goto exit;
 	}
 
Signature · 1 line
1.8.1.1
Acked-by on v1 14/33
#45 lore raw

Re: [PATCH 14/33] media: Convert to devm_ioremap_resource()

Hi,

Quoted 9 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 12 lines
---
 drivers/media/platform/exynos-gsc/gsc-core.c   |  8 +++-----
 drivers/media/platform/mx2_emmaprp.c           |  6 +++---
 drivers/media/platform/s3c-camif/camif-core.c  |  8 +++-----
 drivers/media/platform/s5p-fimc/fimc-core.c    |  8 +++-----
 drivers/media/platform/s5p-fimc/fimc-lite.c    |  8 +++-----
 drivers/media/platform/s5p-fimc/mipi-csis.c    |  8 +++-----
 drivers/media/platform/s5p-g2d/g2d.c           |  8 +++-----
 drivers/media/platform/s5p-jpeg/jpeg-core.c    |  8 +++-----
 drivers/media/platform/s5p-mfc/s5p_mfc.c       |  8 +++-----
 drivers/media/platform/soc_camera/mx2_camera.c | 12 ++++++------
 10 files changed, 33 insertions(+), 49 deletions(-)

That's a nice cleanup. For exynos-gsc, s3c-camif, s5p-* drivers

--

Thanks,
Sylwester

#46 lore raw

PATCH 15/33 memory: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/memory/emif.c       | 8 +++-----
 drivers/memory/tegra20-mc.c | 7 ++++---
 drivers/memory/tegra30-mc.c | 7 ++++---
 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/memory/emif.c +3 -5
index 06d31c9..df08736 100644
@@ -10,6 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/reboot.h>
 #include <linux/platform_data/emif_plat.h>
@@ -1468,12 +1469,9 @@ static int __init_or_module emif_probe(struct platform_device *pdev)
 		goto error;
 	}
 
-	emif->base = devm_request_and_ioremap(emif->dev, res);
-	if (!emif->base) {
-		dev_err(emif->dev, "%s: devm_request_and_ioremap() failed\n",
-			__func__);
+	emif->base = devm_ioremap_resource(emif->dev, res);
+	if (IS_ERR(emif->base))
 		goto error;
-	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
drivers/memory/tegra20-mc.c +4 -3
index 186f27d..2ca5f28 100644
@@ -17,6 +17,7 @@
  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/ratelimit.h>
@@ -216,9 +217,9 @@ static int tegra20_mc_probe(struct platform_device *pdev)
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
 		if (!res)
 			return -ENODEV;
-		mc->regs[i] = devm_request_and_ioremap(&pdev->dev, res);
-		if (!mc->regs[i])
-			return -EBUSY;
+		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(mc->regs[i]))
+			return PTR_ERR(mc->regs[i]);
 	}
 
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
drivers/memory/tegra30-mc.c +4 -3
index 0b7ab93..0b97598 100644
@@ -17,6 +17,7 @@
  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/ratelimit.h>
@@ -336,9 +337,9 @@ static int tegra30_mc_probe(struct platform_device *pdev)
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
 		if (!res)
 			return -ENODEV;
-		mc->regs[i] = devm_request_and_ioremap(&pdev->dev, res);
-		if (!mc->regs[i])
-			return -EBUSY;
+		mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(mc->regs[i]))
+			return PTR_ERR(mc->regs[i]);
 	}
 
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
Signature · 1 line
1.8.1.1
#47 lore raw

PATCH 16/33 mfd: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/mfd/intel_msic.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mfd/intel_msic.c +4 -5
index ab8d0b2..1804331 100644
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/err.h>
 #include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -424,11 +425,9 @@ static int intel_msic_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	msic->irq_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!msic->irq_base) {
-		dev_err(&pdev->dev, "failed to map SRAM memory\n");
-		return -ENOMEM;
-	}
+	msic->irq_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(msic->irq_base))
+		return PTR_ERR(msic->irq_base);
 
 	platform_set_drvdata(pdev, msic);
 
Signature · 1 line
1.8.1.1
Applied
#48 lore raw

Re: [PATCH 16/33] mfd: Convert to devm_ioremap_resource()

Hi Thierry,

Quoted 11 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/mfd/intel_msic.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Applied, thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#49 lore raw

Re: [PATCH 16/33] mfd: Convert to devm_ioremap_resource()

Quoted 9 lines · Samuel Ortiz

Hi Thierry,

Quoted 6 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Quoted 6 lines
Quoted 5 lines
---
 drivers/mfd/intel_msic.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Applied, thanks.

I just realized that this one will go through Greg's driver-core tree as it has a build dependency on it. So dropped from my tree...

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#50 lore raw

PATCH 17/33 misc: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Greg Kroah-Hartman <[email protected]>
Cc Arnd Bergmann <[email protected]>
---
 drivers/misc/atmel-ssc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/misc/atmel-ssc.c +3 -5
index 3c09cbb..c208238 100644
@@ -159,11 +159,9 @@ static int ssc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	ssc->regs = devm_request_and_ioremap(&pdev->dev, regs);
-	if (!ssc->regs) {
-		dev_dbg(&pdev->dev, "ioremap failed\n");
-		return -EINVAL;
-	}
+	ssc->regs = devm_ioremap_resource(&pdev->dev, regs);
+	if (IS_ERR(ssc->regs))
+		return PTR_ERR(ssc->regs);
 
 	ssc->phybase = regs->start;
 
Signature · 1 line
1.8.1.1
#51 lore raw

PATCH 18/33 mmc: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/mmc/host/dw_mmc-pltfm.c | 7 ++++---
 drivers/mmc/host/mxs-mmc.c      | 6 +++---
 drivers/mmc/host/sdhci-s3c.c    | 7 +++----
 3 files changed, 10 insertions(+), 10 deletions(-)
drivers/mmc/host/dw_mmc-pltfm.c +4 -3
index 5e1fb1d..41c27b7 100644
@@ -10,6 +10,7 @@
  * (at your option) any later version.
  */
 
+#include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/io.h>
@@ -46,9 +47,9 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
 	host->dev = &pdev->dev;
 	host->irq_flags = 0;
 	host->pdata = pdev->dev.platform_data;
-	host->regs = devm_request_and_ioremap(&pdev->dev, regs);
-	if (!host->regs)
-		return -ENOMEM;
+	host->regs = devm_ioremap_resource(&pdev->dev, regs);
+	if (IS_ERR(host->regs))
+		return PTR_ERR(host->regs);
 
 	if (drv_data && drv_data->init) {
 		ret = drv_data->init(host);
drivers/mmc/host/mxs-mmc.c +3 -3
index 206fe49..5b66555 100644
@@ -614,9 +614,9 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	host = mmc_priv(mmc);
 	ssp = &host->ssp;
 	ssp->dev = &pdev->dev;
-	ssp->base = devm_request_and_ioremap(&pdev->dev, iores);
-	if (!ssp->base) {
-		ret = -EADDRNOTAVAIL;
+	ssp->base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(ssp->base)) {
+		ret = PTR_ERR(ssp->base);
 		goto out_mmc_free;
 	}
 
drivers/mmc/host/sdhci-s3c.c +3 -4
index 82a8de1..a0c6214 100644
@@ -651,10 +651,9 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 #endif
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!host->ioaddr) {
-		dev_err(dev, "failed to map registers\n");
-		ret = -ENXIO;
+	host->ioaddr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->ioaddr)) {
+		ret = PTR_ERR(host->ioaddr);
 		goto err_req_regs;
 	}
 
Signature · 1 line
1.8.1.1
#52 lore raw

PATCH 19/33 mtd: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/mtd/devices/spear_smi.c   |  7 +++----
 drivers/mtd/maps/autcpu12-nvram.c |  9 ++++-----
 drivers/mtd/maps/lantiq-flash.c   |  8 ++++----
 drivers/mtd/nand/fsmc_nand.c      | 33 +++++++++++++--------------------
 drivers/mtd/nand/lpc32xx_mlc.c    |  9 ++++-----
 drivers/mtd/nand/lpc32xx_slc.c    |  8 +++-----
 drivers/mtd/nand/mxc_nand.c       | 12 ++++++------
 drivers/mtd/nand/s3c2410.c        |  7 +++----
 drivers/mtd/nand/txx9ndfmc.c      |  7 ++++---
 9 files changed, 44 insertions(+), 56 deletions(-)
drivers/mtd/devices/spear_smi.c +3 -4
index 2aabd96..8a82b8b 100644
@@ -949,10 +949,9 @@ static int spear_smi_probe(struct platform_device *pdev)
 
 	smi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	dev->io_base = devm_request_and_ioremap(&pdev->dev, smi_base);
-	if (!dev->io_base) {
-		ret = -EIO;
-		dev_err(&pdev->dev, "devm_request_and_ioremap fail\n");
+	dev->io_base = devm_ioremap_resource(&pdev->dev, smi_base);
+	if (IS_ERR(dev->io_base)) {
+		ret = PTR_ERR(dev->io_base);
 		goto err;
 	}
 
drivers/mtd/maps/autcpu12-nvram.c +4 -5
index a2dc2ae..c3525d2 100644
@@ -16,6 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <linux/err.h>
 #include <linux/sizes.h>
 
 #include <linux/types.h>
@@ -55,12 +56,10 @@ static int autcpu12_nvram_probe(struct platform_device *pdev)
 	priv->map.bankwidth	= 4;
 	priv->map.phys		= res->start;
 	priv->map.size		= resource_size(res);
-	priv->map.virt		= devm_request_and_ioremap(&pdev->dev, res);
+	priv->map.virt = devm_ioremap_resource(&pdev->dev, res);
 	strcpy((char *)priv->map.name, res->name);
-	if (!priv->map.virt) {
-		dev_err(&pdev->dev, "failed to remap mem resource\n");
-		return -EBUSY;
-	}
+	if (IS_ERR(priv->map.virt))
+		return PTR_ERR(priv->map.virt);
 
 	simple_map_init(&priv->map);
 
drivers/mtd/maps/lantiq-flash.c +4 -4
index 3c3c791..d1da6ed 100644
@@ -7,6 +7,7 @@
  *  Copyright (C) 2010 John Crispin <[email protected]>
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -136,10 +137,9 @@ ltq_mtd_probe(struct platform_device *pdev)
 	ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
 	ltq_mtd->map->phys = ltq_mtd->res->start;
 	ltq_mtd->map->size = resource_size(ltq_mtd->res);
-	ltq_mtd->map->virt = devm_request_and_ioremap(&pdev->dev, ltq_mtd->res);
-	if (!ltq_mtd->map->virt) {
-		dev_err(&pdev->dev, "failed to remap mem resource\n");
-		err = -EBUSY;
+	ltq_mtd->map->virt = devm_ioremap_resource(&pdev->dev, ltq_mtd->res);
+	if (IS_ERR(ltq_mtd->map->virt)) {
+		err = PTR_ERR(ltq_mtd->map->virt);
 		goto err_out;
 	}
 
drivers/mtd/nand/fsmc_nand.c +13 -20
index 67e62d3..c543cc0 100644
@@ -937,42 +937,35 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 	if (!res)
 		return -EINVAL;
 
-	host->data_va = devm_request_and_ioremap(&pdev->dev, res);
-	if (!host->data_va) {
-		dev_err(&pdev->dev, "data ioremap failed\n");
-		return -ENOMEM;
-	}
+	host->data_va = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->data_va))
+		return PTR_ERR(host->data_va);
+	
 	host->data_pa = (dma_addr_t)res->start;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_addr");
 	if (!res)
 		return -EINVAL;
 
-	host->addr_va = devm_request_and_ioremap(&pdev->dev, res);
-	if (!host->addr_va) {
-		dev_err(&pdev->dev, "ale ioremap failed\n");
-		return -ENOMEM;
-	}
+	host->addr_va = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->addr_va))
+		return PTR_ERR(host->addr_va);
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_cmd");
 	if (!res)
 		return -EINVAL;
 
-	host->cmd_va = devm_request_and_ioremap(&pdev->dev, res);
-	if (!host->cmd_va) {
-		dev_err(&pdev->dev, "ale ioremap failed\n");
-		return -ENOMEM;
-	}
+	host->cmd_va = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->cmd_va))
+		return PTR_ERR(host->cmd_va);
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fsmc_regs");
 	if (!res)
 		return -EINVAL;
 
-	host->regs_va = devm_request_and_ioremap(&pdev->dev, res);
-	if (!host->regs_va) {
-		dev_err(&pdev->dev, "regs ioremap failed\n");
-		return -ENOMEM;
-	}
+	host->regs_va = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->regs_va))
+		return PTR_ERR(host->regs_va);
 
 	host->clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(host->clk)) {
drivers/mtd/nand/lpc32xx_mlc.c +4 -5
index f182bef..0ca22ae 100644
@@ -677,11 +677,10 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	host->io_base = devm_request_and_ioremap(&pdev->dev, rc);
-	if (host->io_base == NULL) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		return -EIO;
-	}
+	host->io_base = devm_ioremap_resource(&pdev->dev, rc);
+	if (IS_ERR(host->io_base))
+		return PTR_ERR(host->io_base);
+	
 	host->io_base_phy = rc->start;
 
 	mtd = &host->mtd;
drivers/mtd/nand/lpc32xx_slc.c +3 -5
index 030b78c..be94ed5 100644
@@ -778,11 +778,9 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 	}
 	host->io_base_dma = rc->start;
 
-	host->io_base = devm_request_and_ioremap(&pdev->dev, rc);
-	if (host->io_base == NULL) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		return -ENOMEM;
-	}
+	host->io_base = devm_ioremap_resource(&pdev->dev, rc);
+	if (IS_ERR(host->io_base))
+		return PTR_ERR(host->io_base);
 
 	if (pdev->dev.of_node)
 		host->ncfg = lpc32xx_parse_dt(&pdev->dev);
drivers/mtd/nand/mxc_nand.c +6 -6
index 45204e4..60ac5b9 100644
@@ -1437,9 +1437,9 @@ static int mxcnd_probe(struct platform_device *pdev)
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 		if (!res)
 			return -ENODEV;
-		host->regs_ip = devm_request_and_ioremap(&pdev->dev, res);
-		if (!host->regs_ip)
-			return -ENOMEM;
+		host->regs_ip = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(host->regs_ip))
+			return PTR_ERR(host->regs_ip);
 
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	} else {
@@ -1449,9 +1449,9 @@ static int mxcnd_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENODEV;
 
-	host->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!host->base)
-		return -ENOMEM;
+	host->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(host->base))
+		return PTR_ERR(host->base);
 
 	host->main_area0 = host->base;
 
drivers/mtd/nand/s3c2410.c +3 -4
index df954b4..d65afd2 100644
@@ -952,10 +952,9 @@ static int s3c24xx_nand_probe(struct platform_device *pdev)
 	info->platform	= plat;
 	info->cpu_type	= cpu_type;
 
-	info->regs	= devm_request_and_ioremap(&pdev->dev, res);
-	if (info->regs == NULL) {
-		dev_err(&pdev->dev, "cannot reserve register region\n");
-		err = -EIO;
+	info->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(info->regs)) {
+		err = PTR_ERR(info->regs);
 		goto exit_error;
 	}
 
drivers/mtd/nand/txx9ndfmc.c +4 -3
index e3d7266..e1e8748 100644
@@ -9,6 +9,7 @@
  * (C) Copyright TOSHIBA CORPORATION 2004-2007
  * All Rights Reserved.
  */
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -286,9 +287,9 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
 	drvdata = devm_kzalloc(&dev->dev, sizeof(*drvdata), GFP_KERNEL);
 	if (!drvdata)
 		return -ENOMEM;
-	drvdata->base = devm_request_and_ioremap(&dev->dev, res);
-	if (!drvdata->base)
-		return -EBUSY;
+	drvdata->base = devm_ioremap_resource(&dev->dev, res);
+	if (IS_ERR(drvdata->base))
+		return PTR_ERR(drvdata->base);
 
 	hold = plat->hold ?: 20; /* tDH */
 	spw = plat->spw ?: 90; /* max(tREADID, tWP, tRP) */
Signature · 1 line
1.8.1.1
#53 lore raw

PATCH 20/33 net: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/net/can/grcan.c                               | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 9 ++++-----
 2 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/can/grcan.c +4 -4
index 17fbc7a..4c3a7dd 100644
@@ -26,6 +26,7 @@
  * Contributors: Andreas Larsson <[email protected]>
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
@@ -1683,10 +1684,9 @@ static int grcan_probe(struct platform_device *ofdev)
 	}
 
 	res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
-	base = devm_request_and_ioremap(&ofdev->dev, res);
-	if (!base) {
-		dev_err(&ofdev->dev, "couldn't map IO resource\n");
-		err = -EADDRNOTAVAIL;
+	base = devm_ioremap_resource(&ofdev->dev, res);
+	if (IS_ERR(base)) {
+		err = PTR_ERR(base);
 		goto exit_error;
 	}
 
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +4 -5
index b43d68b..a3431aa 100644
@@ -22,6 +22,7 @@
   Author: Giuseppe Cavallaro <[email protected]>
 *******************************************************************************/
 
+#include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/of.h>
@@ -88,11 +89,9 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENODEV;
 
-	addr = devm_request_and_ioremap(dev, res);
-	if (!addr) {
-		pr_err("%s: ERROR: memory mapping failed", __func__);
-		return -ENOMEM;
-	}
+	addr = devm_ioremap_resource(dev, res);
+	if (IS_ERR(addr))
+		return PTR_ERR(addr);
 
 	if (pdev->dev.of_node) {
 		plat_dat = devm_kzalloc(&pdev->dev,
Signature · 1 line
1.8.1.1
maintainer
#54 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

From: Thierry Reding <[email protected]>
Date: Mon, 21 Jan 2013 11:09:13 +0100

Quoted 7 lines

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

This won't compile if I apply it.

You really have to be clear when you submit patches like this.

Since you only CC:'d the networking developers for this one patch, there is _ZERO_ context for us to work with to understand what's going on.

You have to also CC: us on the other relevant changes and your "[PATCH 00/33]" posting that explains what is happening.

#55 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

Quoted 13 lines · David Miller

From: Thierry Reding <[email protected]>
Date: Mon, 21 Jan 2013 11:09:13 +0100

Quoted 7 lines

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

This won't compile if I apply it.

Quoted 8 lines

You really have to be clear when you submit patches like this.

Since you only CC:'d the networking developers for this one patch, there is _ZERO_ context for us to work with to understand what's going on.

You have to also CC: us on the other relevant changes and your "[PATCH 00/33]" posting that explains what is happening.

I planned to do so initially, but that yielded a Cc list of 156 people and mailing lists, which I thought wasn't going to go down so well either. In general I like Cc'ing everyone concerned on all patches of the series, specifically for reasons of context. Some people have been annoyed when I did so. Still, for small series where only a few dozen people are concerned that seems to me to be the best way. But 156 email addresses is a different story.

Either you add to many people or you don't add enough. Where do we draw the line?

Thierry

maintainer
#56 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

Quoted 10 lines · Thierry Reding

I planned to do so initially, but that yielded a Cc list of 156 people and mailing lists, which I thought wasn't going to go down so well either. In general I like Cc'ing everyone concerned on all patches of the series, specifically for reasons of context. Some people have been annoyed when I did so. Still, for small series where only a few dozen people are concerned that seems to me to be the best way. But 156 email addresses is a different story.

Either you add to many people or you don't add enough. Where do we draw the line?

I've had the same problem a couple of times. The best compromise seems to be to Cc only the top-level subsystem maintainers and mailing lists on the first email.

Arnd

#57 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · Thierry Reding

I planned to do so initially, but that yielded a Cc list of 156 people and mailing lists, which I thought wasn't going to go down so well either. In general I like Cc'ing everyone concerned on all patches of the series, specifically for reasons of context. Some people have been annoyed when I did so. Still, for small series where only a few dozen people are concerned that seems to me to be the best way. But 156 email addresses is a different story.

Quoted 6 lines
Quoted 2 lines

Either you add to many people or you don't add enough. Where do we draw the line?

I've had the same problem a couple of times. The best compromise seems to be to Cc only the top-level subsystem maintainers and mailing lists on the first email.

Even that would have been about 50 addresses IIRC. But perhaps that's still the best compromise to avoid any confusion.

Thierry

maintainer
#58 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

Quoted 6 lines · Thierry Reding
Quoted 3 lines

I've had the same problem a couple of times. The best compromise seems to be to Cc only the top-level subsystem maintainers and mailing lists on the first email.

Even that would have been about 50 addresses IIRC. But perhaps that's still the best compromise to avoid any confusion.

Be careful though that the Cc list must not exceed 1024 characters or it will get rejected by some of the mailing list servers.

Arnd

maintainer
#59 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Tue, 22 Jan 2013 13:03:06 +0000

Quoted 9 lines · Thierry Reding
Quoted 8 lines

I planned to do so initially, but that yielded a Cc list of 156 people and mailing lists, which I thought wasn't going to go down so well either. In general I like Cc'ing everyone concerned on all patches of the series, specifically for reasons of context. Some people have been annoyed when I did so. Still, for small series where only a few dozen people are concerned that seems to me to be the best way. But 156 email addresses is a different story.

Quoted 6 lines
Quoted 2 lines

Either you add to many people or you don't add enough. Where do we draw the line?

I've had the same problem a couple of times. The best compromise seems to be to Cc only the top-level subsystem maintainers and mailing lists on the first email.

CC:'ing individuals is pointless, CC: only the subsystem lists in question, the maintainers had better be reading those lists.

maintainer
#60 lore raw

Re: [PATCH 20/33] net: Convert to devm_ioremap_resource()

In reply to Thierry Reding

From: Thierry Reding <[email protected]>
Date: Tue, 22 Jan 2013 07:56:29 +0100

Quoted 2 lines

I planned to do so initially, but that yielded a Cc list of 156 people and mailing lists,

Just use mailing lists, the individuals are subscribed to the subsystem lists that cover what they maintain.

Yes, CC:'ing 156 "people" is stupid.

#61 lore raw

PATCH 21/33 pinctrl: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/pinctrl/pinctrl-at91.c         |  7 +++----
 drivers/pinctrl/pinctrl-bcm2835.c      |  6 +++---
 drivers/pinctrl/pinctrl-coh901.c       |  8 +++-----
 drivers/pinctrl/pinctrl-exynos5440.c   |  8 +++-----
 drivers/pinctrl/pinctrl-falcon.c       | 13 +++++--------
 drivers/pinctrl/pinctrl-imx.c          |  6 +++---
 drivers/pinctrl/pinctrl-nomadik.c      |  6 +++---
 drivers/pinctrl/pinctrl-pxa3xx.c       |  7 ++++---
 drivers/pinctrl/pinctrl-samsung.c      |  8 +++-----
 drivers/pinctrl/pinctrl-u300.c         |  6 +++---
 drivers/pinctrl/pinctrl-xway.c         |  9 ++++-----
 drivers/pinctrl/spear/pinctrl-plgpio.c |  8 +++-----
 12 files changed, 40 insertions(+), 52 deletions(-)
drivers/pinctrl/pinctrl-at91.c +3 -4
index 471c71f..75933a6 100644
@@ -1503,10 +1503,9 @@ static int at91_gpio_probe(struct platform_device *pdev)
 		goto err;
 	}
 
-	at91_chip->regbase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!at91_chip->regbase) {
-		dev_err(&pdev->dev, "failed to map registers, ignoring.\n");
-		ret = -EBUSY;
+	at91_chip->regbase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(at91_chip->regbase)) {
+		ret = PTR_ERR(at91_chip->regbase);
 		goto err;
 	}
 
drivers/pinctrl/pinctrl-bcm2835.c +3 -3
index d347b9f..4eb6d2c 100644
@@ -959,9 +959,9 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
 		return err;
 	}
 
-	pc->base = devm_request_and_ioremap(dev, &iomem);
-	if (!pc->base)
-		return -EADDRNOTAVAIL;
+	pc->base = devm_ioremap_resource(dev, &iomem);
+	if (IS_ERR(pc->base))
+		return PTR_ERR(pc->base);
 
 	pc->gpio_chip = bcm2835_gpio_chip;
 	pc->gpio_chip.dev = dev;
drivers/pinctrl/pinctrl-coh901.c +3 -5
index fbb3715..8b7e7bc 100644
@@ -715,11 +715,9 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	gpio->base = devm_request_and_ioremap(&pdev->dev, memres);
-	if (!gpio->base) {
-		dev_err(gpio->dev, "could not get remap memory\n");
-		return -ENOMEM;
-	}
+	gpio->base = devm_ioremap_resource(&pdev->dev, memres);
+	if (IS_ERR(gpio->base))
+		return PTR_ERR(gpio->base);
 
 	gpio->clk = devm_clk_get(gpio->dev, NULL);
 	if (IS_ERR(gpio->clk)) {
drivers/pinctrl/pinctrl-exynos5440.c +3 -5
index de05b64..5e77242 100644
@@ -866,11 +866,9 @@ static int exynos5440_pinctrl_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	priv->reg_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->reg_base) {
-		dev_err(dev, "ioremap failed\n");
-		return -ENODEV;
-	}
+	priv->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->reg_base))
+		return PTR_ERR(priv->reg_base);
 
 	ret = exynos5440_gpiolib_register(pdev, priv);
 	if (ret)
drivers/pinctrl/pinctrl-falcon.c +5 -8
index 8ed20e8..a5d9d56 100644
@@ -411,14 +411,11 @@ static int pinctrl_falcon_probe(struct platform_device *pdev)
 			dev_err(&ppdev->dev, "failed to get clock\n");
 			return PTR_ERR(falcon_info.clk[*bank]);
 		}
-		falcon_info.membase[*bank] =
-				devm_request_and_ioremap(&pdev->dev, &res);
-		if (!falcon_info.membase[*bank]) {
-			dev_err(&pdev->dev,
-				"Failed to remap memory for bank %d\n",
-				*bank);
-			return -ENOMEM;
-		}
+		falcon_info.membase[*bank] = devm_ioremap_resource(&pdev->dev,
+								   &res);
+		if (IS_ERR(falcon_info.membase[*bank]))
+			return PTR_ERR(falcon_info.membase[*bank]);
+		
 		avail = pad_r32(falcon_info.membase[*bank],
 					LTQ_PADC_AVAIL);
 		pins = fls(avail);
drivers/pinctrl/pinctrl-imx.c +3 -3
index 43a6f1f..4cebb9c 100644
@@ -584,9 +584,9 @@ int imx_pinctrl_probe(struct platform_device *pdev,
 	if (!res)
 		return -ENOENT;
 
-	ipctl->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!ipctl->base)
-		return -EBUSY;
+	ipctl->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ipctl->base))
+		return PTR_ERR(ipctl->base);
 
 	imx_pinctrl_desc.name = dev_name(&pdev->dev);
 	imx_pinctrl_desc.pins = info->pins;
drivers/pinctrl/pinctrl-nomadik.c +3 -3
index 1bb16ff..96e7cfb 100644
@@ -1367,9 +1367,9 @@ static int nmk_gpio_probe(struct platform_device *dev)
 		goto out;
 	}
 
-	base = devm_request_and_ioremap(&dev->dev, res);
-	if (!base) {
-		ret = -ENOMEM;
+	base = devm_ioremap_resource(&dev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
 		goto out;
 	}
 
drivers/pinctrl/pinctrl-pxa3xx.c +4 -3
index 51f8a38..1f49bb0 100644
@@ -11,6 +11,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/io.h>
@@ -187,9 +188,9 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENOENT;
-	info->virt_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!info->virt_base)
-		return -ENOMEM;
+	info->virt_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(info->virt_base))
+		return PTR_ERR(info->virt_base);
 	info->pctrl = pinctrl_register(desc, &pdev->dev, info);
 	if (!info->pctrl) {
 		dev_err(&pdev->dev, "failed to register PXA pinmux driver\n");
drivers/pinctrl/pinctrl-samsung.c +3 -5
index fd7b24c..7e6669c 100644
@@ -917,11 +917,9 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	drvdata->virt_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!drvdata->virt_base) {
-		dev_err(dev, "ioremap failed\n");
-		return -ENODEV;
-	}
+	drvdata->virt_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(drvdata->virt_base))
+		return PTR_ERR(drvdata->virt_base);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (res)
drivers/pinctrl/pinctrl-u300.c +3 -3
index 718ec57..2b57725 100644
@@ -1078,9 +1078,9 @@ static int u300_pmx_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENOENT;
 
-	upmx->virtbase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!upmx->virtbase)
-		return -ENOMEM;
+	upmx->virtbase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(upmx->virtbase))
+		return PTR_ERR(upmx->virtbase);
 
 	upmx->pctl = pinctrl_register(&u300_pmx_desc, &pdev->dev, upmx);
 	if (!upmx->pctl) {
drivers/pinctrl/pinctrl-xway.c +4 -5
index 5f0eb04..ae8f3a0 100644
@@ -9,6 +9,7 @@
  *  Copyright (C) 2012 John Crispin <[email protected]>
  */
 
+#include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
@@ -687,11 +688,9 @@ static int pinmux_xway_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Failed to get resource\n");
 		return -ENOENT;
 	}
-	xway_info.membase[0] = devm_request_and_ioremap(&pdev->dev, res);
-	if (!xway_info.membase[0]) {
-		dev_err(&pdev->dev, "Failed to remap resource\n");
-		return -ENOMEM;
-	}
+	xway_info.membase[0] = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(xway_info.membase[0]))
+		return PTR_ERR(xway_info.membase[0]);
 
 	match = of_match_device(xway_match, &pdev->dev);
 	if (match)
drivers/pinctrl/spear/pinctrl-plgpio.c +3 -5
index 3cf4ecd..295b349 100644
@@ -540,11 +540,9 @@ static int plgpio_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	plgpio->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!plgpio->base) {
-		dev_err(&pdev->dev, "request and ioremap fail\n");
-		return -ENOMEM;
-	}
+	plgpio->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(plgpio->base))
+		return PTR_ERR(plgpio->base);
 
 	ret = plgpio_probe_dt(pdev, plgpio);
 	if (ret) {
Signature · 1 line
1.8.1.1
Acked-by on v1 21/33
#62 lore raw

Re: [PATCH 21/33] pinctrl: Convert to devm_ioremap_resource()

drivers/pinctrl/spear/pinctrl-plgpio.c static int plgpio_probe(struct platform_device *pdev) · line 545

Quoted 11 lines · Thierry Reding
drivers/pinctrl/spear/pinctrl-plgpio.c +0 -3
index 3cf4ecd..295b349 100644
@@ -540,11 +540,9 @@ static int plgpio_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       plgpio->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!plgpio->base) {
-               dev_err(&pdev->dev, "request and ioremap fail\n");

can we keep this as is?

drivers/pinctrl/spear/pinctrl-plgpio.c static int plgpio_probe(struct platform_device *pdev) · line 546

Quoted 6 lines
drivers/pinctrl/spear/pinctrl-plgpio.c +3 -2
-               return -ENOMEM;
-       }
+       plgpio->base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(plgpio->base))
+               return PTR_ERR(plgpio->base);
 
#63 lore raw

PATCH 22/33 power: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Cc Anton Vorontsov <[email protected]>
Cc David Woodhouse <[email protected]>
---
 drivers/power/jz4740-battery.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/power/jz4740-battery.c +4 -3
index bf91489..c675553 100644
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 
 #include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/gpio.h>
 #include <linux/mfd/core.h>
 #include <linux/power_supply.h>
@@ -266,9 +267,9 @@ static int jz_battery_probe(struct platform_device *pdev)
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	jz_battery->base = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!jz_battery->base)
-		return -EBUSY;
+	jz_battery->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(jz_battery->base))
+		return PTR_ERR(jz_battery->base);
 
 	battery = &jz_battery->battery;
 	battery->name = pdata->info.name;
Signature · 1 line
1.8.1.1
#64 lore raw

PATCH 23/33 pwm: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

---
 drivers/pwm/pwm-imx.c      | 6 +++---
 drivers/pwm/pwm-lpc32xx.c  | 6 +++---
 drivers/pwm/pwm-mxs.c      | 6 +++---
 drivers/pwm/pwm-puv3.c     | 6 +++---
 drivers/pwm/pwm-pxa.c      | 6 +++---
 drivers/pwm/pwm-spear.c    | 6 +++---
 drivers/pwm/pwm-tegra.c    | 6 +++---
 drivers/pwm/pwm-tiecap.c   | 6 +++---
 drivers/pwm/pwm-tiehrpwm.c | 6 +++---
 drivers/pwm/pwm-tipwmss.c  | 6 +++---
 drivers/pwm/pwm-vt8500.c   | 6 +++---
 11 files changed, 33 insertions(+), 33 deletions(-)
drivers/pwm/pwm-imx.c +3 -3
index 65a86bd..3f5677b 100644
@@ -274,9 +274,9 @@ static int imx_pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	imx->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (imx->mmio_base == NULL)
-		return -EADDRNOTAVAIL;
+	imx->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(imx->mmio_base))
+		return PTR_ERR(imx->mmio_base);
 
 	data = of_id->data;
 	imx->config = data->config;
drivers/pwm/pwm-lpc32xx.c +3 -3
index 1410644..b3f0d0d 100644
@@ -110,9 +110,9 @@ static int lpc32xx_pwm_probe(struct platform_device *pdev)
 	if (!res)
 		return -EINVAL;
 
-	lpc32xx->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!lpc32xx->base)
-		return -EADDRNOTAVAIL;
+	lpc32xx->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(lpc32xx->base))
+		return PTR_ERR(lpc32xx->base);
 
 	lpc32xx->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(lpc32xx->clk))
drivers/pwm/pwm-mxs.c +3 -3
index 7ec345f..a53d309 100644
@@ -139,9 +139,9 @@ static int mxs_pwm_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	mxs->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!mxs->base)
-		return -EADDRNOTAVAIL;
+	mxs->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(mxs->base))
+		return PTR_ERR(mxs->base);
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl))
drivers/pwm/pwm-puv3.c +3 -3
index b882f60..db964e6e 100644
@@ -123,9 +123,9 @@ static int pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	puv3->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (puv3->base == NULL)
-		return -EADDRNOTAVAIL;
+	puv3->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(puv3->base))
+		return PTR_ERR(puv3->base);
 
 	puv3->chip.dev = &pdev->dev;
 	puv3->chip.ops = &puv3_pwm_ops;
drivers/pwm/pwm-pxa.c +3 -3
index f32fc4e..20370e6 100644
@@ -165,9 +165,9 @@ static int pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	pwm->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (pwm->mmio_base == NULL)
-		return -EADDRNOTAVAIL;
+	pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(pwm->mmio_base))
+		return PTR_ERR(pwm->mmio_base);
 
 	ret = pwmchip_add(&pwm->chip);
 	if (ret < 0) {
drivers/pwm/pwm-spear.c +3 -3
index 83b21d9..69a2d9e 100644
@@ -192,9 +192,9 @@ static int spear_pwm_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	pc->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!pc->mmio_base)
-		return -EADDRNOTAVAIL;
+	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(pc->mmio_base))
+		return PTR_ERR(pc->mmio_base);
 
 	pc->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(pc->clk))
drivers/pwm/pwm-tegra.c +3 -3
index 30c0e2b..71900e8 100644
@@ -186,9 +186,9 @@ static int tegra_pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	pwm->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!pwm->mmio_base)
-		return -EADDRNOTAVAIL;
+	pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(pwm->mmio_base))
+		return PTR_ERR(pwm->mmio_base);
 
 	platform_set_drvdata(pdev, pwm);
 
drivers/pwm/pwm-tiecap.c +3 -3
index 5cf016d..27a67d6 100644
@@ -238,9 +238,9 @@ static int ecap_pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	pc->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!pc->mmio_base)
-		return -EADDRNOTAVAIL;
+	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(pc->mmio_base))
+		return PTR_ERR(pc->mmio_base);
 
 	ret = pwmchip_add(&pc->chip);
 	if (ret < 0) {
drivers/pwm/pwm-tiehrpwm.c +3 -3
index 72a6dd4..5a13995 100644
@@ -453,9 +453,9 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	pc->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!pc->mmio_base)
-		return  -EADDRNOTAVAIL;
+	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(pc->mmio_base))
+		return PTR_ERR(pc->mmio_base);
 
 	/* Acquire tbclk for Time Base EHRPWM submodule */
 	pc->tbclk = devm_clk_get(&pdev->dev, "tbclk");
drivers/pwm/pwm-tipwmss.c +3 -3
index 3448a1c..17cbc59 100644
@@ -75,9 +75,9 @@ static int pwmss_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	info->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!info->mmio_base)
-		return -EADDRNOTAVAIL;
+	info->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(info->mmio_base))
+		return PTR_ERR(info->mmio_base);
 
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
drivers/pwm/pwm-vt8500.c +3 -3
index b0ba2d4..f9de9b2 100644
@@ -178,9 +178,9 @@ static int vt8500_pwm_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	chip->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!chip->base)
-		return -EADDRNOTAVAIL;
+	chip->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(chip->base))
+		return PTR_ERR(chip->base);
 
 	ret = clk_prepare(chip->clk);
 	if (ret < 0) {
Signature · 1 line
1.8.1.1
Acked-by on v1 23/33
#65 lore raw

Re: [PATCH 23/33] pwm: Convert to devm_ioremap_resource()

Quoted 7 lines · Thierry Reding
drivers/pwm/pwm-spear.c +0 -0
index 83b21d9..69a2d9e 100644
@@ -192,9 +192,9 @@ static int spear_pwm_probe(struct platform_device *pdev)
                return -ENOMEM;
        }

drivers/pwm/pwm-spear.c static int spear_pwm_probe(struct platform_device *pdev) · line 200

Quoted 10 lines
drivers/pwm/pwm-spear.c +3 -3
 
-       pc->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
-       if (!pc->mmio_base)
-               return -EADDRNOTAVAIL;
+       pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
+       if (IS_ERR(pc->mmio_base))
+               return PTR_ERR(pc->mmio_base);
 
        pc->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(pc->clk))
#66 lore raw

PATCH 24/33 rtc: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/rtc/rtc-s3c.c   | 8 +++-----
 drivers/rtc/rtc-snvs.c  | 6 +++---
 drivers/rtc/rtc-spear.c | 8 +++-----
 drivers/rtc/rtc-tegra.c | 8 +++-----
 4 files changed, 12 insertions(+), 18 deletions(-)
drivers/rtc/rtc-s3c.c +3 -5
index 4046514..0c397ac 100644
@@ -486,11 +486,9 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	s3c_rtc_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (s3c_rtc_base == NULL) {
-		dev_err(&pdev->dev, "failed to ioremap memory region\n");
-		return -EINVAL;
-	}
+	s3c_rtc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(s3c_rtc_base))
+		return PTR_ERR(s3c_rtc_base);
 
 	rtc_clk = devm_clk_get(&pdev->dev, "rtc");
 	if (IS_ERR(rtc_clk)) {
drivers/rtc/rtc-snvs.c +3 -3
index d5ec785..40662e9 100644
@@ -252,9 +252,9 @@ static int snvs_rtc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	data->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!data->ioaddr)
-		return -EADDRNOTAVAIL;
+	data->ioaddr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(data->ioaddr))
+		return PTR_ERR(data->ioaddr);
 
 	data->irq = platform_get_irq(pdev, 0);
 	if (data->irq < 0)
drivers/rtc/rtc-spear.c +3 -5
index c2121b5..a18c319 100644
@@ -385,11 +385,9 @@ static int spear_rtc_probe(struct platform_device *pdev)
 		return status;
 	}
 
-	config->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
-	if (!config->ioaddr) {
-		dev_err(&pdev->dev, "request-ioremap fail\n");
-		return -ENOMEM;
-	}
+	config->ioaddr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(config->ioaddr))
+		return PTR_ERR(config->ioaddr);
 
 	config->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(config->clk))
drivers/rtc/rtc-tegra.c +3 -5
index c84ea66..7c03375 100644
@@ -327,11 +327,9 @@ static int tegra_rtc_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
-	info->rtc_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!info->rtc_base) {
-		dev_err(&pdev->dev, "Unable to request mem region and grab IOs for device.\n");
-		return -EBUSY;
-	}
+	info->rtc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(info->rtc_base))
+		return PTR_ERR(info->rtc_base);
 
 	info->tegra_rtc_irq = platform_get_irq(pdev, 0);
 	if (info->tegra_rtc_irq <= 0)
Signature · 1 line
1.8.1.1
Acked-by on v1 24/33
#67 lore raw

Re: [PATCH 24/33] rtc: Convert to devm_ioremap_resource()

drivers/rtc/rtc-spear.c static int spear_rtc_probe(struct platform_device *pdev) · line 390

Quoted 11 lines · Thierry Reding
drivers/rtc/rtc-spear.c +0 -3
index c2121b5..a18c319 100644
@@ -385,11 +385,9 @@ static int spear_rtc_probe(struct platform_device *pdev)
                return status;
        }
 
-       config->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
-       if (!config->ioaddr) {
-               dev_err(&pdev->dev, "request-ioremap fail\n");

can we keep it as is?

drivers/rtc/rtc-spear.c static int spear_rtc_probe(struct platform_device *pdev) · line 391

Quoted 6 lines
drivers/rtc/rtc-spear.c +3 -2
-               return -ENOMEM;
-       }
+       config->ioaddr = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(config->ioaddr))
+               return PTR_ERR(config->ioaddr);
 
#68 lore raw

PATCH 25/33 spi: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/spi/spi-ep93xx.c         | 7 +++----
 drivers/spi/spi-mxs.c            | 6 +++---
 drivers/spi/spi-omap2-mcspi.c    | 7 +++----
 drivers/spi/spi-s3c64xx.c        | 7 +++----
 drivers/spi/spi-sirf.c           | 7 +++----
 drivers/spi/spi-tegra20-sflash.c | 8 +++-----
 drivers/spi/spi-tegra20-slink.c  | 8 +++-----
 7 files changed, 21 insertions(+), 29 deletions(-)
drivers/spi/spi-ep93xx.c +3 -4
index acb1e19..2e31f32 100644
@@ -1085,10 +1085,9 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 
 	espi->sspdr_phys = res->start + SSPDR;
 
-	espi->regs_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!espi->regs_base) {
-		dev_err(&pdev->dev, "failed to map resources\n");
-		error = -ENODEV;
+	espi->regs_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(espi->regs_base)) {
+		error = PTR_ERR(espi->regs_base);
 		goto fail_put_clock;
 	}
 
drivers/spi/spi-mxs.c +3 -3
index a3ede24..b735988 100644
@@ -538,9 +538,9 @@ static int mxs_spi_probe(struct platform_device *pdev)
 	if (!iores || irq_err < 0 || irq_dma < 0)
 		return -EINVAL;
 
-	base = devm_request_and_ioremap(&pdev->dev, iores);
-	if (!base)
-		return -EADDRNOTAVAIL;
+	base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl))
drivers/spi/spi-omap2-mcspi.c +3 -4
index b610f52..71a9482 100644
@@ -1204,10 +1204,9 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	r->end += regs_offset;
 	mcspi->phys = r->start;
 
-	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!mcspi->base) {
-		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
-		status = -ENOMEM;
+	mcspi->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(mcspi->base)) {
+		status = PTR_ERR(mcspi->base);
 		goto free_master;
 	}
 
drivers/spi/spi-s3c64xx.c +3 -4
index ad93231..3d4a7c4 100644
@@ -1276,10 +1276,9 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
 	/* the spi->mode bits understood by this driver: */
 	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
 
-	sdd->regs = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (sdd->regs == NULL) {
-		dev_err(&pdev->dev, "Unable to remap IO\n");
-		ret = -ENXIO;
+	sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(sdd->regs)) {
+		ret = PTR_ERR(sdd->regs);
 		goto err1;
 	}
 
drivers/spi/spi-sirf.c +3 -4
index e0f43a5..78c8842 100644
@@ -535,10 +535,9 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 		}
 	}
 
-	sspi->base = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (!sspi->base) {
-		dev_err(&pdev->dev, "IO remap failed!\n");
-		ret = -ENOMEM;
+	sspi->base = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(sspi->base)) {
+		ret = PTR_ERR(sspi->base);
 		goto free_master;
 	}
 
drivers/spi/spi-tegra20-sflash.c +3 -5
index 448a8cc..69c9d23 100644
@@ -508,11 +508,9 @@ static int tegra_sflash_probe(struct platform_device *pdev)
 		ret = -ENODEV;
 		goto exit_free_master;
 	}
-	tsd->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!tsd->base) {
-		dev_err(&pdev->dev,
-			"Cannot request memregion/iomap dma address\n");
-		ret = -EADDRNOTAVAIL;
+	tsd->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(tsd->base)) {
+		ret = PTR_ERR(tsd->base);
 		goto exit_free_master;
 	}
 
drivers/spi/spi-tegra20-slink.c +3 -5
index 651167f..96bd6c2 100644
@@ -1172,11 +1172,9 @@ static int tegra_slink_probe(struct platform_device *pdev)
 		goto exit_free_master;
 	}
 	tspi->phys = r->start;
-	tspi->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!tspi->base) {
-		dev_err(&pdev->dev,
-			"Cannot request memregion/iomap dma address\n");
-		ret = -EADDRNOTAVAIL;
+	tspi->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(tspi->base)) {
+		ret = PTR_ERR(tspi->base);
 		goto exit_free_master;
 	}
 
Signature · 1 line
1.8.1.1
Acked-by on v1 25/33
#69 lore raw

Re: [PATCH 25/33] spi: Convert to devm_ioremap_resource()

Quoted 9 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Grant Likely <grant.likely-s3s/[email protected]>
Cc spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

Looks fine by me. Go ahead and merge with the rest of the series.

Quoted 140 lines
---
 drivers/spi/spi-ep93xx.c         | 7 +++----
 drivers/spi/spi-mxs.c            | 6 +++---
 drivers/spi/spi-omap2-mcspi.c    | 7 +++----
 drivers/spi/spi-s3c64xx.c        | 7 +++----
 drivers/spi/spi-sirf.c           | 7 +++----
 drivers/spi/spi-tegra20-sflash.c | 8 +++-----
 drivers/spi/spi-tegra20-slink.c  | 8 +++-----
 7 files changed, 21 insertions(+), 29 deletions(-)
drivers/spi/spi-ep93xx.c +3 -4
index acb1e19..2e31f32 100644
@@ -1085,10 +1085,9 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 
 	espi->sspdr_phys = res->start + SSPDR;
 
-	espi->regs_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!espi->regs_base) {
-		dev_err(&pdev->dev, "failed to map resources\n");
-		error = -ENODEV;
+	espi->regs_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(espi->regs_base)) {
+		error = PTR_ERR(espi->regs_base);
 		goto fail_put_clock;
 	}
 
drivers/spi/spi-mxs.c +3 -3
index a3ede24..b735988 100644
@@ -538,9 +538,9 @@ static int mxs_spi_probe(struct platform_device *pdev)
 	if (!iores || irq_err < 0 || irq_dma < 0)
 		return -EINVAL;
 
-	base = devm_request_and_ioremap(&pdev->dev, iores);
-	if (!base)
-		return -EADDRNOTAVAIL;
+	base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl))
drivers/spi/spi-omap2-mcspi.c +3 -4
index b610f52..71a9482 100644
@@ -1204,10 +1204,9 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	r->end += regs_offset;
 	mcspi->phys = r->start;
 
-	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!mcspi->base) {
-		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
-		status = -ENOMEM;
+	mcspi->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(mcspi->base)) {
+		status = PTR_ERR(mcspi->base);
 		goto free_master;
 	}
 
drivers/spi/spi-s3c64xx.c +3 -4
index ad93231..3d4a7c4 100644
@@ -1276,10 +1276,9 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
 	/* the spi->mode bits understood by this driver: */
 	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
 
-	sdd->regs = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (sdd->regs == NULL) {
-		dev_err(&pdev->dev, "Unable to remap IO\n");
-		ret = -ENXIO;
+	sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(sdd->regs)) {
+		ret = PTR_ERR(sdd->regs);
 		goto err1;
 	}
 
drivers/spi/spi-sirf.c +3 -4
index e0f43a5..78c8842 100644
@@ -535,10 +535,9 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 		}
 	}
 
-	sspi->base = devm_request_and_ioremap(&pdev->dev, mem_res);
-	if (!sspi->base) {
-		dev_err(&pdev->dev, "IO remap failed!\n");
-		ret = -ENOMEM;
+	sspi->base = devm_ioremap_resource(&pdev->dev, mem_res);
+	if (IS_ERR(sspi->base)) {
+		ret = PTR_ERR(sspi->base);
 		goto free_master;
 	}
 
drivers/spi/spi-tegra20-sflash.c +3 -5
index 448a8cc..69c9d23 100644
@@ -508,11 +508,9 @@ static int tegra_sflash_probe(struct platform_device *pdev)
 		ret = -ENODEV;
 		goto exit_free_master;
 	}
-	tsd->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!tsd->base) {
-		dev_err(&pdev->dev,
-			"Cannot request memregion/iomap dma address\n");
-		ret = -EADDRNOTAVAIL;
+	tsd->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(tsd->base)) {
+		ret = PTR_ERR(tsd->base);
 		goto exit_free_master;
 	}
 
drivers/spi/spi-tegra20-slink.c +3 -5
index 651167f..96bd6c2 100644
@@ -1172,11 +1172,9 @@ static int tegra_slink_probe(struct platform_device *pdev)
 		goto exit_free_master;
 	}
 	tspi->phys = r->start;
-	tspi->base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!tspi->base) {
-		dev_err(&pdev->dev,
-			"Cannot request memregion/iomap dma address\n");
-		ret = -EADDRNOTAVAIL;
+	tspi->base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(tspi->base)) {
+		ret = PTR_ERR(tspi->base);
 		goto exit_free_master;
 	}
 
Signature · 1 line
1.8.1.1
Signature · 8 lines
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
#70 lore raw

PATCH 26/33 staging: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/staging/iio/adc/mxs-lradc.c         |  7 ++++---
 drivers/staging/nvec/nvec.c                 |  8 +++-----
 drivers/staging/omap-thermal/omap-bandgap.c | 11 ++++-------
 3 files changed, 11 insertions(+), 15 deletions(-)
drivers/staging/iio/adc/mxs-lradc.c +4 -3
index c5ceb9d..3d562da 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
@@ -487,9 +488,9 @@ static int mxs_lradc_probe(struct platform_device *pdev)
 	/* Grab the memory area */
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	lradc->dev = &pdev->dev;
-	lradc->base = devm_request_and_ioremap(dev, iores);
-	if (!lradc->base) {
-		ret = -EADDRNOTAVAIL;
+	lradc->base = devm_ioremap_resource(dev, iores);
+	if (IS_ERR(lradc->base)) {
+		ret = PTR_ERR(lradc->base);
 		goto err_addr;
 	}
 
drivers/staging/nvec/nvec.c +3 -5
index 2830946..492e0b6 100644
@@ -759,11 +759,9 @@ static int tegra_nvec_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!base) {
-		dev_err(&pdev->dev, "Can't ioremap I2C region\n");
-		return -ENOMEM;
-	}
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
drivers/staging/omap-thermal/omap-bandgap.c +4 -7
index 8346e345..21fd91b 100644
@@ -820,15 +820,12 @@ static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
 		if (!res)
 			break;
-		chunk = devm_request_and_ioremap(&pdev->dev, res);
+		chunk = devm_ioremap_resource(&pdev->dev, res);
 		if (i == 0)
 			bg_ptr->base = chunk;
-		if (!chunk) {
-			dev_err(&pdev->dev,
-				"failed to request the IO (%d:%pR).\n",
-				i, res);
-			return ERR_PTR(-EADDRNOTAVAIL);
-		}
+		if (IS_ERR(chunk))
+			return ERR_CAST(chunk);
+		
 		i++;
 	} while (res);
 
Signature · 1 line
1.8.1.1
#71 lore raw

PATCH 27/33 thermal: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/thermal/exynos_thermal.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/thermal/exynos_thermal.c +3 -5
index 224751e..bada130 100644
@@ -866,11 +866,9 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	data->base = devm_request_and_ioremap(&pdev->dev, data->mem);
-	if (!data->base) {
-		dev_err(&pdev->dev, "Failed to ioremap memory\n");
-		return -ENODEV;
-	}
+	data->base = devm_ioremap_resource(&pdev->dev, data->mem);
+	if (IS_ERR(data->base))
+		return PTR_ERR(data->base);
 
 	ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq,
 		IRQF_TRIGGER_RISING, "exynos-tmu", data);
Signature · 1 line
1.8.1.1
#72 lore raw

PATCH 28/33 serial: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/tty/serial/sccnxp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/tty/serial/sccnxp.c +4 -4
index 418b495..e869eab 100644
@@ -15,6 +15,7 @@
 #define SUPPORT_SYSRQ
 #endif
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/console.h>
@@ -875,10 +876,9 @@ static int sccnxp_probe(struct platform_device *pdev)
 		goto err_out;
 	}
 
-	membase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!membase) {
-		dev_err(&pdev->dev, "Failed to ioremap\n");
-		ret = -EIO;
+	membase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(membase)) {
+		ret = PTR_ERR(membase);
 		goto err_out;
 	}
 
Signature · 1 line
1.8.1.1
#73 lore raw

PATCH 29/33 usb: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Stern <[email protected]>
Cc Felipe Balbi <[email protected]>
---
 drivers/usb/chipidea/usbmisc_imx6q.c |  6 +++---
 drivers/usb/gadget/bcm63xx_udc.c     | 13 +++++++------
 drivers/usb/gadget/s3c-hsotg.c       |  7 +++----
 drivers/usb/gadget/s3c-hsudc.c       |  7 +++----
 drivers/usb/host/ehci-atmel.c        |  7 +++----
 drivers/usb/host/ehci-grlib.c        |  9 ++++-----
 drivers/usb/host/ehci-mxc.c          |  7 +++----
 drivers/usb/host/ehci-platform.c     |  7 ++++---
 drivers/usb/host/ehci-ppc-of.c       |  8 ++++----
 drivers/usb/host/ehci-sead3.c        |  8 ++++----
 drivers/usb/host/ehci-sh.c           |  7 +++----
 drivers/usb/host/ehci-vt8500.c       |  8 ++++----
 drivers/usb/host/ehci-xilinx-of.c    |  8 ++++----
 drivers/usb/host/ohci-nxp.c          |  7 +++----
 drivers/usb/host/ohci-platform.c     |  7 ++++---
 drivers/usb/host/ohci-s3c2410.c      |  7 +++----
 drivers/usb/musb/musb_dsps.c         |  7 +++----
 drivers/usb/musb/omap2430.c          |  4 +---
 drivers/usb/otg/mxs-phy.c            |  6 +++---
 drivers/usb/phy/mv_u3d_phy.c         |  8 +++-----
 drivers/usb/phy/omap-usb2.c          |  8 +++-----
 drivers/usb/renesas_usbhs/common.c   |  9 ++++-----
 22 files changed, 76 insertions(+), 89 deletions(-)
drivers/usb/chipidea/usbmisc_imx6q.c +3 -3
index 845efe2..a1bce39 100644
@@ -98,9 +98,9 @@ static int usbmisc_imx6q_probe(struct platform_device *pdev)
 	spin_lock_init(&data->lock);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	data->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!data->base)
-		return -EADDRNOTAVAIL;
+	data->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(data->base))
+		return PTR_ERR(data->base);
 
 	data->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(data->clk)) {
drivers/usb/gadget/bcm63xx_udc.c +7 -6
index 47a4993..8cc8253 100644
@@ -2351,19 +2351,20 @@ static int bcm63xx_udc_probe(struct platform_device *pdev)
 		dev_err(dev, "error finding USBD resource\n");
 		return -ENXIO;
 	}
-	udc->usbd_regs = devm_request_and_ioremap(dev, res);
+
+	udc->usbd_regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(udc->usbd_regs))
+		return PTR_ERR(udc->usbd_regs);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	if (!res) {
 		dev_err(dev, "error finding IUDMA resource\n");
 		return -ENXIO;
 	}
-	udc->iudma_regs = devm_request_and_ioremap(dev, res);
 
-	if (!udc->usbd_regs || !udc->iudma_regs) {
-		dev_err(dev, "error requesting resources\n");
-		return -ENXIO;
-	}
+	udc->iudma_regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(udc->iudma_regs))
+		return PTR_ERR(udc->iudma_regs);
 
 	spin_lock_init(&udc->lock);
 	INIT_WORK(&udc->ep0_wq, bcm63xx_ep0_process);
drivers/usb/gadget/s3c-hsotg.c +3 -4
index 439c3f9..de80fa6 100644
@@ -3525,10 +3525,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	hsotg->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hsotg->regs) {
-		dev_err(dev, "cannot map registers\n");
-		ret = -ENXIO;
+	hsotg->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hsotg->regs)) {
+		ret = PTR_ERR(hsotg->regs);
 		goto err_clk;
 	}
 
drivers/usb/gadget/s3c-hsudc.c +3 -4
index 52379b1..94ca33b 100644
@@ -1295,10 +1295,9 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	hsudc->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hsudc->regs) {
-		dev_err(dev, "error mapping device register area\n");
-		ret = -EBUSY;
+	hsudc->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hsudc->regs)) {
+		ret = PTR_ERR(hsudc->regs);
 		goto err_res;
 	}
 
drivers/usb/host/ehci-atmel.c +3 -4
index 27639487..f3beac4 100644
@@ -143,10 +143,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (hcd->regs == NULL) {
-		dev_dbg(&pdev->dev, "error mapping memory\n");
-		retval = -EFAULT;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		retval = PTR_ERR(hcd->regs);
 		goto fail_request_resource;
 	}
 
drivers/usb/host/ehci-grlib.c +4 -5
index 1fc8929..5d75de9 100644
@@ -25,7 +25,7 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-
+#include <linux/err.h>
 #include <linux/signal.h>
 
 #include <linux/of_irq.h>
@@ -118,10 +118,9 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
 		goto err_irq;
 	}
 
-	hcd->regs = devm_request_and_ioremap(&op->dev, &res);
-	if (!hcd->regs) {
-		pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
-		rv = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&op->dev, &res);
+	if (IS_ERR(hcd->regs)) {
+		rv = PTR_ERR(hcd->regs);
 		goto err_ioremap;
 	}
 
drivers/usb/host/ehci-mxc.c +3 -4
index ec7f5d2..4f506af 100644
@@ -128,10 +128,9 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hcd->regs) {
-		dev_err(dev, "error mapping memory\n");
-		ret = -EFAULT;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		ret = PTR_ERR(hcd->regs);
 		goto err_alloc;
 	}
 
drivers/usb/host/ehci-platform.c +4 -3
index 58fa0c9..ca75063 100644
@@ -18,6 +18,7 @@
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/hrtimer.h>
 #include <linux/io.h>
@@ -104,9 +105,9 @@ static int ehci_platform_probe(struct platform_device *dev)
 	hcd->rsrc_start = res_mem->start;
 	hcd->rsrc_len = resource_size(res_mem);
 
-	hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
-	if (!hcd->regs) {
-		err = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
+	if (IS_ERR(hcd->regs)) {
+		err = PTR_ERR(hcd->regs);
 		goto err_put_hcd;
 	}
 	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
drivers/usb/host/ehci-ppc-of.c +4 -4
index 45aceef..56dc732 100644
@@ -12,6 +12,7 @@
  * This file is licenced under the GPL.
  */
 
+#include <linux/err.h>
 #include <linux/signal.h>
 
 #include <linux/of.h>
@@ -121,10 +122,9 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
 		goto err_irq;
 	}
 
-	hcd->regs = devm_request_and_ioremap(&op->dev, &res);
-	if (!hcd->regs) {
-		pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
-		rv = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&op->dev, &res);
+	if (IS_ERR(hcd->regs)) {
+		rv = PTR_ERR(hcd->regs);
 		goto err_ioremap;
 	}
 
drivers/usb/host/ehci-sead3.c +4 -4
index efad02d..f55477c 100644
@@ -19,6 +19,7 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/err.h>
 #include <linux/platform_device.h>
 
 static int ehci_sead3_setup(struct usb_hcd *hcd)
@@ -112,10 +113,9 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hcd->regs) {
-		pr_debug("ioremap failed");
-		ret = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		ret = PTR_ERR(hcd->regs);
 		goto err1;
 	}
 
drivers/usb/host/ehci-sh.c +3 -4
index 0c90a24..3565a30 100644
@@ -118,10 +118,9 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (hcd->regs == NULL) {
-		dev_dbg(&pdev->dev, "error mapping memory\n");
-		ret = -ENXIO;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		ret = PTR_ERR(hcd->regs);
 		goto fail_request_resource;
 	}
 
drivers/usb/host/ehci-vt8500.c +4 -4
index 11695d5..7ecf709 100644
@@ -16,6 +16,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
@@ -96,10 +97,9 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hcd->regs) {
-		pr_debug("ioremap failed");
-		ret = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		ret = PTR_ERR(hcd->regs);
 		goto err1;
 	}
 
drivers/usb/host/ehci-xilinx-of.c +4 -4
index 4f285e8..d845e3b 100644
@@ -25,6 +25,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/signal.h>
 
 #include <linux/of.h>
@@ -159,10 +160,9 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
 		goto err_irq;
 	}
 
-	hcd->regs = devm_request_and_ioremap(&op->dev, &res);
-	if (!hcd->regs) {
-		pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
-		rv = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&op->dev, &res);
+	if (IS_ERR(hcd->regs)) {
+		rv = PTR_ERR(hcd->regs);
 		goto err_irq;
 	}
 
drivers/usb/host/ohci-nxp.c +3 -4
index 2344040..f4988fb 100644
@@ -306,10 +306,9 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev)
 		goto out8;
 	}
 
-	hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hcd->regs) {
-		dev_err(&pdev->dev, "Failed to devm_request_and_ioremap\n");
-		ret =  -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		ret = PTR_ERR(hcd->regs);
 		goto out8;
 	}
 	hcd->rsrc_start = res->start;
drivers/usb/host/ohci-platform.c +4 -3
index 084503b..c3e7287 100644
@@ -13,6 +13,7 @@
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
+#include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/usb/ohci_pdriver.h>
 
@@ -127,9 +128,9 @@ static int ohci_platform_probe(struct platform_device *dev)
 	hcd->rsrc_start = res_mem->start;
 	hcd->rsrc_len = resource_size(res_mem);
 
-	hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
-	if (!hcd->regs) {
-		err = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
+	if (IS_ERR(hcd->regs)) {
+		err = PTR_ERR(hcd->regs);
 		goto err_put_hcd;
 	}
 	err = usb_add_hcd(hcd, irq, IRQF_SHARED);
drivers/usb/host/ohci-s3c2410.c +3 -4
index ad0f552..e125770 100644
@@ -351,10 +351,9 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
 	hcd->rsrc_start = dev->resource[0].start;
 	hcd->rsrc_len	= resource_size(&dev->resource[0]);
 
-	hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
-	if (!hcd->regs) {
-		dev_err(&dev->dev, "devm_request_and_ioremap failed\n");
-		retval = -ENOMEM;
+	hcd->regs = devm_ioremap_resource(&dev->dev, &dev->resource[0]);
+	if (IS_ERR(hcd->regs)) {
+		retval = PTR_ERR(hcd->regs);
 		goto err_put;
 	}
 
drivers/usb/musb/musb_dsps.c +3 -4
index f7d764d..99f470d 100644
@@ -500,10 +500,9 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
 	resources[0].end = resources[0].start + SZ_4 - 1;
 	resources[0].flags = IORESOURCE_MEM;
 
-	glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, resources);
-	if (glue->usb_ctrl[id] == NULL) {
-		dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id);
-		ret = -ENODEV;
+	glue->usb_ctrl[id] = devm_ioremap_resource(&pdev->dev, resources);
+	if (IS_ERR(glue->usb_ctrl[id])) {
+		ret = PTR_ERR(glue->usb_ctrl[id]);
 		goto err0;
 	}
 
drivers/usb/musb/omap2430.c +1 -3
index da00af4..acd5f9d 100644
@@ -523,9 +523,7 @@ static int omap2430_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 
-	glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res);
-	if (glue->control_otghs == NULL)
-		dev_dbg(&pdev->dev, "Failed to obtain control memory\n");
+	glue->control_otghs = devm_ioremap_resource(&pdev->dev, res);
 
 	if (np) {
 		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
drivers/usb/otg/mxs-phy.c +3 -3
index 7630272..60df28a 100644
@@ -115,9 +115,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!base)
-		return -EBUSY;
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
drivers/usb/phy/mv_u3d_phy.c +3 -5
index eaddbe3..9d85991 100644
@@ -283,11 +283,9 @@ static int mv_u3d_phy_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	phy_base = devm_request_and_ioremap(dev, res);
-	if (!phy_base) {
-		dev_err(dev, "%s: register mapping failed\n", __func__);
-		return -ENXIO;
-	}
+	phy_base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(phy_base))
+		return PTR_ERR(phy_base);
 
 	mv_u3d_phy = devm_kzalloc(dev, sizeof(*mv_u3d_phy), GFP_KERNEL);
 	if (!mv_u3d_phy)
drivers/usb/phy/omap-usb2.c +3 -5
index 26ae8f4..2fdb8ed 100644
@@ -168,11 +168,9 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 
-	phy->control_dev = devm_request_and_ioremap(&pdev->dev, res);
-	if (phy->control_dev == NULL) {
-		dev_err(&pdev->dev, "Failed to obtain io memory\n");
-		return -ENXIO;
-	}
+	phy->control_dev = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(phy->control_dev))
+		return PTR_ERR(phy->control_dev);
 
 	phy->is_suspended	= 1;
 	omap_usb_phy_power(phy, 0);
drivers/usb/renesas_usbhs/common.c +4 -5
index 38bce04..cfd2050 100644
@@ -14,6 +14,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -443,11 +444,9 @@ static int usbhs_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	priv->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!priv->base) {
-		dev_err(&pdev->dev, "ioremap error.\n");
-		return -ENOMEM;
-	}
+	priv->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
 
 	/*
 	 * care platform info
Signature · 1 line
1.8.1.1
maintainer Acked-by on v1 29/33
#74 lore raw

Re: [PATCH 29/33] usb: Convert to devm_ioremap_resource()

Quoted 11 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Stern <[email protected]>
Cc Felipe Balbi <[email protected]>

For the EHCI and OHCI changes:

Acked-by on v1 29/33
#75 lore raw

Re: [PATCH 29/33] usb: Convert to devm_ioremap_resource()

In reply to Thierry Reding
Quoted 11 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Greg Kroah-Hartman <[email protected]>
Cc Alan Stern <[email protected]>
Cc Felipe Balbi <[email protected]>

For drivers/usb/renenas, drivers/usb/otg, drivers/usb/phy, drivers/usb/musb and drivers/usb/gadget:

Signature · 1 line
balbi
#76 lore raw

PATCH 30/33 video: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Florian Tobias Schandinat <[email protected]>
---
 drivers/video/exynos/exynos_dp_core.c | 8 +++-----
 drivers/video/jz4740_fb.c             | 6 +++---
 drivers/video/omap2/dss/hdmi.c        | 8 +++-----
 drivers/video/omap2/vrfb.c            | 9 ++++-----
 drivers/video/s3c-fb.c                | 7 +++----
 5 files changed, 16 insertions(+), 22 deletions(-)
drivers/video/exynos/exynos_dp_core.c +3 -5
index 4ef18e2..7aae0bf 100644
@@ -1076,11 +1076,9 @@ static int exynos_dp_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	dp->reg_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!dp->reg_base) {
-		dev_err(&pdev->dev, "failed to ioremap\n");
-		return -ENOMEM;
-	}
+	dp->reg_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(dp->reg_base))
+		return PTR_ERR(dp->reg_base);
 
 	dp->irq = platform_get_irq(pdev, 0);
 	if (dp->irq = -ENXIO) {
drivers/video/jz4740_fb.c +3 -3
index d999bb5..36979b4 100644
@@ -660,9 +660,9 @@ static int jzfb_probe(struct platform_device *pdev)
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	jzfb->base = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!jzfb->base) {
-		ret = -EBUSY;
+	jzfb->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(jzfb->base)) {
+		ret = PTR_ERR(jzfb->base);
 		goto err_framebuffer_release;
 	}
 
drivers/video/omap2/dss/hdmi.c +3 -5
index 769d082..7292364 100644
@@ -1080,11 +1080,9 @@ static int __init omapdss_hdmihw_probe(struct platform_device *pdev)
 	}
 
 	/* Base address taken from platform */
-	hdmi.ip_data.base_wp = devm_request_and_ioremap(&pdev->dev, res);
-	if (!hdmi.ip_data.base_wp) {
-		DSSERR("can't ioremap WP\n");
-		return -ENOMEM;
-	}
+	hdmi.ip_data.base_wp = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hdmi.ip_data.base_wp))
+		return PTR_ERR(hdmi.ip_data.base_wp);
 
 	r = hdmi_get_clocks(pdev);
 	if (r) {
drivers/video/omap2/vrfb.c +4 -5
index 5d8fdac..10560ef 100644
@@ -20,6 +20,7 @@
 
 /*#define DEBUG*/
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/ioport.h>
@@ -357,11 +358,9 @@ static int __init vrfb_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	vrfb_base = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!vrfb_base) {
-		dev_err(&pdev->dev, "can't ioremap vrfb memory\n");
-		return -ENOMEM;
-	}
+	vrfb_base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(vrfb_base))
+		return PTR_ERR(vrfb_base);
 
 	num_ctxs = pdev->num_resources - 1;
 
drivers/video/s3c-fb.c +3 -4
index 9b57a23..968a625 100644
@@ -1421,10 +1421,9 @@ static int s3c_fb_probe(struct platform_device *pdev)
 	pm_runtime_enable(sfb->dev);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	sfb->regs = devm_request_and_ioremap(dev, res);
-	if (!sfb->regs) {
-		dev_err(dev, "failed to map registers\n");
-		ret = -ENXIO;
+	sfb->regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(sfb->regs)) {
+		ret = PTR_ERR(sfb->regs);
 		goto err_lcd_clk;
 	}
 
Signature · 1 line
1.8.1.1
Acked-by on v1 30/33
#77 lore raw

Re: [PATCH 30/33] video: Convert to devm_ioremap_resource()

On Monday, January 21, 2013 7:09 PM, Thierry wrote

Quoted 10 lines

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Florian Tobias Schandinat <[email protected]>
Quoted 8 lines
---
 drivers/video/exynos/exynos_dp_core.c | 8 +++-----
 drivers/video/jz4740_fb.c             | 6 +++---
 drivers/video/omap2/dss/hdmi.c        | 8 +++-----
 drivers/video/omap2/vrfb.c            | 9 ++++-----
 drivers/video/s3c-fb.c                | 7 +++----
 5 files changed, 16 insertions(+), 22 deletions(-)

For drivers/video/s3c-fb.c, drivers/video/exynos/exynos_dp_core.c

Best regards,
Jingoo Han

#78 lore raw

PATCH 31/33 w1: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Evgeniy Polyakov <[email protected]>
---
 drivers/w1/masters/omap_hdq.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/w1/masters/omap_hdq.c +3 -5
index 184dbce..db2390a 100644
@@ -560,11 +560,9 @@ static int omap_hdq_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	hdq_data->hdq_base = devm_request_and_ioremap(dev, res);
-	if (!hdq_data->hdq_base) {
-		dev_dbg(&pdev->dev, "ioremap failed\n");
-		return -ENOMEM;
-	}
+	hdq_data->hdq_base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(hdq_data->hdq_base))
+		return PTR_ERR(hdq_data->hdq_base);
 
 	hdq_data->hdq_usecount = 0;
 	mutex_init(&hdq_data->hdq_mutex);
Signature · 1 line
1.8.1.1
Acked-by on v1 31/33
#79 lore raw

Re: [PATCH 31/33] w1: Convert to devm_ioremap_resource()

Hi

Quoted 8 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

Cc Evgeniy Polyakov <[email protected]>

Looks good to me

Signature · 1 line
	Evgeniy Polyakov
#80 lore raw

PATCH 32/33 watchdog: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 drivers/watchdog/ar7_wdt.c     | 8 +++-----
 drivers/watchdog/dw_wdt.c      | 6 +++---
 drivers/watchdog/imx2_wdt.c    | 8 +++-----
 drivers/watchdog/jz4740_wdt.c  | 6 +++---
 drivers/watchdog/lantiq_wdt.c  | 8 +++-----
 drivers/watchdog/max63xx_wdt.c | 7 ++++---
 drivers/watchdog/pnx4008_wdt.c | 6 +++---
 drivers/watchdog/txx9wdt.c     | 6 +++---
 8 files changed, 25 insertions(+), 30 deletions(-)
drivers/watchdog/ar7_wdt.c +3 -5
index 3003e2a..2f3cc8f 100644
@@ -285,11 +285,9 @@ static int ar7_wdt_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ar7_wdt = devm_request_and_ioremap(&pdev->dev, ar7_regs_wdt);
-	if (!ar7_wdt) {
-		pr_err("could not ioremap registers\n");
-		return -ENXIO;
-	}
+	ar7_wdt = devm_ioremap_resource(&pdev->dev, ar7_regs_wdt);
+	if (IS_ERR(ar7_wdt))
+		return PTR_ERR(ar7_wdt);
 
 	vbus_clk = clk_get(NULL, "vbus");
 	if (IS_ERR(vbus_clk)) {
drivers/watchdog/dw_wdt.c +3 -3
index a0eba3c..2037669 100644
@@ -301,9 +301,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
 	if (!mem)
 		return -EINVAL;
 
-	dw_wdt.regs = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!dw_wdt.regs)
-		return -ENOMEM;
+	dw_wdt.regs = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(dw_wdt.regs))
+		return PTR_ERR(dw_wdt.regs);
 
 	dw_wdt.clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(dw_wdt.clk))
drivers/watchdog/imx2_wdt.c +3 -5
index 9a45d029..7f023e2 100644
@@ -262,11 +262,9 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	imx2_wdt.base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!imx2_wdt.base) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		return -ENOMEM;
-	}
+	imx2_wdt.base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(imx2_wdt.base))
+		return PTR_ERR(imx2_wdt.base);
 
 	imx2_wdt.clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(imx2_wdt.clk)) {
drivers/watchdog/jz4740_wdt.c +3 -3
index a61408f..1cb25f6 100644
@@ -171,9 +171,9 @@ static int jz4740_wdt_probe(struct platform_device *pdev)
 	watchdog_set_drvdata(jz4740_wdt, drvdata);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	drvdata->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (drvdata->base == NULL) {
-		ret = -EBUSY;
+	drvdata->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(drvdata->base)) {
+		ret = PTR_ERR(drvdata->base);
 		goto err_out;
 	}
 
drivers/watchdog/lantiq_wdt.c +3 -5
index 79fe01b..088fd0c 100644
@@ -197,11 +197,9 @@ ltq_wdt_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
-	ltq_wdt_membase = devm_request_and_ioremap(&pdev->dev, res);
-	if (!ltq_wdt_membase) {
-		dev_err(&pdev->dev, "cannot remap I/O memory region\n");
-		return -ENOMEM;
-	}
+	ltq_wdt_membase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ltq_wdt_membase))
+		return PTR_ERR(ltq_wdt_membase);
 
 	/* we do not need to enable the clock as it is always running */
 	clk = clk_get_io();
drivers/watchdog/max63xx_wdt.c +4 -3
index 773c661..cc9d328 100644
@@ -14,6 +14,7 @@
  * another interface, some abstraction will have to be introduced.
  */
 
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/types.h>
@@ -198,9 +199,9 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
 	heartbeat = current_timeout->twd;
 
 	wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	wdt_base = devm_request_and_ioremap(&pdev->dev, wdt_mem);
-	if (!wdt_base)
-		return -ENOMEM;
+	wdt_base = devm_ioremap_resource(&pdev->dev, wdt_mem);
+	if (IS_ERR(wdt_base))
+		return PTR_ERR(wdt_base);
 
 	max63xx_wdt_dev.timeout = heartbeat;
 	watchdog_set_nowayout(&max63xx_wdt_dev, nowayout);
drivers/watchdog/pnx4008_wdt.c +3 -3
index dcba5da..de1f3fa 100644
@@ -155,9 +155,9 @@ static int pnx4008_wdt_probe(struct platform_device *pdev)
 		heartbeat = DEFAULT_HEARTBEAT;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	wdt_base = devm_request_and_ioremap(&pdev->dev, r);
-	if (!wdt_base)
-		return -EADDRINUSE;
+	wdt_base = devm_ioremap_resource(&pdev->dev, r);
+	if (IS_ERR(wdt_base))
+		return PTR_ERR(wdt_base);
 
 	wdt_clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(wdt_clk))
drivers/watchdog/txx9wdt.c +3 -3
index 98e1637..626dc0b 100644
@@ -121,9 +121,9 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 	}
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	txx9wdt_reg = devm_request_and_ioremap(&dev->dev, res);
-	if (!txx9wdt_reg) {
-		ret = -EBUSY;
+	txx9wdt_reg = devm_ioremap_resource(&dev->dev, res);
+	if (IS_ERR(txx9wdt_reg)) {
+		ret = PTR_ERR(txx9wdt_reg);
 		goto exit;
 	}
 
Signature · 1 line
1.8.1.1
#81 lore raw

PATCH 33/33 ASoC: Convert to devm_ioremap_resource()

In reply to Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit error messages can be removed from the failure code paths.

---
 sound/soc/cirrus/ep93xx-ac97.c    | 7 ++++---
 sound/soc/cirrus/ep93xx-i2s.c     | 6 +++---
 sound/soc/codecs/jz4740.c         | 6 +++---
 sound/soc/fsl/imx-audmux.c        | 6 +++---
 sound/soc/fsl/imx-ssi.c           | 7 +++----
 sound/soc/kirkwood/kirkwood-i2s.c | 8 +++-----
 sound/soc/mxs/mxs-saif.c          | 8 +++-----
 sound/soc/pxa/mmp-sspa.c          | 6 +++---
 8 files changed, 25 insertions(+), 29 deletions(-)
sound/soc/cirrus/ep93xx-ac97.c +4 -3
index f3f50e6..1738d28 100644
@@ -11,6 +11,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/init.h>
 #include <linux/module.h>
@@ -367,9 +368,9 @@ static int ep93xx_ac97_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENODEV;
 
-	info->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!info->regs)
-		return -ENXIO;
+	info->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(info->regs))
+		return PTR_ERR(info->regs);
 
 	irq = platform_get_irq(pdev, 0);
 	if (!irq)
sound/soc/cirrus/ep93xx-i2s.c +3 -3
index 3365d4e..323ed69 100644
@@ -380,9 +380,9 @@ static int ep93xx_i2s_probe(struct platform_device *pdev)
 	if (!res)
 		return -ENODEV;
 
-	info->regs = devm_request_and_ioremap(&pdev->dev, res);
-	if (!info->regs)
-		return -ENXIO;
+	info->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(info->regs))
+		return PTR_ERR(info->regs);
 
 	info->mclk = clk_get(&pdev->dev, "mclk");
 	if (IS_ERR(info->mclk)) {
sound/soc/codecs/jz4740.c +3 -3
index d991529..5f607b3 100644
@@ -361,9 +361,9 @@ static int jz4740_codec_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	base = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!base)
-		return -EBUSY;
+	base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	jz4740_codec->regmap = devm_regmap_init_mmio(&pdev->dev, base,
 					    &jz4740_codec_regmap_config);
sound/soc/fsl/imx-audmux.c +3 -3
index 251f4d9..c21ac9c 100644
@@ -252,9 +252,9 @@ static int imx_audmux_probe(struct platform_device *pdev)
 			of_match_device(imx_audmux_dt_ids, &pdev->dev);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	audmux_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!audmux_base)
-		return -EADDRNOTAVAIL;
+	audmux_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(audmux_base))
+		return PTR_ERR(audmux_base);
 
 	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
 	if (IS_ERR(pinctrl)) {
sound/soc/fsl/imx-ssi.c +3 -4
index 3b48042..55464a5 100644
@@ -550,10 +550,9 @@ static int imx_ssi_probe(struct platform_device *pdev)
 		goto failed_get_resource;
 	}
 
-	ssi->base = devm_request_and_ioremap(&pdev->dev, res);
-	if (!ssi->base) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		ret = -ENODEV;
+	ssi->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(ssi->base)) {
+		ret = PTR_ERR(ssi->base);
 		goto failed_register;
 	}
 
sound/soc/kirkwood/kirkwood-i2s.c +3 -5
index 282d8b1..c74c890 100644
@@ -472,11 +472,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	priv->io = devm_request_and_ioremap(&pdev->dev, mem);
-	if (!priv->io) {
-		dev_err(&pdev->dev, "devm_request_and_ioremap failed\n");
-		return -ENOMEM;
-	}
+	priv->io = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(priv->io))
+		return PTR_ERR(priv->io);
 
 	priv->irq = platform_get_irq(pdev, 0);
 	if (priv->irq <= 0) {
sound/soc/mxs/mxs-saif.c +3 -5
index 365d9d2..b327709 100644
@@ -724,11 +724,9 @@ static int mxs_saif_probe(struct platform_device *pdev)
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	saif->base = devm_request_and_ioremap(&pdev->dev, iores);
-	if (!saif->base) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		return -ENODEV;
-	}
+	saif->base = devm_ioremap_resource(&pdev->dev, iores);
+	if (IS_ERR(saif->base))
+		return PTR_ERR(saif->base);
 
 	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	if (!dmares) {
sound/soc/pxa/mmp-sspa.c +3 -3
index 41c3a09..9140c4a 100644
@@ -429,9 +429,9 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
 	if (res == NULL)
 		return -ENOMEM;
 
-	priv->sspa->mmio_base = devm_request_and_ioremap(&pdev->dev, res);
-	if (priv->sspa->mmio_base == NULL)
-		return -ENODEV;
+	priv->sspa->mmio_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->sspa->mmio_base))
+		return PTR_ERR(priv->sspa->mmio_base);
 
 	priv->sspa->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(priv->sspa->clk))
Signature · 1 line
1.8.1.1
Applied
#82 lore raw

Re: [PATCH 33/33] ASoC: Convert to devm_ioremap_resource()

Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Applied, thanks.

#83 lore raw

Re: [PATCH 33/33] ASoC: Convert to devm_ioremap_resource()

Quoted 5 lines · Mark Brown
Quoted 2 lines · Thierry Reding

Convert all uses of devm_request_and_ioremap() to the newly introduced devm_ioremap_resource() which provides more consistent error handling.

Applied, thanks.

It's probably too early to apply this yet since the first patch in the series, which introduces the new function, hasn't been merged yet. I seem to have handled this poorly, as David Miller already pointed out, by not Cc'ing everyone involved on the first patch.

Thierry

#84 lore raw

Re: [PATCH 33/33] ASoC: Convert to devm_ioremap_resource()

Quoted 4 lines · Thierry Reding

It's probably too early to apply this yet since the first patch in the series, which introduces the new function, hasn't been merged yet. I seem to have handled this poorly, as David Miller already pointed out, by not Cc'ing everyone involved on the first patch.

Oh, well. Dropped then. Acked-by instead.

Nacked-by on the v1 series NAK
#85 lore raw
In reply to Thierry Reding
Quoted 24 lines · Thierry Reding

Recent discussions about the lack of a meaningful error code returned by devm_request_and_ioremap() have triggered this patch series. One common issue is that the function returns NULL in all failure cases, making it impossible to determine what went wrong exactly. Another problem is that people can't seem to agree on what error code to return in case where the function fails. Both of these problems lead to inconsistent usage.

This series attempts to fix this by providing a replacement function, devm_ioremap_resource(), which returns a pointer to the remapped memory region on success and an ERR_PTR()-encoded error code on failure. Users can check for failure using the IS_ERR() macro and determine the exact cause by extracting the error code using PTR_ERR().

Patch 1 adds the new devm_ioremap_resource() function, which is really just a renamed version of devm_request_and_ioremap() that returns ERR_PTR()-encoded error codes on failure and makes the old function a wrapper around it, returning NULL in case of devm_ioremap_resource() failure. Furthermore the patch marks devm_request_and_ioremap() as a deprecated function to make it clear that it should no longer be used. A semantic patch is included that was used to convert the bulk of the existing calls to devm_request_and_ioremap() to the new API. The patch is far from perfect and a few occurrences had to be converted or fixed up manually.

Quoted 4 lines

The remaining patches convert each subsystem separately to use the new API.

Thierry

I know that this series has wide support and will probably be merged, but I'm reply to this for the record. I do not think the ERR_PTR pattern is a good idea because it goes against expectations of what is and is not a valid pointer.

Greg, if you're merging this series then don't let my objection inhibit spi & gpio changes. I may not be happy, but I won't be an ass about it.

g.