Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp41990imu; Fri, 14 Dec 2018 14:04:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/U8kOlbUwDv+bj+87Nf9dYWQljNkSpzUp/IHbQw6Vq/Ot2Y1wGqZbjDIja2sZX9ZPxu7cSO X-Received: by 2002:a63:f615:: with SMTP id m21mr4317883pgh.428.1544825065868; Fri, 14 Dec 2018 14:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544825065; cv=none; d=google.com; s=arc-20160816; b=QRjk7cyzb4eC/DQmGrWvGaPS9fd/uJdoJadNwKLXSQUZCtJoFHNM6axilvQ8xe7WX9 9pVNe4TYivpzeLIT8i85/4fU3aoN4TWNT4F6LoHyhdmLhlSAI7I1MyECl5Ioj0m9ogqR z6LAziv9hUBADrPbHefIsWb622fkx6Gn2BSvmuLk3BM2KHkGedjojIc/Stfgj5z5c8It aITKf/DsKVwf4qrD7JKvYLCnSRnzeRaZ2/RAzEvlB8UGD9KN3HmcGNCFBFByYJfD2Lf6 wWDZ9HED3LlOrIOtfALepgcpRY0ANvWqQQZNe2D6RxP4ONpn9D92vzMF/+sM2vYPAIYp AyXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:user-agent:from:message-id :references:to:subject:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=5ifL9JXBYxshald6xBmbBThPOwRiZHoxmEwOpB9Y20g=; b=hZf2M0Esvl42NGX2jRHsYeGJTjJmIG4ADRlm311136o8p8CeWKu+ojDJNovBMSg+zw hpQOhIPheWtXP6BcmD56vgXPipHXlKQ2RiODY2J3FCjPmFBBSl06a6/VRN0lkAHva+G4 MUSP1fhmwyc1SVctSy13hSE4K4t5e8L3pczLdgisvZoX248AMnNbPcSwgajnpVyxcfoY AiNvUUbnOM5G/z4yZOceVCgSUuvj8ZzuX++xssKMvMOAaRTyAye2em+fBsEAvru7kDYX KDYKK5KVKW6Uu5MVMLW3yeeBJejpqM6B7iiGdIF8OwWkcKGqlqbcZ7SG7LW19lApfhMd X1VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qXAfPIZs; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44si4869526plc.110.2018.12.14.14.04.09; Fri, 14 Dec 2018 14:04:25 -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=@kernel.org header.s=default header.b=qXAfPIZs; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731288AbeLNWC1 (ORCPT + 99 others); Fri, 14 Dec 2018 17:02:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:53624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731263AbeLNWC0 (ORCPT ); Fri, 14 Dec 2018 17:02:26 -0500 Received: from localhost (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95F02206C0; Fri, 14 Dec 2018 22:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544824946; bh=Xr+Lz27jUrQWOlcWPdqsznHh3qyhbXL1SkP3Xg/000g=; h=In-Reply-To:Subject:To:References:From:Cc:Date:From; b=qXAfPIZseaaJUofwERvW1ix0T3TdYcqPRGjbWyscaN8J4h6xWPZHqO5vE0tWmP2Tv uHLg7XcRwZqLiBIloObhooZfSUgywQ5gO/RCNou8SIVy0s5Ygcu6o3TQogrjxaqoEo hCT6BjX9rEzdt7l6CE/zSFXgdx/J6YEPPXQ9nncw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20181210073240.32278-5-weiyi.lu@mediatek.com> Subject: Re: [PATCH v3 03/12] clk: mediatek: add configurable pcwibits and fmin to mtk_pll_data To: Matthias Brugger , Nicolas Boichat , Rob Herring , Stephen Boyd , Weiyi Lu References: <20181210073240.32278-1-weiyi.lu@mediatek.com> <20181210073240.32278-5-weiyi.lu@mediatek.com> Message-ID: <154482494548.19322.11090762587126084086@swboyd.mtv.corp.google.com> From: Stephen Boyd User-Agent: alot/0.8 Cc: James Liao , Fan Chen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-clk@vger.kernel.org, srv_heupstream@mediatek.com, stable@vger.kernel.org, Weiyi Lu , Owen Chen Date: Fri, 14 Dec 2018 14:02:25 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Weiyi Lu (2018-12-09 23:32:31) > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pl= l.c > index f0ff5f535c7e..81400601f107 100644 > --- a/drivers/clk/mediatek/clk-pll.c > +++ b/drivers/clk/mediatek/clk-pll.c > @@ -69,11 +71,13 @@ static unsigned long __mtk_pll_recalc_rate(struct mtk= _clk_pll *pll, u32 fin, > { > int pcwbits =3D pll->data->pcwbits; > int pcwfbits; > + int ibits; > u64 vco; > u8 c =3D 0; > =20 > /* The fractional part of the PLL divider. */ > - pcwfbits =3D pcwbits > INTEGER_BITS ? pcwbits - INTEGER_BITS : 0; > + ibits =3D pll->data->pcwibits ? pll->data->pcwibits : INTEGER_BIT= S; > + pcwfbits =3D pcwbits > ibits ? pcwbits - ibits : 0; This is practically unreadable. It should be changed to an if statement. > =20 > vco =3D (u64)fin * pcw; > =20 > @@ -167,9 +171,10 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll= *pll, u32 pcw, > static void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *= postdiv, > u32 freq, u32 fin) > { > - unsigned long fmin =3D 1000 * MHZ; > + unsigned long fmin =3D pll->data->fmin ? pll->data->fmin : (1000 = * MHZ); > const struct mtk_pll_div_table *div_table =3D pll->data->div_tabl= e; > u64 _pcw; > + int ibits; > u32 val; > =20 > if (freq > pll->data->fmax) > @@ -193,7 +198,8 @@ static void mtk_pll_calc_values(struct mtk_clk_pll *p= ll, u32 *pcw, u32 *postdiv, > } > =20 > /* _pcw =3D freq * postdiv / fin * 2^pcwfbits */ > - _pcw =3D ((u64)freq << val) << (pll->data->pcwbits - INTEGER_BITS= ); > + ibits =3D pll->data->pcwibits ? pll->data->pcwibits : INTEGER_BIT= S; > + _pcw =3D ((u64)freq << val) << (pll->data->pcwbits - ibits); Similar comment. Readability is low here.