Commit 974e454d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

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: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20201007084635.594991-2-andy.shevchenko@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c808fab6
...@@ -1273,7 +1273,6 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty ...@@ -1273,7 +1273,6 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
struct regmap *regmap, int irq) struct regmap *regmap, int irq)
{ {
int i, ret, fmin, fmax, freq, uartclk; int i, ret, fmin, fmax, freq, uartclk;
struct clk *clk_osc, *clk_xtal;
struct max310x_port *s; struct max310x_port *s;
bool xtal = false; bool xtal = false;
...@@ -1287,23 +1286,24 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty ...@@ -1287,23 +1286,24 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
return -ENOMEM; return -ENOMEM;
} }
clk_osc = devm_clk_get(dev, "osc"); s->clk = devm_clk_get_optional(dev, "osc");
clk_xtal = devm_clk_get(dev, "xtal"); if (IS_ERR(s->clk))
if (!IS_ERR(clk_osc)) { return PTR_ERR(s->clk);
s->clk = clk_osc; if (s->clk) {
fmin = 500000; fmin = 500000;
fmax = 35000000; 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 { } else {
dev_err(dev, "Cannot get clock\n"); s->clk = devm_clk_get_optional(dev, "xtal");
return -EINVAL; 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); ret = clk_prepare_enable(s->clk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment