From patchwork Sun Mar 2 15:24:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3749601 X-Patchwork-Delegate: broonie@sirena.org.uk 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D8B3E9F381 for ; Sun, 2 Mar 2014 15:24:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 043FE20382 for ; Sun, 2 Mar 2014 15:24:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F18052038C for ; Sun, 2 Mar 2014 15:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751284AbaCBPYX (ORCPT ); Sun, 2 Mar 2014 10:24:23 -0500 Received: from mail-pb0-f45.google.com ([209.85.160.45]:64146 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751100AbaCBPYX (ORCPT ); Sun, 2 Mar 2014 10:24:23 -0500 Received: by mail-pb0-f45.google.com with SMTP id uo5so2017339pbc.18 for ; Sun, 02 Mar 2014 07:24:22 -0800 (PST) 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=Y/MBeHtFf3xx7uGagxi5uqmiFh+bRpTpLMxFh71u9SQ=; b=P6elcrc2a0mflDTE89gjUP8Lv59YzfeGyRXGoEs41Iml0+rjxyzX1keqqhNBhcW1li Vx9ovMAalowANfwHGChS/7df4ZHqqu8AP6rhBbNIID0vBYTIF3A01gSC0bGAt7iYGsCA ljE/HLcB/6PZAlvfk3AGYjRWPEZmC7HRrQ/WgJaGQOQt5zvr4UavB19R4EiDfOwOfMJY c9zG0h7gDti2ywpgP+e1Tkn8zwlLUZlLZRJMs5VBi1VUKzfm5acpew+ySje9Ar6yGLr8 9pHsnouVr74hEQroCykdOQKTrCicLrc+d1n9i9FGKDGw3rLvtKSmSHjmHJ2vYvFMcAkn xezg== X-Gm-Message-State: ALoCoQkkKlEpP/Gge5hKsvj2Hy/m5ImN3WSO3UmUxSjxKorqEV/OcvBjPghIFQHQ/Nu2JEbzxPU/ X-Received: by 10.68.108.1 with SMTP id hg1mr14546825pbb.80.1393773862598; Sun, 02 Mar 2014 07:24:22 -0800 (PST) Received: from [192.168.0.102] (218-164-136-100.dynamic.hinet.net. [218.164.136.100]) by mx.google.com with ESMTPSA id g6sm63738708pat.2.2014.03.02.07.24.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 07:24:22 -0800 (PST) Message-ID: <1393773858.4044.12.camel@phoenix> Subject: [PATCH] spi: clps711x: Remove duplicate code to set default bits_per_word and max speed From: Axel Lin To: Mark Brown Cc: Alexander Shiyan , linux-spi@vger.kernel.org Date: Sun, 02 Mar 2014 23:24:18 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 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, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 In the implementation of __spi_validate(), spi core will set transfer bits_per_word and max speed as spi device default if it is not set for this transfer. So we can remove the same logic in spi_clps711x_setup_xfer() and spi_clps711x_transfer_one(). Signed-off-by: Axel Lin --- drivers/spi/spi-clps711x.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index 3900c31..74642f8 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c @@ -44,17 +44,16 @@ static int spi_clps711x_setup(struct spi_device *spi) static void spi_clps711x_setup_xfer(struct spi_device *spi, struct spi_transfer *xfer) { - u32 speed = xfer->speed_hz ? : spi->max_speed_hz; struct spi_clps711x_data *hw = spi_master_get_devdata(spi->master); /* Setup SPI frequency divider */ - if (!speed || (speed >= hw->max_speed_hz)) + if (!xfer->speed_hz || (xfer->speed_hz >= hw->max_speed_hz)) clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | SYSCON1_ADCKSEL(3), SYSCON1); - else if (speed >= (hw->max_speed_hz / 2)) + else if (xfer->speed_hz >= (hw->max_speed_hz / 2)) clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | SYSCON1_ADCKSEL(2), SYSCON1); - else if (speed >= (hw->max_speed_hz / 8)) + else if (xfer->speed_hz >= (hw->max_speed_hz / 8)) clps_writel((clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK) | SYSCON1_ADCKSEL(1), SYSCON1); else @@ -86,7 +85,7 @@ static int spi_clps711x_transfer_one(struct spi_master *master, spi_clps711x_setup_xfer(spi, xfer); hw->len = xfer->len; - hw->bpw = xfer->bits_per_word ? : spi->bits_per_word; + hw->bpw = xfer->bits_per_word; hw->tx_buf = (u8 *)xfer->tx_buf; hw->rx_buf = (u8 *)xfer->rx_buf;