From patchwork Tue Feb 19 07:31:11 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: 158684 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3360271jaa; Mon, 18 Feb 2019 23:31:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IadEhbHD6S+upGDgqvO/yekDWybifMTPC4mgESItQmeaJTtkRtsGtphRUvdmT+tisZIlLzc X-Received: by 2002:a65:5844:: with SMTP id s4mr22341409pgr.77.1550561514901; Mon, 18 Feb 2019 23:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550561514; cv=none; d=google.com; s=arc-20160816; b=MvjQYKNtuoADR3lfsUTZpMz93RPg4uCVWeUIRY0+9Dp3p6IRw1zyxXg5kgCCfYVxUt 47T20ejdBT+haH9bgVmidxjHcxrlGYub6x0l9xlgHvhNhBRQovY/dCsT8EqrDxQERU3c SCP52RlC+MSUctLlyxGkBlW83uqPS0Irf/STmRvMYajGxw+auM0jzEtG9Tgmf7sd/65r K1ERUtnDCQQlRd920sCnDvkqHy3oFNQFL/r6iiNZZ+RB2+JDMaPJ7xu3EqoLJzbfs6Xu a4AUnwi/GjCutFlDq4DA0waayTjqQmnv9DbaJNyE4a5SQfUW5sfgBPylrNLfqVr6+p6q P01g== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=aeVLkZNBgesC+IRltdDGw/TLRa8vIRSPBiqLESkQCWY=; b=L7lKnjKkfWfi8rcmx4fjrvAR9OoYiqYOTr0fDPxlKEyUQ4RTjD7tZHhB6Pat6oRDIY 9oDdB7iZjmhe+XDQe5pPdzYBBeiy5AB8Hn/pNSWUcKphc5m7pa5G9OAlG4F3oZiW+2LV KwK+jog8B3NW5DrsYWEAxUV4Oa8TTrBYe09oZgpedSlmcQXgBYB5xB+uDxFWyA7W9Cf7 eco21qvEc0gNE6R8wzsjsJJ3SeGFkxIOmnOGd69Xzx4x9fOccgFRxuRUF35RWG60vvS2 jpU2aMgCM4Eys2iy/C5Rp8wk4BQCc4Sk2sqBNFcrXMTxxJL8SUIorhRVwaXrYxa5FcVq mPDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M2oVAUua; 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 o188si7405705pfb.66.2019.02.18.23.31.54; Mon, 18 Feb 2019 23:31:54 -0800 (PST) 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=M2oVAUua; 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 S1726978AbfBSHbw (ORCPT + 32 others); Tue, 19 Feb 2019 02:31:52 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36465 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbfBSHbv (ORCPT ); Tue, 19 Feb 2019 02:31:51 -0500 Received: by mail-pl1-f194.google.com with SMTP id k2so651785plt.3 for ; Mon, 18 Feb 2019 23:31:51 -0800 (PST) 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 :in-reply-to:references; bh=aeVLkZNBgesC+IRltdDGw/TLRa8vIRSPBiqLESkQCWY=; b=M2oVAUuaJNwf8FsOJV0QHgUTqac/OCdGhCpwf54UMDwBMVmR/UN+UlIyZrhmttlGS3 uj4UTyEp/4YXow7f7s9A1fEaqigEQ5RFDfC6YWuuEVanTsRVnZBOT6VO1zgKUDblvNMM 0mGm1ekTYL7FzLepaE27CyVmbbVHrUWGRXGk5bHC7XPkobGrbDSwLJXL1NhrcKnvAo63 N/B6o6adlI8MrEvYE3GRcktwcF2fiiF6sCh4FHVvkXUfKLfCUMBIxo34Yep2Eg8ypbaH gJZSgDAn8rfCp9UOpAs7wTVhaSQo4iDSB8JfyzMDt9JvVY0PfIPIIVfDrRHkcwDpyDDA y8Ag== 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:in-reply-to:references; bh=aeVLkZNBgesC+IRltdDGw/TLRa8vIRSPBiqLESkQCWY=; b=oN8o4AAsCtp7OFiEIAoh+jnezjtsyy8U04BvlxrbnyBL+tczWM07l49BmFFU+eio3K Y/4Vt2wXcKEyDTbCgCeCJPnQv41GeGJn5X/xV2Mn9mHxYMpzVmA/nvGE08LwZjcxcte+ v+8vTlZETvWvZdCVTX7lv+5pVse8omWftzE+ns3y0SRJYtJnJsFwFs/46AH17gahDLty BpaleGLZFs4yclfERD3kPNrJ7iF1H31DrmWj63X1soUcYYyZOsx5gOtgtBLB5rUvLa19 AsHzIvbcQRSom/dw+fqtbHxCW/FCOSBVHCa6zVxgHo1Ww66PDdLYK/ocANnbRBxHBc7s 7+wg== X-Gm-Message-State: AHQUAuaZ7ruERAmY0LmK16DQliZXKrnfJ271OFzk605xoleIJGQF9yJq LKRcItEeU+BVuEksOwth7Kx0DiYmGp2Rlg== X-Received: by 2002:a17:902:4124:: with SMTP id e33mr29536066pld.236.1550561511154; Mon, 18 Feb 2019 23:31:51 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id n27sm31556569pfb.8.2019.02.18.23.31.47 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Feb 2019 23:31:50 -0800 (PST) From: Baolin Wang To: gregkh@linuxfoundation.org, jslaby@suse.com, robh+dt@kernel.org, mark.rutland@arm.com, orsonzhai@gmail.com, zhang.lyra@gmail.com Cc: baolin.wang@linaro.org, broonie@kernel.org, lanqing.liu@unisoc.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/5] serial: sprd: Modify the baud rate calculation formula Date: Tue, 19 Feb 2019 15:31:11 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: 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 --- 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 4287ca3..1891a45 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c @@ -371,7 +371,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) {