public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 00/42] devm improvement series, part #1
@ 2013-05-10  8:16 Wolfram Sang
  2013-05-10  8:16 ` [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource Wolfram Sang
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wan ZongShun, linux-mips, alsa-devel, linux-usb, Kevin Hilman,
	Wolfram Sang, Alexander Shishkin, Viresh Kumar, Linus Walleij,
	Matt Mackall, Sekhar Nori, linux-fbdev, dri-devel,
	Jaroslav Kysela, linux-ide, Wim Van Sebroeck, netdev, linux-mtd,
	linux-i2c, Evgeniy Polyakov, Jiri Slaby, ac100, devel, Kukjin Kim,
	Russell King, Herbert Xu, Florian

Lately, I have been experimenting how to improve the devm interface to make
writing device drivers easier and less error prone while also getting rid of
its subtle issues. I think it has more potential but still needs work and
definately conistency, especiall in its usage.

The first thing I come up with is a low hanging fruit regarding
devm_ioremap_resouce(). This function already checks if the passed resource is
valid and gives an error message if not. So, we can remove similar checks from
the drivers and get rid of a bit of code and a number of inconsistent error
strings.

If generally accepted, I'd suggest I rerun my scripts again when rc1 is out and
ask Linus to pull this branch [1] directly? This series is merely to show what
I am up to.

Thanks,

   Wolfram

[1] git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git devm_no_resource_check

Wolfram Sang (42):
  drivers/ata: don't check resource with devm_ioremap_resource
  drivers/char/hw_random: don't check resource with
    devm_ioremap_resource
  drivers/cpufreq: don't check resource with devm_ioremap_resource
  drivers/dma: don't check resource with devm_ioremap_resource
  drivers/gpio: don't check resource with devm_ioremap_resource
  drivers/gpu/drm/exynos: don't check resource with
    devm_ioremap_resource
  drivers/gpu/host1x: don't check resource with devm_ioremap_resource
  drivers/gpu/host1x/drm: don't check resource with
    devm_ioremap_resource
  drivers/i2c/busses: don't check resource with devm_ioremap_resource
  drivers/input/keyboard: don't check resource with
    devm_ioremap_resource
  drivers/input/serio: don't check resource with devm_ioremap_resource
  drivers/memory: don't check resource with devm_ioremap_resource
  drivers/mfd: don't check resource with devm_ioremap_resource
  drivers/misc: don't check resource with devm_ioremap_resource
  drivers/mtd/maps: don't check resource with devm_ioremap_resource
  drivers/mtd/nand: don't check resource with devm_ioremap_resource
  drivers/net/ethernet/renesas: don't check resource with
    devm_ioremap_resource
  drivers/pinctrl: don't check resource with devm_ioremap_resource
  drivers/pinctrl/spear: don't check resource with
    devm_ioremap_resource
  drivers/pwm: don't check resource with devm_ioremap_resource
  drivers/remoteproc: don't check resource with devm_ioremap_resource
  drivers/rtc: don't check resource with devm_ioremap_resource
  drivers/spi: don't check resource with devm_ioremap_resource
  drivers/staging/dwc2: don't check resource with devm_ioremap_resource
  drivers/staging/nvec: don't check resource with devm_ioremap_resource
  drivers/thermal: don't check resource with devm_ioremap_resource
  drivers/tty/serial: don't check resource with devm_ioremap_resource
  drivers/usb/chipidea: don't check resource with devm_ioremap_resource
  drivers/usb/gadget: don't check resource with devm_ioremap_resource
  drivers/usb/host: don't check resource with devm_ioremap_resource
  drivers/usb/phy: don't check resource with devm_ioremap_resource
  drivers/video: don't check resource with devm_ioremap_resource
  drivers/video/omap2: don't check resource with devm_ioremap_resource
  drivers/video/omap2/dss: don't check resource with
    devm_ioremap_resource
  drivers/w1/masters: don't check resource with devm_ioremap_resource
  drivers/watchdog: don't check resource with devm_ioremap_resource
  arch/arm/mach-tegra: don't check resource with devm_ioremap_resource
  arch/arm/plat-omap: don't check resource with devm_ioremap_resource
  arch/arm/plat-samsung: don't check resource with
    devm_ioremap_resource
  arch/mips/lantiq/xway: don't check resource with
    devm_ioremap_resource
  sound/soc/fsl: don't check resource with devm_ioremap_resource
  sound/soc/kirkwood: don't check resource with devm_ioremap_resource

 arch/arm/mach-tegra/tegra2_emc.c            |    5 -----
 arch/arm/plat-omap/dmtimer.c                |    7 +------
 arch/arm/plat-samsung/adc.c                 |    5 -----
 arch/mips/lantiq/xway/gptu.c                |    7 +------
 drivers/ata/pata_ep93xx.c                   |    5 -----
 drivers/char/hw_random/mxc-rnga.c           |    6 ------
 drivers/char/hw_random/omap-rng.c           |    5 -----
 drivers/cpufreq/kirkwood-cpufreq.c          |    4 ----
 drivers/dma/tegra20-apb-dma.c               |    5 -----
 drivers/gpio/gpio-mvebu.c                   |   12 +-----------
 drivers/gpio/gpio-spear-spics.c             |    7 +------
 drivers/gpio/gpio-tegra.c                   |    5 -----
 drivers/gpu/drm/exynos/exynos_hdmi.c        |    5 -----
 drivers/gpu/host1x/dev.c                    |    7 +------
 drivers/gpu/host1x/drm/dc.c                 |    5 -----
 drivers/i2c/busses/i2c-davinci.c            |    6 +-----
 drivers/i2c/busses/i2c-designware-platdrv.c |    6 +-----
 drivers/i2c/busses/i2c-imx.c                |    6 +-----
 drivers/i2c/busses/i2c-omap.c               |    6 +-----
 drivers/i2c/busses/i2c-rcar.c               |    7 +------
 drivers/i2c/busses/i2c-s3c2410.c            |    5 -----
 drivers/i2c/busses/i2c-sirf.c               |    6 ------
 drivers/i2c/busses/i2c-tegra.c              |    5 -----
 drivers/input/keyboard/imx_keypad.c         |    7 +------
 drivers/input/keyboard/spear-keyboard.c     |    7 +------
 drivers/input/keyboard/tegra-kbc.c          |    7 +------
 drivers/input/serio/arc_ps2.c               |    7 +------
 drivers/memory/emif.c                       |    6 ------
 drivers/mfd/intel_msic.c                    |    6 +-----
 drivers/misc/atmel-ssc.c                    |    5 -----
 drivers/mtd/maps/autcpu12-nvram.c           |    7 +------
 drivers/mtd/maps/lantiq-flash.c             |    8 +-------
 drivers/mtd/nand/lpc32xx_mlc.c              |    5 -----
 drivers/mtd/nand/lpc32xx_slc.c              |    7 +------
 drivers/net/ethernet/renesas/sh_eth.c       |   14 +-------------
 drivers/pinctrl/pinctrl-at91.c              |    7 +------
 drivers/pinctrl/pinctrl-coh901.c            |    5 -----
 drivers/pinctrl/pinctrl-exynos5440.c        |    5 -----
 drivers/pinctrl/pinctrl-samsung.c           |    5 -----
 drivers/pinctrl/pinctrl-xway.c              |    4 ----
 drivers/pinctrl/spear/pinctrl-plgpio.c      |    7 +------
 drivers/pwm/pwm-imx.c                       |    5 -----
 drivers/pwm/pwm-puv3.c                      |    5 -----
 drivers/pwm/pwm-pxa.c                       |    5 -----
 drivers/pwm/pwm-spear.c                     |    7 +------
 drivers/pwm/pwm-tegra.c                     |    5 -----
 drivers/pwm/pwm-tiecap.c                    |    5 -----
 drivers/pwm/pwm-tiehrpwm.c                  |    5 -----
 drivers/pwm/pwm-tipwmss.c                   |    5 -----
 drivers/pwm/pwm-vt8500.c                    |    5 -----
 drivers/remoteproc/da8xx_remoteproc.c       |   14 +-------------
 drivers/rtc/rtc-nuc900.c                    |    6 +-----
 drivers/rtc/rtc-omap.c                      |    5 -----
 drivers/rtc/rtc-s3c.c                       |    5 -----
 drivers/rtc/rtc-spear.c                     |    7 +------
 drivers/rtc/rtc-tegra.c                     |    6 ------
 drivers/spi/spi-bcm63xx.c                   |    8 +-------
 drivers/spi/spi-ep93xx.c                    |    8 +-------
 drivers/spi/spi-omap2-mcspi.c               |    7 +------
 drivers/spi/spi-s3c64xx.c                   |    7 +------
 drivers/spi/spi-sirf.c                      |    7 +------
 drivers/spi/spi-tegra114.c                  |    7 +------
 drivers/spi/spi-tegra20-sflash.c            |    5 -----
 drivers/spi/spi-tegra20-slink.c             |    7 +------
 drivers/staging/dwc2/platform.c             |    5 -----
 drivers/staging/nvec/nvec.c                 |    5 -----
 drivers/thermal/dove_thermal.c              |   11 +----------
 drivers/thermal/exynos_thermal.c            |    5 -----
 drivers/thermal/kirkwood_thermal.c          |    7 +------
 drivers/thermal/rcar_thermal.c              |    6 +-----
 drivers/tty/serial/serial-tegra.c           |    6 +-----
 drivers/usb/chipidea/core.c                 |    5 -----
 drivers/usb/gadget/bcm63xx_udc.c            |   10 ----------
 drivers/usb/host/ehci-atmel.c               |    9 +--------
 drivers/usb/host/ehci-mxc.c                 |    8 +-------
 drivers/usb/host/ehci-platform.c            |    6 +-----
 drivers/usb/host/ehci-sh.c                  |   10 +---------
 drivers/usb/host/ohci-nxp.c                 |    6 ------
 drivers/usb/host/ohci-platform.c            |    7 +------
 drivers/usb/phy/phy-mv-u3d-usb.c            |    5 -----
 drivers/usb/phy/phy-mxs-usb.c               |    5 -----
 drivers/usb/phy/phy-samsung-usb2.c          |    5 -----
 drivers/usb/phy/phy-samsung-usb3.c          |    5 -----
 drivers/video/mxsfb.c                       |    7 +------
 drivers/video/omap2/dss/hdmi.c              |    7 +------
 drivers/video/omap2/vrfb.c                  |    5 -----
 drivers/w1/masters/omap_hdq.c               |    5 -----
 drivers/watchdog/imx2_wdt.c                 |    5 -----
 sound/soc/fsl/imx-ssi.c                     |    6 ------
 sound/soc/kirkwood/kirkwood-i2s.c           |    5 -----
 90 files changed, 43 insertions(+), 525 deletions(-)

-- 
1.7.10.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
@ 2013-05-10  8:16 ` Wolfram Sang
       [not found]   ` <1368173847-5661-5-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
       [not found] ` <1368173847-5661-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Vinod Koul, Dan Williams, Stephen Warren,
	linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/dma/tegra20-apb-dma.c |    5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index fcee27e..53e1375 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -1279,11 +1279,6 @@ static int tegra_dma_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, tdma);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "No mem resource for DMA\n");
