From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58F3EC10F13 for ; Tue, 16 Apr 2019 13:25:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29AA420870 for ; Tue, 16 Apr 2019 13:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555421157; bh=enwqljrYfxlRhKghP4FSmykf8ITDS4xMQdtEFfTmmd0=; h=Subject:To:From:Date:List-ID:From; b=fsj17Z11pYNUsJ2fmb5sxpirNwtqjK7rguLQGZ8bR63sKJzLOgvBXhtOPR3dLmckB GIuhUZYhCGnry07AeRRK1seOow45LKFzmWyjJsIJ01aC6C4L6GIv/R96l/NSi3Kct0 bMOqtrUi9TtfPNu7+2BCXux1+S7IhPQIrhp2r+OQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbfDPNZ4 (ORCPT ); Tue, 16 Apr 2019 09:25:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:38006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfDPNZ4 (ORCPT ); Tue, 16 Apr 2019 09:25:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B0A520821; Tue, 16 Apr 2019 13:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555421155; bh=enwqljrYfxlRhKghP4FSmykf8ITDS4xMQdtEFfTmmd0=; h=Subject:To:From:Date:From; b=ePGHDwZUtmdydmNoYip9PO84Txv5RhfGIVvtilVLtfIee01oyejUQJbTqWQt256M/ U0M6K0ZBnwbDjZ8eCBVZCWY3+Sg/vtIaA1pAH44GoVZGObRaSCigoN+8ldb1JQF8gF R98J6el6cgGjTJjQuB409U6LFJaw1Gf0nwSNckFo= Subject: patch "serial: sh-sci: Fix HSCIF RX sampling point calculation" added to tty-linus To: geert+renesas@glider.be, gregkh@linuxfoundation.org, mojha@codeaurora.org, stable@vger.kernel.org, uli+renesas@fpond.eu From: Date: Tue, 16 Apr 2019 15:25:17 +0200 Message-ID: <15554211175342@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled serial: sh-sci: Fix HSCIF RX sampling point calculation to my tty git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git in the tty-linus branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will hopefully also be merged in Linus's tree for the next -rc kernel release. If you have any questions about this process, please let me know. >From ace965696da2611af759f0284e26342b7b6cec89 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 1 Apr 2019 13:25:10 +0200 Subject: serial: sh-sci: Fix HSCIF RX sampling point calculation There are several issues with the formula used for calculating the deviation from the intended rate: 1. While min_err and last_stop are signed, srr and baud are unsigned. Hence the signed values are promoted to unsigned, which will lead to a bogus value of deviation if min_err is negative, 2. Srr is the register field value, which is one less than the actual sampling rate factor, 3. The divisions do not use rounding. Fix this by casting unsigned variables to int, adding one to srr, and using a single DIV_ROUND_CLOSEST(). Fixes: 63ba1e00f178a448 ("serial: sh-sci: Support for HSCIF RX sampling point adjustment") Signed-off-by: Geert Uytterhoeven Reviewed-by: Mukesh Ojha Cc: stable Reviewed-by: Ulrich Hecht Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sh-sci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 2d1c626312cd..55ef6e577f46 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2512,7 +2512,9 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, * center of the last stop bit in sampling clocks. */ int last_stop = bits * 2 - 1; - int deviation = min_err * srr * last_stop / 2 / baud; + int deviation = DIV_ROUND_CLOSEST(min_err * last_stop * + (int)(srr + 1), + 2 * (int)baud); if (abs(deviation) >= 2) { /* At least two sampling clocks off at the -- 2.21.0