Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp569567imm; Wed, 11 Jul 2018 07:24:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdUwJBCrGavcbzBgQpIOYXpTA5oTBfxdpFjQy3Gv2BXmvaDCWYLujQJN1VI1XdP9Pz0APuj X-Received: by 2002:a65:5c4b:: with SMTP id v11-v6mr27103055pgr.445.1531319085954; Wed, 11 Jul 2018 07:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531319085; cv=none; d=google.com; s=arc-20160816; b=AYp5it6c6h19WIEOmNXKEtz9OJ+85Gn+D1Lmh/+qn25geGGgpdgz3l3y7sTV7JWhDE ZM7coOtsuJZJdKvxLx2vT2tUPYXezFjZtvZfleGmdso+kD6ZKulzW8c0YH5u36cqWVL/ A9pUV2YyYHJ2af9XMi+n/LSpzzSsrY2dRgXdX5U45vkE4JGmVKlYXlceWggn4kYzSepM zkexv4uaap2KTil0EWWdZgVlhf3sRfwNfCvAKs2yWPWel1Fv1K0/XCFN6cEttF7iK+oq UosdY7GUSAnBG8AhL8WMIa2eALpiRYxnPxDmPZY8pef9jKCHnjLHLxYtmy80hgp/GZ6g HNWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=Mm3ken53mMC3ZUemEZ1X5XZ+DVhbH+fl65zc/fIEkds=; b=LIRNDMkEVtb4Ac6TGPkEG8vymN5UsM1kwtAA6Bz1JGGmCfTOSR2gPvuxK69831PGxx ClQFQQUnrrl8TeJic2gKPtjSe4w4q+Zy3ub1oOf6dvYx8n+CqUCBAA/4FuS/sAir6vHu IgkoX97+hdbp/TrBEh+DgOo3K2lGNQQITi+wKt/wmx2GIU02BQlhYJfc2KRnjF6eupnu EaZfS1DomKUMcCSbotrEH0VN08wEqeW+hMH+UHdBDdnra9X0GxoD0gWGFD8qpW79XJ+K UCg3UJA2V5qocBD4A9M5HU9/yRKpvme9WjIFqOAteogdIuhJVfqnpLuH+pdkjJUIfT/X fJWA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1-v6si20101536pln.471.2018.07.11.07.24.30; Wed, 11 Jul 2018 07:24:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388563AbeGKO1x (ORCPT + 99 others); Wed, 11 Jul 2018 10:27:53 -0400 Received: from mga11.intel.com ([192.55.52.93]:33885 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387949AbeGKO1x (ORCPT ); Wed, 11 Jul 2018 10:27:53 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2018 07:23:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,338,1526367600"; d="scan'208";a="73957147" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by orsmga002.jf.intel.com with ESMTP; 11 Jul 2018 07:23:15 -0700 Message-ID: Subject: Re: [PATCH v4 3/3] serial: 8250_dw: add fractional divisor support From: Andy Shevchenko To: Jisheng Zhang Cc: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org Date: Wed, 11 Jul 2018 17:23:13 +0300 In-Reply-To: <20180711144125.7d4e6a73@xhacker.debian> References: <20180710110942.5b0a016e@xhacker.debian> <20180710111516.13b8c570@xhacker.debian> <8c5b6bbbde12b0836e1f833c86b805a817596654.camel@linux.intel.com> <20180711144125.7d4e6a73@xhacker.debian> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-07-11 at 14:41 +0800, Jisheng Zhang wrote: > On Tue, 10 Jul 2018 19:19:21 +0300 Andy Shevchenko wrote: > > > +/* > > > + * divisor = div(I) + div(F) > > > + * "I" means integer, "F" means fractional > > > + * quot = div(I) = clk / (16 * baud) > > > + * frac = div(F) * 2^dlf_size > > > + * > > > + * let rem = clk % (16 * baud) > > > + * we have: div(F) * (16 * baud) = rem > > > + * so frac = 2^dlf_size * rem / (16 * baud) = (rem << dlf_size) / > > > (16 > > > * baud) > > > + */ > > > + quot = p->uartclk / (16 * baud); > > > + rem = p->uartclk % (16 * baud); > > > + *frac = DIV_ROUND_CLOSEST(rem << d->dlf_size, 16 * baud > My python coding skill is limited. So I wrote a simple c program to > do the check for common clks and baudrate combination. All passed. I > paste the code here: > OK, I wrote test case in Python: https://gist.github.com/andy-shev/5e980f1d752617ba814725248556ac19 Looks good to me. Please, send v6 and assume my Reviewed-by for entire series. -- Andy Shevchenko Intel Finland Oy