Skip to content

Commit

Permalink
serial: amba-pl010: Use devres APIs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tushar Behera authored and Greg Kroah-Hartman committed Jul 10, 2014
1 parent 7f6d942 commit 44acd26
Showing 1 changed file with 16 additions and 32 deletions.
48 changes: 16 additions & 32 deletions drivers/tty/serial/amba-pl010.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
#include <linux/amba/serial.h>
#include <linux/clk.h>
#include <linux/slab.h>

#include <asm/io.h>
#include <linux/io.h>

#define UART_NR 8

Expand Down Expand Up @@ -688,28 +687,22 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
if (amba_ports[i] == NULL)
break;

if (i == ARRAY_SIZE(amba_ports)) {
ret = -EBUSY;
goto out;
}
if (i == ARRAY_SIZE(amba_ports))
return -EBUSY;

uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
if (!uap) {
ret = -ENOMEM;
goto out;
}
uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
GFP_KERNEL);
if (!uap)
return -ENOMEM;

base = ioremap(dev->res.start, resource_size(&dev->res));
if (!base) {
ret = -ENOMEM;
goto free;
}
base = devm_ioremap(&dev->dev, dev->res.start,
resource_size(&dev->res));
if (!base)
return -ENOMEM;

uap->clk = clk_get(&dev->dev, NULL);
if (IS_ERR(uap->clk)) {
ret = PTR_ERR(uap->clk);
goto unmap;
}
uap->clk = devm_clk_get(&dev->dev, NULL);
if (IS_ERR(uap->clk))
return PTR_ERR(uap->clk);

uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start;
Expand All @@ -727,15 +720,9 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)

amba_set_drvdata(dev, uap);
ret = uart_add_one_port(&amba_reg, &uap->port);
if (ret) {
if (ret)
amba_ports[i] = NULL;
clk_put(uap->clk);
unmap:
iounmap(base);
free:
kfree(uap);
}
out:

return ret;
}

Expand All @@ -750,9 +737,6 @@ static int pl010_remove(struct amba_device *dev)
if (amba_ports[i] == uap)
amba_ports[i] = NULL;

iounmap(uap->port.membase);
clk_put(uap->clk);
kfree(uap);
return 0;
}

Expand Down

0 comments on commit 44acd26

Please sign in to comment.