linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare
@ 2012-08-26 16:00 Julia Lawall
  2012-08-26 16:00 ` [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: " Julia Lawall
                   ` (12 more replies)
  0 siblings, 13 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

The transformation is made using the following semantic patch
(http://coccinelle.lip6.fr/).  This semantic patch is not really safe, in
that it doesn't check for clk_disable's that are relying on the removed
clk_unprepare's.  These cases have been adjusted by hand.

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
identifier r;
statement S;
@@

- r = clk_prepare(e); if (r) S
- clk_enable(e);
+ r = clk_prepare_enable(e); if (r) S

@@
expression e;
expression r;
@@

- clk_prepare(e);
  r =
- clk_enable
+ clk_prepare_enable
  (e);
  if (r) { ...
- clk_unprepare(e); // unsafe!
  ...
  return ...;
  }

@@
expression e;
expression r;
@@

- clk_prepare(e);
  r =
- clk_enable
+ clk_prepare_enable
  (e);

@@
expression e;
statement S;
@@

- if (clk_prepare(e)) S
- clk_enable(e);
+ if (clk_prepare_enable(e)) S

@@
expression e;
@@

- clk_prepare(e);
  if (
- clk_enable(e)
+ clk_prepare_enable(e)
  ) { ...
- clk_unprepare(e); // unsafe!
  ...
  return ...;
  }

@@
expression e;
statement S;
@@

- clk_prepare(e);
  if (
- clk_enable(e)
+ clk_prepare_enable(e)
  ) S

@@
expression e,r2;
identifier r1;
statement S;
@@

- r1 = clk_prepare(e); if (r1) S
  r2 =
-  clk_enable
+  clk_prepare_enable
   (e);
  if (r2) { ...
- clk_unprepare(e); // unsafe!
  ...
  return ...;
  }

@@
expression e,r2;
identifier r1;
statement S;
@@

- r1 = clk_prepare(e); if (r1) S
  r2 =
-  clk_enable
+  clk_prepare_enable
   (e);

@@
expression e;
statement S1;
@@

- if (clk_prepare(e)) S1
  if (
-  clk_enable
+  clk_prepare_enable
     (e)) { ...
- clk_unprepare(e); // unsafe!
  ...
  return ...;
  }

@@
expression e;
statement S1,S2;
@@

- if (clk_prepare(e)) S1
  if (
-  clk_enable
+  clk_prepare_enable
     (e)) S2

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>


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

* [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-08-27  4:01   ` viresh kumar
  2012-08-26 16:00 ` [PATCH 2/13] drivers/spi/spi-{orion,pl022}.c: " Julia Lawall
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: kernel-janitors, Greg Kroah-Hartman, linux-iio, devel, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/staging/iio/adc/spear_adc.c |   25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
index 675c427..0b83e2e 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -330,36 +330,30 @@ static int __devinit spear_adc_probe(struct platform_device *pdev)
 		goto errout3;
 	}
 
-	ret = clk_prepare(info->clk);
-	if (ret) {
-		dev_err(dev, "failed preparing clock\n");
-		goto errout4;
-	}
-
-	ret = clk_enable(info->clk);
+	ret = clk_prepare_enable(info->clk);
 	if (ret) {
 		dev_err(dev, "failed enabling clock\n");
-		goto errout5;
+		goto errout4;
 	}
 
 	irq = platform_get_irq(pdev, 0);
 	if ((irq < 0) || (irq >= NR_IRQS)) {
 		dev_err(dev, "failed getting interrupt resource\n");
 		ret = -EINVAL;
-		goto errout6;
+		goto errout5;
 	}
 
 	ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
 	if (ret < 0) {
 		dev_err(dev, "failed requesting interrupt\n");
-		goto errout6;
+		goto errout5;
 	}
 
 	if (of_property_read_u32(np, "sampling-frequency",
 				 &info->sampling_freq)) {
 		dev_err(dev, "sampling-frequency missing in DT\n");
 		ret = -EINVAL;
-		goto errout6;
+		goto errout5;
 	}
 
 	/*
@@ -389,16 +383,14 @@ static int __devinit spear_adc_probe(struct platform_device *pdev)
 
 	ret = iio_device_register(iodev);
 	if (ret)
-		goto errout6;
+		goto errout5;
 
 	dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
 
 	return 0;
 
-errout6:
-	clk_disable(info->clk);
 errout5:
-	clk_unprepare(info->clk);
+	clk_disable_unprepare(info->clk);
 errout4:
 	clk_put(info->clk);
 errout3:
@@ -416,8 +408,7 @@ static int __devexit spear_adc_remove(struct platform_device *pdev)
 
 	iio_device_unregister(iodev);
 	platform_set_drvdata(pdev, NULL);
-	clk_disable(info->clk);
-	clk_unprepare(info->clk);
+	clk_disable_unprepare(info->clk);
 	clk_put(info->clk);
 	iounmap(info->adc_base_spear6xx);
 	iio_device_free(iodev);


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

* [PATCH 2/13] drivers/spi/spi-{orion,pl022}.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
  2012-08-26 16:00 ` [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: " Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-08-26 16:00 ` [PATCH 3/13] drivers/gpio/gpio-pxa.c: " Julia Lawall
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Grant Likely; +Cc: kernel-janitors, spi-devel-general, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/spi/spi-orion.c |    3 +--
 drivers/spi/spi-pl022.c |   17 ++++-------------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index b17c09c..b2a7199 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -416,8 +416,7 @@ static int __init orion_spi_probe(struct platform_device *pdev)
 		goto out;
 	}
 
-	clk_prepare(spi->clk);
-	clk_enable(spi->clk);
+	clk_prepare_enable(spi->clk);
 	tclk_hz = clk_get_rate(spi->clk);
 	spi->max_speed = DIV_ROUND_UP(tclk_hz, 4);
 	spi->min_speed = DIV_ROUND_UP(tclk_hz, 30);
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index b0fec03..0d235d4 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2142,16 +2142,10 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 		goto err_no_clk;
 	}
 
-	status = clk_prepare(pl022->clk);
-	if (status) {
-		dev_err(&adev->dev, "could not prepare SSP/SPI bus clock\n");
-		goto  err_clk_prep;
-	}
-
-	status = clk_enable(pl022->clk);
+	status = clk_prepare_enable(pl022->clk);
 	if (status) {
 		dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n");
-		goto err_no_clk_en;
+		goto err_clk_prep;
 	}
 
 	/* Initialize transfer pump */
@@ -2207,9 +2201,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
 
 	free_irq(adev->irq[0], pl022);
  err_no_irq:
-	clk_disable(pl022->clk);
- err_no_clk_en:
-	clk_unprepare(pl022->clk);
+	clk_disable_unprepare(pl022->clk);
  err_clk_prep:
 	clk_put(pl022->clk);
  err_no_clk:
@@ -2243,8 +2235,7 @@ pl022_remove(struct amba_device *adev)
 		pl022_dma_remove(pl022);
 
 	free_irq(adev->irq[0], pl022);
-	clk_disable(pl022->clk);
-	clk_unprepare(pl022->clk);
+	clk_disable_unprepare(pl022->clk);
 	clk_put(pl022->clk);
 	pm_runtime_disable(&adev->dev);
 	iounmap(pl022->virtbase);


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

* [PATCH 3/13] drivers/gpio/gpio-pxa.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
  2012-08-26 16:00 ` [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: " Julia Lawall
  2012-08-26 16:00 ` [PATCH 2/13] drivers/spi/spi-{orion,pl022}.c: " Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-09-01  4:15   ` Linus Walleij
  2012-08-26 16:00 ` [PATCH 4/13] i2c: sirf: " Julia Lawall
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Grant Likely; +Cc: kernel-janitors, Linus Walleij, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/gpio/gpio-pxa.c |    9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 9528779..bd8fb66 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -589,19 +589,12 @@ static int __devinit pxa_gpio_probe(struct platform_device *pdev)
 		iounmap(gpio_reg_base);
 		return PTR_ERR(clk);
 	}
-	ret = clk_prepare(clk);
+	ret = clk_prepare_enable(clk);
 	if (ret) {
 		clk_put(clk);
 		iounmap(gpio_reg_base);
 		return ret;
 	}
-	ret = clk_enable(clk);
-	if (ret) {
-		clk_unprepare(clk);
-		clk_put(clk);
-		iounmap(gpio_reg_base);
-		return ret;
-	}
 
 	/* Initialize GPIO chips */
 	info = dev_get_platdata(&pdev->dev);


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

* [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (2 preceding siblings ...)
  2012-08-26 16:00 ` [PATCH 3/13] drivers/gpio/gpio-pxa.c: " Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-08-27  1:44   ` Barry Song
  2012-08-26 16:00 ` [PATCH 5/13] arch/arm: " Julia Lawall
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Barry Song
  Cc: kernel-janitors, Jean Delvare (PC drivers, core),
	Ben Dooks (embedded platforms), Wolfram Sang (embedded platforms),
	linux-arm-kernel, linux-i2c, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/i2c/busses/i2c-sirf.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index 5574a47..110660a 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -278,18 +278,12 @@ static int __devinit i2c_sirfsoc_probe(struct platform_device *pdev)
 		goto err_get_clk;
 	}
 
-	err = clk_prepare(clk);
+	err = clk_prepare_enable(clk);
 	if (err) {
-		dev_err(&pdev->dev, "Clock prepare failed\n");
+		dev_err(&pdev->dev, "Clock prepare or enable failed\n");
 		goto err_clk_prep;
 	}
 
-	err = clk_enable(clk);
-	if (err) {
-		dev_err(&pdev->dev, "Clock enable failed\n");
-		goto err_clk_en;
-	}
-
 	ctrl_speed = clk_get_rate(clk);
 
 	siic = devm_kzalloc(&pdev->dev, sizeof(*siic), GFP_KERNEL);
@@ -376,9 +370,7 @@ static int __devinit i2c_sirfsoc_probe(struct platform_device *pdev)
 	return 0;
 
 out:
-	clk_disable(clk);
-err_clk_en:
-	clk_unprepare(clk);
+	clk_disable_unprepare(clk);
 err_clk_prep:
 	clk_put(clk);
 err_get_clk:


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

* [PATCH 5/13] arch/arm: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (3 preceding siblings ...)
  2012-08-26 16:00 ` [PATCH 4/13] i2c: sirf: " Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-08-27  5:57   ` Pankaj Jangra
  2012-08-26 16:00 ` [PATCH 6/13] drivers/iio/adc/at91_adc.c: " Julia Lawall
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Russell King; +Cc: kernel-janitors, linux-arm-kernel, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/arm/common/sa1111.c   |    3 +--
 arch/arm/common/timer-sp.c |   16 ++++------------
 arch/arm/kernel/smp_twd.c  |   13 +++----------
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 9173d11..bd58414 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -834,8 +834,7 @@ static void __sa1111_remove(struct sa1111 *sachip)
 	sa1111_writel(0, irqbase + SA1111_WAKEEN0);
 	sa1111_writel(0, irqbase + SA1111_WAKEEN1);
 
-	clk_disable(sachip->clk);
-	clk_unprepare(sachip->clk);
+	clk_disable_unprepare(sachip->clk);
 
 	if (sachip->irq != NO_IRQ) {
 		irq_set_chained_handler(sachip->irq, NULL);
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index df13a3f..af1a4ab 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -42,17 +42,10 @@ static long __init sp804_get_clock_rate(const char *name)
 		return PTR_ERR(clk);
 	}
 
-	err = clk_prepare(clk);
+	err = clk_prepare_enable(clk);
 	if (err) {
-		pr_err("sp804: %s clock failed to prepare: %d\n", name, err);
-		clk_put(clk);
-		return err;
-	}
-
-	err = clk_enable(clk);
-	if (err) {
-		pr_err("sp804: %s clock failed to enable: %d\n", name, err);
-		clk_unprepare(clk);
+		pr_err("sp804: %s clock failed to prepare or to enable: %d\n",
+		       name, err);
 		clk_put(clk);
 		return err;
 	}
@@ -60,8 +53,7 @@ static long __init sp804_get_clock_rate(const char *name)
 	rate = clk_get_rate(clk);
 	if (rate < 0) {
 		pr_err("sp804: %s clock failed to get rate: %ld\n", name, rate);
-		clk_disable(clk);
-		clk_unprepare(clk);
+		clk_disable_unprepare(clk);
 		clk_put(clk);
 	}
 
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index fef42b2..8c94b8b 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -204,17 +204,10 @@ static struct clk *twd_get_clock(void)
 		return clk;
 	}
 
-	err = clk_prepare(clk);
+	err = clk_prepare_enable(clk);
 	if (err) {
-		pr_err("smp_twd: clock failed to prepare: %d\n", err);
-		clk_put(clk);
-		return ERR_PTR(err);
-	}
-
-	err = clk_enable(clk);
-	if (err) {
-		pr_err("smp_twd: clock failed to enable: %d\n", err);
-		clk_unprepare(clk);
+		pr_err("smp_twd: clock failed to prepare or to enable: %d\n",
+		       err);
 		clk_put(clk);
 		return ERR_PTR(err);
 	}


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

* [PATCH 6/13] drivers/iio/adc/at91_adc.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (4 preceding siblings ...)
  2012-08-26 16:00 ` [PATCH 5/13] arch/arm: " Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-08-27 20:12   ` Jonathan Cameron
  2012-08-26 16:00 ` [PATCH 7/13] drivers/mmc/host/mmci.c: " Julia Lawall
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: kernel-janitors, linux-iio, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/iio/adc/at91_adc.c |   33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 98c96f9..c1e4690 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -589,18 +589,13 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
 		goto error_free_irq;
 	}
 
-	ret = clk_prepare(st->clk);
+	ret = clk_prepare_enable(st->clk);
 	if (ret) {
-		dev_err(&pdev->dev, "Could not prepare the clock.\n");
+		dev_err(&pdev->dev,
+			"Could not prepare or enable the clock.\n");
 		goto error_free_irq;
 	}
 
-	ret = clk_enable(st->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Could not enable the clock.\n");
-		goto error_unprepare_clk;
-	}
-
 	st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk");
 	if (IS_ERR(st->adc_clk)) {
 		dev_err(&pdev->dev, "Failed to get the ADC clock.\n");
@@ -608,18 +603,13 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
 		goto error_disable_clk;
 	}
 
-	ret = clk_prepare(st->adc_clk);
+	ret = clk_prepare_enable(st->adc_clk);
 	if (ret) {
-		dev_err(&pdev->dev, "Could not prepare the ADC clock.\n");
+		dev_err(&pdev->dev,
+			"Could not prepare or enable the ADC clock.\n");
 		goto error_disable_clk;
 	}
 
-	ret = clk_enable(st->adc_clk);
-	if (ret) {
-		dev_err(&pdev->dev, "Could not enable the ADC clock.\n");
-		goto error_unprepare_adc_clk;
-	}
-
 	/*
 	 * Prescaler rate computation using the formula from the Atmel's
 	 * datasheet : ADC Clock = MCK / ((Prescaler + 1) * 2), ADC Clock being
@@ -681,13 +671,9 @@ error_remove_triggers:
 error_unregister_buffer:
 	at91_adc_buffer_remove(idev);
 error_disable_adc_clk:
-	clk_disable(st->adc_clk);
-error_unprepare_adc_clk:
-	clk_unprepare(st->adc_clk);
+	clk_disable_unprepare(st->adc_clk);
 error_disable_clk:
-	clk_disable(st->clk);
-error_unprepare_clk:
-	clk_unprepare(st->clk);
+	clk_disable_unprepare(st->clk);
 error_free_irq:
 	free_irq(st->irq, idev);
 error_free_device:
@@ -705,8 +691,7 @@ static int __devexit at91_adc_remove(struct platform_device *pdev)
 	at91_adc_trigger_remove(idev);
 	at91_adc_buffer_remove(idev);
 	clk_disable_unprepare(st->adc_clk);
-	clk_disable(st->clk);
-	clk_unprepare(st->clk);
+	clk_disable_unprepare(st->clk);
 	free_irq(st->irq, idev);
 	iio_device_free(idev);
 


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

* [PATCH 7/13] drivers/mmc/host/mmci.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (5 preceding siblings ...)
  2012-08-26 16:00 ` [PATCH 6/13] drivers/iio/adc/at91_adc.c: " Julia Lawall
@ 2012-08-26 16:00 ` Julia Lawall
  2012-08-27 12:33   ` Ulf Hansson
  2012-09-19  5:09   ` Chris Ball
  2012-08-26 16:01 ` [PATCH 8/13] i2c: mv64xxx: " Julia Lawall
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:00 UTC (permalink / raw)
  To: Chris Ball; +Cc: kernel-janitors, linux-mmc, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/mmc/host/mmci.c |   13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 50ff19a..edc3e9b 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1309,14 +1309,10 @@ static int __devinit mmci_probe(struct amba_device *dev,
 		goto host_free;
 	}
 
-	ret = clk_prepare(host->clk);
+	ret = clk_prepare_enable(host->clk);
 	if (ret)
 		goto clk_free;
 
-	ret = clk_enable(host->clk);
-	if (ret)
-		goto clk_unprep;
-
 	host->plat = plat;
 	host->variant = variant;
 	host->mclk = clk_get_rate(host->clk);
@@ -1515,9 +1511,7 @@ static int __devinit mmci_probe(struct amba_device *dev,
  err_gpio_cd:
 	iounmap(host->base);
  clk_disable:
-	clk_disable(host->clk);
- clk_unprep:
-	clk_unprepare(host->clk);
+	clk_disable_unprepare(host->clk);
  clk_free:
 	clk_put(host->clk);
  host_free:
@@ -1564,8 +1558,7 @@ static int __devexit mmci_remove(struct amba_device *dev)
 			gpio_free(host->gpio_cd);
 
 		iounmap(host->base);
-		clk_disable(host->clk);
-		clk_unprepare(host->clk);
+		clk_disable_unprepare(host->clk);
 		clk_put(host->clk);
 
 		if (host->vcc)


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

* [PATCH 8/13] i2c: mv64xxx: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (6 preceding siblings ...)
  2012-08-26 16:00 ` [PATCH 7/13] drivers/mmc/host/mmci.c: " Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
  2012-08-26 16:01 ` [PATCH 9/13] drivers/tty/serial/amba-pl0{10,11}.c: " Julia Lawall
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:01 UTC (permalink / raw)
  To: Jean Delvare (PC drivers core)
  Cc: kernel-janitors, Ben Dooks (embedded platforms),
	Wolfram Sang (embedded platforms),
	linux-i2c, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/i2c/busses/i2c-mv64xxx.c |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 2e9d567..046c4b5 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -633,10 +633,8 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 #if defined(CONFIG_HAVE_CLK)
 	/* Not all platforms have a clk */
 	drv_data->clk = clk_get(&pd->dev, NULL);
-	if (!IS_ERR(drv_data->clk)) {
-		clk_prepare(drv_data->clk);
-		clk_enable(drv_data->clk);
-	}
+	if (!IS_ERR(drv_data->clk))
+		clk_prepare_enable(drv_data->clk);
 #endif
 	if (pdata) {
 		drv_data->freq_m = pdata->freq_m;
@@ -686,10 +684,8 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 	exit_unmap_regs:
 #if defined(CONFIG_HAVE_CLK)
 	/* Not all platforms have a clk */
-	if (!IS_ERR(drv_data->clk)) {
-		clk_disable(drv_data->clk);
-		clk_unprepare(drv_data->clk);
-	}
+	if (!IS_ERR(drv_data->clk))
+		clk_disable_unprepare(drv_data->clk);
 #endif
 		mv64xxx_i2c_unmap_regs(drv_data);
 	exit_kfree:
@@ -708,10 +704,8 @@ mv64xxx_i2c_remove(struct platform_device *dev)
 	mv64xxx_i2c_unmap_regs(drv_data);
 #if defined(CONFIG_HAVE_CLK)
 	/* Not all platforms have a clk */
-	if (!IS_ERR(drv_data->clk)) {
-		clk_disable(drv_data->clk);
-		clk_unprepare(drv_data->clk);
-	}
+	if (!IS_ERR(drv_data->clk))
+		clk_disable_unprepare(drv_data->clk);
 #endif
 	kfree(drv_data);
 


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

* [PATCH 9/13] drivers/tty/serial/amba-pl0{10,11}.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (7 preceding siblings ...)
  2012-08-26 16:01 ` [PATCH 8/13] i2c: mv64xxx: " Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
  2012-08-26 16:01 ` [PATCH 10/13] drivers/watchdog/sp805_wdt.c: " Julia Lawall
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:01 UTC (permalink / raw)
  To: Alan Cox; +Cc: kernel-janitors, Greg Kroah-Hartman, linux-serial, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  The9 make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/tty/serial/amba-pl010.c |   15 ++++-----------
 drivers/tty/serial/amba-pl011.c |   15 ++++-----------
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 0d91a54..22317dd 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -312,16 +312,12 @@ static int pl010_startup(struct uart_port *port)
 	struct uart_amba_port *uap = (struct uart_amba_port *)port;
 	int retval;
 
-	retval = clk_prepare(uap->clk);
-	if (retval)
-		goto out;
-
 	/*
 	 * Try to enable the clock producer.
 	 */
-	retval = clk_enable(uap->clk);
+	retval = clk_prepare_enable(uap->clk);
 	if (retval)
-		goto clk_unprep;
+		goto out;
 
 	uap->port.uartclk = clk_get_rate(uap->clk);
 
@@ -346,9 +342,7 @@ static int pl010_startup(struct uart_port *port)
 	return 0;
 
  clk_dis:
-	clk_disable(uap->clk);
- clk_unprep:
-	clk_unprepare(uap->clk);
+	clk_disable_unprepare(uap->clk);
  out:
 	return retval;
 }
@@ -375,8 +369,7 @@ static void pl010_shutdown(struct uart_port *port)
 	/*
 	 * Shut down the clock producer
 	 */
-	clk_disable(uap->clk);
-	clk_unprepare(uap->clk);
+	clk_disable_unprepare(uap->clk);
 }
 
 static void
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 92b1ac8..3322023 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1324,16 +1324,12 @@ static int pl011_startup(struct uart_port *port)
 				"could not set default pins\n");
 	}
 
