From patchwork Tue Apr 21 01:58:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 6245191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3D10A9F1BE for ; Tue, 21 Apr 2015 02:01:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76A3F203E6 for ; Tue, 21 Apr 2015 02:01:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD85C20259 for ; Tue, 21 Apr 2015 02:01:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YkNSR-0001E3-Db; Tue, 21 Apr 2015 01:58:39 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YkNSO-0001Az-6Z for linux-arm-kernel@lists.infradead.org; Tue, 21 Apr 2015 01:58:37 +0000 Received: by paboj16 with SMTP id oj16so225256991pab.0 for ; Mon, 20 Apr 2015 18:58:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=15M4ox0mT1D1WKIcLbgE+XFNy0OAKF+VeHZDFIGBMzg=; b=dMZs+etXY5dy88iCyRuQK9xNDjlUnBYgGNtw24KrMlI4YFtQBZVZmvAzxadJPwe955 ARDNi90Bey8GBR1wmmNRd21+mkalyZTkhZrYOxiGXMxS5Ef3KVRlsVmMx4ChsZfk84Dp fGPQFIsHlmnkM56sXkqCGooPKkeIP3WdE9x6E/VlR3wxahfEClrKwHf+Z9GFGaWblf+c /+lrnQk81GhQX7USKLDxcbamdze8LCubpqXXYk5OEF3S0d+fgwwqiR3JTdKDxTanM8EU WdCPEBGRTsv5beB5qV+z9ShF0iGwt+p2k+hMcmDZczPVwey7qzzczj5s41xyiGyB53O2 DzDw== X-Gm-Message-State: ALoCoQnU8GOsbH82i1R+L0cXndwN0ehXusb3v6vF5qvkPmJqotrWZyLJabTxiae7/3CYtCthtO4N X-Received: by 10.68.210.46 with SMTP id mr14mr32599243pbc.73.1429581492720; Mon, 20 Apr 2015 18:58:12 -0700 (PDT) Received: from phoenix.local (218-164-101-26.dynamic.hinet.net. [218.164.101.26]) by mx.google.com with ESMTPSA id c8sm250394pdj.65.2015.04.20.18.58.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2015 18:58:11 -0700 (PDT) Message-ID: <1429581487.5994.1.camel@ingics.com> Subject: Question about checking rate_spi in pwrap_init_reg_clock From: Axel Lin To: linux-arm-kernel Date: Tue, 21 Apr 2015 09:58:07 +0800 X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150420_185836_294197_21E885D2 X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.0 (-) Cc: Matthias Brugger , Flora Fu , Sascha Hauer X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP hi, The implementation in pwrap_init_reg_clock seems has off-by-one bug. If rate_spi is 26000000, current code set ck_mhz to 18 rather than 26. I guess it needs below fix, but I'm not 100% sure as I don't have the datasheet. Can someone confirm if this is a bug or not? diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c index db5be1e..e910e19 100644 --- a/drivers/soc/mediatek/mtk-pmic-wrap.c +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c @@ -568,9 +568,9 @@ static int pwrap_init_reg_clock(struct pmic_wrapper *wrp) rate_spi = clk_get_rate(wrp->clk_spi); - if (rate_spi > 26000000) + if (rate_spi >= 26000000) ck_mhz = 26; - else if (rate_spi > 18000000) + else if (rate_spi >= 18000000) ck_mhz = 18; else ck_mhz = 0;