serial/amba-pl011: use devm_* managed resources
PATCH RESEND 1/1 serial/amba-pl011: use devm_* managed resources
From: Linus Walleij <[email protected]>
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.
--- drivers/tty/serial/amba-pl011.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/tty/serial/amba-pl011.c +9 -16
@@ -56,8 +56,7 @@#include <linux/of_device.h> #include <linux/pinctrl/consumer.h> #include <linux/sizes.h> - -#include <asm/io.h> +#include <linux/io.h> #define UART_NR 14
@@ -1973,7 +1972,8 @@ 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;
@@ -1981,16 +1981,17 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) i =pl011_probe_dt_alias (i, &dev->dev); - 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 );
@@ -2002,10 +2003,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)if (IS_ERR (uap->pins_sleep))dev_dbg (&dev->dev,"could not get sleep pinstate\n" ); - uap->clk =clk_get (&dev->dev,NULL ); + uap->clk =devm_clk_get (&dev->dev,NULL );if (IS_ERR (uap->clk)) { ret =PTR_ERR (uap->clk); - goto unmap; + goto out; } uap->vendor = vendor;
@@ -2038,11 +2039,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)amba_set_drvdata (dev,NULL ); amba_ports[i] =NULL ;pl011_dma_remove (uap); -clk_put (uap->clk); - unmap: -iounmap (base); - free: -kfree (uap); } out:return ret;
@@ -2062,9 +2058,6 @@ 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 ; }
Signature · 1 line
1.7.11.3
PATCH RESEND 1/1 serial/amba-pl011: use devm_* managed resources
Quoted 10 lines · Linus Walleij
From: Linus Walleij <[email protected]>
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 <[email protected]>
Best Regards,
J.
PATCH RESEND 1/1 serial/amba-pl011: use devm_* managed resources
In reply to Linus WalleijQuoted 85 lines · Linus Walleij
From: Linus Walleij <[email protected]>
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 <[email protected]>--- drivers/tty/serial/amba-pl011.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)drivers/tty/serial/amba-pl011.c +9
-13@@ -56,8 +56,7 @@#include <linux/of_device.h> #include <linux/pinctrl/consumer.h> #include <linux/sizes.h> - -#include <asm/io.h> +#include <linux/io.h> #define UART_NR 14@@ -1973,7 +1972,8 @@ 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;@@ -1981,16 +1981,17 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) i =pl011_probe_dt_alias (i, &dev->dev); - 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 );@@ -2002,10 +2003,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)if (IS_ERR (uap->pins_sleep))dev_dbg (&dev->dev,"could not get sleep pinstate\n" ); - uap->clk =clk_get (&dev->dev,NULL ); + uap->clk =devm_clk_get (&dev->dev,NULL );if (IS_ERR (uap->clk)) { ret =PTR_ERR (uap->clk); - goto unmap; + goto out; } uap->vendor = vendor;@@ -2038,11 +2039,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)amba_set_drvdata (dev,NULL ); amba_ports[i] =NULL ;pl011_dma_remove (uap); -clk_put (uap->clk); - unmap: -iounmap (base); - free: -kfree (uap); } out:return ret;
drivers/tty/serial/amba-pl011.c static int pl011_remove(struct amba_device *dev) · line 2063
Quoted 9 lines
drivers/tty/serial/amba-pl011.c +0
-3@@ -2062,9 +2058,6 @@ 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 ; }
Thanks,
Domenido