-		return -EINVAL;
-	}
-
 	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(tdma->base_addr))
 		return PTR_ERR(tdma->base_addr);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 05/42] drivers/gpio: don't check resource with devm_ioremap_resource
       [not found] ` <1368173847-5661-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-10  8:16   ` Wolfram Sang
       [not found]     ` <1368173847-5661-6-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  0 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:16 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Wolfram Sang, Grant Likely, Linus Walleij, Stephen Warren,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
---
 drivers/gpio/gpio-mvebu.c       |   12 +-----------
 drivers/gpio/gpio-spear-spics.c |    7 +------
 drivers/gpio/gpio-tegra.c       |    5 -----
 3 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index bf69a7e..60e8c6e 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -566,12 +566,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	else
 		soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Cannot get memory resource\n");
-		return -ENODEV;
-	}
-
 	mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip), GFP_KERNEL);
 	if (!mvchip) {
 		dev_err(&pdev->dev, "Cannot allocate memory\n");
@@ -611,6 +605,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	mvchip->chip.dbg_show = mvebu_gpio_dbg_show;
 
 	spin_lock_init(&mvchip->lock);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mvchip->membase = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(mvchip->membase))
 		return PTR_ERR(mvchip->membase);
@@ -619,11 +614,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 	 * per-CPU registers */
 	if (soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) {
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-		if (!res) {
-			dev_err(&pdev->dev, "Cannot get memory resource\n");
-			return -ENODEV;
-		}
-
 		mvchip->percpu_membase = devm_ioremap_resource(&pdev->dev,
 							       res);
 		if (IS_ERR(mvchip->percpu_membase))
diff --git a/drivers/gpio/gpio-spear-spics.c b/drivers/gpio/gpio-spear-spics.c
index 7a4bf7c..e9a0415 100644
--- a/drivers/gpio/gpio-spear-spics.c
+++ b/drivers/gpio/gpio-spear-spics.c
@@ -128,18 +128,13 @@ static int spics_gpio_probe(struct platform_device *pdev)
 	struct resource *res;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "invalid IORESOURCE_MEM\n");
-		return -EBUSY;
-	}
-
 	spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL);
 	if (!spics) {
 		dev_err(&pdev->dev, "memory allocation fail\n");
 		return -ENOMEM;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	spics->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(spics->base))
 		return PTR_ERR(spics->base);
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index da4cb5b..9a62672 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -463,11 +463,6 @@ static int tegra_gpio_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "Missing MEM resource\n");
-		return -ENODEV;
-	}
-
 	regs = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(regs))
 		return PTR_ERR(regs);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 09/42] drivers/i2c/busses: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
  2013-05-10  8:16 ` [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource Wolfram Sang
       [not found] ` <1368173847-5661-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-10  8:16 ` Wolfram Sang
  2013-05-11  5:18   ` Jingoo Han
  2013-06-04 18:34   ` Kevin Hilman
  2013-05-10  8:16 ` [RFC 10/42] drivers/input/keyboard: " Wolfram Sang
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Sekhar Nori, Kevin Hilman, Tony Lindgren, Ben Dooks,
	Kukjin Kim, Barry Song, Stephen Warren, davinci-linux-open-source,
	linux-i2c, linux-omap, linux-arm-kernel, linux-samsung-soc,
	linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/i2c/busses/i2c-davinci.c            |    6 +-----
 drivers/i2c/busses/i2c-designware-platdrv.c |    6 +-----
 drivers/i2c/busses/i2c-imx.c                |    6 +-----
 drivers/i2c/busses/i2c-omap.c               |    6 +-----
 drivers/i2c/busses/i2c-rcar.c               |    7 +------
 drivers/i2c/busses/i2c-s3c2410.c            |    5 -----
 drivers/i2c/busses/i2c-sirf.c               |    6 ------
 drivers/i2c/busses/i2c-tegra.c              |    5 -----
 8 files changed, 5 insertions(+), 42 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index cf20e06..2ed3e7b 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -647,11 +647,6 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 	int r;
 
 	/* NOTE: driver uses the static register mapping */
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "no mem resource?\n");
-		return -ENODEV;
-	}
 
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!irq) {
@@ -697,6 +692,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 		return -ENODEV;
 	clk_prepare_enable(dev->clk);
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dev->base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(dev->base)) {
 		r = PTR_ERR(dev->base);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 8ec9133..6f3c612 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -87,11 +87,6 @@ static int dw_i2c_probe(struct platform_device *pdev)
 	int irq, r;
 
 	/* NOTE: driver uses the static register mapping */
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "no mem resource?\n");
-		return -EINVAL;
-	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
@@ -103,6 +98,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dev->base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(dev->base))
 		return PTR_ERR(dev->base);
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 82f20c6..b274ca1 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -500,17 +500,13 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "<%s>\n", __func__);
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "can't get device resources\n");
-		return -ENOENT;
-	}
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "can't get irq number\n");
 		return -ENOENT;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e02f9e3..8498ab7 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1085,11 +1085,6 @@ omap_i2c_probe(struct platform_device *pdev)
 	u16 minor, major, scheme;
 
 	/* NOTE: driver uses the static register mapping */
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem) {
-		dev_err(&pdev->dev, "no mem resource?\n");
-		return -ENODEV;
-	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
@@ -1103,6 +1098,7 @@ omap_i2c_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	dev->base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(dev->base))
 		return PTR_ERR(dev->base);
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 4ba4a95..0fc5858 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -623,12 +623,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	u32 bus_speed;
 	int ret;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "no mmio resources\n");
-		return -ENODEV;
-	}
-
 	priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL);
 	if (!priv) {
 		dev_err(dev, "no mem for private data\n");
@@ -642,6 +636,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	priv->io = devm_ioremap_resource(dev, res);
 	if (IS_ERR(priv->io))
 		return PTR_ERR(priv->io);
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 6e8ee92..cab1c91 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1082,11 +1082,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	/* map the registers */
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "cannot find IO resource\n");
-		return -ENOENT;
-	}
-
 	i2c->regs = devm_ioremap_resource(&pdev->dev, res);
 
 	if (IS_ERR(i2c->regs))
diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index 5a7ad24..a63c7d5 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -303,12 +303,6 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
 	adap->class = I2C_CLASS_HWMON;
 
 	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (mem_res == NULL) {
-		dev_err(&pdev->dev, "Unable to get MEM resource\n");
-		err = -EINVAL;
-		goto out;
-	}
-
 	siic->base = devm_ioremap_resource(&pdev->dev, mem_res);
 	if (IS_ERR(siic->base)) {
 		err = PTR_ERR(siic->base);
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index b60ff90..9aa1b60 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -714,11 +714,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 	int ret = 0;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no mem resource\n");
-		return -EINVAL;
-	}
-
 	base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 10/42] drivers/input/keyboard: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (2 preceding siblings ...)
  2013-05-10  8:16 ` [RFC 09/42] drivers/i2c/busses: " Wolfram Sang
@ 2013-05-10  8:16 ` Wolfram Sang
  2013-05-12 15:12   ` Viresh Kumar
  2013-05-10  8:17 ` [RFC 20/42] drivers/pwm: " Wolfram Sang
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Dmitry Torokhov, Stephen Warren, linux-input,
	linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/input/keyboard/imx_keypad.c     |    7 +------
 drivers/input/keyboard/spear-keyboard.c |    7 +------
 drivers/input/keyboard/tegra-kbc.c      |    7 +------
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
index 03c8cc5..328cfc1 100644
--- a/drivers/input/keyboard/imx_keypad.c
+++ b/drivers/input/keyboard/imx_keypad.c
@@ -442,12 +442,6 @@ static int imx_keypad_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "no I/O memory defined in platform data\n");
-		return -EINVAL;
-	}
-
 	input_dev = devm_input_allocate_device(&pdev->dev);
 	if (!input_dev) {
 		dev_err(&pdev->dev, "failed to allocate the input device\n");
@@ -468,6 +462,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
 	setup_timer(&keypad->check_matrix_timer,
 		    imx_keypad_check_for_events, (unsigned long) keypad);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(keypad->mmio_base))
 		return PTR_ERR(keypad->mmio_base);
diff --git a/drivers/input/keyboard/spear-keyboard.c b/drivers/input/keyboard/spear-keyboard.c
index cb1e8f6..b2e77e4 100644
--- a/drivers/input/keyboard/spear-keyboard.c
+++ b/drivers/input/keyboard/spear-keyboard.c
@@ -191,12 +191,6 @@ static int spear_kbd_probe(struct platform_device *pdev)
 	int irq;
 	int error;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no keyboard resource defined\n");
-		return -EBUSY;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "not able to get irq for the device\n");
@@ -228,6 +222,7 @@ static int spear_kbd_probe(struct platform_device *pdev)
 		kbd->suspended_rate = pdata->suspended_rate;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	kbd->io_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(kbd->io_base))
 		return PTR_ERR(kbd->io_base);
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index b46142f..9cd20e6 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -638,12 +638,6 @@ static int tegra_kbc_probe(struct platform_device *pdev)
 	if (!tegra_kbc_check_pin_cfg(kbc, &num_rows))
 		return -EINVAL;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "failed to get I/O memory\n");
-		return -ENXIO;
-	}
-
 	kbc->irq = platform_get_irq(pdev, 0);
 	if (kbc->irq < 0) {
 		dev_err(&pdev->dev, "failed to get keyboard IRQ\n");
@@ -658,6 +652,7 @@ static int tegra_kbc_probe(struct platform_device *pdev)
 
 	setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc);
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	kbc->mmio = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(kbc->mmio))
 		return PTR_ERR(kbc->mmio);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 20/42] drivers/pwm: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (3 preceding siblings ...)
  2013-05-10  8:16 ` [RFC 10/42] drivers/input/keyboard: " Wolfram Sang
@ 2013-05-10  8:17 ` Wolfram Sang
       [not found]   ` <1368173847-5661-21-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  2013-05-10  8:17 ` [RFC 22/42] drivers/rtc: " Wolfram Sang
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Thierry Reding, Stephen Warren, Tony Prisk,
	linux-tegra, linux-arm-kernel

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/pwm/pwm-imx.c      |    5 -----
 drivers/pwm/pwm-puv3.c     |    5 -----
 drivers/pwm/pwm-pxa.c      |    5 -----
 drivers/pwm/pwm-spear.c    |    7 +------
 drivers/pwm/pwm-tegra.c    |    5 -----
 drivers/pwm/pwm-tiecap.c   |    5 -----
 drivers/pwm/pwm-tiehrpwm.c |    5 -----
 drivers/pwm/pwm-tipwmss.c  |    5 -----
 drivers/pwm/pwm-vt8500.c   |    5 -----
 9 files changed, 1 insertion(+), 46 deletions(-)

diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index ec28798..c938bae 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -265,11 +265,6 @@ static int imx_pwm_probe(struct platform_device *pdev)
 	imx->chip.npwm = 1;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	imx->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(imx->mmio_base))
 		return PTR_ERR(imx->mmio_base);
diff --git a/drivers/pwm/pwm-puv3.c b/drivers/pwm/pwm-puv3.c
index d1eb499..ed6007b 100644
--- a/drivers/pwm/pwm-puv3.c
+++ b/drivers/pwm/pwm-puv3.c
@@ -117,11 +117,6 @@ static int pwm_probe(struct platform_device *pdev)
 		return PTR_ERR(puv3->clk);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	puv3->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(puv3->base))
 		return PTR_ERR(puv3->base);
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index dee6ab55..dc97175 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -147,11 +147,6 @@ static int pwm_probe(struct platform_device *pdev)
 	pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(pwm->mmio_base))
 		return PTR_ERR(pwm->mmio_base);
diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
index 6d99e2c..8af6ea8 100644
--- a/drivers/pwm/pwm-spear.c
+++ b/drivers/pwm/pwm-spear.c
@@ -178,18 +178,13 @@ static int spear_pwm_probe(struct platform_device *pdev)
 	int ret;
 	u32 val;
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "no memory resources defined\n");
-		return -ENODEV;
-	}
-
 	pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
 	if (!pc) {
 		dev_err(&pdev->dev, "failed to allocate memory\n");
 		return -ENOMEM;
 	}
 
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(pc->mmio_base))
 		return PTR_ERR(pc->mmio_base);
diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index 3d75f4a..a540293 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -181,11 +181,6 @@ static int tegra_pwm_probe(struct platform_device *pdev)
 	pwm->dev = &pdev->dev;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "no memory resources defined\n");
-		return -ENODEV;
-	}
-
 	pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(pwm->mmio_base))
 		return PTR_ERR(pwm->mmio_base);
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 0d65fb2..72ca42d 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -240,11 +240,6 @@ static int ecap_pwm_probe(struct platform_device *pdev)
 	pc->chip.npwm = 1;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(pc->mmio_base))
 		return PTR_ERR(pc->mmio_base);
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 6a21759..48a485c 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -471,11 +471,6 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
 	pc->chip.npwm = NUM_PWM_CHANNEL;
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	pc->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(pc->mmio_base))
 		return PTR_ERR(pc->mmio_base);
diff --git a/drivers/pwm/pwm-tipwmss.c b/drivers/pwm/pwm-tipwmss.c
index c9c3d3a..3b119bc 100644
--- a/drivers/pwm/pwm-tipwmss.c
+++ b/drivers/pwm/pwm-tipwmss.c
@@ -70,11 +70,6 @@ static int pwmss_probe(struct platform_device *pdev)
 	mutex_init(&info->pwmss_lock);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	info->mmio_base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(info->mmio_base))
 		return PTR_ERR(info->mmio_base);
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index 69effd1..323125a 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -230,11 +230,6 @@ static int vt8500_pwm_probe(struct platform_device *pdev)
 	}
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENODEV;
-	}
-
 	chip->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(chip->base))
 		return PTR_ERR(chip->base);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 22/42] drivers/rtc: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (4 preceding siblings ...)
  2013-05-10  8:17 ` [RFC 20/42] drivers/pwm: " Wolfram Sang
@ 2013-05-10  8:17 ` Wolfram Sang
       [not found]   ` <1368173847-5661-23-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  2013-05-10  8:17 ` [RFC 23/42] drivers/spi: " Wolfram Sang
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Wan ZongShun, Alessandro Zummo, Stephen Warren,
	linux-arm-kernel, rtc-linux, linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/rtc/rtc-nuc900.c |    6 +-----
 drivers/rtc/rtc-omap.c   |    5 -----
 drivers/rtc/rtc-s3c.c    |    5 -----
 drivers/rtc/rtc-spear.c  |    7 +------
 drivers/rtc/rtc-tegra.c  |    6 ------
 5 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c
index f5dfb6e..c0f54ec 100644
--- a/drivers/rtc/rtc-nuc900.c
+++ b/drivers/rtc/rtc-nuc900.c
@@ -233,12 +233,8 @@ static int __init nuc900_rtc_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n");
 		return -ENOMEM;
 	}
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "platform_get_resource failed\n");
-		return -ENXIO;
-	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	nuc900_rtc->rtc_reg = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(nuc900_rtc->rtc_reg))
 		return PTR_ERR(nuc900_rtc->rtc_reg);
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 4e1bdb8..b0ba3fc 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -347,11 +347,6 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		pr_debug("%s: RTC resource data missing\n", pdev->name);
-		return -ENOENT;
-	}
-
 	rtc_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(rtc_base))
 		return PTR_ERR(rtc_base);
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 14040b2..0b495e8 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -477,11 +477,6 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 	/* get the memory region */
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "failed to get memory region resource\n");
-		return -ENOENT;
-	}
-
 	s3c_rtc_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(s3c_rtc_base))
 		return PTR_ERR(s3c_rtc_base);
diff --git a/drivers/rtc/rtc-spear.c b/drivers/rtc/rtc-spear.c
index 574359c..34eed6a 100644
--- a/drivers/rtc/rtc-spear.c
+++ b/drivers/rtc/rtc-spear.c
@@ -358,12 +358,6 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	int status = 0;
 	int irq;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no resource defined\n");
-		return -EBUSY;
-	}
-
 	config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
 	if (!config) {
 		dev_err(&pdev->dev, "out of memory\n");
@@ -385,6 +379,7 @@ static int spear_rtc_probe(struct platform_device *pdev)
 		return status;
 	}
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	config->ioaddr = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(config->ioaddr))
 		return PTR_ERR(config->ioaddr);
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index a34315d..76af92a 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -322,12 +322,6 @@ static int __init tegra_rtc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev,
-			"Unable to allocate resources 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);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 23/42] drivers/spi: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (5 preceding siblings ...)
  2013-05-10  8:17 ` [RFC 22/42] drivers/rtc: " Wolfram Sang
@ 2013-05-10  8:17 ` Wolfram Sang
       [not found]   ` <1368173847-5661-24-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
                     ` (2 more replies)
  2013-05-10  8:17 ` [RFC 25/42] drivers/staging/nvec: " Wolfram Sang
                   ` (2 subsequent siblings)
  9 siblings, 3 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Mark Brown, Grant Likely, Ben Dooks, Kukjin Kim,
	Barry Song, Stephen Warren, spi-devel-general, linux-arm-kernel,
	linux-samsung-soc, linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/spi/spi-bcm63xx.c        |    8 +-------
 drivers/spi/spi-ep93xx.c         |    8 +-------
 drivers/spi/spi-omap2-mcspi.c    |    7 +------
 drivers/spi/spi-s3c64xx.c        |    7 +------
 drivers/spi/spi-sirf.c           |    7 +------
 drivers/spi/spi-tegra114.c       |    7 +------
 drivers/spi/spi-tegra20-sflash.c |    5 -----
 drivers/spi/spi-tegra20-slink.c  |    7 +------
 8 files changed, 7 insertions(+), 49 deletions(-)

diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index a4ec5f4..9804ee0 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -378,13 +378,6 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	struct bcm63xx_spi *bs;
 	int ret;
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(dev, "no iomem\n");
-		ret = -ENXIO;
-		goto out;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(dev, "no irq\n");
@@ -411,6 +404,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 	bs->pdev = pdev;
 
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	bs->regs = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(bs->regs)) {
 		ret = PTR_ERR(bs->regs);
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index d7bac60..213cb7a3 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -1076,15 +1076,9 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
 		goto fail_put_clock;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "unable to get iomem resource\n");
-		error = -ENODEV;
-		goto fail_put_clock;
-	}
-
 	espi->sspdr_phys = res->start + SSPDR;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	espi->regs_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(espi->regs_base)) {
 		error = PTR_ERR(espi->regs_base);
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 86d2158..31c054e 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1228,16 +1228,11 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	}
 	regs_offset = pdata->regs_offset;
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (r == NULL) {
-		status = -ENODEV;
-		goto free_master;
-	}
-
 	r->start += regs_offset;
 	r->end += regs_offset;
 	mcspi->phys = r->start;
 
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	mcspi->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(mcspi->base)) {
 		status = PTR_ERR(mcspi->base);
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 5000586..fd763cc 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1243,12 +1243,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (mem_res == NULL) {
-		dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
-		return -ENXIO;
-	}
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq);
@@ -1318,6 +1312,7 @@ static int 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;
 
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
 	if (IS_ERR(sdd->regs)) {
 		ret = PTR_ERR(sdd->regs);
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index 0808cd5..318ca5b 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -502,12 +502,6 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, master);
 	sspi = spi_master_get_devdata(master);
 
-	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem_res) {
-		dev_err(&pdev->dev, "Unable to get IO resource\n");
-		ret = -ENODEV;
-		goto free_master;
-	}
 	master->num_chipselect = num_cs;
 
 	for (i = 0; i < master->num_chipselect; i++) {
@@ -534,6 +528,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
 		}
 	}
 
+	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	sspi->base = devm_ioremap_resource(&pdev->dev, mem_res);
 	if (IS_ERR(sspi->base)) {
 		ret = PTR_ERR(sspi->base);
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index 598eb45..fc39365 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -1058,13 +1058,8 @@ static int tegra_spi_probe(struct platform_device *pdev)
 	tspi->dev = &pdev->dev;
 	spin_lock_init(&tspi->lock);
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "No IO memory resource\n");
-		ret = -ENODEV;
-		goto exit_free_master;
-	}
 	tspi->phys = r->start;
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	tspi->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(tspi->base)) {
 		ret = PTR_ERR(tspi->base);
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index d65c000..09df8e2 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -489,11 +489,6 @@ static int tegra_sflash_probe(struct platform_device *pdev)
 	tegra_sflash_parse_dt(tsd);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "No IO memory resource\n");
-		ret = -ENODEV;
-		goto exit_free_master;
-	}
 	tsd->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(tsd->base)) {
 		ret = PTR_ERR(tsd->base);
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index 3faf88d..46392f0 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -1098,13 +1098,8 @@ static int tegra_slink_probe(struct platform_device *pdev)
 
 	tegra_slink_parse_dt(tspi);
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "No IO memory resource\n");
-		ret = -ENODEV;
-		goto exit_free_master;
-	}
 	tspi->phys = r->start;
+	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	tspi->base = devm_ioremap_resource(&pdev->dev, r);
 	if (IS_ERR(tspi->base)) {
 		ret = PTR_ERR(tspi->base);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 25/42] drivers/staging/nvec: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (6 preceding siblings ...)
  2013-05-10  8:17 ` [RFC 23/42] drivers/spi: " Wolfram Sang
@ 2013-05-10  8:17 ` Wolfram Sang
  2013-05-10 15:24   ` Greg Kroah-Hartman
       [not found]   ` <1368173847-5661-26-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  2013-05-10  8:17 ` [RFC 27/42] drivers/tty/serial: " Wolfram Sang
  2013-05-10  8:17 ` [RFC 37/42] arch/arm/mach-tegra: " Wolfram Sang
  9 siblings, 2 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: devel, Wolfram Sang, Greg Kroah-Hartman, linux-tegra, ac100

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/staging/nvec/nvec.c |    5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index a88959f..863b22e 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -800,11 +800,6 @@ static int tegra_nvec_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "no mem resource?\n");
-		return -ENODEV;
-	}
-
 	base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 27/42] drivers/tty/serial: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (7 preceding siblings ...)
  2013-05-10  8:17 ` [RFC 25/42] drivers/staging/nvec: " Wolfram Sang
@ 2013-05-10  8:17 ` Wolfram Sang
  2013-05-10 15:26   ` Greg Kroah-Hartman
  2013-05-10  8:17 ` [RFC 37/42] arch/arm/mach-tegra: " Wolfram Sang
  9 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Greg Kroah-Hartman, Jiri Slaby, Stephen Warren,
	linux-serial, linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/tty/serial/serial-tegra.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index 9799d04..9570b55 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -1295,13 +1295,9 @@ static int tegra_uart_probe(struct platform_device *pdev)
 	tup->cdata = cdata;
 
 	platform_set_drvdata(pdev, tup);
-	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!resource) {
-		dev_err(&pdev->dev, "No IO memory resource\n");
-		return -ENODEV;
-	}
 
 	u->mapbase = resource->start;
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	u->membase = devm_ioremap_resource(&pdev->dev, resource);
 	if (IS_ERR(u->membase))
 		return PTR_ERR(u->membase);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [RFC 37/42] arch/arm/mach-tegra: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
                   ` (8 preceding siblings ...)
  2013-05-10  8:17 ` [RFC 27/42] drivers/tty/serial: " Wolfram Sang
@ 2013-05-10  8:17 ` Wolfram Sang
  9 siblings, 0 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10  8:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Russell King, Stephen Warren, linux-arm-kernel,
	linux-tegra

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 arch/arm/mach-tegra/tegra2_emc.c |    5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra2_emc.c b/arch/arm/mach-tegra/tegra2_emc.c
index 9e8bdfa..31e69a0 100644
--- a/arch/arm/mach-tegra/tegra2_emc.c
+++ b/arch/arm/mach-tegra/tegra2_emc.c
@@ -307,11 +307,6 @@ static int tegra_emc_probe(struct platform_device *pdev)
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "missing register base\n");
-		return -ENOMEM;
-	}
-
 	emc_regbase = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(emc_regbase))
 		return PTR_ERR(emc_regbase);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [RFC 23/42] drivers/spi: don't check resource with devm_ioremap_resource
       [not found]   ` <1368173847-5661-24-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-10 10:55     ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2013-05-10 10:55 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Grant Likely, Ben Dooks,
	Kukjin Kim, Barry Song, Stephen Warren,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 264 bytes --]

On Fri, May 10, 2013 at 10:17:08AM +0200, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.

Acked-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 25/42] drivers/staging/nvec: don't check resource with devm_ioremap_resource
  2013-05-10  8:17 ` [RFC 25/42] drivers/staging/nvec: " Wolfram Sang
