From patchwork Tue Jun 12 11:22:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 928280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 414nX617hnz9s1B for ; Tue, 12 Jun 2018 21:21:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754048AbeFLLVl (ORCPT ); Tue, 12 Jun 2018 07:21:41 -0400 Received: from mga02.intel.com ([134.134.136.20]:61105 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932555AbeFLLVk (ORCPT ); Tue, 12 Jun 2018 07:21:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jun 2018 04:21:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,214,1526367600"; d="scan'208";a="56660769" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.150]) by FMSMGA003.fm.intel.com with ESMTP; 12 Jun 2018 04:21:39 -0700 From: Jarkko Nikula To: linux-i2c@vger.kernel.org Cc: Wolfram Sang , Andy Shevchenko , Mika Westerberg , Jarkko Nikula Subject: [PATCH v4 4/8] i2c: designware: Call i2c_dw_clk_rate() only once in i2c_dw_init_master() Date: Tue, 12 Jun 2018 14:22:01 +0300 Message-Id: <20180612112205.11200-5-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612112205.11200-1-jarkko.nikula@linux.intel.com> References: <20180612112205.11200-1-jarkko.nikula@linux.intel.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This is rather readability update than micro-optimization, or if not optimization at all. We take the input clock rate to a variable and pass that to SCL timing parameter calculation functions. While at it, indent i2c_dw_scl_hcnt()/i2c_dw_scl_lcnt() argument list to the same alignment. Now first argument is off by one character. Instead of indenting the following lines we move the function calls to own lines as this keeps the argument list aligned, line length below 80 characters and no need to align with spaces. Reviewed-by: Andy Shevchenko Signed-off-by: Jarkko Nikula --- v2: - Add comment why i2c_dw_scl_hcnt()/i2c_dw_scl_lcnt() calls are moved to own lines. --- drivers/i2c/busses/i2c-designware-master.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c index 3a7c184f24c8..76071332f09c 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -55,6 +55,7 @@ static void i2c_dw_configure_fifo_master(struct dw_i2c_dev *dev) */ static int i2c_dw_init_master(struct dw_i2c_dev *dev) { + u32 ic_clk = i2c_dw_clk_rate(dev); u32 hcnt, lcnt; u32 reg, comp_param1; u32 sda_falling_time, scl_falling_time; @@ -79,12 +80,14 @@ static int i2c_dw_init_master(struct dw_i2c_dev *dev) hcnt = dev->ss_hcnt; lcnt = dev->ss_lcnt; } else { - hcnt = i2c_dw_scl_hcnt(i2c_dw_clk_rate(dev), + hcnt = + i2c_dw_scl_hcnt(ic_clk, 4000, /* tHD;STA = tHIGH = 4.0 us */ sda_falling_time, 0, /* 0: DW default, 1: Ideal */ 0); /* No offset */ - lcnt = i2c_dw_scl_lcnt(i2c_dw_clk_rate(dev), + lcnt = + i2c_dw_scl_lcnt(ic_clk, 4700, /* tLOW = 4.7 us */ scl_falling_time, 0); /* No offset */ @@ -101,12 +104,14 @@ static int i2c_dw_init_master(struct dw_i2c_dev *dev) hcnt = dev->fs_hcnt; lcnt = dev->fs_lcnt; } else { - hcnt = i2c_dw_scl_hcnt(i2c_dw_clk_rate(dev), + hcnt = + i2c_dw_scl_hcnt(ic_clk, 600, /* tHD;STA = tHIGH = 0.6 us */ sda_falling_time, 0, /* 0: DW default, 1: Ideal */ 0); /* No offset */ - lcnt = i2c_dw_scl_lcnt(i2c_dw_clk_rate(dev), + lcnt = + i2c_dw_scl_lcnt(ic_clk, 1300, /* tLOW = 1.3 us */ scl_falling_time, 0); /* No offset */