All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] i2c-s3c2410: Convert to devm_kzalloc()
@ 2012-02-13 23:05 Mark Brown
  2012-02-13 23:05 ` [PATCH 2/3] i2c-s3c2410: Add stub runtime power management Mark Brown
  2012-02-13 23:05 ` [PATCH 3/3] i2c-s3c2410: Refactor ifdefs for PM_SLEEP Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2012-02-13 23:05 UTC (permalink / raw)
  To: Ben Dooks, khali-PUYAD+kWke1g9hUCZPvPmw, w.sang-bIcnvbaLZ9MEGnE8C9+IrQ
  Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Mark Brown

Saves remembering to call kfree(). There's some kfree()s used by the
resource still, these will be removed in 3.4 using the newly added
devm_request_and_ioremap().

Signed-off-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Reviewed-by: Barry Song <Baohua.Song-kQvG35nSl+M@public.gmane.org>
---
 drivers/i2c/busses/i2c-s3c2410.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 4c17180..e6f982b 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -890,7 +890,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 		}
 	}
 
-	i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
+	i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL);
 	if (!i2c) {
 		dev_err(&pdev->dev, "no memory for state\n");
 		return -ENOMEM;
@@ -1035,7 +1035,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	clk_put(i2c->clk);
 
  err_noclk:
-	kfree(i2c);
 	return ret;
 }
 
@@ -1061,7 +1060,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 	release_resource(i2c->ioarea);
 	s3c24xx_i2c_dt_gpio_free(i2c);
 	kfree(i2c->ioarea);
-	kfree(i2c);
 
 	return 0;
 }
-- 
1.7.9.rc1

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

* [PATCH 2/3] i2c-s3c2410: Add stub runtime power management
  2012-02-13 23:05 [PATCH 1/3] i2c-s3c2410: Convert to devm_kzalloc() Mark Brown
@ 2012-02-13 23:05 ` Mark Brown
  2012-02-13 23:05 ` [PATCH 3/3] i2c-s3c2410: Refactor ifdefs for PM_SLEEP Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-02-13 23:05 UTC (permalink / raw)
  To: Ben Dooks, khali, w.sang; +Cc: linux-samsung-soc, linux-i2c, Mark Brown

Add stub runtime_pm calls which go through the flow of enabling and
disabling but don't actually do anything with the device itself as
there's nothing useful we can do. This provides the core PM framework
with information about when the device is idle, enabling chip wide
power savings.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/i2c/busses/i2c-s3c2410.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index e6f982b..1cb06c58 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -31,6 +31,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
 #include <linux/slab.h>
@@ -564,6 +565,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
 	int retry;
 	int ret;
 
+	pm_runtime_get_sync(i2c->dev);
 	clk_enable(i2c->clk);
 
 	for (retry = 0; retry < adap->retries; retry++) {
@@ -572,6 +574,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
 
 		if (ret != -EAGAIN) {
 			clk_disable(i2c->clk);
+			pm_runtime_put(i2c->dev);
 			return ret;
 		}
 
@@ -581,6 +584,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
 	}
 
 	clk_disable(i2c->clk);
+	pm_runtime_put(i2c->dev);
 	return -EREMOTEIO;
 }
 
@@ -930,6 +934,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 	dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
 
 	clk_enable(i2c->clk);
+	pm_runtime_enable(&pdev->dev);
 
 	/* map the registers */
 
@@ -967,7 +972,9 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
 
 	/* initialise the i2c controller */
 
+	pm_runtime_get(&pdev->dev);
 	ret = s3c24xx_i2c_init(i2c);
+	pm_runtime_put(&pdev->dev);
 	if (ret != 0)
 		goto err_iomap;
 
