Skip to content

Commit aef6b86

Browse files
andy-shevgregkh
authored andcommitted
serial: 8250_of: Use devm_clk_get_enabled()
Use devm_clk_get_enabled() to simplify the code. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 182fb83 commit aef6b86

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

drivers/tty/serial/8250/8250_of.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,12 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
4747
if (of_property_read_u32(np, "clock-frequency", &clk)) {
4848

4949
/* Get clk rate through clk driver if present */
50-
info->clk = devm_clk_get(&ofdev->dev, NULL);
50+
info->clk = devm_clk_get_enabled(dev, NULL);
5151
if (IS_ERR(info->clk)) {
5252
ret = dev_err_probe(dev, PTR_ERR(info->clk), "failed to get clock\n");
5353
goto err_pmruntime;
5454
}
5555

56-
ret = clk_prepare_enable(info->clk);
57-
if (ret < 0)
58-
goto err_pmruntime;
59-
6056
clk = clk_get_rate(info->clk);
6157
}
6258
/* If current-speed was set, then try not to change it. */
@@ -66,7 +62,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
6662
ret = of_address_to_resource(np, 0, &resource);
6763
if (ret) {
6864
dev_err_probe(dev, ret, "invalid address\n");
69-
goto err_unprepare;
65+
goto err_pmruntime;
7066
}
7167

7268
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT |
@@ -85,7 +81,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
8581
if (prop >= port->mapsize) {
8682
ret = dev_err_probe(dev, -EINVAL, "reg-offset %u exceeds region size %pa\n",
8783
prop, &port->mapsize);
88-
goto err_unprepare;
84+
goto err_pmruntime;
8985
}
9086

9187
port->mapbase += prop;
@@ -108,7 +104,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
108104
default:
109105
ret = dev_err_probe(dev, -EINVAL, "unsupported reg-io-width (%u)\n",
110106
prop);
111-
goto err_unprepare;
107+
goto err_pmruntime;
112108
}
113109
}
114110
port->flags |= UPF_IOREMAP;
@@ -135,7 +131,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
135131
if (irq < 0) {
136132
if (irq == -EPROBE_DEFER) {
137133
ret = -EPROBE_DEFER;
138-
goto err_unprepare;
134+
goto err_pmruntime;
139135
}
140136
/* IRQ support not mandatory */
141137
irq = 0;
@@ -146,12 +142,12 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
146142
info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
147143
if (IS_ERR(info->rst)) {
148144
ret = PTR_ERR(info->rst);
149-
goto err_unprepare;
145+
goto err_pmruntime;
150146
}
151147

152148
ret = reset_control_deassert(info->rst);
153149
if (ret)
154-
goto err_unprepare;
150+
goto err_pmruntime;
155151

156152
port->type = type;
157153
port->uartclk = clk;
@@ -169,7 +165,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
169165
case PORT_RT2880:
170166
ret = rt288x_setup(port);
171167
if (ret)
172-
goto err_unprepare;
168+
goto err_pmruntime;
173169
break;
174170
}
175171

@@ -181,8 +177,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
181177
}
182178

183179
return 0;
184-
err_unprepare:
185-
clk_disable_unprepare(info->clk);
186180
err_pmruntime:
187181
pm_runtime_put_sync(&ofdev->dev);
188182
pm_runtime_disable(&ofdev->dev);
@@ -249,7 +243,6 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
249243
irq_dispose_mapping(port8250.port.irq);
250244
pm_runtime_put_sync(&ofdev->dev);
251245
pm_runtime_disable(&ofdev->dev);
252-
clk_disable_unprepare(info->clk);
253246
err_free:
254247
kfree(info);
255248
return ret;
@@ -267,7 +260,6 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
267260
reset_control_assert(info->rst);
268261
pm_runtime_put_sync(&ofdev->dev);
269262
pm_runtime_disable(&ofdev->dev);
270-
clk_disable_unprepare(info->clk);
271263
kfree(info);
272264
return 0;
273265
}

0 commit comments

Comments
 (0)