From: Geert Uytterhoeven Date: Fri, 29 Mar 2019 09:10:26 +0000 (+0100) Subject: serial: sh-sci: Fix HSCIF RX sampling point adjustment X-Git-Tag: v4.19.37~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de6d6b8902fb2d26a46d266841364c3bfa70dc41;p=thirdparty%2Fkernel%2Fstable.git serial: sh-sci: Fix HSCIF RX sampling point adjustment commit 6b87784b53592a90d21576be8eff688b56d93cce upstream. The calculation of the sampling point has min() and max() exchanged. Fix this by using the clamp() helper instead. Fixes: 63ba1e00f178a448 ("serial: sh-sci: Support for HSCIF RX sampling point adjustment") Signed-off-by: Geert Uytterhoeven Reviewed-by: Ulrich Hecht Reviewed-by: Wolfram Sang Acked-by: Dirk Behme Cc: stable Reviewed-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index cbbf239aea0f1..3c25e9f0b5790 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2504,7 +2504,7 @@ done: * last stop bit; we can increase the error * margin by shifting the sampling point. */ - int shift = min(-8, max(7, deviation / 2)); + int shift = clamp(deviation / 2, -8, 7); hssrr |= (shift << HSCIF_SRHP_SHIFT) & HSCIF_SRHP_MASK;