platform: add platform_devm_request_and_ioremap() common API
Subsystems (5)
cover platform: add platform_devm_request_and_ioremap() common API
these patches move the common pattern from
"
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -ENODEV;
goto err;
}base = devm_request_and_ioremap(&dev->dev, mem_res);
if (!base) {
ret = -ENODEV;
goto err;
}"
to
"
base = platform_devm_request_and_ioremap(pdev, 0);
if (!base) {
ret = -ENODEV;
goto err;
}"
Barry Song (3):
platform: add common resource requesting and mapping helper
GPIO: TEGRA: move to use platform_devm_request_and_ioremap() helper
MTD: NAND: txx9ndfmc: move to use platform_devm_request_and_ioremap()
helper
drivers/base/platform.c | 19 +++++++++++++++++++ drivers/gpio/gpio-tegra.c | 8 +------- drivers/mtd/nand/txx9ndfmc.c | 6 +----- include/linux/platform_device.h | 1 + 4 files changed, 22 insertions(+), 12 deletions(-)
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 1/3 platform: add common resource requesting and mapping helper
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
"
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -ENODEV;
goto err;
}base = devm_request_and_ioremap(&dev->dev, mem_res);
if (!base) {
ret = -ENODEV;
goto err;
}"
to
"
base = platform_devm_request_and_ioremap(pdev, 0);
if (!base) {
ret = -ENODEV;
goto err;
}"
--- drivers/base/platform.c | 19 +++++++++++++++++++ include/linux/platform_device.h | 1 + 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/base/platform.c +19 -0
@@ -72,6 +72,25 @@ struct resource *platform_get_resource(struct platform_device *dev,EXPORT_SYMBOL_GPL (platform_get_resource);/** +* platform_devm_request_and_ioremap() - get resource, check, request region, +* and ioremap resource +* @dev: platform device +* @num: IOMEM resource index +*/ +void __iomem *platform_devm_request_and_ioremap (struct platform_device *dev, +unsigned int num) +{ +struct resource *res; + + res =platform_get_resource (dev,IORESOURCE_MEM , num); +if (!res) +return NULL ; + +return devm_request_and_ioremap (&dev->dev, res); +} +EXPORT_SYMBOL_GPL (platform_devm_request_and_ioremap); + +/** * platform_get_irq - get an IRQ for a device * @dev: platform device * @num: IRQ number index
include/linux/platform_device.h +1 -0
@@ -44,6 +44,7 @@ extern struct device platform_bus;extern void arch_setup_pdev_archdata (struct platform_device *);extern struct resource *platform_get_resource (struct platform_device *,unsigned int ,unsigned int ); +extern void __iomem *platform_devm_request_and_ioremap (struct platform_device *,unsigned int );extern int platform_get_irq (struct platform_device *,unsigned int );extern struct resource *platform_get_resource_byname (struct platform_device *,unsigned int ,const char *);extern int platform_get_irq_byname (struct platform_device *,const char *);
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Quoted 10 lines · Barry Song
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
"
res =platform_get_resource(pdev, IORESOURCE_MEM, 0);if (!res) { ret = -ENODEV; goto err; }
You don't need to do the error checking for 'res'. You can simply do
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_request_and_ioremap(&dev->dev, res);
devm_request_and_ioremap() will check res. Given that, I don't think we can save a lot with another wrapper.
Thanks,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
2012/1/31 Wolfram Sang <[email protected]>:
Quoted 12 lines · Barry Song
Quoted 10 lines
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
"
res =platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) {
ret =-ENODEV;
goto err;
}
Quoted 4 lines
You don't need to do the error checking for 'res'. You can simply do
res =
platform_get_resource(pdev, IORESOURCE_MEM, 0); base =devm_request_and_ioremap(&dev->dev, res);
i do know devm_request_and_ioremap() does res checking. but that is implicit, confused and not a smart way actually. actually, no people by now really use the implicit checking. that shows people don't really think that is a good programming way.
Quoted 3 lines
devm_request_and_ioremap()will check res. Given that, I don't think we can save a lot with another wrapper.
i think we can save some.
The story begins from Grant's feedback in:
http://www.spinics.net/lists/arm-kernel/msg157644.html
Quoted 8 lines
Thanks,
Wolfram
--
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
-barry
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Barry,
Quoted 7 lines
Quoted 4 lines
You don't need to do the error checking for 'res'. You can simply do
res =
platform_get_resource(pdev, IORESOURCE_MEM, 0); base =devm_request_and_ioremap(&dev->dev, res);i do know
devm_request_and_ioremap()does res checking. but that is implicit, confused and not a smart way actually.
I agree about the implicit thing (keep in mind the function is new). But calling a function "not smart" because it checks its arguments? I do like the NULL check of kfree() for example.
Quoted 2 lines
actually, no people by now really use the implicit checking. that shows people don't really think that is a good programming way.
I'd think most people just copy&paste and don't have an opinion either way, so the quantity doesn't show much.
Quoted 6 lines
Quoted 2 lines
devm_request_and_ioremap()will check res. Given that, I don't think we can save a lot with another wrapper.i think we can save some.
The story begins from Grant's feedback in:
http://www.spinics.net/lists/arm-kernel/msg157644.html
I am not sure using 'platform_devm_request_and_ioremap' and later using plain 'devm_*' functions (without platform_-prefix) is less confusing. The alternative would be to check which helper functions also use 'struct resource' and if they do checks on that. If all do that, you would have the simple rule, that you only need to check yourself if you access it yourself.
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
hi Wolfram,
2012/1/31 Wolfram Sang <[email protected]>:
Quoted 7 lines
Barry,
Quoted 5 lines
Quoted 4 lines
You don't need to do the error checking for 'res'. You can simply do
res =
platform_get_resource(pdev, IORESOURCE_MEM, 0); base =devm_request_and_ioremap(&dev->dev, res);
Quoted 6 lines
Quoted 2 lines
i do know devm_request_and_ioremap() does res checking. but that is implicit, confused and not a smart way actually.
I agree about the implicit thing (keep in mind the function is new). But calling a function "not smart" because it checks its arguments? I do like the NULL check of
kfree()for example.
i didn't mean it is not smart for devm_request_and_ioremap() to check its param. that is definitely ok.
i mean it is not smart for people to depend on another function to do implicit check on what they should check by themselves.
Quoted 14 lines
Quoted 3 lines
actually, no people by now really use the implicit checking. that shows people don't really think that is a good programming way.
I'd think most people just copy&paste and don't have an opinion either way, so the quantity doesn't show much.
Quoted 6 lines
Quoted 2 lines
devm_request_and_ioremap()will check res. Given that, I don't think we can save a lot with another wrapper.i think we can save some.
The story begins from Grant's feedback in:
http://www.spinics.net/lists/arm-kernel/msg157644.html
Quoted 6 lines
I am not sure using '
platform_devm_request_and_ioremap' and later using plain 'devm_*' functions (without platform_-prefix) is less confusing. The alternative would be to check which helper functions also use 'struct resource' and if they do checks on that. If all do that, you would have the simple rule, that you only need to check yourself if you access it yourself.
it is just a helper, just like clk_disable_unprepare() which do clk_disable() + clk_unprepare().
Quoted 8 lines
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
-barry
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
In reply to Wolfram SangQuoted 27 lines · Wolfram Sang
Barry,
Quoted 7 lines
Quoted 4 lines
You don't need to do the error checking for 'res'. You can simply do
res =
platform_get_resource(pdev, IORESOURCE_MEM, 0); base =devm_request_and_ioremap(&dev->dev, res);i do know
devm_request_and_ioremap()does res checking. but that is implicit, confused and not a smart way actually.I agree about the implicit thing (keep in mind the function is new). But calling a function "not smart" because it checks its arguments? I do like the NULL check of
kfree()for example.Quoted 2 lines
actually, no people by now really use the implicit checking. that shows people don't really think that is a good programming way.
I'd think most people just copy&paste and don't have an opinion either way, so the quantity doesn't show much.
Quoted 6 lines
Quoted 2 lines
devm_request_and_ioremap()will check res. Given that, I don't think we can save a lot with another wrapper.i think we can save some.
The story begins from Grant's feedback in:
http://www.spinics.net/lists/arm-kernel/msg157644.html
Quoted 6 lines
I am not sure using '
platform_devm_request_and_ioremap' and later using plain 'devm_*' functions (without platform_-prefix) is less confusing. The alternative would be to check which helper functions also use 'struct resource' and if they do checks on that. If all do that, you would have the simple rule, that you only need to check yourself if you access it yourself.
The reason I suggested the wrapper is that then the driver code doesn't need to fart around with the res pointer at all. It reduces boilerplate in platform drivers which I think is a good thing.
g.
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Quoted 11 lines
Quoted 7 lines
I am not sure using '
platform_devm_request_and_ioremap' and later using plain 'devm_*' functions (without platform_-prefix) is less confusing. The alternative would be to check which helper functions also use 'struct resource' and if they do checks on that. If all do that, you would have the simple rule, that you only need to check yourself if you access it yourself.The reason I suggested the wrapper is that then the driver code doesn't need to fart around with the res pointer at all. It reduces boilerplate in platform drivers which I think is a good thing.
I do understand your motivation and fully agree with what you are aiming for (that's exactly why I implemented devm_request_and_ioremap()).
This patch is a micro-optimization, though, and won't cut it IMHO. I still have issues with only one platform_devm_* and all the rest being devm_* (without platform_). Things might look better, if we'd for example also have platform_devm_request_irq() or something similar. That might be an approach where we can play around with and see what is left to do. Or, if other approaches might be more elegant.
To discuss that, try things, etc, I'd simply like to have a bit more time. If we are accepting the first iteration right away, and people let run their coccinelle-scripts based on that, it might get annoying to change that a second time, I'd think.
Regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Quoted 22 lines · Wolfram Sang
Quoted 11 lines
Quoted 7 lines
I am not sure using '
platform_devm_request_and_ioremap' and later using plain 'devm_*' functions (without platform_-prefix) is less confusing. The alternative would be to check which helper functions also use 'struct resource' and if they do checks on that. If all do that, you would have the simple rule, that you only need to check yourself if you access it yourself.The reason I suggested the wrapper is that then the driver code doesn't need to fart around with the res pointer at all. It reduces boilerplate in platform drivers which I think is a good thing.
I do understand your motivation and fully agree with what you are aiming for (that's exactly why I implemented
devm_request_and_ioremap()).This patch is a micro-optimization, though, and won't cut it IMHO. I still have issues with only one platform_devm_* and all the rest being devm_* (without
platform_). Things might look better, if we'd for example also haveplatform_devm_request_irq()or something similar. That might be an approach where we can play around with and see what is left to do. Or, if other approaches might be more elegant.
Quoted 4 lines
To discuss that, try things, etc, I'd simply like to have a bit more time. If we are accepting the first iteration right away, and people let run their coccinelle-scripts based on that, it might get annoying to change that a second time, I'd think.
Okay, I'm willing to sit-tight on this for a bit.
g.
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
In reply to Wolfram Sanghi Wolfram,
2012/2/1 Wolfram Sang <[email protected]>:
Quoted 22 lines
Quoted 11 lines
Quoted 7 lines
I am not sure using '
platform_devm_request_and_ioremap' and later using plain 'devm_*' functions (without platform_-prefix) is less confusing. The alternative would be to check which helper functions also use 'struct resource' and if they do checks on that. If all do that, you would have the simple rule, that you only need to check yourself if you access it yourself.The reason I suggested the wrapper is that then the driver code doesn't need to fart around with the res pointer at all. It reduces boilerplate in platform drivers which I think is a good thing.
I do understand your motivation and fully agree with what you are aiming for (that's exactly why I implemented
devm_request_and_ioremap()).This patch is a micro-optimization, though, and won't cut it IMHO. I still have issues with only one platform_devm_* and all the rest being devm_* (without
platform_). Things might look better, if we'd for example also haveplatform_devm_request_irq()or something similar. That might be an approach where we can play around with and see what is left to do. Or, if other approaches might be more elegant.
Quoted 5 lines
To discuss that, try things, etc, I'd simply like to have a bit more time. If we are accepting the first iteration right away, and people let run their coccinelle-scripts based on that, it might get annoying to change that a second time, I'd think.
i think it makes sense for us to have platform_devm_request_irq() and similar things. i'll take care.
PS: as the man maintaining embedded systems of the i2c subsystem, would you comment the CSR i2c driver which has been there waiting for a long time?
http://www.spinics.net/lists/linux-i2c/msg07081.html
Quoted 7 lines
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Thanks
barry
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Quoted 3 lines
i think it makes sense for us to have
platform_devm_request_irq()and similar things. i'll take care.
I'll try, too. Then we can compare and learn from that.
Quoted 4 lines
PS: as the man maintaining embedded systems of the i2c subsystem, would you comment the CSR i2c driver which has been there waiting for a long time?
http://www.spinics.net/lists/linux-i2c/msg07081.html
Relax, you sent that only two days ago.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
2012/2/1 Wolfram Sang <[email protected]>:
Quoted 5 lines
Quoted 3 lines
i think it makes sense for us to have
platform_devm_request_irq()and similar things. i'll take care.I'll try, too. Then we can compare and learn from that.
well, thanks.
Quoted 7 lines
Quoted 5 lines
PS: as the man maintaining embedded systems of the i2c subsystem, would you comment the CSR i2c driver which has been there waiting for a long time?
http://www.spinics.net/lists/linux-i2c/msg07081.htmlRelax, you sent that only two days ago.
the v5 is sent two days ago with deleting only one line, v1-v4 has been there 3 monthes :-)
i was not complaining you haven't sent comments for v5.
Quoted 4 lines
--
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
-barry
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
In reply to Barry SongQuoted 2 lines · Barry Song
i think it makes sense for us to have
platform_devm_request_irq()and similar things. i'll take care.
Note that this one is more tricky than most as it's really important that the interrupt handler can't be called when the data it needs and so on have been freed. With things like memory this really doesn't matter and you can happily free in any order.
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Quoted 9 lines · Mark Brown
Quoted 2 lines · Barry Song
i think it makes sense for us to have
platform_devm_request_irq()and similar things. i'll take care.Note that this one is more tricky than most as it's really important that the interrupt handler can't be called when the data it needs and so on have been freed. With things like memory this really doesn't matter and you can happily free in any order.
Good point.
g.
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
In reply to Barry SongQuoted 26 lines · Barry Song
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
"
res =platform_get_resource(pdev, IORESOURCE_MEM, 0);if (!res) { ret = -ENODEV; goto err; }base =
devm_request_and_ioremap(&dev->dev, mem_res);if (!base) { ret = -ENODEV; goto err; }"
to
"
base =platform_devm_request_and_ioremap(pdev, 0);if (!base) { ret = -ENODEV; goto err; }
Quoted 8 lines
"
Signed-off-by Barry Song <[email protected]>Cc Grant Likely <[email protected]>Cc Linus Walleij <[email protected]>Cc Erik Gilling <[email protected]>Cc Atsushi Nemoto <[email protected]>Cc David Woodhouse <[email protected]>
Quoted 54 lines
--- drivers/base/platform.c | 19 +++++++++++++++++++ include/linux/platform_device.h | 1 + 2 files changed, 20 insertions(+), 0 deletions(-)drivers/base/platform.c +19
-0@@ -72,6 +72,25 @@ struct resource *platform_get_resource(struct platform_device *dev,EXPORT_SYMBOL_GPL (platform_get_resource);/** +* platform_devm_request_and_ioremap() - get resource, check, request region, +* and ioremap resource +* @dev: platform device +* @num: IOMEM resource index +*/ +void __iomem *platform_devm_request_and_ioremap (struct platform_device *dev, +unsigned int num) +{ +struct resource *res; + + res =platform_get_resource (dev,IORESOURCE_MEM , num); +if (!res) +return NULL ; + +return devm_request_and_ioremap (&dev->dev, res); +} +EXPORT_SYMBOL_GPL (platform_devm_request_and_ioremap); + +/** * platform_get_irq - get an IRQ for a device * @dev: platform device * @num: IRQ number index include/linux/platform_device.h +1
-0@@ -44,6 +44,7 @@ extern struct device platform_bus;extern void arch_setup_pdev_archdata (struct platform_device *);extern struct resource *platform_get_resource (struct platform_device *,unsigned int ,unsigned int ); +extern void __iomem *platform_devm_request_and_ioremap (struct platform_device *,unsigned int );extern int platform_get_irq (struct platform_device *,unsigned int );extern struct resource *platform_get_resource_byname (struct platform_device *,unsigned int ,const char *);extern int platform_get_irq_byname (struct platform_device *,const char *);Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
In reply to Barry SongQuoted 3 lines · Barry Song
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
Good idea!
include/linux/platform_device.h extern struct device platform_bus; · line 47
Quoted 5 lines
include/linux/platform_device.h +1
-0@@ -44,6 +44,7 @@ extern struct device platform_bus; extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); +extern void __iomem *platform_devm_request_and_ioremap (struct platform_device *,unsigned int );
But don't you want a reverse call for the module remove() function?
Like:
extern void __iomem *platform_devm_iounmap_and_free(struct platform_device *, unsigned int);
?
Yours,
Linus Walleij
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
Quoted 16 lines · Linus Walleij
Quoted 3 lines · Barry Song
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
Good idea!
include/linux/platform_device.h extern struct device platform_bus; · line 47
Quoted 5 lines
include/linux/platform_device.h +1
-0@@ -44,6 +44,7 @@ extern struct device platform_bus; extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); +extern void __iomem *platform_devm_request_and_ioremap (struct platform_device *,unsigned int );But don't you want a reverse call for the module
remove()function?
Quoted 4 lines
Like:
extern void
__iomem*platform_devm_iounmap_and_free(structplatform_device*, unsigned int);
I wouldn't because it is exactly the same as the normal unwind call. I don't think the name redirection buys us anything here.
g.
Re: [PATCH 1/3] platform: add common resource requesting and mapping helper
In reply to Linus WalleijLinus,
2012/2/1 Linus Walleij <[email protected]>:
Quoted 16 lines · Barry Song
Quoted 4 lines
From: Barry Song <[email protected]>
this patch helps to move the common pattern from
Good idea!
include/linux/platform_device.h extern struct device platform_bus; · line 47
Quoted 5 lines
include/linux/platform_device.h +1
-0@@ -44,6 +44,7 @@ extern struct device platform_bus; extern void arch_setup_pdev_archdata(struct platform_device *); extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); +extern void __iomem *platform_devm_request_and_ioremap (struct platform_device *,unsigned int );But don't you want a reverse call for the module
remove()function?
Quoted 4 lines
Like:
extern void
__iomem*platform_devm_iounmap_and_free(structplatform_device*, unsigned int);
that point is we have the garbage collection mechanism by calling devm_ function families. everything is undone on driver detach. so we will not have the free and unmap things.
Quoted 5 lines
?
Yours,
Linus Walleij
-barry
PATCH 2/3 GPIO: TEGRA: move to use platform_devm_request_and_ioremap() helper
In reply to Barry SongFrom: Barry Song <[email protected]>
--- drivers/gpio/gpio-tegra.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/gpio/gpio-tegra.c +1 -7
@@ -355,13 +355,7 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev) bank->irq = res->start; } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"Missing MEM resource\n" ); -return -ENODEV ; - } - - regs =devm_request_and_ioremap (&pdev->dev, res); + regs =platform_devm_request_and_ioremap (pdev,0 );if (!regs) {dev_err (&pdev->dev,"Couldn't ioremap regs\n" );return -ENODEV ;
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
RE: [PATCH 2/3] GPIO: TEGRA: move to use platform_devm_request_and_ioremap() helper
Barry Song wrote at Tuesday, January 31, 2012 3:00 AM:
Quoted 2 lines
[no description]Signed-off-by Barry Song <[email protected]>
Signature · 1 line
nvpublic
Re: [PATCH 2/3] GPIO: TEGRA: move to use platform_devm_request_and_ioremap() helper
In reply to Barry SongQuoted 6 lines · Barry Song
From: Barry Song <[email protected]>
Signed-off-by Barry Song <[email protected]>Cc Grant Likely <[email protected]>Cc Linus Walleij <[email protected]>Cc Erik Gilling <[email protected]>
This of course depends on the other patch, so I won't merge it until there is an okay from gregkh. Also, with his okay I'd be happy to take it through the gpio tree to reduce dependencies.
g.
Quoted 30 lines
--- drivers/gpio/gpio-tegra.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)drivers/gpio/gpio-tegra.c +1
-7@@ -355,13 +355,7 @@ static int __devinit tegra_gpio_probe(struct platform_device *pdev) bank->irq = res->start; } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"Missing MEM resource\n" ); -return -ENODEV ; - } - - regs =devm_request_and_ioremap (&pdev->dev, res); + regs =platform_devm_request_and_ioremap (pdev,0 );if (!regs) {dev_err (&pdev->dev,"Couldn't ioremap regs\n" );return -ENODEV ;Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 3/3 MTD: NAND: txx9ndfmc: move to use platform_devm_request_and_ioremap() helper
In reply to Barry SongFrom: Barry Song <[email protected]>
--- drivers/mtd/nand/txx9ndfmc.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
drivers/mtd/nand/txx9ndfmc.c +1 -5
@@ -290,15 +290,11 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)int i;struct txx9ndfmc_drvdata *drvdata;unsigned long gbusclk = plat->gbus_clock; -struct resource *res; - res =platform_get_resource (dev,IORESOURCE_MEM ,0 ); -if (!res) -return -ENODEV ; drvdata =devm_kzalloc (&dev->dev,sizeof (*drvdata),GFP_KERNEL );if (!drvdata)return -ENOMEM ; - drvdata->base =devm_request_and_ioremap (&dev->dev, res); + drvdata->base =platform_devm_request_and_ioremap (dev,0 );if (!drvdata->base)return -EBUSY ;
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Quoted 9 lines · Barry Song
these patches move the common pattern from
"
res =platform_get_resource(pdev, IORESOURCE_MEM, 0);if (!res) { ret = -ENODEV; goto err; }
Quoted 6 lines
base =
devm_request_and_ioremap(&dev->dev, mem_res);if (!base) { ret = -ENODEV; goto err; }"
Am I right that these patches have been generated using the coccinelle/api/devm_request_and_ioremap.cocci script?
If yes, I think it would be nice of you to give a credit to coccinelle and its authors for developing this awesome tool in every commit message.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Hi Artem,
2012/1/31 Artem Bityutskiy <[email protected]>:
Quoted 17 lines · Barry Song
Quoted 9 lines
these patches move the common pattern from
"
res =platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) {
ret =-ENODEV;
goto err;
}Quoted 6 lines
base =
devm_request_and_ioremap(&dev->dev, mem_res); if (!base) {
ret =-ENODEV;
goto err;
}
"
Quoted 6 lines
Am I right that these patches have been generated using the
coccinelle/api/devm_request_and_ioremap.cocciscript?If yes, I think it would be nice of you to give a credit to coccinelle and its authors for developing this awesome tool in every commit message.
devm_request_and_ioremap() is still something new by commit 72f8c0bfa0de64c68ee59f40eb9b2683bffffbb0:
author Wolfram Sang <[email protected]>
Tue, 25 Oct 2011 13:16:47 +0000 (15:16 +0200)
there are only a few users until now. but it is going to be used as a common/suggested way to request and map resource. now we don't need a script to find them, just cscope "cs f c devm_request_and_ioremap".
Quoted 4 lines
--
Best Regards,
Artem Bityutskiy
-barry
Quoted 5 lines · Barry Song
Quoted 3 lines
If yes, I think it would be nice of you to give a credit to coccinelle and its authors for developing this awesome tool in every commit message.
devm_request_and_ioremap()is still something new by commit
Ah, ok. But it would be cool if you could create a coccinell semantic patch for this, although I should admit this is not very easy, but a lot of fun.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 10 lines · Artem Bityutskiy
Quoted 5 lines · Barry Song
Quoted 3 lines
If yes, I think it would be nice of you to give a credit to coccinelle and its authors for developing this awesome tool in every commit message.
devm_request_and_ioremap()is still something new by commitAh, ok. But it would be cool if you could create a coccinell semantic patch for this, although I should admit this is not very easy, but a lot of fun.
To promote the idea further. If you manage to create a semantic patch for this, then you will just generate your patches automatically. You will also be able to make it more probable that people will use this new api by adding your semantic patch to scripts/coccinelle/api.
I do not know how many people run coccinelle, but I recently started to check all incoming MTD patches with coccinelle before applying them. A little bit of scripting and this becomes easy to do.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 5 lines
To promote the idea further. If you manage to create a semantic patch for this, then you will just generate your patches automatically. You will also be able to make it more probable that people will use this new api by adding your semantic patch to
scripts/coccinelle/api.
I'd think Julia is already at it [1], but the same issue has come up there, too [2].
Regards,
Wolfram
[1] http://lkml.org/lkml/2012/1/26/169
[2] http://lkml.org/lkml/2012/1/28/10
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |