linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/27] devm cleanup, part #1, take #3
@ 2013-07-23 18:01 Wolfram Sang
  2013-07-23 18:01 ` [PATCH 03/27] drivers/cpuidle: don't check resource with devm_ioremap_resource Wolfram Sang
  2013-07-23 18:02 ` [PATCH 27/27] thermal: ti-bandgap: cleanup resource allocation Wolfram Sang
  0 siblings, 2 replies; 5+ messages in thread
From: Wolfram Sang @ 2013-07-23 18:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, alsa-devel, Bjorn Helgaas, Daniel Lezcano,
	Dan Williams, David Woodhouse, devel, Dmitry Torokhov, dri-devel,
	Eduardo Valentin, Eric Miao, Felipe Balbi, Giuseppe Cavallaro,
	Grant Likely, Greg Kroah-Hartman, Haojian Zhuang,
	James E.J. Bottomley, Jaroslav Kysela, Liam Girdwood,
	Linus Walleij

Here is another bit of cleaning up the devm usage. It is again removing the
resource check with devm_ioremap_resource, because a) new drivers came in and
b) coccinelle had a bug and missed to find a couple of occasions. Unlike last
time, I think it is better if these patches go in via the subsystem trees to
reduce merge conflicts. And there is one driver which I fixed manually because
the original code needed some bigger update. All is based on v3.11-rc2 and the
branch can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git devm_no_resource_check

Other things which happened: I wanted to get rid of devm_request_and_ioremap,
luckily other people are already working on it. Hooray! I already sent a patch
series picking another low hanging fruit, i.e. drivers can skip devm_pinctrl
handling if they are using only the default pin setup. And not devm related,
there is still my proposal to rename INIT_COMPLETION to reinit_completion, that
probably needs some more persistence... Yay, so much to clean up \o/

Regards,

   Wolfram


Wolfram Sang (27):
  arch/mips/lantiq/xway: don't check resource with
    devm_ioremap_resource
  drivers/amba: don't check resource with devm_ioremap_resource
  drivers/cpuidle: don't check resource with devm_ioremap_resource
  drivers/dma: 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/serio: don't check resource with devm_ioremap_resource
  drivers/iommu: don't check resource with devm_ioremap_resource
  drivers/media/platform: don't check resource with
    devm_ioremap_resource
  drivers/memory: don't check resource with devm_ioremap_resource
  drivers/mtd/nand: don't check resource with devm_ioremap_resource
  drivers/net/ethernet/stmicro/stmmac: don't check resource with
    devm_ioremap_resource
  drivers/pci/host: don't check resource with devm_ioremap_resource
  drivers/pinctrl: don't check resource with devm_ioremap_resource
  drivers/pwm: don't check resource with devm_ioremap_resource
  drivers/scsi/ufs: don't check resource with devm_ioremap_resource
  drivers/spi: don't check resource with devm_ioremap_resource
  drivers/staging/imx-drm: don't check resource with
    devm_ioremap_resource
  drivers/usb/phy: don't check resource with devm_ioremap_resource
  drivers/watchdog: don't check resource with devm_ioremap_resource
  sound/soc/au1x: don't check resource with devm_ioremap_resource
  sound/soc/cirrus: don't check resource with devm_ioremap_resource
  sound/soc/nuc900: don't check resource with devm_ioremap_resource
  sound/soc/pxa: don't check resource with devm_ioremap_resource
  sound/soc/tegra: don't check resource with devm_ioremap_resource
  sound/soc/txx9: don't check resource with devm_ioremap_resource
  thermal: ti-bandgap: cleanup resource allocation

 arch/mips/lantiq/xway/dma.c                        |    4 ----
 drivers/amba/tegra-ahb.c                           |    2 --
 drivers/cpuidle/cpuidle-kirkwood.c                 |    3 ---
 drivers/dma/mmp_pdma.c                             |    3 ---
 drivers/dma/mmp_tdma.c                             |    3 ---
 drivers/gpu/host1x/drm/hdmi.c                      |    3 ---
 drivers/i2c/busses/i2c-stu300.c                    |    3 ---
 drivers/input/serio/olpc_apsp.c                    |    3 ---
 drivers/iommu/tegra-smmu.c                         |    2 --
 drivers/media/platform/coda.c                      |    5 -----
 drivers/memory/tegra20-mc.c                        |    2 --
 drivers/memory/tegra30-mc.c                        |    2 --
 drivers/mtd/nand/mxc_nand.c                        |    5 -----
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |    3 ---
 drivers/pci/host/pcie-designware.c                 |   12 ------------
 drivers/pinctrl/pinctrl-imx.c                      |    3 ---
 drivers/pinctrl/pinctrl-rockchip.c                 |    5 -----
 drivers/pinctrl/pinctrl-u300.c                     |    3 ---
 drivers/pwm/pwm-lpc32xx.c                          |    3 ---
 drivers/pwm/pwm-renesas-tpu.c                      |    5 -----
 drivers/scsi/ufs/ufshcd-pltfrm.c                   |    6 ------
 drivers/spi/spi-bcm2835.c                          |    6 ------
 drivers/staging/imx-drm/imx-tve.c                  |    5 -----
 drivers/thermal/ti-soc-thermal/ti-bandgap.c        |   20 ++++----------------
 drivers/usb/phy/phy-rcar-usb.c                     |    5 -----
 drivers/watchdog/nuc900_wdt.c                      |    5 -----
 drivers/watchdog/ts72xx_wdt.c                      |   10 ----------
 sound/soc/au1x/psc-ac97.c                          |    3 ---
 sound/soc/cirrus/ep93xx-ac97.c                     |    3 ---
 sound/soc/cirrus/ep93xx-i2s.c                      |    3 ---
 sound/soc/nuc900/nuc900-ac97.c                     |    3 ---
 sound/soc/pxa/mmp-sspa.c                           |    3 ---
 sound/soc/tegra/tegra20_ac97.c                     |    7 -------
 sound/soc/txx9/txx9aclc-ac97.c                     |    3 ---
 34 files changed, 4 insertions(+), 152 deletions(-)