-	retval = clk_prepare(uap->clk);
-	if (retval)
-		goto out;
-
 	/*
 	 * Try to enable the clock producer.
 	 */
-	retval = clk_enable(uap->clk);
+	retval = clk_prepare_enable(uap->clk);
 	if (retval)
-		goto clk_unprep;
+		goto out;
 
 	uap->port.uartclk = clk_get_rate(uap->clk);
 
@@ -1411,9 +1407,7 @@ static int pl011_startup(struct uart_port *port)
 	return 0;
 
  clk_dis:
-	clk_disable(uap->clk);
- clk_unprep:
-	clk_unprepare(uap->clk);
+	clk_disable_unprepare(uap->clk);
  out:
 	return retval;
 }
@@ -1473,8 +1467,7 @@ static void pl011_shutdown(struct uart_port *port)
 	/*
 	 * Shut down the clock producer
 	 */
-	clk_disable(uap->clk);
-	clk_unprepare(uap->clk);
+	clk_disable_unprepare(uap->clk);
 	/* Optionally let pins go into sleep states */
 	if (!IS_ERR(uap->pins_sleep)) {
 		retval = pinctrl_select_state(uap->pinctrl, uap->pins_sleep);


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

* [PATCH 10/13] drivers/watchdog/sp805_wdt.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (8 preceding siblings ...)
  2012-08-26 16:01 ` [PATCH 9/13] drivers/tty/serial/amba-pl0{10,11}.c: " Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
  2012-08-27  4:04   ` viresh kumar
  2012-08-26 16:01 ` [PATCH 11/13] arch/arm/mach-at91/gpio.c: " Julia Lawall
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:01 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: kernel-janitors, linux-watchdog, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/watchdog/sp805_wdt.c |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/sp805_wdt.c b/drivers/watchdog/sp805_wdt.c
index e4841c3..cabb040 100644
--- a/drivers/watchdog/sp805_wdt.c
+++ b/drivers/watchdog/sp805_wdt.c
@@ -130,16 +130,10 @@ static int wdt_config(struct watchdog_device *wdd, bool ping)
 	int ret;
 
 	if (!ping) {
-		ret = clk_prepare(wdt->clk);
-		if (ret) {
-			dev_err(&wdt->adev->dev, "clock prepare fail");
-			return ret;
-		}
 
-		ret = clk_enable(wdt->clk);
+		ret = clk_prepare_enable(wdt->clk);
 		if (ret) {
 			dev_err(&wdt->adev->dev, "clock enable fail");
-			clk_unprepare(wdt->clk);
 			return ret;
 		}
 	}
@@ -190,8 +184,7 @@ static int wdt_disable(struct watchdog_device *wdd)
 	readl_relaxed(wdt->base + WDTLOCK);
 	spin_unlock(&wdt->lock);
 
-	clk_disable(wdt->clk);
-	clk_unprepare(wdt->clk);
+	clk_disable_unprepare(wdt->clk);
 
 	return 0;
 }


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

* [PATCH 11/13] arch/arm/mach-at91/gpio.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (9 preceding siblings ...)
  2012-08-26 16:01 ` [PATCH 10/13] drivers/watchdog/sp805_wdt.c: " Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
  2012-08-26 16:01 ` [PATCH 12/13] drivers/amba/bus.c: " Julia Lawall
  2012-08-26 16:01 ` [PATCH 13/13] drivers/rtc/rtc-coh901331.c: " Julia Lawall
  12 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:01 UTC (permalink / raw)
  To: Andrew Victor
  Cc: kernel-janitors, Nicolas Ferre, Jean-Christophe Plagniol-Villard,
	Russell King, linux-arm-kernel, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 arch/arm/mach-at91/gpio.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index be42cf0..7760f35 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -956,19 +956,14 @@ static int __init at91_gpio_setup_clk(int idx)
 		goto err;
 	}
 
-	if (clk_prepare(at91_gpio->clock))
-		goto clk_prep_err;
-
 	/* enable PIO controller's clock */
-	if (clk_enable(at91_gpio->clock)) {
+	if (clk_prepare_enable(at91_gpio->clock)) {
 		pr_err("at91_gpio.%d, failed to enable clock, ignoring.\n", idx);
-		goto clk_err;
+		goto clk_prep_err;
 	}
 
 	return 0;
 
-clk_err:
-	clk_unprepare(at91_gpio->clock);
 clk_prep_err:
 	clk_put(at91_gpio->clock);
 err:


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

* [PATCH 12/13] drivers/amba/bus.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (10 preceding siblings ...)
  2012-08-26 16:01 ` [PATCH 11/13] arch/arm/mach-at91/gpio.c: " Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
  2012-08-26 16:01 ` [PATCH 13/13] drivers/rtc/rtc-coh901331.c: " Julia Lawall
  12 siblings, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:01 UTC (permalink / raw)
  To: Russell King; +Cc: kernel-janitors, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/amba/bus.c |   15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index e8eb91b..6374ee6 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -329,17 +329,9 @@ static int amba_get_enable_pclk(struct amba_device *pcdev)
 	if (IS_ERR(pclk))
 		return PTR_ERR(pclk);
 
-	ret = clk_prepare(pclk);
-	if (ret) {
-		clk_put(pclk);
-		return ret;
-	}
-
-	ret = clk_enable(pclk);
-	if (ret) {
-		clk_unprepare(pclk);
+	ret = clk_prepare_enable(pclk);
+	if (ret)
 		clk_put(pclk);
-	}
 
 	return ret;
 }
