i2c-s3c2410: Convert to devm_kzalloc()
Subsystems (2)
PATCH 1/2 i2c-s3c2410: Convert to devm_kzalloc()
Saves remembering to call kfree(). There's some kfree()s used by the resource still, these will be removed in 3.3 using the newly added devm_request_and_ioremap().
--- drivers/i2c/busses/i2c-s3c2410.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-s3c2410.c +1 -3
@@ -889,7 +889,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 ;
@@ -1034,7 +1034,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)clk_put (i2c->clk); err_noclk: -kfree (i2c);return ret; }
@@ -1060,7 +1059,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 ; }
Signature · 1 line
1.7.7.3
A message that is not in the archive (sent off-list or not yet received): 1323093966-9045-1-git-send-email-broonie-yzvPICuk2AATkU/[email protected]
PATCH 2/2 i2c-s3c2410: Add stub runtime power management
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.
--- drivers/i2c/busses/i2c-s3c2410.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/i2c/busses/i2c-s3c2410.c +10 -0
@@ -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>
@@ -563,6 +564,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,int retry;int ret; +pm_runtime_get_sync (&adap->dev);clk_enable (i2c->clk);for (retry =0 ; retry < adap->retries; retry++) {
@@ -571,6 +573,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,if (ret != -EAGAIN ) {clk_disable (i2c->clk); +pm_runtime_put_sync (&adap->dev);return ret; }
@@ -580,6 +583,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, }clk_disable (i2c->clk); +pm_runtime_put_sync (&adap->dev);return -EREMOTEIO ; }
@@ -1012,6 +1016,9 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)of_i2c_register_devices (&i2c->adap);platform_set_drvdata (pdev, i2c); +pm_runtime_enable (&pdev->dev); +pm_runtime_enable (&i2c->adap.dev); +dev_info (&pdev->dev,"%s: S3C I2C adapter\n" ,dev_name (&i2c->adap.dev));clk_disable (i2c->clk);return 0 ;
@@ -1046,6 +1053,9 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) {struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); +pm_runtime_disable (&i2c->adap.dev); +pm_runtime_disable (&pdev->dev); +s3c24xx_i2c_deregister_cpufreq (i2c);i2c_del_adapter (&i2c->adap);
Signature · 1 line
1.7.7.3
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Am Montag, 5. Dezember 2011, 15:06:06 schrieb Mark Brown:
Quoted 7 lines
Add stub
runtime_pmcalls 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 <[email protected]>
Kgene, Jean, Ben: could we move this forward please?
Thanks
Heiko
Quoted 60 lines
--- drivers/i2c/busses/i2c-s3c2410.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)(quoted diff) +0
-0
b/drivers/i2c/busses/i2c-s3c2410.cindex ed62a7f..065c316 100644drivers/i2c/busses/i2c-s3c2410.c +10
-0@@ -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> @@ -563,6 +564,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,int retry;int ret; +pm_runtime_get_sync (&adap->dev);clk_enable (i2c->clk);for (retry =0 ; retry < adap->retries; retry++) {@@ -571,6 +573,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,if (ret != -EAGAIN ) {clk_disable (i2c->clk); +pm_runtime_put_sync (&adap->dev);return ret; }@@ -580,6 +583,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, }clk_disable (i2c->clk); +pm_runtime_put_sync (&adap->dev);return -EREMOTEIO ; }@@ -1012,6 +1016,9 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) of_i2c_register_devices(&i2c->adap);platform_set_drvdata (pdev, i2c); +pm_runtime_enable (&pdev->dev); +pm_runtime_enable (&i2c->adap.dev); +dev_info (&pdev->dev,"%s: S3C I2C adapter\n" ,dev_name (&i2c->adap.dev));clk_disable (i2c->clk);return 0 ;@@ -1046,6 +1053,9 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) {struct s3c24xx_i2c *i2c =platform_get_drvdata (pdev); +pm_runtime_disable (&i2c->adap.dev); +pm_runtime_disable (&pdev->dev); +s3c24xx_i2c_deregister_cpufreq (i2c);i2c_del_adapter (&i2c->adap);
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 11 lines · Heiko Stübner
Am Montag, 5. Dezember 2011, 15:06:06 schrieb Mark Brown:
Quoted 7 lines
Add stub
runtime_pmcalls 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 <[email protected]>Acked-by Heiko Stuebner <[email protected]>Kgene, Jean, Ben: could we move this forward please?
The i2c-s3c2410 driver is in Ben's garden, not mine.
Signature · 1 line
Jean Delvare