-- 
1.7.10.4

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

* [PATCH 03/27] drivers/cpuidle: don't check resource with devm_ioremap_resource
  2013-07-23 18:01 [PATCH 00/27] devm cleanup, part #1, take #3 Wolfram Sang
@ 2013-07-23 18:01 ` Wolfram Sang
  2013-07-23 21:26   ` Rafael J. Wysocki
  2013-07-23 18:02 ` [PATCH 27/27] thermal: ti-bandgap: cleanup resource allocation Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2013-07-23 18:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfram Sang, Rafael J. Wysocki, Daniel Lezcano, linux-pm

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>
---
Please apply via the subsystem-tree.

 drivers/cpuidle/cpuidle-kirkwood.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index 521b0a7..2237135 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -60,9 +60,6 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
 	struct resource *res;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL)
-		return -EINVAL;
-
 	ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(ddr_operation_base))
 		return PTR_ERR(ddr_operation_base);
-- 
1.7.10.4

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

* [PATCH 27/27] thermal: ti-bandgap: cleanup resource allocation
  2013-07-23 18:01 [PATCH 00/27] devm cleanup, part #1, take #3 Wolfram Sang
  2013-07-23 18:01 ` [PATCH 03/27] drivers/cpuidle: don't check resource with devm_ioremap_resource Wolfram Sang
@ 2013-07-23 18:02 ` Wolfram Sang
  2013-07-26 15:43   ` Eduardo Valentin
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2013-07-23 18:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfram Sang, Eduardo Valentin, Zhang Rui, linux-pm

When cleaning up usage of devm_ioremap_resource, I found that resource
allocation in this driver is ugly and buggy. If resource[0] is not
found, bgp->base will end up NULL, so OOPS. All other resources get
ioremapped, but their pointers are discarded, so why bother. So, let's
keep things simple. Just remap resource[0] and pass the error, if any.
Compile tested only, due to no hardware.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
Please apply via the subsystem-tree.

 drivers/thermal/ti-soc-thermal/ti-bandgap.c |   20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 9dfd471..416be5d 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -1130,7 +1130,6 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev)
 	const struct of_device_id *of_id;
 	struct ti_bandgap *bgp;
 	struct resource *res;
-	int i;
 
 	/* just for the sake */
 	if (!node) {
@@ -1156,21 +1155,10 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev)
 		return ERR_PTR(-ENOMEM);
 	}
 
-	i = 0;
-	do {
-		void __iomem *chunk;
-
-		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-		if (!res)
-			break;
-		chunk = devm_ioremap_resource(&pdev->dev, res);
-		if (i == 0)
-			bgp->base = chunk;
-		if (IS_ERR(chunk))
-			return ERR_CAST(chunk);
-
-		i++;
-	} while (res);
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	bgp->base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(bgp->base))
+		return bgp->base;
 
 	if (TI_BANDGAP_HAS(bgp, TSHUT)) {
 		bgp->tshut_gpio = of_get_gpio(node, 0);
-- 
1.7.10.4


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

* Re: [PATCH 03/27] drivers/cpuidle: don't check resource with devm_ioremap_resource
  2013-07-23 18:01 ` [PATCH 03/27] drivers/cpuidle: don't check resource with devm_ioremap_resource Wolfram Sang
@ 2013-07-23 21:26   ` Rafael J. Wysocki
  0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2013-07-23 21:26 UTC (permalink / raw)
  To: Wolfram Sang, Daniel Lezcano; +Cc: linux-kernel, linux-pm

On Tuesday, July 23, 2013 08:01:36 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>

Daniel, I'm leaving this one to you.

Thanks,
Rafael


> ---
> Please apply via the subsystem-tree.
> 
>  drivers/cpuidle/cpuidle-kirkwood.c |    3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
> index 521b0a7..2237135 100644
> --- a/drivers/cpuidle/cpuidle-kirkwood.c
> +++ b/drivers/cpuidle/cpuidle-kirkwood.c
> @@ -60,9 +60,6 @@ static int kirkwood_cpuidle_probe(struct platform_device *pdev)
>  	struct resource *res;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (res == NULL)
> -		return -EINVAL;
> -
>  	ddr_operation_base = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(ddr_operation_base))
>  		return PTR_ERR(ddr_operation_base);
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH 27/27] thermal: ti-bandgap: cleanup resource allocation
  2013-07-23 18:02 ` [PATCH 27/27] thermal: ti-bandgap: cleanup resource allocation Wolfram Sang
@ 2013-07-26 15:43   ` Eduardo Valentin
  0 siblings, 0 replies; 5+ messages in thread
From: Eduardo Valentin @ 2013-07-26 15:43 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, Eduardo Valentin, Zhang Rui, linux-pm

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

On 23-07-2013 14:02, Wolfram Sang wrote:
> When cleaning up usage of devm_ioremap_resource, I found that resource
> allocation in this driver is ugly and buggy. If resource[0] is not
> found, bgp->base will end up NULL, so OOPS. All other resources get
> ioremapped, but their pointers are discarded, so why bother. So, let's
> keep things simple. Just remap resource[0] and pass the error, if any.
> Compile tested only, due to no hardware.


Nack, this will actually break the driver. This device has several
sections of registers, and not a single io region. Check
Documentation/devicetree/bindings/thermal/ti_soc_thermal.txt for examples.

> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> ---
> Please apply via the subsystem-tree.
> 
>  drivers/thermal/ti-soc-thermal/ti-bandgap.c |   20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
> index 9dfd471..416be5d 100644
> --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
> +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
> @@ -1130,7 +1130,6 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev)
>  	const struct of_device_id *of_id;
>  	struct ti_bandgap *bgp;
>  	struct resource *res;
> -	int i;
>  
>  	/* just for the sake */
>  	if (!node) {
> @@ -1156,21 +1155,10 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev)
>  		return ERR_PTR(-ENOMEM);
>  	}
>  
> -	i = 0;
> -	do {
> -		void __iomem *chunk;
> -
> -		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
> -		if (!res)
> -			break;
> -		chunk = devm_ioremap_resource(&pdev->dev, res);
> -		if (i == 0)
> -			bgp->base = chunk;
> -		if (IS_ERR(chunk))
> -			return ERR_CAST(chunk);

In case resource 0 is not found, the error will be repassed.

> -
> -		i++;
> -	} while (res);

And yes, other IORESOURCE_MEM resources are required, depending on chip
version.

> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	bgp->base = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(bgp->base))
> +		return bgp->base;
>  
>  	if (TI_BANDGAP_HAS(bgp, TSHUT)) {
>  		bgp->tshut_gpio = of_get_gpio(node, 0);
> 


-- 
You have got to be excited about what you are doing. (L. Lamport)

Eduardo Valentin


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 295 bytes --]

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

end of thread, other threads:[~2013-07-26 15:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 18:01 [PATCH 00/27] devm cleanup, part #1, take #3 Wolfram Sang
2013-07-23 18:01 ` [PATCH 03/27] drivers/cpuidle: don't check resource with devm_ioremap_resource Wolfram Sang
2013-07-23 21:26   ` Rafael J. Wysocki
2013-07-23 18:02 ` [PATCH 27/27] thermal: ti-bandgap: cleanup resource allocation Wolfram Sang
2013-07-26 15:43   ` Eduardo Valentin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).