@@ -348,8 +340,7 @@ static void amba_put_disable_pclk(struct amba_device *pcdev)
 {
 	struct clk *pclk = pcdev->pclk;
 
-	clk_disable(pclk);
-	clk_unprepare(pclk);
+	clk_disable_unprepare(pclk);
 	clk_put(pclk);
 }
 


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

* [PATCH 13/13] drivers/rtc/rtc-coh901331.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
                   ` (11 preceding siblings ...)
  2012-08-26 16:01 ` [PATCH 12/13] drivers/amba/bus.c: " Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
  2012-08-28  0:25   ` Linus Walleij
  12 siblings, 1 reply; 27+ messages in thread
From: Julia Lawall @ 2012-08-26 16:01 UTC (permalink / raw)
  To: Linus Walleij
  Cc: kernel-janitors, Alessandro Zummo, linux-arm-kernel, rtc-linux,
	linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
I'm not sure about this.  Maybe it would be better to leave the disable and
unprepare separated, since there is no matching nearby clk_prepare.

 drivers/rtc/rtc-coh901331.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c
index 76b2156..c8115b8 100644
--- a/drivers/rtc/rtc-coh901331.c
+++ b/drivers/rtc/rtc-coh901331.c
@@ -276,8 +276,7 @@ static void coh901331_shutdown(struct platform_device *pdev)
 
 	clk_enable(rtap->clk);
 	writel(0, rtap->virtbase + COH901331_IRQ_MASK);
-	clk_disable(rtap->clk);
-	clk_unprepare(rtap->clk);
+	clk_disable_unprepare(rtap->clk);
 }
 
 static struct platform_driver coh901331_driver = {


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

* Re: [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 4/13] i2c: sirf: " Julia Lawall
@ 2012-08-27  1:44   ` Barry Song
  0 siblings, 0 replies; 27+ messages in thread
