* [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare
[not found] <1345996865-32082-1-git-send-email-Julia.Lawall@lip6.fr>
@ 2012-08-26 16:00 ` Julia Lawall
[not found] ` <1345996865-32082-5-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2012-08-26 16:01 ` [PATCH 8/13] i2c: mv64xxx: " Julia Lawall
1 sibling, 1 reply; 3+ 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] 3+ messages in thread
* [PATCH 8/13] i2c: mv64xxx: use clk_prepare_enable and clk_disable_unprepare
[not found] <1345996865-32082-1-git-send-email-Julia.Lawall@lip6.fr>
2012-08-26 16:00 ` [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare Julia Lawall
@ 2012-08-26 16:01 ` Julia Lawall
1 sibling, 0 replies; 3+ 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] 3+ messages in thread
* Re: [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare
[not found] ` <1345996865-32082-5-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
@ 2012-08-27 1:44 ` Barry Song
0 siblings, 0 replies; 3+ messages in thread
From: Barry Song @ 2012-08-27 1:44 UTC (permalink / raw)
To: Julia Lawall
Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
Wolfram Sang (embedded platforms),
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks (embedded platforms),
Jean Delvare (PC drivers, core),
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
DL-SHA-WorkGroupLinux
2012/8/27 Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>:
> From: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
>
> 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-L2FTfq7BK8M@public.gmane.org>
Acked-by: Barry Song <21cnbao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-27 1:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1345996865-32082-1-git-send-email-Julia.Lawall@lip6.fr>
2012-08-26 16:00 ` [PATCH 4/13] i2c: sirf: use clk_prepare_enable and clk_disable_unprepare Julia Lawall
[not found] ` <1345996865-32082-5-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2012-08-27 1:44 ` Barry Song
2012-08-26 16:01 ` [PATCH 8/13] i2c: mv64xxx: " Julia Lawall
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).