summaryrefslogtreecommitdiff
path: root/drivers/tty/serial/max310x.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andy.shevchenko@gmail.com>2020-10-07 11:46:35 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-28 13:31:32 +0100
commit974e454d6f96da0c0ab1b4115b92587dd9406f6a (patch)
treea52a9e472a60f2084ef25c681eeb93c62e4656d1 /drivers/tty/serial/max310x.c
parentc808fab604ca62cff19ee6b261211483830807aa (diff)
serial: max310x: Use devm_clk_get_optional() to get the input clock
Simplify the code which fetches the input clock by using devm_clk_get_optional(). If no input clock is present devm_clk_get_optional() will return NULL instead of an error which matches the behavior of the old code. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20201007084635.594991-2-andy.shevchenko@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/max310x.c')
-rw-r--r--drivers/tty/serial/max310x.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index f25b9516109c..9795b2e8b0b2 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1273,7 +1273,6 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
struct regmap *regmap, int irq)
{
int i, ret, fmin, fmax, freq, uartclk;
- struct clk *clk_osc, *clk_xtal;
struct max310x_port *s;
bool xtal = false;
@@ -1287,23 +1286,24 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
return -ENOMEM;
}
- clk_osc = devm_clk_get(dev, "osc");
- clk_xtal = devm_clk_get(dev, "xtal");
- if (!IS_ERR(clk_osc)) {
- s->clk = clk_osc;
+ s->clk = devm_clk_get_optional(dev, "osc");
+ if (IS_ERR(s->clk))
+ return PTR_ERR(s->clk);
+ if (s->clk) {
fmin = 500000;
fmax = 35000000;
- } else if (!IS_ERR(clk_xtal)) {
- s->clk = clk_xtal;
- fmin = 1000000;
- fmax = 4000000;
- xtal = true;
- } else if (PTR_ERR(clk_osc) == -EPROBE_DEFER ||
- PTR_ERR(clk_xtal) == -EPROBE_DEFER) {
- return -EPROBE_DEFER;
} else {
- dev_err(dev, "Cannot get clock\n");
- return -EINVAL;
+ s->clk = devm_clk_get_optional(dev, "xtal");
+ if (IS_ERR(s->clk))
+ return PTR_ERR(s->clk);
+ if (s->clk) {
+ fmin = 1000000;
+ fmax = 4000000;
+ xtal = true;
+ } else {
+ dev_err(dev, "Cannot get clock\n");
+ return -EINVAL;
+ }
}
ret = clk_prepare_enable(s->clk);