From: Barry Song @ 2012-08-27  1:44 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Wolfram Sang (embedded platforms),
	linux-kernel, linux-i2c, Ben Dooks (embedded platforms),
	Jean Delvare (PC drivers, core),
	linux-arm-kernel, DL-SHA-WorkGroupLinux

2012/8/27 Julia Lawall <Julia.Lawall@lip6.fr>:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
>
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e;
> @@
>
> - clk_prepare(e);
> - clk_enable(e);
> + clk_prepare_enable(e);
>
> @@
> expression e;
> @@
>
> - clk_disable(e);
> - clk_unprepare(e);
> + clk_disable_unprepare(e);
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Acked-by: Barry Song <21cnbao@gmail.com>

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

* Re: [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: " Julia Lawall
@ 2012-08-27  4:01   ` viresh kumar
  2012-08-27 20:06     ` Jonathan Cameron
  0 siblings, 1 reply; 27+ messages in thread
From: viresh kumar @ 2012-08-27  4:01 UTC (permalink / raw)
  To: Julia Lawall, Stefan Roese, Shiraz HASHIM
  Cc: Jonathan Cameron, kernel-janitors, Greg Kroah-Hartman, linux-iio,
	devel, linux-kernel, spear-devel

On Sun, Aug 26, 2012 at 9:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
>
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)

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

@Stefan/Shiraz: Can you update spear-devel mailing list in MAINTAINERS file
for this driver?

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

* Re: [PATCH 10/13] drivers/watchdog/sp805_wdt.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:01 ` [PATCH 10/13] drivers/watchdog/sp805_wdt.c: " Julia Lawall
@ 2012-08-27  4:04   ` viresh kumar
  0 siblings, 0 replies; 27+ messages in thread
From: viresh kumar @ 2012-08-27  4:04 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Wim Van Sebroeck, kernel-janitors, linux-watchdog, linux-kernel,
	spear-devel

On Sun, Aug 26, 2012 at 9:31 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
>
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)

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

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

* Re: [PATCH 5/13] arch/arm: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 5/13] arch/arm: " Julia Lawall
@ 2012-08-27  5:57   ` Pankaj Jangra
  0 siblings, 0 replies; 27+ messages in thread
From: Pankaj Jangra @ 2012-08-27  5:57 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Russell King, kernel-janitors, linux-kernel, linux-arm-kernel

Hi,

On Sun, Aug 26, 2012 at 9:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
>
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e;
> @@
>
> - clk_prepare(e);
> - clk_enable(e);
> + clk_prepare_enable(e);
>
> @@
> expression e;
> @@
>
> - clk_disable(e);
> - clk_unprepare(e);
> + clk_disable_unprepare(e);
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  arch/arm/common/sa1111.c   |    3 +--
>  arch/arm/common/timer-sp.c |   16 ++++------------
>  arch/arm/kernel/smp_twd.c  |   13 +++----------
>  3 files changed, 8 insertions(+), 24 deletions(-)
>

Reviewed-by: Pankaj Jangra <jangra.pankaj9@gmail.com>

Regards,
Pankaj Jangra

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

* Re: [PATCH 7/13] drivers/mmc/host/mmci.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 7/13] drivers/mmc/host/mmci.c: " Julia Lawall
@ 2012-08-27 12:33   ` Ulf Hansson
  2012-08-27 12:46     ` Julia Lawall
  2012-08-27 12:55     ` Julia Lawall
  2012-09-19  5:09   ` Chris Ball
  1 sibling, 2 replies; 27+ messages in thread
From: Ulf Hansson @ 2012-08-27 12:33 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Chris Ball, kernel-janitors, linux-mmc, linux-kernel

Hi Julia,

Patches for mmci should normally be sent on the arm list as well. mmci
is maintained by Russell King, even if the MAINTAINER file does not
say so.

Some minor comment below.

On 26 August 2012 18:00, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>

I think can simplify the commit msg a lot. Just say something with
"simplify clock code in probe".

> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
>
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e;
> @@
>
> - clk_prepare(e);
> - clk_enable(e);
> + clk_prepare_enable(e);
>
> @@
> expression e;
> @@
>
> - clk_disable(e);
> - clk_unprepare(e);
> + clk_disable_unprepare(e);
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/mmc/host/mmci.c |   13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 50ff19a..edc3e9b 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -1309,14 +1309,10 @@ static int __devinit mmci_probe(struct amba_device *dev,
>                 goto host_free;
>         }
>
> -       ret = clk_prepare(host->clk);
> +       ret = clk_prepare_enable(host->clk);

white space? Did you run checkpatch?

>         if (ret)
>                 goto clk_free;
>
> -       ret = clk_enable(host->clk);
> -       if (ret)
> -               goto clk_unprep;
> -
>         host->plat = plat;
>         host->variant = variant;
>         host->mclk = clk_get_rate(host->clk);
> @@ -1515,9 +1511,7 @@ static int __devinit mmci_probe(struct amba_device *dev,
>   err_gpio_cd:
>         iounmap(host->base);
>   clk_disable:
> -       clk_disable(host->clk);
> - clk_unprep:
> -       clk_unprepare(host->clk);
> +       clk_disable_unprepare(host->clk);

white space? Did you run checkpatch?

>   clk_free:
>         clk_put(host->clk);
>   host_free:
> @@ -1564,8 +1558,7 @@ static int __devexit mmci_remove(struct amba_device *dev)
>                         gpio_free(host->gpio_cd);
>
>                 iounmap(host->base);
> -               clk_disable(host->clk);
> -               clk_unprepare(host->clk);
> +               clk_disable_unprepare(host->clk);

white space? Did you run checkpatch?

>                 clk_put(host->clk);
>
>                 if (host->vcc)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Kind regards
Ulf Hansson

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

* Re: [PATCH 7/13] drivers/mmc/host/mmci.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-27 12:33   ` Ulf Hansson
@ 2012-08-27 12:46     ` Julia Lawall
  2012-08-27 12:55     ` Julia Lawall
  1 sibling, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-27 12:46 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Julia Lawall, Chris Ball, kernel-janitors, linux-mmc, linux-kernel

