From patchwork Wed Nov 19 22:58:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 5344601 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B7709F387 for ; Wed, 19 Nov 2014 22:58:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59A1F201BB for ; Wed, 19 Nov 2014 22:58:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 153242018E for ; Wed, 19 Nov 2014 22:58:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753629AbaKSW6k (ORCPT ); Wed, 19 Nov 2014 17:58:40 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:38115 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754910AbaKSW6j (ORCPT ); Wed, 19 Nov 2014 17:58:39 -0500 Received: by mail-pa0-f44.google.com with SMTP id et14so1200694pad.17 for ; Wed, 19 Nov 2014 14:58:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=QpHdGBF1ogUpkcoxkqW4f3p5e0+ddtB4H2UlHu+pJNw=; b=H1uHBm5yZvo/y58W1Gyh/exrZOE1TiZTKXQabNQlh9Ec8fmP1sm0TVS3oCsVfsjnhd E73S3UiKLqPPVxjp2svNGHr3E+VNN7bZJipITYdYINrg+x/8hp5/1OHtikNJVw2kU4hi g3NqMC2i14eqp9AthBXloXP/b1w9w9+MiraY0oCa8hqNVDI76qCspcuHXYSMqOjY8fh0 TRgsddhErPvSvNKmo8QNKxeXhBhibf5qYbvuPd4X+S0+pdv+Gj81nq/mMPAvwbphUqy9 az/GUa1/dESRqwD1Cz3C2wweNvZ6VcXsJLBRXQim6oqKJ66cqQcnCzILjEDFQ1O3GaiP rwyQ== X-Gm-Message-State: ALoCoQkMTc+5rtAzhya4yJpdQzLpM5hrGGLHDt3sDoxDHfSE1ZkS91qJ6fJzo1qaeQBHYK0HF1Ip X-Received: by 10.69.16.99 with SMTP id fv3mr50984182pbd.43.1416437918861; Wed, 19 Nov 2014 14:58:38 -0800 (PST) Received: from xps-iwamatsu.renesas.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id sq2sm242233pbc.73.2014.11.19.14.58.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Nov 2014 14:58:37 -0800 (PST) From: Nobuhiro Iwamatsu To: linux-sh@vger.kernel.org, linux-serial@vger.kernel.org Cc: horms@verge.net.au, Nobuhiro Iwamatsu Subject: [PATCH] serial: sh-sci: Change checking for error rate of HSCIF Date: Thu, 20 Nov 2014 07:58:27 +0900 Message-Id: <1416437907-15160-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> X-Mailer: git-send-email 2.1.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This changes negative values of error rate to be checked, because these values are valid as error rate. And this changes in the process of adopting a value close to 0. Signed-off-by: Nobuhiro Iwamatsu --- drivers/tty/serial/sh-sci.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 3081e46..ae7ac07 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1812,9 +1812,6 @@ static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq, err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr * (1 << (2 * c + 1)) / 1000)) - 1000; - if (err < 0) - continue; - /* Calc recv margin * M: Receive margin (%) * N: Ratio of bit rate to clock (N = sampling rate) @@ -1829,7 +1826,7 @@ static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq, */ recv_margin = abs((500 - DIV_ROUND_CLOSEST(1000, sr << 1)) / 10); - if (min_err > err) { + if (abs(min_err) > abs(err)) { min_err = err; recv_max_margin = recv_margin; } else if ((min_err == err) &&