Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp290739ybe; Wed, 4 Sep 2019 20:15:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzw2pHK2lbLtLFEYKnTszOx5N5aD2ulyTLDdb/MnT+QiNcx5AZ5Vx4PUvQTCg4nqHJzdKvC X-Received: by 2002:a17:902:a58c:: with SMTP id az12mr1078785plb.129.1567653331782; Wed, 04 Sep 2019 20:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567653331; cv=none; d=google.com; s=arc-20160816; b=aiCHm5dq0GSOjoZt8XoZLjfZU+znLiWkbN962iTOnkM3i7tdQ3BS3wLrxQGQViC+og IcWcdJlfMirZ5yyU2X5XZVzD3+2b1sT174dKkmXvJ9JM0X8FIdS/gP98KRztrLfBJWNQ 3wOyYC4bPxTo6qCPUm6GAZDJdtuEk7gbKrT4GaH/uxjvSo7wMniVykmxDau5uztmklCv RiSPnsKlwidmfuwPvf9LfezpPcSmG/AMaDbwHZLDAYGs/6NYOMej/FVP7jSE0paXOzwh XPm670A6ybqB/G4v23RE14ZQY/PuxIwv2Vi0FuYxrB6UmrS1FkVdO46+fJFTE77TNRVR qOGA== 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=ygoCR3G6RVhvvu1jdEJp9xkQg/SoiJHOgV1vDUHyFkge82hRtj4nQopeZ5aDgux7Td BZcqbhXTa23TDm7Q1tCr4aBh+sxvLTJ1CyPsR/hCKQ1vM9JNDO/R5m+Dh7lz4dwum9wt s7HT2KDesa5t2SnjyzxMzH835bhaoiNfF55md2S+MHvuYGHY/mkVT9ceT8jtHyq/rESk h3OMoVMFIldUDZ5wH5iH+7VIXIlrm7YLcxYPIwevM8T2oQb7FCnkqLJKtxW+psz9cGNf nQOD4yt0S2FKgEcA908LVabGjanN6OZX2i+7GZ4V1wyCuqoIhgQfjemwkI0ZNEeZ1NhX kRjw== 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-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 p10si717112plq.320.2019.09.04.20.15.15; Wed, 04 Sep 2019 20:15:31 -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="V/XN2SYW"; 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 S1731122AbfIEDL6 (ORCPT + 99 others); Wed, 4 Sep 2019 23:11:58 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39503 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730684AbfIEDL5 (ORCPT ); Wed, 4 Sep 2019 23:11:57 -0400 Received: by mail-pl1-f193.google.com with SMTP id bd8so572549plb.6 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=L9dZGh1G94Pq4q8wYUdcBiuFuPH2j04I20JkiYuqFQmzFubxxKj7iLZaZFt+J0Web6 1xN5T/7bvnJex3PjFYs047b2ay4w9XmFnfseHSjq75/fNndTJUW7WAfsRob8FE7gTS9A jQ+i8tEjmC6o2C+okE14Xk7khunw7Huj57Ih/MQ19xX+ICWIlaj5OnMX4wwbk0iDRnj0 2LwqonTYh2sistG2fdZuWpr60csNphW09VyIVaC9Tu6baUQye08pAukKOjJ7pjNJza9q srmgtJvnrgqyIuQrR/P3lR2DIkzEWudcIttWfY6FITgNjIPUnpWrH3GhJt5kSqIbMTeb Q3rw== X-Gm-Message-State: APjAAAVdx+sFh+paaTZJ6M49YmwC0+jiWTfEqQqLuol3DuijFPLNcxXa 48v297BzBYoJV3hinnkkuCcB2w== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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) { -- 1.7.9.5