* [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
@ 2012-01-21 13:28 Mark Brown
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
` (2 more replies)
0 siblings, 3 replies; 24+ messages in thread
From: Mark Brown @ 2012-01-21 13:28 UTC (permalink / raw)
To: Jean Delvare, Wolfram Sang, Ben Dooks
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.3 using the newly added
devm_request_and_ioremap().
Signed-off-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@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.7.3
^ permalink raw reply related [flat|nested] 24+ messages in thread
[parent not found: <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>]
* [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2012-01-21 13:28 ` Mark Brown
2012-01-21 15:52 ` Sylwester Nawrocki
[not found] ` <1327152527-11364-2-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-21 16:10 ` [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Sylwester Nawrocki
2012-02-14 13:03 ` Shubhrajyoti Datta
2 siblings, 2 replies; 24+ messages in thread
From: Mark Brown @ 2012-01-21 13:28 UTC (permalink / raw)
To: Jean Delvare, Wolfram Sang, Ben Dooks
Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
linux-i2c-u79uwXL29TY76Z2rM5mHXA, 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-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Acked-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
---
drivers/i2c/busses/i2c-s3c2410.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index e6f982b..737f721 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(&adap->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_sync(&adap->dev);
return ret;
}
@@ -581,6 +584,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
}
clk_disable(i2c->clk);
+ pm_runtime_put_sync(&adap->dev);
return -EREMOTEIO;
}
@@ -1013,6 +1017,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;
@@ -1047,6 +1054,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);
--
1.7.7.3
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
2012-01-21 13:28 ` [PATCH 2/2] i2c-s3c2410: Add stub runtime power management Mark Brown
@ 2012-01-21 15:52 ` Sylwester Nawrocki
2012-01-21 18:31 ` Mark Brown
[not found] ` <1327152527-11364-2-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
1 sibling, 1 reply; 24+ messages in thread
From: Sylwester Nawrocki @ 2012-01-21 15:52 UTC (permalink / raw)
To: Mark Brown, linux-i2c
Cc: Jean Delvare, Wolfram Sang, Ben Dooks, linux-samsung-soc
On 01/21/2012 02:28 PM, Mark Brown wrote:
> 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-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> Acked-by: Heiko Stuebner<heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-s3c2410.c | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index e6f982b..737f721 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(&adap->dev);
> clk_enable(i2c->clk);
It looks a bit strange to have pm_runtime* and manual clock control side
by side. How about implementing proper runtime_suspend/resume calls and
moving clk_enable/disable to these handlers ?
It might also make sense to check return value of pm_runtime_get_sync().
> 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_sync(&adap->dev);
I would go for just pm_runtime_put() here...
> return ret;
> }
>
> @@ -581,6 +584,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
> }
>
> clk_disable(i2c->clk);
> + pm_runtime_put_sync(&adap->dev);
.. and here as well.
> return -EREMOTEIO;
> }
>
> @@ -1013,6 +1017,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);
Why do we need pm_runtime_enable() on i2c->adap.dev ?
AFAIK enabling runtime PM on the platform device only should do.
> +
> dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
> clk_disable(i2c->clk);
> return 0;
> @@ -1047,6 +1054,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);
Ditto.
> +
> s3c24xx_i2c_deregister_cpufreq(i2c);
>
> i2c_del_adapter(&i2c->adap);
--
Thanks,
Sylwester
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
2012-01-21 15:52 ` Sylwester Nawrocki
@ 2012-01-21 18:31 ` Mark Brown
2012-01-21 20:38 ` Sylwester Nawrocki
0 siblings, 1 reply; 24+ messages in thread
From: Mark Brown @ 2012-01-21 18:31 UTC (permalink / raw)
To: Sylwester Nawrocki
Cc: linux-i2c, Jean Delvare, Wolfram Sang, Ben Dooks,
linux-samsung-soc
On Sat, Jan 21, 2012 at 04:52:58PM +0100, Sylwester Nawrocki wrote:
> On 01/21/2012 02:28 PM, Mark Brown wrote:
> > + pm_runtime_get_sync(&adap->dev);
> > clk_enable(i2c->clk);
> It looks a bit strange to have pm_runtime* and manual clock control side
> by side. How about implementing proper runtime_suspend/resume calls and
> moving clk_enable/disable to these handlers ?
I'd rather not do that in a single patch, and really we ought to be
doing more than just stopping and starting the clocks anyway. Given
that the rather serious problems with getting I2C patches applied I'd
rather do as little as possible in individual patches.
It would also introduce a regression for systems that don't use runtime
PM (probably most s3c24xx ones).
> It might also make sense to check return value of pm_runtime_get_sync().
This is fairly idiomatic for the API, the error handling gets a bit
complicated if you do it properly.
> > 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_sync(&adap->dev);
> I would go for just pm_runtime_put() here...
Yeah, me too but it seemed idiomatic. Frankly I don't really understand
why there's a synchronous version of put.
> > + pm_runtime_enable(&pdev->dev);
> > + pm_runtime_enable(&i2c->adap.dev);
> Why do we need pm_runtime_enable() on i2c->adap.dev ?
> AFAIK enabling runtime PM on the platform device only should do.
We probably don't need to, no.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
2012-01-21 18:31 ` Mark Brown
@ 2012-01-21 20:38 ` Sylwester Nawrocki
[not found] ` <4F1B2235.4000009-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 24+ messages in thread
From: Sylwester Nawrocki @ 2012-01-21 20:38 UTC (permalink / raw)
To: Mark Brown
Cc: linux-i2c, Jean Delvare, Wolfram Sang, Ben Dooks,
linux-samsung-soc
On 01/21/2012 07:31 PM, Mark Brown wrote:
> On Sat, Jan 21, 2012 at 04:52:58PM +0100, Sylwester Nawrocki wrote:
>> On 01/21/2012 02:28 PM, Mark Brown wrote:
>
>>> + pm_runtime_get_sync(&adap->dev);
>>> clk_enable(i2c->clk);
>
>> It looks a bit strange to have pm_runtime* and manual clock control side
>> by side. How about implementing proper runtime_suspend/resume calls and
>> moving clk_enable/disable to these handlers ?
>
> I'd rather not do that in a single patch, and really we ought to be
> doing more than just stopping and starting the clocks anyway. Given
Agreed.
> that the rather serious problems with getting I2C patches applied I'd
> rather do as little as possible in individual patches.
>
> It would also introduce a regression for systems that don't use runtime
> PM (probably most s3c24xx ones).
Indeed, I'd forgotten about this fact for a while. I suspect the Run-time PM
core functionality could be enabled on those platform, allowing to make the
common driver dependant on PM_RUNTIME. Not sure if that's acceptable for
the smaller SoCs though. It rather sounds more like lots of trouble for
little benefits. Maybe it's desirable to do that at some point anyway.
>> It might also make sense to check return value of pm_runtime_get_sync().
>
> This is fairly idiomatic for the API, the error handling gets a bit
> complicated if you do it properly.
OK.
>>> 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_sync(&adap->dev);
>
>> I would go for just pm_runtime_put() here...
>
> Yeah, me too but it seemed idiomatic. Frankly I don't really understand
> why there's a synchronous version of put.
The synchronous put callbacks might be needed for instance in a bus core code
to make sure the child device drivers aren't accessing resources while
bus adapter (USB/PCI) is being unplugged for example. In cases like platform
I2C bus controller it might be more optimal to use asynchronous put versions.
As there are usually performed fast multiple adjacent transfers and multiple
put runtime get/put might be merged to one get/put due to scheduling latency.
However I've never really measured that. Implementing autosuspend might give
some insights about that.
^ permalink raw reply [flat|nested] 24+ messages in thread
[parent not found: <1327152527-11364-2-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>]
* Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
[not found] ` <1327152527-11364-2-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2012-02-13 23:39 ` Ben Dooks
0 siblings, 0 replies; 24+ messages in thread
From: Ben Dooks @ 2012-02-13 23:39 UTC (permalink / raw)
To: Mark Brown
Cc: Jean Delvare, Wolfram Sang, Ben Dooks,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
On Sat, Jan 21, 2012 at 01:28:47PM +0000, Mark Brown wrote:
> 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-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
> Acked-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
I've applied these two to for-34/i2c/i2c-samsung and will start a -next
branch later in the week
> ---
> drivers/i2c/busses/i2c-s3c2410.c | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
> index e6f982b..737f721 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(&adap->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_sync(&adap->dev);
> return ret;
> }
>
> @@ -581,6 +584,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
> }
>
> clk_disable(i2c->clk);
> + pm_runtime_put_sync(&adap->dev);
> return -EREMOTEIO;
> }
>
> @@ -1013,6 +1017,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;
> @@ -1047,6 +1054,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);
> --
> 1.7.7.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-21 13:28 ` [PATCH 2/2] i2c-s3c2410: Add stub runtime power management Mark Brown
@ 2012-01-21 16:10 ` Sylwester Nawrocki
2012-01-21 17:57 ` Mark Brown
[not found] ` <4F1AE36E.3070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-02-14 13:03 ` Shubhrajyoti Datta
2 siblings, 2 replies; 24+ messages in thread
From: Sylwester Nawrocki @ 2012-01-21 16:10 UTC (permalink / raw)
To: Mark Brown; +Cc: Ben Dooks, linux-samsung-soc, linux-i2c-u79uwXL29TY76Z2rM5mHXA
On 01/21/2012 02:28 PM, Mark Brown wrote:
> 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().
>
> Signed-off-by: Mark Brown Mark Brown<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@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);
Just in case you are resending the patch for any other reason, it might be worth
to change to sizeof(*i2c) for consistency.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
2012-01-21 16:10 ` [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Sylwester Nawrocki
@ 2012-01-21 17:57 ` Mark Brown
2012-01-21 18:27 ` Sylwester Nawrocki
[not found] ` <4F1AE36E.3070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
1 sibling, 1 reply; 24+ messages in thread
From: Mark Brown @ 2012-01-21 17:57 UTC (permalink / raw)
To: Sylwester Nawrocki; +Cc: Ben Dooks, linux-samsung-soc, linux-i2c
On Sat, Jan 21, 2012 at 05:10:22PM +0100, Sylwester Nawrocki wrote:
> > - i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
> > + i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL);
> Just in case you are resending the patch for any other reason, it might be worth
> to change to sizeof(*i2c) for consistency.
Consistency with...?
TBH I'd rather not change the coding style as well as presumably Ben
likes that the way it is.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
2012-01-21 17:57 ` Mark Brown
@ 2012-01-21 18:27 ` Sylwester Nawrocki
[not found] ` <4F1B0394.8050003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 24+ messages in thread
From: Sylwester Nawrocki @ 2012-01-21 18:27 UTC (permalink / raw)
To: Mark Brown; +Cc: Sylwester Nawrocki, Ben Dooks, linux-samsung-soc, linux-i2c
On 01/21/2012 06:57 PM, Mark Brown wrote:
> On Sat, Jan 21, 2012 at 05:10:22PM +0100, Sylwester Nawrocki wrote:
>>> - i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
>>> + i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL);
>
>> Just in case you are resending the patch for any other reason, it might be worth
>> to change to sizeof(*i2c) for consistency.
>
> Consistency with...?
Consistency with the rest of code in i2c-s3c244.c, all other occurrences
of sizeof take name of a variable, rather than its type.
> TBH I'd rather not change the coding style as well as presumably Ben
> likes that the way it is.
If that's Ben's will then let it stay as it is. I don't even dare to propose
any change ;) It's rather a meaningless detail. I personally like more using
variable's name, and I had a feeling it was preferred style in the kernel.
It's even mentioned in Documentation/CodingStyle:
"The kernel provides the following general purpose memory allocators:
kmalloc(), kzalloc(), kcalloc(), vmalloc(), and vzalloc(). Please refer to
the API documentation for further information about them.
The preferred form for passing a size of a struct is the following:
p = kmalloc(sizeof(*p), ...);
The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not."
^ permalink raw reply [flat|nested] 24+ messages in thread
[parent not found: <4F1AE36E.3070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
[not found] ` <4F1AE36E.3070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-02-13 23:38 ` Ben Dooks
0 siblings, 0 replies; 24+ messages in thread
From: Ben Dooks @ 2012-02-13 23:38 UTC (permalink / raw)
To: Sylwester Nawrocki
Cc: Mark Brown, Ben Dooks, linux-samsung-soc,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
On Sat, Jan 21, 2012 at 05:10:22PM +0100, Sylwester Nawrocki wrote:
> On 01/21/2012 02:28 PM, Mark Brown wrote:
> > 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().
> >
> > Signed-off-by: Mark Brown Mark Brown<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@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);
>
> Just in case you are resending the patch for any other reason, it might be worth
> to change to sizeof(*i2c) for consistency.
Yuck.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-21 13:28 ` [PATCH 2/2] i2c-s3c2410: Add stub runtime power management Mark Brown
2012-01-21 16:10 ` [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Sylwester Nawrocki
@ 2012-02-14 13:03 ` Shubhrajyoti Datta
2012-02-14 13:52 ` Sylwester Nawrocki
2 siblings, 1 reply; 24+ messages in thread
From: Shubhrajyoti Datta @ 2012-02-14 13:03 UTC (permalink / raw)
To: Mark Brown
Cc: Jean Delvare, Wolfram Sang, Ben Dooks,
linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
linux-i2c-u79uwXL29TY76Z2rM5mHXA
Hi Mark,
The changes look good to me.
Reviewed-by: Datta Shubhrajyoti <shubhrajyoti-l0cyMroinI0@public.gmane.org>
For your changes.
Some other doubts though not related to your patch.
Just curious.
On Sat, Jan 21, 2012 at 6:58 PM, Mark Brown
<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org> wrote:
> 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().
>
> Signed-off-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@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");
The comment looks confusing as I am not sure what is meant here by state.
> 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);
Do we need both release_resource and kfree
> - kfree(i2c);
>
> return 0;
> }
> --
> 1.7.7.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
2012-02-14 13:03 ` Shubhrajyoti Datta
@ 2012-02-14 13:52 ` Sylwester Nawrocki
0 siblings, 0 replies; 24+ messages in thread
From: Sylwester Nawrocki @ 2012-02-14 13:52 UTC (permalink / raw)
To: Shubhrajyoti Datta
Cc: Mark Brown, Jean Delvare, Wolfram Sang, Ben Dooks,
linux-samsung-soc, linux-i2c
Hi Shubhrajyoti,
On 02/14/2012 02:03 PM, Shubhrajyoti Datta wrote:
> Hi Mark,
>
> The changes look good to me.
> Reviewed-by: Datta Shubhrajyoti <shubhrajyoti@ti.com>
> For your changes.
>
> Some other doubts though not related to your patch.
> Just curious.
>
...
>> 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
...
>> @@ -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);
> Do we need both release_resource and kfree
No, instead of release_resource() and kfree() you normally use
release_mem_region() to free resources acquired with request_mem_region().
See this patch for instance:
http://www.spinics.net/lists/linux-samsung-soc/msg08325.html
--
Thanks,
Sylwester
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
2012-01-21 13:28 [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Mark Brown
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
@ 2012-01-21 15:59 ` Sylwester Nawrocki
2012-01-29 5:14 ` Barry Song
2 siblings, 0 replies; 24+ messages in thread
From: Sylwester Nawrocki @ 2012-01-21 15:59 UTC (permalink / raw)
To: Mark Brown
Cc: Jean Delvare, Wolfram Sang, Ben Dooks, linux-samsung-soc,
linux-i2c
On 01/21/2012 02:28 PM, Mark Brown wrote:
> 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().
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
> ---
> 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;
> }
--
Thanks!
Sylwester
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
2012-01-21 13:28 [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Mark Brown
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-21 15:59 ` Sylwester Nawrocki
@ 2012-01-29 5:14 ` Barry Song
2 siblings, 0 replies; 24+ messages in thread
From: Barry Song @ 2012-01-29 5:14 UTC (permalink / raw)
To: Mark Brown
Cc: Jean Delvare, Wolfram Sang, Ben Dooks, linux-samsung-soc,
linux-i2c
2012/1/21 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> 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().
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Reviewed-by: Barry Song <Baohua.Song@csr.com>
> ---
> 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.7.3
^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc()
@ 2011-12-05 14:06 Mark Brown
[not found] ` <1323093966-9045-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
0 siblings, 1 reply; 24+ messages in thread
From: Mark Brown @ 2011-12-05 14:06 UTC (permalink / raw)
To: Jean Delvare, Ben Dooks, Kukjin Kim
Cc: linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
linux-i2c-u79uwXL29TY76Z2rM5mHXA,
patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E, Mark Brown
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().
Signed-off-by: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@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 2754cef..ed62a7f 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -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;
}
--
1.7.7.3
^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2012-02-14 13:52 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-21 13:28 [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Mark Brown
[not found] ` <1327152527-11364-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-01-21 13:28 ` [PATCH 2/2] i2c-s3c2410: Add stub runtime power management Mark Brown
2012-01-21 15:52 ` Sylwester Nawrocki
2012-01-21 18:31 ` Mark Brown
2012-01-21 20:38 ` Sylwester Nawrocki
[not found] ` <4F1B2235.4000009-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-21 21:23 ` Mark Brown
2012-01-21 21:23 ` Heiko Stübner
2012-01-21 21:33 ` Sylwester Nawrocki
[not found] ` <4F1B2F38.9050708-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-21 21:57 ` Mark Brown
2012-01-21 22:49 ` Sylwester Nawrocki
2012-01-21 23:10 ` Mark Brown
[not found] ` <1327152527-11364-2-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-02-13 23:39 ` Ben Dooks
2012-01-21 16:10 ` [PATCH 1/2] i2c-s3c2410: Convert to devm_kzalloc() Sylwester Nawrocki
2012-01-21 17:57 ` Mark Brown
2012-01-21 18:27 ` Sylwester Nawrocki
[not found] ` <4F1B0394.8050003-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-21 18:36 ` Mark Brown
[not found] ` <4F1AE36E.3070403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-02-13 23:38 ` Ben Dooks
2012-02-14 13:03 ` Shubhrajyoti Datta
2012-02-14 13:52 ` Sylwester Nawrocki
2012-01-21 15:59 ` Sylwester Nawrocki
2012-01-29 5:14 ` Barry Song
-- strict thread matches above, loose matches on Subject: below --
2011-12-05 14:06 Mark Brown
[not found] ` <1323093966-9045-1-git-send-email-broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-12-05 14:06 ` [PATCH 2/2] i2c-s3c2410: Add stub runtime power management Mark Brown
2011-12-13 14:53 ` Heiko Stübner
2011-12-13 15:06 ` Jean Delvare
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).