Commit a324e4de authored by Gabor Juhos's avatar Gabor Juhos Committed by Greg Kroah-Hartman

tty: ar933x_uart: convert to use devm_* functions

Use devm_* functions in order to simplify cleanup
paths.
Signed-off-by: default avatarGabor Juhos <juhosg@openwrt.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent aefceaf4
...@@ -652,19 +652,18 @@ static int ar933x_uart_probe(struct platform_device *pdev) ...@@ -652,19 +652,18 @@ static int ar933x_uart_probe(struct platform_device *pdev)
return -EINVAL; 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) if (!up)
return -ENOMEM; return -ENOMEM;
port = &up->port; port = &up->port;
port->mapbase = mem_res->start;
port->membase = ioremap(mem_res->start, AR933X_UART_REGS_SIZE); port->membase = devm_ioremap_resource(&pdev->dev, mem_res);
if (!port->membase) { if (IS_ERR(port->membase))
ret = -ENOMEM; return PTR_ERR(port->membase);
goto err_free_up;
}
port->mapbase = mem_res->start;
port->line = id; port->line = id;
port->irq = irq_res->start; port->irq = irq_res->start;
port->dev = &pdev->dev; port->dev = &pdev->dev;
...@@ -686,16 +685,10 @@ static int ar933x_uart_probe(struct platform_device *pdev) ...@@ -686,16 +685,10 @@ static int ar933x_uart_probe(struct platform_device *pdev)
ret = uart_add_one_port(&ar933x_uart_driver, &up->port); ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
if (ret) if (ret)
goto err_unmap; return ret;
platform_set_drvdata(pdev, up); platform_set_drvdata(pdev, up);
return 0; return 0;
err_unmap:
iounmap(up->port.membase);
err_free_up:
kfree(up);
return ret;
} }
static int ar933x_uart_remove(struct platform_device *pdev) static int ar933x_uart_remove(struct platform_device *pdev)
...@@ -704,11 +697,8 @@ static int ar933x_uart_remove(struct platform_device *pdev) ...@@ -704,11 +697,8 @@ static int ar933x_uart_remove(struct platform_device *pdev)
up = platform_get_drvdata(pdev); up = platform_get_drvdata(pdev);
if (up) { if (up)
uart_remove_one_port(&ar933x_uart_driver, &up->port); uart_remove_one_port(&ar933x_uart_driver, &up->port);
iounmap(up->port.membase);
kfree(up);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment