From patchwork Tue Sep 3 07:01:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 172784 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5279700ily; Tue, 3 Sep 2019 00:01:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqznMBOU2SrvzahkF3Ol5ilAThIUnfpo3om1mSdEHQVORec2jswYXMa5JiK403N503ZuXomE X-Received: by 2002:a62:ac0e:: with SMTP id v14mr8122933pfe.14.1567494116612; Tue, 03 Sep 2019 00:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567494116; cv=none; d=google.com; s=arc-20160816; b=U+5tWE1ysDSAlCBvZa4yzy7mN0OGMWivU5SpPPs70QNUk3tamg3TdULHplliGao+AW CY3SExm7ERrnxDCJhhPcaf+xxY2WRTm1afqWHIQ0UpmCWbjR+ycogl4jkDcwbmQs3OYy UwHsKgnIks+jW0sTYJROr4neXi5ZGdVI/LLkxnUJfKvOrhg68Gp21LYq3bYdOd6cNT4I +WJbMSFYz2/RXs9IykQWVTUTaKnqCaWYmLEK2KscCPkb2If/orj+CA2YtnZv1mL47ecx CRlYOpanHviJexDInLvh9yKh0W7gVzToUlSeypzTo5A6kJkM7mlzdE9kWCDOLTcYuTmP ASxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ATcsitRpTyb5wI6PMkB6H6IJliZcFvf7R0g9NfFMg9A=; b=JiXpxKmH2m93VjQ1aCpYI9ATzYJ6Gaw6KO24/5IXI2/GwsgKaDJLCfyueW2Gjenmz5 YQT9URCIKj46UvQdbRhARi4N6YPc8h2xsb4rbD8+GCaVp55FLGcP5ecnduz27/G0Z3G6 F0Iy4EhroH+txUSb0RgcOaAW8bhkB4iuz2gF9WiDlurwDtyFj/bYSJ1F3R5TmRbDEQJf jRVppX/B3fdRoJ+ggWZNzWvvpePCPPJKHIiPdR2jMWx60UpunFGQwCoM9ExoZY0eXS71 OMBWo/hxq9fzUXwxbQMuW1RzQo7EeZfrk0Dhv8bi8KL4CSaKFig3LPnQUbsVumDQT7bN mKJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EHgBr9Kf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si13822364pgt.447.2019.09.03.00.01.56; Tue, 03 Sep 2019 00:01:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EHgBr9Kf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727541AbfICHBz (ORCPT + 28 others); Tue, 3 Sep 2019 03:01:55 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41108 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726980AbfICHBz (ORCPT ); Tue, 3 Sep 2019 03:01:55 -0400 Received: by mail-pg1-f195.google.com with SMTP id x15so8587944pgg.8 for ; Tue, 03 Sep 2019 00:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ATcsitRpTyb5wI6PMkB6H6IJliZcFvf7R0g9NfFMg9A=; b=EHgBr9KfYik5R6FusPDhu53l+J3bX9l8zy+rd7KHjP5eJpWMJBDrvwknS9Pt9RsCsr 1AhNQzcmCHH9hqmZxFEi9bKhZfz9UiEgVdHOCOBb26fxtUWMRm90Wpehtn/bqoHFE7bB goOWVwvsODaia2BAUb32k0QYR4cWSFXHHeaHp4RuK6nDFMiUZQTYFCPSUBW3MDWQApv+ Y9SP5AXKkI1/kJsVfCFyEsbDGeymtrlHCMxAg8nB/8sVoLY/KFIw1Gm2GH7Q42O2mWqv I0cFnHbxAmjHo51uvaqpSr6CFedJhzS1ZJp8PYutClpWHQYPWbz8ASS6WgRUtQJyZchn SUEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ATcsitRpTyb5wI6PMkB6H6IJliZcFvf7R0g9NfFMg9A=; b=H1eR4k3RuOD6+njHnSx7/tZTdiEmPyAyVRKMXcp6kBAShPSR39YTBA+T3ct12cG94c KbmP5l9bEY6R+O0CH4xTtg0A2TJNVf6NNDHFbYej3NdR52HNwga/Pt3g0auMSNL7bsck G+jiWSdsgiCZlnte2ldM5kPMbAruFRoAn40hSoR/5gyufBBVExIr7QEGqcYKAVDDDC5N EftT6bGnHALieC4ZOPnsFArk2Nmijnp3mk+pfKgbGDzeqhuMTZ4F+sKssr2kLkZ25PkY pvb7LAh5BrKaXRwBVcXdfFezXLjtXSQr4VjEKlg0RXn/MToLbF81df5OsYjOfeCZkz1x p7eg== X-Gm-Message-State: APjAAAWyJFVdBW2w4pu7tK+qN0+2aDBJiRg+YXJ0PJvd7PeJQlSgYwWW yzkaBCHwfoIlXV8KnYNZaoCqFg== X-Received: by 2002:a65:690f:: with SMTP id s15mr27939370pgq.432.1567494114841; Tue, 03 Sep 2019 00:01:54 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 19sm16471892pjc.25.2019.09.03.00.01.50 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Sep 2019 00:01:54 -0700 (PDT) From: Baolin Wang To: stable@vger.kernel.org, gregkh@linuxfoundation.org Cc: lanqing.liu@unisoc.com, linux-serial@vger.kernel.org, arnd@arndb.de, baolin.wang@linaro.org, orsonzhai@gmail.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.14.y 8/8] serial: sprd: Modify the baud rate calculation formula Date: Tue, 3 Sep 2019 15:01:25 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lanqing Liu When the source clock is not divisible by the expected baud rate and the remainder is not less than half of the expected baud rate, the old formular will round up the frequency division coefficient. This will make the actual baud rate less than the expected value and can not meet the external transmission requirements. Thus this patch modifies the baud rate calculation formula to support the serial controller output the maximum baud rate. Signed-off-by: Lanqing Liu Signed-off-by: Baolin Wang Signed-off-by: Greg Kroah-Hartman Signed-off-by: Baolin Wang --- drivers/tty/serial/sprd_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c index e902494..72e96ab8 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c @@ -380,7 +380,7 @@ static void sprd_set_termios(struct uart_port *port, /* ask the core to calculate the divisor for us */ baud = uart_get_baud_rate(port, termios, old, 0, SPRD_BAUD_IO_LIMIT); - quot = (unsigned int)((port->uartclk + baud / 2) / baud); + quot = port->uartclk / baud; /* set data length */ switch (termios->c_cflag & CSIZE) {