Skip to content

Commit

Permalink
tty: ar933x_uart: convert to use devm_* functions
Browse files Browse the repository at this point in the history
Use devm_* functions in order to simplify cleanup
paths.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Gabor Juhos authored and Greg Kroah-Hartman committed Aug 12, 2013
1 parent aefceaf commit a324e4d
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions drivers/tty/serial/ar933x_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,19 +652,18 @@ static int ar933x_uart_probe(struct platform_device *pdev)
return -EINVAL;
}

up = kzalloc(sizeof(struct ar933x_uart_port), GFP_KERNEL);
up = devm_kzalloc(&pdev->dev, sizeof(struct ar933x_uart_port),
GFP_KERNEL);
if (!up)
return -ENOMEM;

port = &up->port;
port->mapbase = mem_res->start;

port->membase = ioremap(mem_res->start, AR933X_UART_REGS_SIZE);
if (!port->membase) {
ret = -ENOMEM;
goto err_free_up;
}
port->membase = devm_ioremap_resource(&pdev->dev, mem_res);
if (IS_ERR(port->membase))
return PTR_ERR(port->membase);

port->mapbase = mem_res->start;
port->line = id;
port->irq = irq_res->start;
port->dev = &pdev->dev;
Expand All @@ -686,16 +685,10 @@ static int ar933x_uart_probe(struct platform_device *pdev)

ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret)
goto err_unmap;
return ret;

platform_set_drvdata(pdev, up);
return 0;

err_unmap:
iounmap(up->port.membase);
err_free_up:
kfree(up);
return ret;
}

static int ar933x_uart_remove(struct platform_device *pdev)
Expand All @@ -704,11 +697,8 @@ static int ar933x_uart_remove(struct platform_device *pdev)

up = platform_get_drvdata(pdev);

if (up) {
if (up)
uart_remove_one_port(&ar933x_uart_driver, &up->port);
iounmap(up->port.membase);
kfree(up);
}

return 0;
}
Expand Down

0 comments on commit a324e4d

Please sign in to comment.