diff options
Diffstat (limited to 'drivers/tty/serial/8250/8250_of.c')
-rw-r--r-- | drivers/tty/serial/8250/8250_of.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 51329625c4..ef3e745bd0 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -33,7 +33,8 @@ static int of_platform_serial_setup(struct platform_device *ofdev, struct of_serial_info *info) { struct resource resource; - struct device_node *np = ofdev->dev.of_node; + struct device *dev = &ofdev->dev; + struct device_node *np = dev->of_node; struct uart_port *port = &up->port; u32 clk, spd, prop; int ret, irq; @@ -46,19 +47,12 @@ static int of_platform_serial_setup(struct platform_device *ofdev, if (of_property_read_u32(np, "clock-frequency", &clk)) { /* Get clk rate through clk driver if present */ - info->clk = devm_clk_get(&ofdev->dev, NULL); + info->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(info->clk)) { - ret = PTR_ERR(info->clk); - if (ret != -EPROBE_DEFER) - dev_warn(&ofdev->dev, - "failed to get clock: %d\n", ret); + ret = dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n"); goto err_pmruntime; } - ret = clk_prepare_enable(info->clk); - if (ret < 0) - goto err_pmruntime; - clk = clk_get_rate(info->clk); } /* If current-speed was set, then try not to change it. */ @@ -67,8 +61,8 @@ static int of_platform_serial_setup(struct platform_device *ofdev, ret = of_address_to_resource(np, 0, &resource); if (ret) { - dev_warn(&ofdev->dev, "invalid address\n"); - goto err_unprepare; + dev_err_probe(dev, ret, "invalid address\n"); + goto err_pmruntime; } port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | @@ -85,10 +79,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev, /* Check for shifted address mapping */ if (of_property_read_u32(np, "reg-offset", &prop) == 0) { if (prop >= port->mapsize) { - dev_warn(&ofdev->dev, "reg-offset %u exceeds region size %pa\n", - prop, &port->mapsize); - ret = -EINVAL; - goto err_unprepare; + ret = dev_err_probe(dev, -EINVAL, "reg-offset %u exceeds region size %pa\n", + prop, &port->mapsize); + goto err_pmruntime; } port->mapbase += prop; @@ -109,10 +102,9 @@ static int of_platform_serial_setup(struct platform_device *ofdev, UPIO_MEM32BE : UPIO_MEM32; break; default: - dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", - prop); - ret = -EINVAL; - goto err_unprepare; + ret = dev_err_probe(dev, -EINVAL, "unsupported reg-io-width (%u)\n", + prop); + goto err_pmruntime; } } port->flags |= UPF_IOREMAP; @@ -139,7 +131,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, if (irq < 0) { if (irq == -EPROBE_DEFER) { ret = -EPROBE_DEFER; - goto err_unprepare; + goto err_pmruntime; } /* IRQ support not mandatory */ irq = 0; @@ -150,12 +142,12 @@ static int of_platform_serial_setup(struct platform_device *ofdev, info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); if (IS_ERR(info->rst)) { ret = PTR_ERR(info->rst); - goto err_unprepare; + goto err_pmruntime; } ret = reset_control_deassert(info->rst); if (ret) - goto err_unprepare; + goto err_pmruntime; port->type = type; port->uartclk = clk; @@ -173,7 +165,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, case PORT_RT2880: ret = rt288x_setup(port); if (ret) - goto err_unprepare; + goto err_pmruntime; break; } @@ -185,8 +177,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev, } return 0; -err_unprepare: - clk_disable_unprepare(info->clk); err_pmruntime: pm_runtime_put_sync(&ofdev->dev); pm_runtime_disable(&ofdev->dev); @@ -253,7 +243,6 @@ err_dispose: irq_dispose_mapping(port8250.port.irq); pm_runtime_put_sync(&ofdev->dev); pm_runtime_disable(&ofdev->dev); - clk_disable_unprepare(info->clk); err_free: kfree(info); return ret; @@ -271,7 +260,6 @@ static int of_platform_serial_remove(struct platform_device *ofdev) reset_control_assert(info->rst); pm_runtime_put_sync(&ofdev->dev); pm_runtime_disable(&ofdev->dev); - clk_disable_unprepare(info->clk); kfree(info); return 0; } |