From patchwork Tue Feb 24 11:32:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 5872301 Return-Path: X-Original-To: patchwork-linux-spi@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 037529F693 for ; Tue, 24 Feb 2015 11:32:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BEE920272 for ; Tue, 24 Feb 2015 11:32:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C26820653 for ; Tue, 24 Feb 2015 11:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752351AbbBXLcq (ORCPT ); Tue, 24 Feb 2015 06:32:46 -0500 Received: from mga09.intel.com ([134.134.136.24]:54610 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752331AbbBXLcq (ORCPT ); Tue, 24 Feb 2015 06:32:46 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 24 Feb 2015 03:27:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,638,1418112000"; d="scan'208";a="689951409" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.90]) by orsmga002.jf.intel.com with ESMTP; 24 Feb 2015 03:32:15 -0800 Received: from andy by smile with local (Exim 4.84) (envelope-from ) id 1YQDio-0003ih-MK; Tue, 24 Feb 2015 13:32:14 +0200 From: Andy Shevchenko To: Mark Brown , linux-spi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 3/5] spi: dw: refactor code that handles clk_div Date: Tue, 24 Feb 2015 13:32:12 +0200 Message-Id: <1424777534-14246-4-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424777534-14246-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1424777534-14246-1-git-send-email-andriy.shevchenko@linux.intel.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch does the following changes: a) the calculation of clk_div is simplified to oneliner; b) chip->clk_div is updated if clk_div is not zero, therefore the condition is simplified by using chip->clk_div in both cases; c) while here, the redundant parentheses are removed. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-dw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 0febb97..0e0c48b 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -416,12 +416,11 @@ static void pump_transfers(unsigned long data) if (transfer->speed_hz) { speed = chip->speed_hz; - if ((transfer->speed_hz != speed) || (!chip->clk_div)) { + if ((transfer->speed_hz != speed) || !chip->clk_div) { speed = transfer->speed_hz; /* clk_div doesn't support odd number */ - clk_div = dws->max_freq / speed; - clk_div = (clk_div + 1) & 0xfffe; + clk_div = (dws->max_freq / speed + 1) & 0xfffe; chip->speed_hz = speed; chip->clk_div = clk_div; @@ -480,7 +479,7 @@ static void pump_transfers(unsigned long data) if (dw_readw(dws, DW_SPI_CTRL0) != cr0) dw_writew(dws, DW_SPI_CTRL0, cr0); - spi_set_clk(dws, clk_div ? clk_div : chip->clk_div); + spi_set_clk(dws, chip->clk_div); spi_chip_sel(dws, spi, 1); /* Set the interrupt mask, for poll mode just disable all int */