@@ -1047,6 +1054,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 {
 	struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
 
+	pm_runtime_disable(&pdev->dev);
+
 	s3c24xx_i2c_deregister_cpufreq(i2c);
 
 	i2c_del_adapter(&i2c->adap);
-- 
1.7.9.rc1

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

* [PATCH 3/3] i2c-s3c2410: Refactor ifdefs for PM_SLEEP
  2012-02-13 23:05 [PATCH 1/3] i2c-s3c2410: Convert to devm_kzalloc() Mark Brown
  2012-02-13 23:05 ` [PATCH 2/3] i2c-s3c2410: Add stub runtime power management Mark Brown
@ 2012-02-13 23:05 ` Mark Brown
  2012-02-17 12:19   ` Shubhrajyoti Datta
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-02-13 23:05 UTC (permalink / raw)
  To: Ben Dooks, khali, w.sang; +Cc: linux-samsung-soc, linux-i2c, Mark Brown

Use the PM_SLEEP ifdef for system suspend and resume. This is partly
in preparation for adding runtime operations and partly because a user
may in theory choose to enable runtime suspend but not system suspend.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/i2c/busses/i2c-s3c2410.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1cb06c58..5d8e802 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1073,7 +1073,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int s3c24xx_i2c_suspend_noirq(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -1096,10 +1096,14 @@ static int s3c24xx_i2c_resume(struct device *dev)
 
 	return 0;
 }
+#endif
 
+#ifdef CONFIG_PM
 static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
+#ifdef CONFIG_PM_SLEEP
 	.suspend_noirq = s3c24xx_i2c_suspend_noirq,
 	.resume = s3c24xx_i2c_resume,
+#endif
 };
 
 #define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
-- 
1.7.9.rc1

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

* Re: [PATCH 3/3] i2c-s3c2410: Refactor ifdefs for PM_SLEEP
  2012-02-13 23:05 ` [PATCH 3/3] i2c-s3c2410: Refactor ifdefs for PM_SLEEP Mark Brown
@ 2012-02-17 12:19   ` Shubhrajyoti Datta
  0 siblings, 0 replies; 4+ messages in thread
From: Shubhrajyoti Datta @ 2012-02-17 12:19 UTC (permalink / raw)
  To: Mark Brown; +Cc: Ben Dooks, khali, w.sang, linux-samsung-soc, linux-i2c

On Tue, Feb 14, 2012 at 4:35 AM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> Use the PM_SLEEP ifdef for system suspend and resume. This is partly
> in preparation for adding runtime operations and partly because a user
> may in theory choose to enable runtime suspend but not system suspend.
>
Yes also rand defconfig may see some warns.

Looks good to me
Reviewed-by: Shubhrajyoti D <shubhrajyoti@ti.com>

> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/i2c/busses/i2c-s3c2410.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index 1cb06c58..5d8e802 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -1073,7 +1073,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
>        return 0;
>  }
>
> -#ifdef CONFIG_PM
> +#ifdef CONFIG_PM_SLEEP
>  static int s3c24xx_i2c_suspend_noirq(struct device *dev)
>  {
>        struct platform_device *pdev = to_platform_device(dev);
> @@ -1096,10 +1096,14 @@ static int s3c24xx_i2c_resume(struct device *dev)
>
>        return 0;
>  }
> +#endif
>
> +#ifdef CONFIG_PM
>  static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
> +#ifdef CONFIG_PM_SLEEP
>        .suspend_noirq = s3c24xx_i2c_suspend_noirq,
>        .resume = s3c24xx_i2c_resume,
> +#endif
>  };
>
>  #define S3C24XX_DEV_PM_OPS (&s3c24xx_i2c_dev_pm_ops)
> --
> 1.7.9.rc1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" 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] 4+ messages in thread

end of thread, other threads:[~2012-02-17 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-13 23:05 [PATCH 1/3] i2c-s3c2410: Convert to devm_kzalloc() Mark Brown
2012-02-13 23:05 ` [PATCH 2/3] i2c-s3c2410: Add stub runtime power management Mark Brown
2012-02-13 23:05 ` [PATCH 3/3] i2c-s3c2410: Refactor ifdefs for PM_SLEEP Mark Brown
2012-02-17 12:19   ` Shubhrajyoti Datta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.