@ 2013-05-10 15:24   ` Greg Kroah-Hartman
       [not found]   ` <1368173847-5661-26-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  1 sibling, 0 replies; 31+ messages in thread
From: Greg Kroah-Hartman @ 2013-05-10 15:24 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, devel, linux-tegra, ac100

On Fri, May 10, 2013 at 10:17:10AM +0200, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 27/42] drivers/tty/serial: don't check resource with devm_ioremap_resource
  2013-05-10  8:17 ` [RFC 27/42] drivers/tty/serial: " Wolfram Sang
@ 2013-05-10 15:26   ` Greg Kroah-Hartman
  2013-05-10 17:58     ` Wolfram Sang
  0 siblings, 1 reply; 31+ messages in thread
From: Greg Kroah-Hartman @ 2013-05-10 15:26 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Jiri Slaby, Stephen Warren, linux-serial,
	linux-tegra

On Fri, May 10, 2013 at 10:17:12AM +0200, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>  drivers/tty/serial/serial-tegra.c |    6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
> index 9799d04..9570b55 100644
> --- a/drivers/tty/serial/serial-tegra.c
> +++ b/drivers/tty/serial/serial-tegra.c
> @@ -1295,13 +1295,9 @@ static int tegra_uart_probe(struct platform_device *pdev)
>  	tup->cdata = cdata;
>  
>  	platform_set_drvdata(pdev, tup);
> -	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!resource) {
> -		dev_err(&pdev->dev, "No IO memory resource\n");
> -		return -ENODEV;
> -	}
>  
>  	u->mapbase = resource->start;
> +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);

You need to look at your scripts, as again, this is totally wrong.

greg k-h

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 25/42] drivers/staging/nvec: don't check resource with devm_ioremap_resource
       [not found]   ` <1368173847-5661-26-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-10 16:07     ` Marc Dietrich
  0 siblings, 0 replies; 31+ messages in thread
From: Marc Dietrich @ 2013-05-10 16:07 UTC (permalink / raw)
  To: Wolfram Sang, linux-tegra-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Julian Andres Klode,
	Greg Kroah-Hartman, devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b

On Friday 10 May 2013 10:17:10 Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>

Acked-by: Marc Dietrich <marvin24-Mmb7MZpHnFY@public.gmane.org>

> ---
>  drivers/staging/nvec/nvec.c |    5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index a88959f..863b22e 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -800,11 +800,6 @@ static int tegra_nvec_probe(struct platform_device
> *pdev) }
> 
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "no mem resource?\n");
> -		return -ENODEV;
> -	}
> -
>  	base = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(base))
>  		return PTR_ERR(base);

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
       [not found]   ` <1368173847-5661-5-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-10 16:35     ` Stephen Warren
       [not found]       ` <518D21D4.6000609-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  0 siblings, 1 reply; 31+ messages in thread
