From patchwork Thu Sep 5 03:11:26 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: 173112 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp156930ilq; Wed, 4 Sep 2019 20:11:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXk3ohyo0hGnwJZqnOI84pKDWJK4JoQKLvRahSlIrszCKQjjAe90p3Duy+BGNIAB9O7f44 X-Received: by 2002:aa7:8f03:: with SMTP id x3mr1113171pfr.91.1567653117901; Wed, 04 Sep 2019 20:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567653117; cv=none; d=google.com; s=arc-20160816; b=TGjH1NL0AZbDE5oRw1LqBG3hrf0y2MYER0RXszRTAD3W/DohvXygEVJxoo9S8zaqxa fOkKzUOehK4rKbcwJLNEAQOXYSEky4dl/sFkQ+RAkblSubHlDzF+a3Wj0L1vOotWuy8/ zPFJ3Kng2vbTOZ6fZIFPEPta2npZ4UiK/TKZib2+gEj9guzUzl734p3HynA1yjzgRjkn VsF3FBLNW7iP0L8BGKr/hClmy7n0lmgD1W1+jMu5ftSiAc7oFz/f5oFLSbzMiIMuL1wL ihWy3cztGow0/AfIemk7Bv2i8e0XZiI44/CSLeuC/S/fhcLHJXZc+CVS46epqLGWLXJJ KA/A== 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=MfYJlRyMu0jxdb95Tor8jXonvcKSRTtOHygj9lvQK5Q=; b=W8GbbDs7MjLTCRG+Q33IPEYi0OcYj8E2uBciZYDHodUZ4yHSKvUYdEVdYntflkkE7g s+Wf8MK8EPdSU3muM3bW9djc4BHIyZcaFejnvfBcubHMXweyZ4EA+TuOOCaW52U5rEGL ouTjQYOkAvPQfeGU4r89yOQHGSPppbf56Hb2kwbCgVg3jP9valYACJeC543vCHyc5gvx /nZbkWiQs95cEbV+LFSTsyuwZ4QObNOLoDfIx1GHYkXIwEKsY7q8db9BAZpnbTmn6izw TvFgjs0OUCo8TbFNob0E0htBjUnIG1+qlzNBp5lh0rBnALhGFtJ/z9+HQiNLTkKGEnAJ PREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V/XN2SYW"; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-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 j12si558814pgp.261.2019.09.04.20.11.57; Wed, 04 Sep 2019 20:11:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-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="V/XN2SYW"; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-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 S1730780AbfIEDL5 (ORCPT + 1 other); Wed, 4 Sep 2019 23:11:57 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36491 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730651AbfIEDL5 (ORCPT ); Wed, 4 Sep 2019 23:11:57 -0400 Received: by mail-pl1-f195.google.com with SMTP id f19so585576plr.3 for ; Wed, 04 Sep 2019 20:11:57 -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=MfYJlRyMu0jxdb95Tor8jXonvcKSRTtOHygj9lvQK5Q=; b=V/XN2SYWaXgG95UKQOBazHPQNX4yF9rbsyhWfaiJO99o1PFJCJ5ExV+iHPhe9gWcfb d+gnfF/jUCXjFp++dpHXIT9atOwaB+ufdY+uF7aCm8FKCGoI+yC0EHbmB5Fh2Mx4+lvl T245rf0maHvVK/nbjVWbI/P61i52O+QMwd1i74b1ymoo7taCm2Wy9r3OxWAV30aSZ57+ GeVWWE/l3GcqdCpnQVsvvWGWdOValI6PD020pKQJUTLQH002e2khBy7i2qALZlHCFbOe Pnj4lckDukWO/UZusJMceMmP8zxrnw1e3V6kcUtpQQCsojsREAuChcgA5w5GJOmbOhy/ HceQ== 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=MfYJlRyMu0jxdb95Tor8jXonvcKSRTtOHygj9lvQK5Q=; b=TYCX3FbiCzjgKqRGL30sGczzLPROKMIhIEHf8HiYLP3p/AKymcgelOK9u4sihRVPIO LBprQU1DcAG8fwWc3ng1PY/TyO5BUt8hqTPKTvILcc8gmm+nIY4bu5bTNtwzhigTMOJc 5S4vGCQRoOejxZAALe7hB20cTkjikS54EJq7v5aQxpzW19dRbqrafr2YbsXa2lTregTS jV6p9ZtoJsn2v13Hkf0KGp3IVKF/Tdpkfdn+G/Gb072gp8RmsXKFKo0lnk8aP5mfeBGb OdbAW8/B5dYU19HU/sd6NXXG+Tl4NRxCXD0trvBQZeeIyvRjWPxzNOSd6cuG0taRd6In DsAA== X-Gm-Message-State: APjAAAUHk+sr4dn4mSaGYj+mRshW1DEkm9yow4IyzDQ1ml9hJxl6YTCB aaDSLyi+IycPO25i4eiZ9wDbdQ== X-Received: by 2002:a17:902:33c1:: with SMTP id b59mr1094665plc.104.1567653116718; Wed, 04 Sep 2019 20:11:56 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id 15sm530957pfh.188.2019.09.04.20.11.53 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Sep 2019 20:11:56 -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 v2 6/6] serial: sprd: Modify the baud rate calculation formula Date: Thu, 5 Sep 2019 11:11:26 +0800 Message-Id: <4fe6ec82960301126b9f4be52dd6083c30e17420.1567649729.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Lanqing Liu [Upstream commit 5b9cea15a3de5d65000d49f626b71b00d42a0577] 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) {