aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-10-15 07:36:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-25 14:29:44 -0400
commitde609582072af195673e72d9e7647d5cba8eb7e4 (patch)
tree3bdcab5105dfd648636cd5dab9d63ba039386a05 /drivers
parent40477d0e04fd8d004ee9c70ad57e397a6b6ead63 (diff)
serial/amba-pl011: use devm_* managed resources
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> Tested-by: Domenico Andreoli <domenico.andreoli@linux.com> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/tty/serial/amba-pl011.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index d7e1edec50b5..7fca4022a8b2 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -56,8 +56,7 @@
56#include <linux/of_device.h> 56#include <linux/of_device.h>
57#include <linux/pinctrl/consumer.h> 57#include <linux/pinctrl/consumer.h>
58#include <linux/sizes.h> 58#include <linux/sizes.h>
59 59#include <linux/io.h>
60#include <asm/io.h>
61 60
62#define UART_NR 14 61#define UART_NR 14
63 62
@@ -1973,7 +1972,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1973 goto out; 1972 goto out;
1974 } 1973 }
1975 1974
1976 uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL); 1975 uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
1976 GFP_KERNEL);
1977 if (uap == NULL) { 1977 if (uap == NULL) {
1978 ret = -ENOMEM; 1978 ret = -ENOMEM;
1979 goto out; 1979 goto out;
@@ -1981,16 +1981,17 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1981 1981
1982 i = pl011_probe_dt_alias(i, &dev->dev); 1982 i = pl011_probe_dt_alias(i, &dev->dev);
1983 1983
1984 base = ioremap(dev->res.start, resource_size(&dev->res)); 1984 base = devm_ioremap(&dev->dev, dev->res.start,
1985 resource_size(&dev->res));
1985 if (!base) { 1986 if (!base) {
1986 ret = -ENOMEM; 1987 ret = -ENOMEM;
1987 goto free; 1988 goto out;
1988 } 1989 }
1989 1990
1990 uap->pinctrl = devm_pinctrl_get(&dev->dev); 1991 uap->pinctrl = devm_pinctrl_get(&dev->dev);
1991 if (IS_ERR(uap->pinctrl)) { 1992 if (IS_ERR(uap->pinctrl)) {
1992 ret = PTR_ERR(uap->pinctrl); 1993 ret = PTR_ERR(uap->pinctrl);
1993 goto unmap; 1994 goto out;
1994 } 1995 }
1995 uap->pins_default = pinctrl_lookup_state(uap->pinctrl, 1996 uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
1996 PINCTRL_STATE_DEFAULT); 1997 PINCTRL_STATE_DEFAULT);
@@ -2002,10 +2003,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2002 if (IS_ERR(uap->pins_sleep)) 2003 if (IS_ERR(uap->pins_sleep))
2003 dev_dbg(&dev->dev, "could not get sleep pinstate\n"); 2004 dev_dbg(&dev->dev, "could not get sleep pinstate\n");
2004 2005
2005 uap->clk = clk_get(&dev->dev, NULL); 2006 uap->clk = devm_clk_get(&dev->dev, NULL);
2006 if (IS_ERR(uap->clk)) { 2007 if (IS_ERR(uap->clk)) {
2007 ret = PTR_ERR(uap->clk); 2008 ret = PTR_ERR(uap->clk);
2008 goto unmap; 2009 goto out;
2009 } 2010 }
2010 2011
2011 uap->vendor = vendor; 2012 uap->vendor = vendor;
@@ -2038,11 +2039,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2038 amba_set_drvdata(dev, NULL); 2039 amba_set_drvdata(dev, NULL);
2039 amba_ports[i] = NULL; 2040 amba_ports[i] = NULL;
2040 pl011_dma_remove(uap); 2041 pl011_dma_remove(uap);
2041 clk_put(uap->clk);
2042 unmap:
2043 iounmap(base);
2044 free:
2045 kfree(uap);
2046 } 2042 }
2047 out: 2043 out:
2048 return ret; 2044 return ret;
@@ -2062,9 +2058,6 @@ static int pl011_remove(struct amba_device *dev)
2062 amba_ports[i] = NULL; 2058 amba_ports[i] = NULL;
2063 2059
2064 pl011_dma_remove(uap); 2060 pl011_dma_remove(uap);
2065 iounmap(uap->port.membase);
2066 clk_put(uap->clk);
2067 kfree(uap);
2068 return 0; 2061 return 0;
2069} 2062}
2070 2063