On Mon, 27 Aug 2012, Ulf Hansson wrote:

> Hi Julia,
>
> Patches for mmci should normally be sent on the arm list as well. mmci
> is maintained by Russell King, even if the MAINTAINER file does not
> say so.

Would it be possible to update the MAINTAINER file?

> Some minor comment below.
>
> On 26 August 2012 18:00, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> > From: Julia Lawall <Julia.Lawall@lip6.fr>
> >
>
> I think can simplify the commit msg a lot. Just say something with
> "simplify clock code in probe".

OK, I wasn't familiar with these functions before, so I wanted to explain
my rationale for making the change, in case I was totally off base.

> > Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> > clk_enable, and clk_disable and clk_unprepare.  They make the code more
> > concise, and ensure that clk_unprepare is called when clk_enable fails.
> >
> > A simplified version of the semantic patch that introduces calls to these
> > functions is as follows: (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @@
> > expression e;
> > @@
> >
> > - clk_prepare(e);
> > - clk_enable(e);
> > + clk_prepare_enable(e);
> >
> > @@
> > expression e;
> > @@
> >
> > - clk_disable(e);
> > - clk_unprepare(e);
> > + clk_disable_unprepare(e);
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >  drivers/mmc/host/mmci.c |   13 +++----------
> >  1 file changed, 3 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> > index 50ff19a..edc3e9b 100644
> > --- a/drivers/mmc/host/mmci.c
> > +++ b/drivers/mmc/host/mmci.c
> > @@ -1309,14 +1309,10 @@ static int __devinit mmci_probe(struct amba_device *dev,
> >                 goto host_free;
> >         }
> >
> > -       ret = clk_prepare(host->clk);
> > +       ret = clk_prepare_enable(host->clk);
>
> white space? Did you run checkpatch?

Yes, I did.  And I did so again just now:

palace:linux-next: scripts/checkpatch.pl ~/patches/prepare2/send7
total: 0 errors, 0 warnings, 34 lines checked

/home/julia/patches/prepare2/send7 has no obvious style problems and is
ready for submission.  I can see that in your reply there are no tabs,
only space.  If you received it that way, perhaps it is a mailer problem
on my side, although I didn't do anything unusual for this patch.

I will try again.

julia


> >         if (ret)
> >                 goto clk_free;
> >
> > -       ret = clk_enable(host->clk);
> > -       if (ret)
> > -               goto clk_unprep;
> > -
> >         host->plat = plat;
> >         host->variant = variant;
> >         host->mclk = clk_get_rate(host->clk);
> > @@ -1515,9 +1511,7 @@ static int __devinit mmci_probe(struct amba_device *dev,
> >   err_gpio_cd:
> >         iounmap(host->base);
> >   clk_disable:
> > -       clk_disable(host->clk);
> > - clk_unprep:
> > -       clk_unprepare(host->clk);
> > +       clk_disable_unprepare(host->clk);
>
> white space? Did you run checkpatch?
>
> >   clk_free:
> >         clk_put(host->clk);
> >   host_free:
> > @@ -1564,8 +1558,7 @@ static int __devexit mmci_remove(struct amba_device *dev)
> >                         gpio_free(host->gpio_cd);
> >
> >                 iounmap(host->base);
> > -               clk_disable(host->clk);
> > -               clk_unprepare(host->clk);
> > +               clk_disable_unprepare(host->clk);
>
> white space? Did you run checkpatch?
>
> >                 clk_put(host->clk);
> >
> >                 if (host->vcc)
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> Kind regards
> Ulf Hansson
>

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

* Re: [PATCH 7/13] drivers/mmc/host/mmci.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-27 12:33   ` Ulf Hansson
  2012-08-27 12:46     ` Julia Lawall
@ 2012-08-27 12:55     ` Julia Lawall
  1 sibling, 0 replies; 27+ messages in thread
From: Julia Lawall @ 2012-08-27 12:55 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Julia Lawall, Chris Ball, kernel-janitors, linux-mmc,
	linux-kernel, Russell King

From: Julia Lawall <Julia.Lawall@lip6.fr>

Simplify clock code in probe.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
v2, try to avoid whitespace problem

 drivers/mmc/host/mmci.c |   13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 50ff19a..edc3e9b 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1309,14 +1309,10 @@ static int __devinit mmci_probe(struct amba_device *dev,
 		goto host_free;
 	}

-	ret = clk_prepare(host->clk);
+	ret = clk_prepare_enable(host->clk);
 	if (ret)
 		goto clk_free;

-	ret = clk_enable(host->clk);
-	if (ret)
-		goto clk_unprep;
-
 	host->plat = plat;
 	host->variant = variant;
 	host->mclk = clk_get_rate(host->clk);
@@ -1515,9 +1511,7 @@ static int __devinit mmci_probe(struct amba_device *dev,
  err_gpio_cd:
 	iounmap(host->base);
  clk_disable:
-	clk_disable(host->clk);
- clk_unprep:
-	clk_unprepare(host->clk);
+	clk_disable_unprepare(host->clk);
  clk_free:
 	clk_put(host->clk);
  host_free:
@@ -1564,8 +1558,7 @@ static int __devexit mmci_remove(struct amba_device *dev)
 			gpio_free(host->gpio_cd);

 		iounmap(host->base);
-		clk_disable(host->clk);
-		clk_unprepare(host->clk);
+		clk_disable_unprepare(host->clk);
 		clk_put(host->clk);

 		if (host->vcc)


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

* Re: [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-27  4:01   ` viresh kumar
@ 2012-08-27 20:06     ` Jonathan Cameron
  2012-08-27 20:09       ` Jonathan Cameron
  0 siblings, 1 reply; 27+ messages in thread
From: Jonathan Cameron @ 2012-08-27 20:06 UTC (permalink / raw)
  To: viresh kumar
  Cc: Julia Lawall, Stefan Roese, Shiraz HASHIM, Jonathan Cameron,
	kernel-janitors, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel, spear-devel

On 08/27/2012 05:01 AM, viresh kumar wrote:
> On Sun, Aug 26, 2012 at 9:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>> From: Julia Lawall <Julia.Lawall@lip6.fr>
>>
>> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
>> clk_enable, and clk_disable and clk_unprepare.  They make the code more
>> concise, and ensure that clk_unprepare is called when clk_enable fails.
>>
>> A simplified version of the semantic patch that introduces calls to these
>> functions is as follows: (http://coccinelle.lip6.fr/)
> 
> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
merged to fixes-togreg branch of kernel.org iio.git will push onwards in a few
days...
> 
> @Stefan/Shiraz: Can you update spear-devel mailing list in MAINTAINERS file
> for this driver?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" 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] 27+ messages in thread

* Re: [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-27 20:06     ` Jonathan Cameron
@ 2012-08-27 20:09       ` Jonathan Cameron
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Cameron @ 2012-08-27 20:09 UTC (permalink / raw)
  To: viresh kumar
  Cc: Julia Lawall, Stefan Roese, Shiraz HASHIM, Jonathan Cameron,
	kernel-janitors, Greg Kroah-Hartman, linux-iio, devel,
	linux-kernel, spear-devel

On 08/27/2012 09:06 PM, Jonathan Cameron wrote:
> On 08/27/2012 05:01 AM, viresh kumar wrote:
>> On Sun, Aug 26, 2012 at 9:30 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
>>> From: Julia Lawall <Julia.Lawall@lip6.fr>
>>>
>>> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
>>> clk_enable, and clk_disable and clk_unprepare.  They make the code more
>>> concise, and ensure that clk_unprepare is called when clk_enable fails.
>>>
>>> A simplified version of the semantic patch that introduces calls to these
>>> functions is as follows: (http://coccinelle.lip6.fr/)
>>
>> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
> merged to fixes-togreg branch of kernel.org iio.git will push onwards in a few
> days...
sorry, wrong branch as clearly just a cleanup not a fix. Will be in togreg
branch instead.
>>
>> @Stefan/Shiraz: Can you update spear-devel mailing list in MAINTAINERS file
>> for this driver?
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" 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] 27+ messages in thread

* Re: [PATCH 6/13] drivers/iio/adc/at91_adc.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 6/13] drivers/iio/adc/at91_adc.c: " Julia Lawall
@ 2012-08-27 20:12   ` Jonathan Cameron
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Cameron @ 2012-08-27 20:12 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Jonathan Cameron, kernel-janitors, linux-iio, linux-kernel

On 08/26/2012 05:00 PM, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
> 
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression e;
> @@
> 
> - clk_prepare(e);
> - clk_enable(e);
> + clk_prepare_enable(e);
> 
> @@
> expression e;
> @@
> 
> - clk_disable(e);
> - clk_unprepare(e);
> + clk_disable_unprepare(e);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
merged to togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

Thanks,

Jonathan
> 
> ---
>  drivers/iio/adc/at91_adc.c |   33 +++++++++------------------------
>  1 file changed, 9 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 98c96f9..c1e4690 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -589,18 +589,13 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
>  		goto error_free_irq;
>  	}
>  
> -	ret = clk_prepare(st->clk);
> +	ret = clk_prepare_enable(st->clk);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Could not prepare the clock.\n");
> +		dev_err(&pdev->dev,
> +			"Could not prepare or enable the clock.\n");
>  		goto error_free_irq;
>  	}
>  
> -	ret = clk_enable(st->clk);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Could not enable the clock.\n");
> -		goto error_unprepare_clk;
> -	}
> -
>  	st->adc_clk = devm_clk_get(&pdev->dev, "adc_op_clk");
>  	if (IS_ERR(st->adc_clk)) {
>  		dev_err(&pdev->dev, "Failed to get the ADC clock.\n");
> @@ -608,18 +603,13 @@ static int __devinit at91_adc_probe(struct platform_device *pdev)
>  		goto error_disable_clk;
>  	}
>  
> -	ret = clk_prepare(st->adc_clk);
> +	ret = clk_prepare_enable(st->adc_clk);
>  	if (ret) {
> -		dev_err(&pdev->dev, "Could not prepare the ADC clock.\n");
> +		dev_err(&pdev->dev,
> +			"Could not prepare or enable the ADC clock.\n");
>  		goto error_disable_clk;
>  	}
>  
> -	ret = clk_enable(st->adc_clk);
> -	if (ret) {
> -		dev_err(&pdev->dev, "Could not enable the ADC clock.\n");
> -		goto error_unprepare_adc_clk;
> -	}
> -
>  	/*
>  	 * Prescaler rate computation using the formula from the Atmel's
>  	 * datasheet : ADC Clock = MCK / ((Prescaler + 1) * 2), ADC Clock being
> @@ -681,13 +671,9 @@ error_remove_triggers:
>  error_unregister_buffer:
>  	at91_adc_buffer_remove(idev);
>  error_disable_adc_clk:
> -	clk_disable(st->adc_clk);
> -error_unprepare_adc_clk:
> -	clk_unprepare(st->adc_clk);
> +	clk_disable_unprepare(st->adc_clk);
>  error_disable_clk:
> -	clk_disable(st->clk);
> -error_unprepare_clk:
> -	clk_unprepare(st->clk);
> +	clk_disable_unprepare(st->clk);
>  error_free_irq:
>  	free_irq(st->irq, idev);
>  error_free_device:
> @@ -705,8 +691,7 @@ static int __devexit at91_adc_remove(struct platform_device *pdev)
>  	at91_adc_trigger_remove(idev);
>  	at91_adc_buffer_remove(idev);
>  	clk_disable_unprepare(st->adc_clk);
> -	clk_disable(st->clk);
> -	clk_unprepare(st->clk);
> +	clk_disable_unprepare(st->clk);
>  	free_irq(st->irq, idev);
>  	iio_device_free(idev);
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" 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] 27+ messages in thread

* Re: [PATCH 13/13] drivers/rtc/rtc-coh901331.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:01 ` [PATCH 13/13] drivers/rtc/rtc-coh901331.c: " Julia Lawall
@ 2012-08-28  0:25   ` Linus Walleij
  0 siblings, 0 replies; 27+ messages in thread
From: Linus Walleij @ 2012-08-28  0:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, Alessandro Zummo, linux-arm-kernel, rtc-linux,
	linux-kernel

On Sun, Aug 26, 2012 at 9:01 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:

> I'm not sure about this.  Maybe it would be better to leave the disable and
> unprepare separated, since there is no matching nearby clk_prepare.

This is OK.
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 3/13] drivers/gpio/gpio-pxa.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 3/13] drivers/gpio/gpio-pxa.c: " Julia Lawall
@ 2012-09-01  4:15   ` Linus Walleij
  0 siblings, 0 replies; 27+ messages in thread
From: Linus Walleij @ 2012-09-01  4:15 UTC (permalink / raw)
  To: Julia Lawall, Eric Miao, Haojian Zhuang
  Cc: Grant Likely, kernel-janitors, linux-kernel, Russell King

On Sun, Aug 26, 2012 at 6:00 PM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:

> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.

Applied,
if your PXA people don't like it, shout.

Yours,
Linus Walleij

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

* Re: [PATCH 7/13] drivers/mmc/host/mmci.c: use clk_prepare_enable and clk_disable_unprepare
  2012-08-26 16:00 ` [PATCH 7/13] drivers/mmc/host/mmci.c: " Julia Lawall
  2012-08-27 12:33   ` Ulf Hansson
@ 2012-09-19  5:09   ` Chris Ball
  1 sibling, 0 replies; 27+ messages in thread
From: Chris Ball @ 2012-09-19  5:09 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, linux-mmc, linux-kernel, Ulf Hansson, Russell King

Hi Julia,

On Sun, Aug 26 2012, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
>
> Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
> clk_enable, and clk_disable and clk_unprepare.  They make the code more
> concise, and ensure that clk_unprepare is called when clk_enable fails.
>
> A simplified version of the semantic patch that introduces calls to these
> functions is as follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e;
> @@
>
> - clk_prepare(e);
> - clk_enable(e);
> + clk_prepare_enable(e);
>
> @@
> expression e;
> @@
>
> - clk_disable(e);
> - clk_unprepare(e);
> + clk_disable_unprepare(e);
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>  drivers/mmc/host/mmci.c |   13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> index 50ff19a..edc3e9b 100644
> --- a/drivers/mmc/host/mmci.c
> +++ b/drivers/mmc/host/mmci.c
> @@ -1309,14 +1309,10 @@ static int __devinit mmci_probe(struct amba_device *dev,
>  		goto host_free;
>  	}
>  
> -	ret = clk_prepare(host->clk);
> +	ret = clk_prepare_enable(host->clk);
>  	if (ret)
>  		goto clk_free;
>  
> -	ret = clk_enable(host->clk);
> -	if (ret)
> -		goto clk_unprep;
> -
>  	host->plat = plat;
>  	host->variant = variant;
>  	host->mclk = clk_get_rate(host->clk);
> @@ -1515,9 +1511,7 @@ static int __devinit mmci_probe(struct amba_device *dev,
>   err_gpio_cd:
>  	iounmap(host->base);
>   clk_disable:
> -	clk_disable(host->clk);
> - clk_unprep:
> -	clk_unprepare(host->clk);
> +	clk_disable_unprepare(host->clk);
>   clk_free:
>  	clk_put(host->clk);
>   host_free:
> @@ -1564,8 +1558,7 @@ static int __devexit mmci_remove(struct amba_device *dev)
>  			gpio_free(host->gpio_cd);
>  
>  		iounmap(host->base);
> -		clk_disable(host->clk);
> -		clk_unprepare(host->clk);
> +		clk_disable_unprepare(host->clk);
>  		clk_put(host->clk);
>  
>  		if (host->vcc)

Thanks, pushed to mmc-next for 3.7.

(I merged v1 instead of v2 because I don't see any whitespace problems
with it, and I liked the verbosity in the original commit message.)

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2012-09-19  5:09 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-26 16:00 [PATCH 0/13] use clk_prepare_enable and clk_disable_unprepare Julia Lawall
2012-08-26 16:00 ` [PATCH 1/13] drivers/staging/iio/adc/spear_adc.c: " Julia Lawall
2012-08-27  4:01   ` viresh kumar
2012-08-27 20:06     ` Jonathan Cameron
2012-08-27 20:09       ` Jonathan Cameron
2012-08-26 16:00 ` [PATCH 2/13] drivers/spi/spi-{orion,pl022}.c: " Julia Lawall
2012-08-26 16:00 ` [PATCH 3/13] drivers/gpio/gpio-pxa.c: " Julia Lawall
2012-09-01  4:15   ` Linus Walleij
2012-08-26 16:00 ` [PATCH 4/13] i2c: sirf: " Julia Lawall
2012-08-27  1:44   ` Barry Song
2012-08-26 16:00 ` [PATCH 5/13] arch/arm: " Julia Lawall
2012-08-27  5:57   ` Pankaj Jangra
2012-08-26 16:00 ` [PATCH 6/13] drivers/iio/adc/at91_adc.c: " Julia Lawall
2012-08-27 20:12   ` Jonathan Cameron
2012-08-26 16:00 ` [PATCH 7/13] drivers/mmc/host/mmci.c: " Julia Lawall
2012-08-27 12:33   ` Ulf Hansson
2012-08-27 12:46     ` Julia Lawall
2012-08-27 12:55     ` Julia Lawall
2012-09-19  5:09   ` Chris Ball
2012-08-26 16:01 ` [PATCH 8/13] i2c: mv64xxx: " Julia Lawall
2012-08-26 16:01 ` [PATCH 9/13] drivers/tty/serial/amba-pl0{10,11}.c: " Julia Lawall
2012-08-26 16:01 ` [PATCH 10/13] drivers/watchdog/sp805_wdt.c: " Julia Lawall
2012-08-27  4:04   ` viresh kumar
2012-08-26 16:01 ` [PATCH 11/13] arch/arm/mach-at91/gpio.c: " Julia Lawall
2012-08-26 16:01 ` [PATCH 12/13] drivers/amba/bus.c: " Julia Lawall
2012-08-26 16:01 ` [PATCH 13/13] drivers/rtc/rtc-coh901331.c: " Julia Lawall
2012-08-28  0:25   ` Linus Walleij

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).