From: Stephen Warren @ 2013-05-10 16:35 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Vinod Koul, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On 05/10/2013 02:16 AM, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.

> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c

>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "No mem resource for DMA\n");
> -		return -EINVAL;
> -	}
> -
>  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);

One issue here is that it's not obvious just from reading the code
that's left behind that the "missing" error-checking of the
platform_get_resource() return value is OK because
devm_ioremap_resource() will check it "for us". Everyone now has to
mentally maintain a list of exceptions where it's OK not to error-check.
A similar situation exists for e.g. kzalloc already spewing an error
when allocations fail, and so drivers don't need to print a diagnostic
in that case, but it's helpful if they do in most other cases, but
that's another issue.

Would it be better to introduce a new devm_ioremap_pdev_resource(pdev,
index) that replaced both those two API calls with a single one. That
way, only the author/reader of the new devm_ioremap_pdev_resource()
would have to remember that caveat, and a single comment could be added
so people unfamiliar with the code remember, without duplicating the
comment in every driver.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 23/42] drivers/spi: don't check resource with devm_ioremap_resource
  2013-05-10  8:17 ` [RFC 23/42] drivers/spi: " Wolfram Sang
       [not found]   ` <1368173847-5661-24-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-10 16:37   ` Stephen Warren
  2013-05-11  5:24   ` Jingoo Han
  2 siblings, 0 replies; 31+ messages in thread
