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>
This commit is contained in:
Andy Shevchenko 2021-05-17 20:34:15 +03:00 committed by Greg Kroah-Hartman
parent d4d6f03c4f
commit cb1b206cff
1 changed files with 13 additions and 13 deletions

View File

@ -1208,8 +1208,16 @@ static int sc16is7xx_probe(struct device *dev,
/* Always ask for fixed clock rate from a property. */ /* Always ask for fixed clock rate from a property. */
device_property_read_u32(dev, "clock-frequency", &uartclk); device_property_read_u32(dev, "clock-frequency", &uartclk);
s->clk = devm_clk_get(dev, NULL); s->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(s->clk)) { if (IS_ERR(s->clk))
return PTR_ERR(s->clk);
ret = clk_prepare_enable(s->clk);
if (ret)
return ret;
freq = clk_get_rate(s->clk);
if (freq == 0) {
if (uartclk) if (uartclk)
freq = uartclk; freq = uartclk;
if (pfreq) if (pfreq)
@ -1217,13 +1225,7 @@ static int sc16is7xx_probe(struct device *dev,
if (freq) if (freq)
dev_dbg(dev, "Clock frequency: %luHz\n", freq); dev_dbg(dev, "Clock frequency: %luHz\n", freq);
else else
return PTR_ERR(s->clk); return -EINVAL;
} else {
ret = clk_prepare_enable(s->clk);
if (ret)
return ret;
freq = clk_get_rate(s->clk);
} }
s->regmap = regmap; s->regmap = regmap;
@ -1358,8 +1360,7 @@ static int sc16is7xx_probe(struct device *dev,
kthread_stop(s->kworker_task); kthread_stop(s->kworker_task);
out_clk: out_clk:
if (!IS_ERR(s->clk)) clk_disable_unprepare(s->clk);
clk_disable_unprepare(s->clk);
return ret; return ret;
} }
@ -1383,8 +1384,7 @@ static int sc16is7xx_remove(struct device *dev)
kthread_flush_worker(&s->kworker); kthread_flush_worker(&s->kworker);
kthread_stop(s->kworker_task); kthread_stop(s->kworker_task);
if (!IS_ERR(s->clk)) clk_disable_unprepare(s->clk);
clk_disable_unprepare(s->clk);
return 0; return 0;
} }