serial: 8250_dw: Honor clk_round_rate errors in dw8250_set_termios
Subsystems (3)
PATCH 1/1 serial: 8250_dw: Honor clk_round_rate errors in dw8250_set_termios
clk_round_rate returns a signed long and may possibly return errors in it, for example if there is no possible rate.
Till now dw8250_set_termios ignored any error, the signednes and would just use the value as input to clk_set_rate. This of course falls apart if there is an actual error, so check for errors and only try to set a rate if the value is actually valid.
--- drivers/tty/serial/8250/8250_dw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_dw.c +5 -2
@@ -257,7 +257,7 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, {unsigned int baud =tty_termios_baud_rate (termios);struct dw8250_data *d = p->private_data; -unsigned int rate; +long rate;int ret;if (IS_ERR (d->clk) || !old)
@@ -265,7 +265,10 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,clk_disable_unprepare (d->clk); rate =clk_round_rate (d->clk, baud *16 ); - ret =clk_set_rate (d->clk, rate); +if (rate <0 ) + ret = rate; +else + ret =clk_set_rate (d->clk, rate);clk_prepare_enable (d->clk);if (!ret)
Signature · 1 line
2.11.0
Quoted 8 lines · Heiko Stuebner
clk_round_ratereturns a signed long and may possibly return errors in it, for example if there is no possible rate.Till now
dw8250_set_termiosignored any error, the signednes and would just use the value as input toclk_set_rate. This of course falls apart if there is an actual error, so check for errors and only try to set a rate if the value is actually valid.
FWIW:
Quoted 33 lines
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/tty/serial/8250/8250_dw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/tty/serial/8250/8250_dw.c +5
-3@@ -257,7 +257,7 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, {unsigned int baud =tty_termios_baud_rate (termios);struct dw8250_data *d = p->private_data; -unsigned int rate; +long rate;int ret;if (IS_ERR (d->clk) || !old)@@ -265,7 +265,10 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,clk_disable_unprepare (d->clk); rate =clk_round_rate (d->clk, baud *16 ); - ret =clk_set_rate (d->clk, rate); +if (rate <0 ) + ret = rate; +else + ret =clk_set_rate (d->clk, rate);clk_prepare_enable (d->clk);if (!ret) --2.11.0
Signature · 2 lines
With Best Regards, Andy Shevchenko