Skip to content

Commit

Permalink
serial: 8250_aspeed_vuart: Use devm_clk_get_enabled()
Browse files Browse the repository at this point in the history
Use devm_clk_get_enabled() to simplify the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20230919195450.3197881-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Andy Shevchenko authored and Greg Kroah-Hartman committed Oct 3, 2023
1 parent 24f2cd0 commit 182fb83
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions drivers/tty/serial/8250/8250_aspeed_vuart.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

struct aspeed_vuart {
struct device *dev;
struct clk *clk;
int line;
struct timer_list unthrottle_timer;
struct uart_8250_port *port;
Expand Down Expand Up @@ -422,6 +421,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
struct resource *res;
u32 clk, prop, sirq[2];
int rc, sirq_polarity;
struct clk *vclk;

np = pdev->dev.of_node;

Expand Down Expand Up @@ -454,18 +454,13 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
return rc;

if (of_property_read_u32(np, "clock-frequency", &clk)) {
vuart->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(vuart->clk)) {
rc = dev_err_probe(dev, PTR_ERR(vuart->clk),
"clk or clock-frequency not defined\n");
vclk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(vclk)) {
rc = dev_err_probe(dev, PTR_ERR(vclk), "clk or clock-frequency not defined\n");
goto err_sysfs_remove;
}

rc = clk_prepare_enable(vuart->clk);
if (rc < 0)
goto err_sysfs_remove;

clk = clk_get_rate(vuart->clk);
clk = clk_get_rate(vclk);
}

/* If current-speed was set, then try not to change it. */
Expand Down Expand Up @@ -565,7 +560,6 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
return 0;

err_clk_disable:
clk_disable_unprepare(vuart->clk);
irq_dispose_mapping(port.port.irq);
err_sysfs_remove:
sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
Expand All @@ -580,7 +574,6 @@ static int aspeed_vuart_remove(struct platform_device *pdev)
aspeed_vuart_set_enabled(vuart, false);
serial8250_unregister_port(vuart->line);
sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
clk_disable_unprepare(vuart->clk);

return 0;
}
Expand Down

0 comments on commit 182fb83

Please sign in to comment.