From: Stephen Warren @ 2013-05-10 16:37 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Mark Brown, Grant Likely, Ben Dooks, Kukjin Kim,
	Barry Song, spi-devel-general, linux-arm-kernel,
	linux-samsung-soc, linux-tegra

On 05/10/2013 02:17 AM, Wolfram Sang wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.

> diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c

> -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!r) {
> -		dev_err(&pdev->dev, "No IO memory resource\n");
> -		ret = -ENODEV;
> -		goto exit_free_master;
> -	}
>  	tspi->phys = r->start;
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);

The tspi->phy assignment is broken there now.

> diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c

> -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!r) {
> -		dev_err(&pdev->dev, "No IO memory resource\n");
> -		ret = -ENODEV;
> -		goto exit_free_master;
> -	}
>  	tspi->phys = r->start;
> +	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);

Same here.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
       [not found]       ` <518D21D4.6000609-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2013-05-10 17:57         ` Wolfram Sang
  2013-05-10 19:25           ` Stephen Warren
  0 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10 17:57 UTC (permalink / raw)
  To: Stephen Warren
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Vinod Koul, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Fri, May 10, 2013 at 10:35:32AM -0600, Stephen Warren wrote:
> On 05/10/2013 02:16 AM, Wolfram Sang wrote:
> > devm_ioremap_resource does sanity checks on the given resource. No need to
> > duplicate this in the driver.
> 
> > diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> 
> >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	if (!res) {
> > -		dev_err(&pdev->dev, "No mem resource for DMA\n");
> > -		return -EINVAL;
> > -	}
> > -
> >  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
> 
> One issue here is that it's not obvious just from reading the code
> that's left behind that the "missing" error-checking of the
> platform_get_resource() return value is OK because
> devm_ioremap_resource() will check it "for us". Everyone now has to
> mentally maintain a list of exceptions where it's OK not to error-check.

My goal is to make not-checking the standard case with devm.

> A similar situation exists for e.g. kzalloc already spewing an error
> when allocations fail, and so drivers don't need to print a diagnostic
> in that case, but it's helpful if they do in most other cases, but
> that's another issue.

My goal is to make drivers-not-printing-errors the standard case with devm :)

> Would it be better to introduce a new devm_ioremap_pdev_resource(pdev,
> index) that replaced both those two API calls with a single one. That
> way, only the author/reader of the new devm_ioremap_pdev_resource()
> would have to remember that caveat, and a single comment could be added
> so people unfamiliar with the code remember, without duplicating the
> comment in every driver.

I see two steps here:

1) make devm interface consistent
2) ease the devm interface with platform drivers

I am currently working on the first step.

Thanks,

   Wolfram

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 27/42] drivers/tty/serial: don't check resource with devm_ioremap_resource
  2013-05-10 15:26   ` Greg Kroah-Hartman
@ 2013-05-10 17:58     ` Wolfram Sang
  0 siblings, 0 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-10 17:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jiri Slaby, Stephen Warren, linux-serial,
	linux-tegra

On Fri, May 10, 2013 at 08:26:36AM -0700, Greg Kroah-Hartman wrote:
> On Fri, May 10, 2013 at 10:17:12AM +0200, Wolfram Sang wrote:
> > devm_ioremap_resource does sanity checks on the given resource. No need to
> > duplicate this in the driver.
> > 
> > Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> > ---
> >  drivers/tty/serial/serial-tegra.c |    6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
> > index 9799d04..9570b55 100644
> > --- a/drivers/tty/serial/serial-tegra.c
> > +++ b/drivers/tty/serial/serial-tegra.c
> > @@ -1295,13 +1295,9 @@ static int tegra_uart_probe(struct platform_device *pdev)
> >  	tup->cdata = cdata;
> >  
> >  	platform_set_drvdata(pdev, tup);
> > -	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	if (!resource) {
> > -		dev_err(&pdev->dev, "No IO memory resource\n");
> > -		return -ENODEV;
> > -	}
> >  
> >  	u->mapbase = resource->start;
> > +	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> 
> You need to look at your scripts, as again, this is totally wrong.

Yes, brown paper bag mistake :( Will fix!


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
  2013-05-10 17:57         ` Wolfram Sang
@ 2013-05-10 19:25           ` Stephen Warren
       [not found]             ` <518D49B0.4050901-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
  0 siblings, 1 reply; 31+ messages in thread
From: Stephen Warren @ 2013-05-10 19:25 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Vinod Koul, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On 05/10/2013 11:57 AM, Wolfram Sang wrote:
> On Fri, May 10, 2013 at 10:35:32AM -0600, Stephen Warren wrote:
>> On 05/10/2013 02:16 AM, Wolfram Sang wrote:
>>> devm_ioremap_resource does sanity checks on the given resource. No need to
>>> duplicate this in the driver.
>>
>>> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
>>
>>>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> -	if (!res) {
>>> -		dev_err(&pdev->dev, "No mem resource for DMA\n");
>>> -		return -EINVAL;
>>> -	}
>>> -
>>>  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
>>
>> One issue here is that it's not obvious just from reading the code
>> that's left behind that the "missing" error-checking of the
>> platform_get_resource() return value is OK because
>> devm_ioremap_resource() will check it "for us". Everyone now has to
>> mentally maintain a list of exceptions where it's OK not to error-check.
> 
> My goal is to make not-checking the standard case with devm.

OK, if no parameters passed to any devm function every need to be
error-checked, that'll certainly be a bit easier to remember.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 09/42] drivers/i2c/busses: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 ` [RFC 09/42] drivers/i2c/busses: " Wolfram Sang
@ 2013-05-11  5:18   ` Jingoo Han
  2013-06-04 18:34   ` Kevin Hilman
  1 sibling, 0 replies; 31+ messages in thread
From: Jingoo Han @ 2013-05-11  5:18 UTC (permalink / raw)
  To: 'Wolfram Sang', linux-kernel
  Cc: 'Sekhar Nori', 'Kevin Hilman',
	'Tony Lindgren', 'Ben Dooks',
	'Kukjin Kim', 'Barry Song',
	'Stephen Warren', davinci-linux-open-source, linux-i2c,
	linux-omap, linux-arm-kernel, linux-samsung-soc, linux-tegra,
	Jingoo Han

On Friday, May 10, 2013 5:17 PM, Wolfram Sang wrote:
> 
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>  drivers/i2c/busses/i2c-davinci.c            |    6 +-----
>  drivers/i2c/busses/i2c-designware-platdrv.c |    6 +-----
>  drivers/i2c/busses/i2c-imx.c                |    6 +-----
>  drivers/i2c/busses/i2c-omap.c               |    6 +-----
>  drivers/i2c/busses/i2c-rcar.c               |    7 +------
>  drivers/i2c/busses/i2c-s3c2410.c            |    5 -----

For drivers/i2c/busses/i2c-s3c2410.c

Reviewed-by: Jingoo Han <jg1.han@samsung.com>

Best regards,
Jingoo Han


>  drivers/i2c/busses/i2c-sirf.c               |    6 ------
>  drivers/i2c/busses/i2c-tegra.c              |    5 -----
>  8 files changed, 5 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index cf20e06..2ed3e7b 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -647,11 +647,6 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  	int r;
> 
>  	/* NOTE: driver uses the static register mapping */
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!mem) {
> -		dev_err(&pdev->dev, "no mem resource?\n");
> -		return -ENODEV;
> -	}
> 
>  	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>  	if (!irq) {
> @@ -697,6 +692,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	clk_prepare_enable(dev->clk);
> 
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	dev->base = devm_ioremap_resource(&pdev->dev, mem);
>  	if (IS_ERR(dev->base)) {
>  		r = PTR_ERR(dev->base);
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index 8ec9133..6f3c612 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -87,11 +87,6 @@ static int dw_i2c_probe(struct platform_device *pdev)
>  	int irq, r;
> 
>  	/* NOTE: driver uses the static register mapping */
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!mem) {
> -		dev_err(&pdev->dev, "no mem resource?\n");
> -		return -EINVAL;
> -	}
> 
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
> @@ -103,6 +98,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
>  	if (!dev)
>  		return -ENOMEM;
> 
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	dev->base = devm_ioremap_resource(&pdev->dev, mem);
>  	if (IS_ERR(dev->base))
>  		return PTR_ERR(dev->base);
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 82f20c6..b274ca1 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -500,17 +500,13 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
> 
>  	dev_dbg(&pdev->dev, "<%s>\n", __func__);
> 
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "can't get device resources\n");
> -		return -ENOENT;
> -	}
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		dev_err(&pdev->dev, "can't get irq number\n");
>  		return -ENOENT;
>  	}
> 
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	base = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(base))
>  		return PTR_ERR(base);
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index e02f9e3..8498ab7 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -1085,11 +1085,6 @@ omap_i2c_probe(struct platform_device *pdev)
>  	u16 minor, major, scheme;
> 
>  	/* NOTE: driver uses the static register mapping */
> -	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!mem) {
> -		dev_err(&pdev->dev, "no mem resource?\n");
> -		return -ENODEV;
> -	}
> 
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
> @@ -1103,6 +1098,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	}
> 
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	dev->base = devm_ioremap_resource(&pdev->dev, mem);
>  	if (IS_ERR(dev->base))
>  		return PTR_ERR(dev->base);
> diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
> index 4ba4a95..0fc5858 100644
> --- a/drivers/i2c/busses/i2c-rcar.c
> +++ b/drivers/i2c/busses/i2c-rcar.c
> @@ -623,12 +623,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
>  	u32 bus_speed;
>  	int ret;
> 
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(dev, "no mmio resources\n");
> -		return -ENODEV;
> -	}
> -
>  	priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL);
>  	if (!priv) {
>  		dev_err(dev, "no mem for private data\n");
> @@ -642,6 +636,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		return ret;
> 
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	priv->io = devm_ioremap_resource(dev, res);
>  	if (IS_ERR(priv->io))
>  		return PTR_ERR(priv->io);
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index 6e8ee92..cab1c91 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -1082,11 +1082,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
>  	/* map the registers */
> 
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (res == NULL) {
> -		dev_err(&pdev->dev, "cannot find IO resource\n");
> -		return -ENOENT;
> -	}
> -
>  	i2c->regs = devm_ioremap_resource(&pdev->dev, res);
> 
>  	if (IS_ERR(i2c->regs))
> diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
> index 5a7ad24..a63c7d5 100644
> --- a/drivers/i2c/busses/i2c-sirf.c
> +++ b/drivers/i2c/busses/i2c-sirf.c
> @@ -303,12 +303,6 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
>  	adap->class = I2C_CLASS_HWMON;
> 
>  	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (mem_res == NULL) {
> -		dev_err(&pdev->dev, "Unable to get MEM resource\n");
> -		err = -EINVAL;
> -		goto out;
> -	}
> -
>  	siic->base = devm_ioremap_resource(&pdev->dev, mem_res);
>  	if (IS_ERR(siic->base)) {
>  		err = PTR_ERR(siic->base);
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index b60ff90..9aa1b60 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -714,11 +714,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>  	int ret = 0;
> 
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "no mem resource\n");
> -		return -EINVAL;
> -	}
> -
>  	base = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(base))
>  		return PTR_ERR(base);
> --
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 23/42] drivers/spi: don't check resource with devm_ioremap_resource
  2013-05-10  8:17 ` [RFC 23/42] drivers/spi: " Wolfram Sang
       [not found]   ` <1368173847-5661-24-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  2013-05-10 16:37   ` Stephen Warren
@ 2013-05-11  5:24   ` Jingoo Han
  2 siblings, 0 replies; 31+ messages in thread
