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
@@ -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 ; }
Signature · 1 line
1.7.7.3
A message that is not in the archive (sent off-list or not yet received): 1327152527-11364-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>
@@ -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);
Signature · 1 line
1.7.7.3
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 25 lines · Mark Brown
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<broonie-yzvPICuk2AATkU/[email protected]>Acked-by Heiko Stuebner<[email protected]>--- drivers/i2c/busses/i2c-s3c2410.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)drivers/i2c/busses/i2c-s3c2410.c +1
-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>
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 569
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0@@ -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().
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 577
Quoted 6 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0for (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...
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 587
Quoted 8 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0return 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.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 1021
Quoted 9 lines
drivers/i2c/busses/i2c-s3c2410.c +2
-0return -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.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_remove(struct platform_device *pdev) · line 1058
Quoted 10 lines
drivers/i2c/busses/i2c-s3c2410.c +3
-0+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.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_remove(struct platform_device *pdev) · line 1062
Quoted 4 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-0+s3c24xx_i2c_deregister_cpufreq (i2c);i2c_del_adapter (&i2c->adap);
--
Thanks,
Sylwester
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 8 lines · Sylwester Nawrocki
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 569
Quoted 2 lines · Mark Brown
drivers/i2c/busses/i2c-s3c2410.c +1
-0+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).
Quoted 1 line
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.
Quoted 8 lines
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 577
Quoted 6 lines
for (retry = 0; retry< adap->retries; retry++) {drivers/i2c/busses/i2c-s3c2410.c +1
-0@@ -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.
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 1021
Quoted 2 lines
drivers/i2c/busses/i2c-s3c2410.c +2
-0+pm_runtime_enable (&pdev->dev); +pm_runtime_enable (&i2c->adap.dev);Why do we need
pm_runtime_enable()oni2c->adap.dev? AFAIK enabling runtime PM on the platform device only should do.
We probably don't need to, no.
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 10 lines · Mark Brown
Quoted 8 lines · Sylwester Nawrocki
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 569
Quoted 2 lines · Mark Brown
drivers/i2c/busses/i2c-s3c2410.c +1
-0+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 ?
Quoted 2 lines
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.
Quoted 5 lines
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.
Quoted 4 lines
Quoted 1 line
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.
Quoted 11 lines
Quoted 8 lines
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, · line 577
Quoted 6 lines
for (retry = 0; retry< adap->retries; retry++) {drivers/i2c/busses/i2c-s3c2410.c +1
-0@@ -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.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 8 lines · Sylwester Nawrocki
Quoted 2 lines · Mark Brown
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
In those cases it feels like we ought to either do what we do with suspend and make sure the device is resumed on the exit path (like we do when we're entering system suspend) or just disable the PM operations, especially given that we're reference counting.
Quoted 5 lines
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.
As I was just saying in another thread I do think it's probably worth considering adding some small amount of autosuspend by default in order to try to deal with that sort of pattern. Of course for I2C devices I rather suspect the bus is sufficiently slow that any performance work we do in the host is immaterial.
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
In reply to a message not in the archiveAm Samstag 21 Januar 2012, 21:38:13 schrieb Sylwester Nawrocki:
Quoted 6 lines · Mark Brown
Quoted 5 lines · Sylwester Nawrocki
Quoted 1 line · Mark Brown
that the rather serious problems with getting I2C patches applied I'd rather do as little as possible in individual patches.
Quoted 8 lines
Quoted 2 lines
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.
At least S3C2416/S3C2450 and S3C2412 (i.e. the ARMv5 SoCs) might profit from it, as they also support the idle modes (stop modes) that Mark is targetting with his patches in the long run.
Not sure about the 2410, 2440 and 2443 currently
Heiko
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 16 lines · Heiko Stübner
Am Samstag 21 Januar 2012, 21:38:13 schrieb Sylwester Nawrocki:
Quoted 6 lines · Mark Brown
Quoted 5 lines · Sylwester Nawrocki
Quoted 1 line · Mark Brown
that the rather serious problems with getting I2C patches applied I'd rather do as little as possible in individual patches.
Quoted 8 lines
Quoted 2 lines
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.
Quoted 3 lines
At least S3C2416/S3C2450 and S3C2412 (i.e. the ARMv5 SoCs) might profit from it, as they also support the idle modes (stop modes) that Mark is targetting with his patches in the long run.
Ah, I was just about to ask whether this patch is a part of some wider plan. It would be much better to enable core runtime PM support on all platforms that use particular driver, even though there is no any drivers adapted runtime PM on some of them yet.
Quoted 2 lines
Not sure about the 2410, 2440 and 2443 currently
But would just enabling RUNTIME_PM make any harm to those platforms ?
Signature · 2 lines
Regards, Sylwester
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 9 lines · Sylwester Nawrocki
Quoted 3 lines · Heiko Stübner
At least S3C2416/S3C2450 and S3C2412 (i.e. the ARMv5 SoCs) might profit from it, as they also support the idle modes (stop modes) that Mark is targetting with his patches in the long run.
It would be much better to enable core runtime PM support on all platforms that use particular driver, even though there is no any drivers adapted runtime PM on some of them yet.
It's just a Kconfig switch, the only issue is that users might not turn it on and for platforms where there's not much driver support they're more likely to not have done so.
Quoted 3 lines
Quoted 1 line
Not sure about the 2410, 2440 and 2443 currently
But would just enabling
RUNTIME_PMmake any harm to those platforms ?
It really shouldn't cause any issues but it seems better to not push people towards it too much when there's not much win yet. What I've been doing with all these patches is leaving any PM that already exists untouched (in so far as it's not buggy). Where there's nothing already and it's all new code I've been using a more modern idiom. I hope that this minimise any impact on existing systems.
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 7 lines · Mark Brown
Quoted 5 lines · Sylwester Nawrocki
Quoted 3 lines · Heiko Stübner
At least S3C2416/S3C2450 and S3C2412 (i.e. the ARMv5 SoCs) might profit from it, as they also support the idle modes (stop modes) that Mark is targetting with his patches in the long run.
Quoted 7 lines
Quoted 3 lines
It would be much better to enable core runtime PM support on all platforms that use particular driver, even though there is no any drivers adapted runtime PM on some of them yet.
It's just a
Kconfigswitch, the only issue is that users might not turn it on and for platforms where there's not much driver support they're more likely to not have done so.
Yes, and some simple SoCs might probably never benefit from runtime PM due to their limited power modes. Hence enforcing RUNTIME_PM dependency on some common drivers might not be sane. But it would be ideal not to work around things too much, and reimplement in drivers functionality that involves upper layers.
Quoted 10 lines
Quoted 3 lines
Quoted 1 line
Not sure about the 2410, 2440 and 2443 currently
But would just enabling
RUNTIME_PMmake any harm to those platforms ?It really shouldn't cause any issues but it seems better to not push people towards it too much when there's not much win yet. What I've been doing with all these patches is leaving any PM that already exists untouched (in so far as it's not buggy). Where there's nothing already and it's all new code I've been using a more modern idiom. I hope that this minimise any impact on existing systems.
Sounds good. The idea of enforcing runtime PM seems to be good for /dev/null only.. I noticed recently that you did a nice work correcting broken s3c-fb driver PM code. I've done similar corrections but the patches never left the internal trees due to limited time for this. And there is also a DRM driver for FIMD on Exynos now.
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 11 lines · Sylwester Nawrocki
Quoted 3 lines · Mark Brown
It's just a
Kconfigswitch, the only issue is that users might not turn it on and for platforms where there's not much driver support they're more likely to not have done so.Yes, and some simple SoCs might probably never benefit from runtime PM due to their limited power modes. Hence enforcing
RUNTIME_PMdependency on some common drivers might not be sane. But it would be ideal not to work around things too much, and reimplement in drivers functionality that involves upper layers.
Yes, that's the thinking behind my approach of not touching existing code - I don't feel too bad about making new stuff depend on new features but for older stuff I'd rather leave it alone for now. Once we can manage to deliver the WFI states there would be a very useful win there so there's going to be a benefit to users from turning it on.
Quoted 2 lines
only.. I noticed recently that you did a nice work correcting broken s3c-fb driver PM code. I've done similar corrections but the patches never left the
Thanks.
Quoted 2 lines
internal trees due to limited time for this. And there is also a DRM driver for FIMD on Exynos now.
Yeah, I don't really have access to too much of the shiny new stuff right now so I've not been able to take advantage of a lot of the stuff you guys are doing. My primary development platform is S3C6410 based at the minute.
A message that is not in the archive (sent off-list or not yet received): 1327152527-11364-2-git-send-email-broonie-yzvPICuk2AATkU/[email protected]
Re: [PATCH 2/2] i2c-s3c2410: Add stub runtime power management
Quoted 8 lines · Mark Brown
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 <broonie-yzvPICuk2AATkU/[email protected]>Acked-by Heiko Stuebner <[email protected]>
I've applied these two to for-34/i2c/i2c-samsung and will start a -next branch later in the week
Quoted 67 lines
--- 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> @@ -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);Signature · 6 lines
1.7.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · 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 addeddevm_request_and_ioremap().--- drivers/i2c/busses/i2c-s3c2410.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-s3c2410.c +0
-0
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 893
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-1@@ -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.
Quoted 5 lines · Sylwester Nawrocki
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 893
Quoted 2 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-1- 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.
Quoted 8 lines · Mark Brown
Quoted 5 lines · Sylwester Nawrocki
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 893
Quoted 2 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-1- 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.
Quoted 2 lines
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."
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Sylwester Nawrocki
Quoted 2 lines · Mark Brown
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.
I tend to use the variable myself, but when editing existing code I'm going to stick with what's there.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 18 lines · Sylwester Nawrocki
Quoted 17 lines · 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 addeddevm_request_and_ioremap().--- drivers/i2c/busses/i2c-s3c2410.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-s3c2410.c +0
-0@@ -890,7 +890,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) } }
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 893
Quoted 2 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-1- 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.
Shubhrajyoti Datta
Reviewed-by Datta ShubhrajyotiHi Mark,
The changes look good to me.
For your changes.
Some other doubts though not related to your patch. Just curious.
Quoted 14 lines · 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 addeddevm_request_and_ioremap().Signed-off-by Mark Brown <broonie-yzvPICuk2AATkU/[email protected]>---
drivers/i2c/busses/i2c-s3c2410.c | 4 +---1 files changed, 1 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-s3c2410.c +0
-0
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_probe(struct platform_device *pdev) · line 895
Quoted 7 lines
drivers/i2c/busses/i2c-s3c2410.c +1
-1@@ -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.
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_remove(struct platform_device *pdev) · line 1062
Quoted 13 lines
drivers/i2c/busses/i2c-s3c2410.c +0
-0return -ENOMEM;@@ -1035,7 +1035,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) clk_put(i2c->clk);err_noclk:
- kfree(i2c);
return ret;
}drivers/i2c/busses/i2c-s3c2410.c +0
-0@@ -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
Quoted 11 lines
drivers/i2c/busses/i2c-s3c2410.c +0
-2- 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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Shubhrajyoti,
Quoted 9 lines · Shubhrajyoti Datta
Hi Mark,
The changes look good to me.
Reviewed-by Datta Shubhrajyoti <[email protected]>For your changes.
Some other doubts though not related to your patch. Just curious.
...
Quoted 4 lines
Quoted 4 lines
drivers/i2c/busses/i2c-s3c2410.c +0
-0
...
Quoted 5 lines
drivers/i2c/busses/i2c-s3c2410.c static int s3c24xx_i2c_remove(struct platform_device *pdev) · line 1062
Quoted 4 lines
drivers/i2c/busses/i2c-s3c2410.c +0
-0@@ -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_resourceand 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
Quoted 5 lines · 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 addeddevm_request_and_ioremap().Signed-off-by Mark Brown <[email protected]>
Quoted 33 lines
--- drivers/i2c/busses/i2c-s3c2410.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-s3c2410.c +1
-3@@ -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 ; }
Signature · 2 lines
Thanks! Sylwester
2012/1/21 Mark Brown <[email protected]>:
Quoted 5 lines
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 addeddevm_request_and_ioremap().Signed-off-by Mark Brown <[email protected]>
Quoted 35 lines
---
drivers/i2c/busses/i2c-s3c2410.c | 4 +---1 files changed, 1 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-s3c2410.c +1
-1@@ -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;
}drivers/i2c/busses/i2c-s3c2410.c +0
-2@@ -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