Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: sc16is7xx: Use devm_clk_get_optional()

Replace open coded variants of devm_clk_get_optional().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210517173415.7483-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
cb1b206c d4d6f03c

+13 -13
+13 -13
drivers/tty/serial/sc16is7xx.c
··· 1208 1208 /* Always ask for fixed clock rate from a property. */ 1209 1209 device_property_read_u32(dev, "clock-frequency", &uartclk); 1210 1210 1211 - s->clk = devm_clk_get(dev, NULL); 1212 - if (IS_ERR(s->clk)) { 1211 + s->clk = devm_clk_get_optional(dev, NULL); 1212 + if (IS_ERR(s->clk)) 1213 + return PTR_ERR(s->clk); 1214 + 1215 + ret = clk_prepare_enable(s->clk); 1216 + if (ret) 1217 + return ret; 1218 + 1219 + freq = clk_get_rate(s->clk); 1220 + if (freq == 0) { 1213 1221 if (uartclk) 1214 1222 freq = uartclk; 1215 1223 if (pfreq) ··· 1225 1217 if (freq) 1226 1218 dev_dbg(dev, "Clock frequency: %luHz\n", freq); 1227 1219 else 1228 - return PTR_ERR(s->clk); 1229 - } else { 1230 - ret = clk_prepare_enable(s->clk); 1231 - if (ret) 1232 - return ret; 1233 - 1234 - freq = clk_get_rate(s->clk); 1220 + return -EINVAL; 1235 1221 } 1236 1222 1237 1223 s->regmap = regmap; ··· 1360 1358 kthread_stop(s->kworker_task); 1361 1359 1362 1360 out_clk: 1363 - if (!IS_ERR(s->clk)) 1364 - clk_disable_unprepare(s->clk); 1361 + clk_disable_unprepare(s->clk); 1365 1362 1366 1363 return ret; 1367 1364 } ··· 1384 1383 kthread_flush_worker(&s->kworker); 1385 1384 kthread_stop(s->kworker_task); 1386 1385 1387 - if (!IS_ERR(s->clk)) 1388 - clk_disable_unprepare(s->clk); 1386 + clk_disable_unprepare(s->clk); 1389 1387 1390 1388 return 0; 1391 1389 }