From: Jingoo Han @ 2013-05-11  5:24 UTC (permalink / raw)
  To: 'Wolfram Sang', linux-kernel
  Cc: 'Mark Brown', 'Grant Likely', 'Ben Dooks',
	'Kukjin Kim', 'Barry Song',
	'Stephen Warren', spi-devel-general, linux-arm-kernel,
	linux-samsung-soc, linux-tegra, Jingoo Han

On Friday, May 10, 2013 5:17 PM, Wolfram Sang wrote:
> 
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>  drivers/spi/spi-bcm63xx.c        |    8 +-------
>  drivers/spi/spi-ep93xx.c         |    8 +-------
>  drivers/spi/spi-omap2-mcspi.c    |    7 +------
>  drivers/spi/spi-s3c64xx.c        |    7 +------
>  drivers/spi/spi-sirf.c           |    7 +------
>  drivers/spi/spi-tegra114.c       |    7 +------
>  drivers/spi/spi-tegra20-sflash.c |    5 -----
>  drivers/spi/spi-tegra20-slink.c  |    7 +------
>  8 files changed, 7 insertions(+), 49 deletions(-)
> 

[.....]

> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index 5000586..fd763cc 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -1243,12 +1243,6 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
> 
> -	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (mem_res == NULL) {
> -		dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
> -		return -ENXIO;
> -	}
> -

It breaks 'sdd->sfr_start' assignment as below:

1272         sdd->sfr_start = mem_res->start;


Best regards,
Jingoo Han

>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		dev_warn(&pdev->dev, "Failed to get IRQ: %d\n", irq);
> @@ -1318,6 +1312,7 @@ static int 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;
> 
> +	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res);
>  	if (IS_ERR(sdd->regs)) {
>  		ret = PTR_ERR(sdd->regs);

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 05/42] drivers/gpio: don't check resource with devm_ioremap_resource
       [not found]     ` <1368173847-5661-6-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-12 15:11       ` Viresh Kumar
  0 siblings, 0 replies; 31+ messages in thread
From: Viresh Kumar @ 2013-05-12 15:11 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Grant Likely, Linus Walleij,
	Stephen Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Fri, May 10, 2013 at 1:46 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
>
> Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
> ---
>  drivers/gpio/gpio-spear-spics.c |    7 +------

Acked-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 22/42] drivers/rtc: don't check resource with devm_ioremap_resource
       [not found]   ` <1368173847-5661-23-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-12 15:11     ` Viresh Kumar
  0 siblings, 0 replies; 31+ messages in thread
From: Viresh Kumar @ 2013-05-12 15:11 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Wan ZongShun,
	Alessandro Zummo, Stephen Warren,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	rtc-linux-/JYPxA39Uh5TLH3MbocFFw,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Fri, May 10, 2013 at 1:47 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
>
> Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
> ---
>  drivers/rtc/rtc-spear.c  |    7 +------

Acked-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 20/42] drivers/pwm: don't check resource with devm_ioremap_resource
       [not found]   ` <1368173847-5661-21-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-05-12 15:12     ` Viresh Kumar
  0 siblings, 0 replies; 31+ messages in thread
From: Viresh Kumar @ 2013-05-12 15:12 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Thierry Reding,
	Stephen Warren, Tony Prisk, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Fri, May 10, 2013 at 1:47 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
>
> Signed-off-by: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
> ---
>  drivers/pwm/pwm-spear.c    |    7 +------

Acked-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 10/42] drivers/input/keyboard: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 ` [RFC 10/42] drivers/input/keyboard: " Wolfram Sang
@ 2013-05-12 15:12   ` Viresh Kumar
  0 siblings, 0 replies; 31+ messages in thread
From: Viresh Kumar @ 2013-05-12 15:12 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Dmitry Torokhov, Stephen Warren, linux-input,
	linux-tegra

On Fri, May 10, 2013 at 1:46 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
>  drivers/input/keyboard/spear-keyboard.c

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
       [not found]             ` <518D49B0.4050901-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2013-05-12 16:04               ` Vinod Koul
       [not found]                 ` <20130512160440.GA27639-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 31+ messages in thread
From: Vinod Koul @ 2013-05-12 16:04 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Wolfram Sang, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Fri, May 10, 2013 at 01:25:36PM -0600, Stephen Warren wrote:
> On 05/10/2013 11:57 AM, Wolfram Sang wrote:
> > On Fri, May 10, 2013 at 10:35:32AM -0600, Stephen Warren wrote:
> >> On 05/10/2013 02:16 AM, Wolfram Sang wrote:
> >>> devm_ioremap_resource does sanity checks on the given resource. No need to
> >>> duplicate this in the driver.
> >>
> >>> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> >>
> >>>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >>> -	if (!res) {
> >>> -		dev_err(&pdev->dev, "No mem resource for DMA\n");
> >>> -		return -EINVAL;
> >>> -	}
> >>> -
> >>>  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
> >>
> >> One issue here is that it's not obvious just from reading the code
> >> that's left behind that the "missing" error-checking of the
> >> platform_get_resource() return value is OK because
> >> devm_ioremap_resource() will check it "for us". Everyone now has to
> >> mentally maintain a list of exceptions where it's OK not to error-check.
> > 
> > My goal is to make not-checking the standard case with devm.
> 
> OK, if no parameters passed to any devm function every need to be
> error-checked, that'll certainly be a bit easier to remember.
Okay to remove the log message and move to devm_ but I dont agree with this
patch not returning error above. We shouldnt supress the error..

--
~Vinod

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
       [not found]                 ` <20130512160440.GA27639-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2013-05-12 18:28                   ` Wolfram Sang
  2013-05-13  2:10                     ` Vinod Koul
  0 siblings, 1 reply; 31+ messages in thread
From: Wolfram Sang @ 2013-05-12 18:28 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Stephen Warren, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Sun, May 12, 2013 at 09:34:40PM +0530, Vinod Koul wrote:
> On Fri, May 10, 2013 at 01:25:36PM -0600, Stephen Warren wrote:
> > On 05/10/2013 11:57 AM, Wolfram Sang wrote:
> > > On Fri, May 10, 2013 at 10:35:32AM -0600, Stephen Warren wrote:
> > >> On 05/10/2013 02:16 AM, Wolfram Sang wrote:
> > >>> devm_ioremap_resource does sanity checks on the given resource. No need to
> > >>> duplicate this in the driver.
> > >>
> > >>> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> > >>
> > >>>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > >>> -	if (!res) {
> > >>> -		dev_err(&pdev->dev, "No mem resource for DMA\n");
> > >>> -		return -EINVAL;
> > >>> -	}
> > >>> -
> > >>>  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
> > >>
> > >> One issue here is that it's not obvious just from reading the code
> > >> that's left behind that the "missing" error-checking of the
> > >> platform_get_resource() return value is OK because
> > >> devm_ioremap_resource() will check it "for us". Everyone now has to
> > >> mentally maintain a list of exceptions where it's OK not to error-check.
> > > 
> > > My goal is to make not-checking the standard case with devm.
> > 
> > OK, if no parameters passed to any devm function every need to be
> > error-checked, that'll certainly be a bit easier to remember.
> Okay to remove the log message and move to devm_ but I dont agree with this
> patch not returning error above. We shouldnt supress the error..

The error will be reported because devm_ioremap_resource will return an
ERR_PTR.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
  2013-05-12 18:28                   ` Wolfram Sang
@ 2013-05-13  2:10                     ` Vinod Koul
       [not found]                       ` <20130513021000.GB27639-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 31+ messages in thread
From: Vinod Koul @ 2013-05-13  2:10 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Stephen Warren, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

On Sun, May 12, 2013 at 08:28:07PM +0200, Wolfram Sang wrote:
> On Sun, May 12, 2013 at 09:34:40PM +0530, Vinod Koul wrote:
> > On Fri, May 10, 2013 at 01:25:36PM -0600, Stephen Warren wrote:
> > > On 05/10/2013 11:57 AM, Wolfram Sang wrote:
> > > > On Fri, May 10, 2013 at 10:35:32AM -0600, Stephen Warren wrote:
> > > >> On 05/10/2013 02:16 AM, Wolfram Sang wrote:
> > > >>> devm_ioremap_resource does sanity checks on the given resource. No need to
> > > >>> duplicate this in the driver.
> > > >>
> > > >>> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> > > >>
> > > >>>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > >>> -	if (!res) {
> > > >>> -		dev_err(&pdev->dev, "No mem resource for DMA\n");
> > > >>> -		return -EINVAL;
> > > >>> -	}
> > > >>> -
> > > >>>  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
> > > >>
> > > >> One issue here is that it's not obvious just from reading the code
> > > >> that's left behind that the "missing" error-checking of the
> > > >> platform_get_resource() return value is OK because
> > > >> devm_ioremap_resource() will check it "for us". Everyone now has to
> > > >> mentally maintain a list of exceptions where it's OK not to error-check.
> > > > 
> > > > My goal is to make not-checking the standard case with devm.
> > > 
> > > OK, if no parameters passed to any devm function every need to be
> > > error-checked, that'll certainly be a bit easier to remember.
> > Okay to remove the log message and move to devm_ but I dont agree with this
> > patch not returning error above. We shouldnt supress the error..
> 
> The error will be reported because devm_ioremap_resource will return an
> ERR_PTR.
And this patch removed the check on 'res' pointer, so on failure we continue...

--
~Vinod
> 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource
       [not found]                       ` <20130513021000.GB27639-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2013-05-13  6:08                         ` Wolfram Sang
  0 siblings, 0 replies; 31+ messages in thread
From: Wolfram Sang @ 2013-05-13  6:08 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Stephen Warren, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dan Williams,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA


> > > > >>> devm_ioremap_resource does sanity checks on the given resource. No need to
> > > > >>> duplicate this in the driver.
> > > > >>
> > > > >>> diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
> > > > >>
> > > > >>>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > > >>> -	if (!res) {
> > > > >>> -		dev_err(&pdev->dev, "No mem resource for DMA\n");
> > > > >>> -		return -EINVAL;
> > > > >>> -	}
> > > > >>> -
> > > > >>>  	tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
> > > > >>
> > > > >> One issue here is that it's not obvious just from reading the code
> > > > >> that's left behind that the "missing" error-checking of the
> > > > >> platform_get_resource() return value is OK because
> > > > >> devm_ioremap_resource() will check it "for us". Everyone now has to
> > > > >> mentally maintain a list of exceptions where it's OK not to error-check.
> > > > > 
> > > > > My goal is to make not-checking the standard case with devm.
> > > > 
> > > > OK, if no parameters passed to any devm function every need to be
> > > > error-checked, that'll certainly be a bit easier to remember.
> > > Okay to remove the log message and move to devm_ but I dont agree with this
> > > patch not returning error above. We shouldnt supress the error..
> > 
> > The error will be reported because devm_ioremap_resource will return an
> > ERR_PTR.
> And this patch removed the check on 'res' pointer, so on failure we continue...

I don't get it. What is the difference between a manual check of res and
the directly following devm_ioremap_resource returning ERR_PTR(-EINVAL)
if res is NULL?

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [RFC 09/42] drivers/i2c/busses: don't check resource with devm_ioremap_resource
  2013-05-10  8:16 ` [RFC 09/42] drivers/i2c/busses: " Wolfram Sang
  2013-05-11  5:18   ` Jingoo Han
@ 2013-06-04 18:34   ` Kevin Hilman
  1 sibling, 0 replies; 31+ messages in thread
From: Kevin Hilman @ 2013-06-04 18:34 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: linux-kernel, Sekhar Nori, Tony Lindgren, Ben Dooks, Kukjin Kim,
	Barry Song, Stephen Warren, davinci-linux-open-source, linux-i2c,
	linux-omap, linux-arm-kernel, linux-samsung-soc, linux-tegra

Wolfram Sang <wsa@the-dreams.de> writes:

> devm_ioremap_resource does sanity checks on the given resource. No need to
> duplicate this in the driver.
>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Acked-by: Kevin Hilman <khilman@linaro.org>  # for i2c-omap.c

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-06-04 18:34 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-10  8:16 [RFC 00/42] devm improvement series, part #1 Wolfram Sang
2013-05-10  8:16 ` [RFC 04/42] drivers/dma: don't check resource with devm_ioremap_resource Wolfram Sang
     [not found]   ` <1368173847-5661-5-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-10 16:35     ` Stephen Warren
     [not found]       ` <518D21D4.6000609-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-05-10 17:57         ` Wolfram Sang
2013-05-10 19:25           ` Stephen Warren
     [not found]             ` <518D49B0.4050901-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-05-12 16:04               ` Vinod Koul
     [not found]                 ` <20130512160440.GA27639-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-05-12 18:28                   ` Wolfram Sang
2013-05-13  2:10                     ` Vinod Koul
     [not found]                       ` <20130513021000.GB27639-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-05-13  6:08                         ` Wolfram Sang
     [not found] ` <1368173847-5661-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-10  8:16   ` [RFC 05/42] drivers/gpio: " Wolfram Sang
     [not found]     ` <1368173847-5661-6-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-12 15:11       ` Viresh Kumar
2013-05-10  8:16 ` [RFC 09/42] drivers/i2c/busses: " Wolfram Sang
2013-05-11  5:18   ` Jingoo Han
2013-06-04 18:34   ` Kevin Hilman
2013-05-10  8:16 ` [RFC 10/42] drivers/input/keyboard: " Wolfram Sang
2013-05-12 15:12   ` Viresh Kumar
2013-05-10  8:17 ` [RFC 20/42] drivers/pwm: " Wolfram Sang
     [not found]   ` <1368173847-5661-21-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-12 15:12     ` Viresh Kumar
2013-05-10  8:17 ` [RFC 22/42] drivers/rtc: " Wolfram Sang
     [not found]   ` <1368173847-5661-23-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-12 15:11     ` Viresh Kumar
2013-05-10  8:17 ` [RFC 23/42] drivers/spi: " Wolfram Sang
     [not found]   ` <1368173847-5661-24-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-10 10:55     ` Mark Brown
2013-05-10 16:37   ` Stephen Warren
2013-05-11  5:24   ` Jingoo Han
2013-05-10  8:17 ` [RFC 25/42] drivers/staging/nvec: " Wolfram Sang
2013-05-10 15:24   ` Greg Kroah-Hartman
     [not found]   ` <1368173847-5661-26-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-05-10 16:07     ` Marc Dietrich
2013-05-10  8:17 ` [RFC 27/42] drivers/tty/serial: " Wolfram Sang
2013-05-10 15:26   ` Greg Kroah-Hartman
2013-05-10 17:58     ` Wolfram Sang
2013-05-10  8:17 ` [RFC 37/42] arch/arm/mach-tegra: " Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox