* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-17 13:44 ` Linus Walleij
0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-06-17 13:44 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-serial; +Cc: linux-arm-kernel, Linus Walleij
From: Linus Walleij <linus.walleij@linaro.org>
This switches a bunch of allocation and remapping to use the
devm_* garbage collected methods and cleans up the error
path and remove() paths consequently.
devm_ioremap() is only in <linux/io.h> so fix up the
erroneous <asm/*> include as well.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/tty/serial/amba-pl011.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c17923e..3ce984f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -53,8 +53,8 @@
#include <linux/delay.h>
#include <linux/types.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/io.h>
-#include <asm/io.h>
#include <asm/sizes.h>
#define UART_NR 14
@@ -1885,22 +1885,24 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
goto out;
}
- uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
+ uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
+ GFP_KERNEL);
if (uap == NULL) {
ret = -ENOMEM;
goto out;
}
- base = ioremap(dev->res.start, resource_size(&dev->res));
+ base = devm_ioremap(&dev->dev, dev->res.start,
+ resource_size(&dev->res));
if (!base) {
ret = -ENOMEM;
- goto free;
+ goto out;
}
uap->pinctrl = devm_pinctrl_get(&dev->dev);
if (IS_ERR(uap->pinctrl)) {
ret = PTR_ERR(uap->pinctrl);
- goto unmap;
+ goto out;
}
uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
PINCTRL_STATE_DEFAULT);
@@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
uap->clk = clk_get(&dev->dev, NULL);
if (IS_ERR(uap->clk)) {
ret = PTR_ERR(uap->clk);
- goto unmap;
+ goto out;
}
uap->vendor = vendor;
@@ -1950,10 +1952,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
amba_ports[i] = NULL;
pl011_dma_remove(uap);
clk_put(uap->clk);
- unmap:
- iounmap(base);
- free:
- kfree(uap);
}
out:
return ret;
@@ -1973,9 +1971,7 @@ static int pl011_remove(struct amba_device *dev)
amba_ports[i] = NULL;
pl011_dma_remove(uap);
- iounmap(uap->port.membase);
clk_put(uap->clk);
- kfree(uap);
return 0;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-17 13:44 ` Linus Walleij
0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-06-17 13:44 UTC (permalink / raw)
To: linux-arm-kernel
From: Linus Walleij <linus.walleij@linaro.org>
This switches a bunch of allocation and remapping to use the
devm_* garbage collected methods and cleans up the error
path and remove() paths consequently.
devm_ioremap() is only in <linux/io.h> so fix up the
erroneous <asm/*> include as well.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/tty/serial/amba-pl011.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index c17923e..3ce984f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -53,8 +53,8 @@
#include <linux/delay.h>
#include <linux/types.h>
#include <linux/pinctrl/consumer.h>
+#include <linux/io.h>
-#include <asm/io.h>
#include <asm/sizes.h>
#define UART_NR 14
@@ -1885,22 +1885,24 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
goto out;
}
- uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
+ uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
+ GFP_KERNEL);
if (uap == NULL) {
ret = -ENOMEM;
goto out;
}
- base = ioremap(dev->res.start, resource_size(&dev->res));
+ base = devm_ioremap(&dev->dev, dev->res.start,
+ resource_size(&dev->res));
if (!base) {
ret = -ENOMEM;
- goto free;
+ goto out;
}
uap->pinctrl = devm_pinctrl_get(&dev->dev);
if (IS_ERR(uap->pinctrl)) {
ret = PTR_ERR(uap->pinctrl);
- goto unmap;
+ goto out;
}
uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
PINCTRL_STATE_DEFAULT);
@@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
uap->clk = clk_get(&dev->dev, NULL);
if (IS_ERR(uap->clk)) {
ret = PTR_ERR(uap->clk);
- goto unmap;
+ goto out;
}
uap->vendor = vendor;
@@ -1950,10 +1952,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
amba_ports[i] = NULL;
pl011_dma_remove(uap);
clk_put(uap->clk);
- unmap:
- iounmap(base);
- free:
- kfree(uap);
}
out:
return ret;
@@ -1973,9 +1971,7 @@ static int pl011_remove(struct amba_device *dev)
amba_ports[i] = NULL;
pl011_dma_remove(uap);
- iounmap(uap->port.membase);
clk_put(uap->clk);
- kfree(uap);
return 0;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
2012-06-17 13:44 ` Linus Walleij
@ 2012-06-17 14:13 ` Fabio Estevam
-1 siblings, 0 replies; 12+ messages in thread
From: Fabio Estevam @ 2012-06-17 14:13 UTC (permalink / raw)
To: Linus Walleij
Cc: Greg Kroah-Hartman, linux-serial, Linus Walleij, linux-arm-kernel
On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
<linus.walleij@stericsson.com> wrote:
> uap->pinctrl = devm_pinctrl_get(&dev->dev);
> if (IS_ERR(uap->pinctrl)) {
> ret = PTR_ERR(uap->pinctrl);
> - goto unmap;
> + goto out;
> }
> uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
> PINCTRL_STATE_DEFAULT);
> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
> uap->clk = clk_get(&dev->dev, NULL);
Maybe you can use devm_clk_get here too.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-17 14:13 ` Fabio Estevam
0 siblings, 0 replies; 12+ messages in thread
From: Fabio Estevam @ 2012-06-17 14:13 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
<linus.walleij@stericsson.com> wrote:
> ? ? ? ?uap->pinctrl = devm_pinctrl_get(&dev->dev);
> ? ? ? ?if (IS_ERR(uap->pinctrl)) {
> ? ? ? ? ? ? ? ?ret = PTR_ERR(uap->pinctrl);
> - ? ? ? ? ? ? ? goto unmap;
> + ? ? ? ? ? ? ? goto out;
> ? ? ? ?}
> ? ? ? ?uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PINCTRL_STATE_DEFAULT);
> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
> ? ? ? ?uap->clk = clk_get(&dev->dev, NULL);
Maybe you can use devm_clk_get here too.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
2012-06-17 14:13 ` Fabio Estevam
@ 2012-06-18 6:37 ` Linus Walleij
-1 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-06-18 6:37 UTC (permalink / raw)
To: Fabio Estevam, Russell King - ARM Linux
Cc: Linus Walleij, Greg Kroah-Hartman, linux-serial, linux-arm-kernel
On Sun, Jun 17, 2012 at 4:13 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
> <linus.walleij@stericsson.com> wrote:
>
>> uap->pinctrl = devm_pinctrl_get(&dev->dev);
>> if (IS_ERR(uap->pinctrl)) {
>> ret = PTR_ERR(uap->pinctrl);
>> - goto unmap;
>> + goto out;
>> }
>> uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
>> PINCTRL_STATE_DEFAULT);
>> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>> uap->clk = clk_get(&dev->dev, NULL);
>
> Maybe you can use devm_clk_get here too.
That requires all users of the driver to be using CONFIG_CLKDEV, which
I *think* is safe to do, but better check: Russell, do you know if
it's safe to use
this feature from clkdev in the PL011 driver?
It seems so to me and most likely works on the systems I have (Ux500, U300,
Nomadik, Integrator, RealView) but the world of PL011 is so big...
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-18 6:37 ` Linus Walleij
0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-06-18 6:37 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jun 17, 2012 at 4:13 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
> <linus.walleij@stericsson.com> wrote:
>
>> ? ? ? ?uap->pinctrl = devm_pinctrl_get(&dev->dev);
>> ? ? ? ?if (IS_ERR(uap->pinctrl)) {
>> ? ? ? ? ? ? ? ?ret = PTR_ERR(uap->pinctrl);
>> - ? ? ? ? ? ? ? goto unmap;
>> + ? ? ? ? ? ? ? goto out;
>> ? ? ? ?}
>> ? ? ? ?uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PINCTRL_STATE_DEFAULT);
>> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>> ? ? ? ?uap->clk = clk_get(&dev->dev, NULL);
>
> Maybe you can use devm_clk_get here too.
That requires all users of the driver to be using CONFIG_CLKDEV, which
I *think* is safe to do, but better check: Russell, do you know if
it's safe to use
this feature from clkdev in the PL011 driver?
It seems so to me and most likely works on the systems I have (Ux500, U300,
Nomadik, Integrator, RealView) but the world of PL011 is so big...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
2012-06-17 13:44 ` Linus Walleij
@ 2012-06-19 0:34 ` Greg Kroah-Hartman
-1 siblings, 0 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2012-06-19 0:34 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-serial, linux-arm-kernel, Linus Walleij
On Sun, Jun 17, 2012 at 03:44:08PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> This switches a bunch of allocation and remapping to use the
> devm_* garbage collected methods and cleans up the error
> path and remove() paths consequently.
>
> devm_ioremap() is only in <linux/io.h> so fix up the
> erroneous <asm/*> include as well.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/tty/serial/amba-pl011.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
This patch doesn't apply, what tree did you make it against?
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-19 0:34 ` Greg Kroah-Hartman
0 siblings, 0 replies; 12+ messages in thread
From: Greg Kroah-Hartman @ 2012-06-19 0:34 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jun 17, 2012 at 03:44:08PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> This switches a bunch of allocation and remapping to use the
> devm_* garbage collected methods and cleans up the error
> path and remove() paths consequently.
>
> devm_ioremap() is only in <linux/io.h> so fix up the
> erroneous <asm/*> include as well.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/tty/serial/amba-pl011.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
This patch doesn't apply, what tree did you make it against?
greg k-h
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
2012-06-19 0:34 ` Greg Kroah-Hartman
@ 2012-06-20 9:16 ` Linus Walleij
-1 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-06-20 9:16 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Linus Walleij, linux-serial, linux-arm-kernel
On Tue, Jun 19, 2012 at 2:34 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Sun, Jun 17, 2012 at 03:44:08PM +0200, Linus Walleij wrote:
>>
>> This switches a bunch of allocation and remapping to use the
>> devm_* garbage collected methods and cleans up the error
>> path and remove() paths consequently.
>> (...)
>
> This patch doesn't apply, what tree did you make it against?
It was on top of the patch pending for inclusion into the -rc:s,
I can sure wait for that to be upstream and resend this then,
no hurry.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-20 9:16 ` Linus Walleij
0 siblings, 0 replies; 12+ messages in thread
From: Linus Walleij @ 2012-06-20 9:16 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jun 19, 2012 at 2:34 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Sun, Jun 17, 2012 at 03:44:08PM +0200, Linus Walleij wrote:
>>
>> This switches a bunch of allocation and remapping to use the
>> devm_* garbage collected methods and cleans up the error
>> path and remove() paths consequently.
>> (...)
>
> This patch doesn't apply, what tree did you make it against?
It was on top of the patch pending for inclusion into the -rc:s,
I can sure wait for that to be upstream and resend this then,
no hurry.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] serial/amba-pl011: use devm_* allocators
2012-06-18 6:37 ` Linus Walleij
@ 2012-06-20 10:03 ` Russell King - ARM Linux
-1 siblings, 0 replies; 12+ messages in thread
From: Russell King - ARM Linux @ 2012-06-20 10:03 UTC (permalink / raw)
To: Linus Walleij
Cc: Fabio Estevam, Linus Walleij, Greg Kroah-Hartman, linux-serial,
linux-arm-kernel
On Mon, Jun 18, 2012 at 08:37:20AM +0200, Linus Walleij wrote:
> On Sun, Jun 17, 2012 at 4:13 PM, Fabio Estevam <festevam@gmail.com> wrote:
> > On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
> > <linus.walleij@stericsson.com> wrote:
> >
> >> uap->pinctrl = devm_pinctrl_get(&dev->dev);
> >> if (IS_ERR(uap->pinctrl)) {
> >> ret = PTR_ERR(uap->pinctrl);
> >> - goto unmap;
> >> + goto out;
> >> }
> >> uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
> >> PINCTRL_STATE_DEFAULT);
> >> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
> >> uap->clk = clk_get(&dev->dev, NULL);
> >
> > Maybe you can use devm_clk_get here too.
>
> That requires all users of the driver to be using CONFIG_CLKDEV, which
> I *think* is safe to do, but better check: Russell, do you know if
> it's safe to use
> this feature from clkdev in the PL011 driver?
No idea. What I have said is that the devm_* clk_get interfaces should
not be dependent on clkdev being built.
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] serial/amba-pl011: use devm_* allocators
@ 2012-06-20 10:03 ` Russell King - ARM Linux
0 siblings, 0 replies; 12+ messages in thread
From: Russell King - ARM Linux @ 2012-06-20 10:03 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Jun 18, 2012 at 08:37:20AM +0200, Linus Walleij wrote:
> On Sun, Jun 17, 2012 at 4:13 PM, Fabio Estevam <festevam@gmail.com> wrote:
> > On Sun, Jun 17, 2012 at 10:44 AM, Linus Walleij
> > <linus.walleij@stericsson.com> wrote:
> >
> >> ? ? ? ?uap->pinctrl = devm_pinctrl_get(&dev->dev);
> >> ? ? ? ?if (IS_ERR(uap->pinctrl)) {
> >> ? ? ? ? ? ? ? ?ret = PTR_ERR(uap->pinctrl);
> >> - ? ? ? ? ? ? ? goto unmap;
> >> + ? ? ? ? ? ? ? goto out;
> >> ? ? ? ?}
> >> ? ? ? ?uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PINCTRL_STATE_DEFAULT);
> >> @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
> >> ? ? ? ?uap->clk = clk_get(&dev->dev, NULL);
> >
> > Maybe you can use devm_clk_get here too.
>
> That requires all users of the driver to be using CONFIG_CLKDEV, which
> I *think* is safe to do, but better check: Russell, do you know if
> it's safe to use
> this feature from clkdev in the PL011 driver?
No idea. What I have said is that the devm_* clk_get interfaces should
not be dependent on clkdev being built.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-06-20 10:03 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-17 13:44 [PATCH 1/2] serial/amba-pl011: use devm_* allocators Linus Walleij
2012-06-17 13:44 ` Linus Walleij
2012-06-17 14:13 ` Fabio Estevam
2012-06-17 14:13 ` Fabio Estevam
2012-06-18 6:37 ` Linus Walleij
2012-06-18 6:37 ` Linus Walleij
2012-06-20 10:03 ` Russell King - ARM Linux
2012-06-20 10:03 ` Russell King - ARM Linux
2012-06-19 0:34 ` Greg Kroah-Hartman
2012-06-19 0:34 ` Greg Kroah-Hartman
2012-06-20 9:16 ` Linus Walleij
2012-06-20 9:16 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.