serial: amba-pl010: Use devres APIs

Migrating to use devres managed APIs devm_kzalloc, devm_ioremap and
devm_clk_get.

Signed-off-by: Tushar Behera <tushar.b@samsung.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tushar Behera 2014-06-26 15:35:36 +05:30 committed by Greg Kroah-Hartman
parent 7f6d942a81
commit 44acd26063
1 changed files with 16 additions and 32 deletions

View File

@ -46,8 +46,7 @@
#include <linux/amba/serial.h> #include <linux/amba/serial.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/io.h>
#include <asm/io.h>
#define UART_NR 8 #define UART_NR 8
@ -688,28 +687,22 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
if (amba_ports[i] == NULL) if (amba_ports[i] == NULL)
break; break;
if (i == ARRAY_SIZE(amba_ports)) { if (i == ARRAY_SIZE(amba_ports))
ret = -EBUSY; return -EBUSY;
goto out;
}
uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL); uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
if (!uap) { GFP_KERNEL);
ret = -ENOMEM; if (!uap)
goto out; return -ENOMEM;
}
base = ioremap(dev->res.start, resource_size(&dev->res)); base = devm_ioremap(&dev->dev, dev->res.start,
if (!base) { resource_size(&dev->res));
ret = -ENOMEM; if (!base)
goto free; return -ENOMEM;
}
uap->clk = clk_get(&dev->dev, NULL); uap->clk = devm_clk_get(&dev->dev, NULL);
if (IS_ERR(uap->clk)) { if (IS_ERR(uap->clk))
ret = PTR_ERR(uap->clk); return PTR_ERR(uap->clk);
goto unmap;
}
uap->port.dev = &dev->dev; uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start; uap->port.mapbase = dev->res.start;
@ -727,15 +720,9 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
amba_set_drvdata(dev, uap); amba_set_drvdata(dev, uap);
ret = uart_add_one_port(&amba_reg, &uap->port); ret = uart_add_one_port(&amba_reg, &uap->port);
if (ret) { if (ret)
amba_ports[i] = NULL; amba_ports[i] = NULL;
clk_put(uap->clk);
unmap:
iounmap(base);
free:
kfree(uap);
}
out:
return ret; return ret;
} }
@ -750,9 +737,6 @@ static int pl010_remove(struct amba_device *dev)
if (amba_ports[i] == uap) if (amba_ports[i] == uap)
amba_ports[i] = NULL; amba_ports[i] = NULL;
iounmap(uap->port.membase);
clk_put(uap->clk);
kfree(uap);
return 0; return 0;
} }