Message ID | bce27288cb570952dd96b441e1af8768ad8b4870.1639663832.git.geert+renesas@glider.be |
---|---|
State | New |
Headers | show |
Series | serial: sh-sci: Clock handling improvements | expand |
Hi Geert, Thank you for the patch. On Thu, Dec 16, 2021 at 03:17:34PM +0100, Geert Uytterhoeven wrote: > The sh-sci driver supports up to four input clocks, of which only the > first one is mandatory. > > Replace devm_clk_get() and custom error checking by > devm_clk_get_optional(), to simplify the code and to catch all real > errors. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > drivers/tty/serial/sh-sci.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c > index 5f6d85b8e3dd4173..bb3adf0a109324ca 100644 > --- a/drivers/tty/serial/sh-sci.c > +++ b/drivers/tty/serial/sh-sci.c > @@ -2779,11 +2779,11 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) > clk_names[SCI_SCK] = "hsck"; > > for (i = 0; i < SCI_NUM_CLKS; i++) { > - clk = devm_clk_get(dev, clk_names[i]); > - if (PTR_ERR(clk) == -EPROBE_DEFER) > - return -EPROBE_DEFER; > + clk = devm_clk_get_optional(dev, clk_names[i]); > + if (IS_ERR(clk)) > + return PTR_ERR(clk); > > - if (IS_ERR(clk) && i == SCI_FCK) { > + if (!clk && i == SCI_FCK) { > /* > * Not all SH platforms declare a clock lookup entry > * for SCI devices, in which case we need to get the > @@ -2796,13 +2796,12 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) > clk_names[i]); > } > > - if (IS_ERR(clk)) > - dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i], > - PTR_ERR(clk)); > + if (!clk) > + dev_dbg(dev, "failed to get %s\n", clk_names[i]); > else > dev_dbg(dev, "clk %s is %pC rate %lu\n", clk_names[i], > clk, clk_get_rate(clk)); > - sci_port->clks[i] = IS_ERR(clk) ? NULL : clk; > + sci_port->clks[i] = clk; > } > return 0; > }
On Thu, Dec 16, 2021 at 03:17:34PM +0100, Geert Uytterhoeven wrote: > The sh-sci driver supports up to four input clocks, of which only the > first one is mandatory. > > Replace devm_clk_get() and custom error checking by > devm_clk_get_optional(), to simplify the code and to catch all real > errors. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Yeah, much better. Great cleanup! Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 5f6d85b8e3dd4173..bb3adf0a109324ca 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2779,11 +2779,11 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) clk_names[SCI_SCK] = "hsck"; for (i = 0; i < SCI_NUM_CLKS; i++) { - clk = devm_clk_get(dev, clk_names[i]); - if (PTR_ERR(clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + clk = devm_clk_get_optional(dev, clk_names[i]); + if (IS_ERR(clk)) + return PTR_ERR(clk); - if (IS_ERR(clk) && i == SCI_FCK) { + if (!clk && i == SCI_FCK) { /* * Not all SH platforms declare a clock lookup entry * for SCI devices, in which case we need to get the @@ -2796,13 +2796,12 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) clk_names[i]); } - if (IS_ERR(clk)) - dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i], - PTR_ERR(clk)); + if (!clk) + dev_dbg(dev, "failed to get %s\n", clk_names[i]); else dev_dbg(dev, "clk %s is %pC rate %lu\n", clk_names[i], clk, clk_get_rate(clk)); - sci_port->clks[i] = IS_ERR(clk) ? NULL : clk; + sci_port->clks[i] = clk; } return 0; }
The sh-sci driver supports up to four input clocks, of which only the first one is mandatory. Replace devm_clk_get() and custom error checking by devm_clk_get_optional(), to simplify the code and to catch all real errors. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/tty/serial/sh-sci.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)