From patchwork Wed Jan 15 07:57:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3490561 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 B75129F169 for ; Wed, 15 Jan 2014 07:57:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE72E201D3 for ; Wed, 15 Jan 2014 07:57:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD56C201DE for ; Wed, 15 Jan 2014 07:57:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbaAOH5X (ORCPT ); Wed, 15 Jan 2014 02:57:23 -0500 Received: from mail-pa0-f47.google.com ([209.85.220.47]:53882 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750799AbaAOH5W (ORCPT ); Wed, 15 Jan 2014 02:57:22 -0500 Received: by mail-pa0-f47.google.com with SMTP id kp14so801636pab.34 for ; Tue, 14 Jan 2014 23:57: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=jYZ0y+Cuh4175g1E9re6H45IJI7xuNmdY3iZCiwoSgI=; b=ITtuGfks9DEBn8FB6hlXvRJixVeaNbEwuy7BewmCkwAYdKovifDfR1QLqzAw3wu/b/ saVq17mWW0qgHf7RhnpVsDyKwSSh+NZKA0VsngzYuA3/bd4Tg+rspipZNhwS4yFPT/pZ vKFzMyYU5SN1joKnFnR/QsTiv9gAFVy5J7ixwSn0ZmaCevjKJhzFjcVfMTLezRaIEI/S piwhUcQ9KzHzUDp1s0vS/mBkfLqomVuFS1DJyVVi/oWMiHQqT2pVs02tn3cifdXhCXsi fn+xf19pTmi9vouWfRkeM6RiJlFcZgcf+BvjqWk2cVUfe4+I4QEvTh7HbRXLc4JE4khN Abyw== X-Gm-Message-State: ALoCoQnUx+iCnfEHG0cpA+uDyhqEL0PcujjVx/EmvoM98QXuoHLLUsy8TqrTKhQCrbr/yA9TBYTE X-Received: by 10.69.19.161 with SMTP id gv1mr963821pbd.134.1389772642452; Tue, 14 Jan 2014 23:57:22 -0800 (PST) Received: from [192.168.0.102] (218-164-139-120.dynamic.hinet.net. [218.164.139.120]) by mx.google.com with ESMTPSA id sj1sm6178167pbc.28.2014.01.14.23.57.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 Jan 2014 23:57:21 -0800 (PST) Message-ID: <1389772636.13585.1.camel@phoenix> Subject: [PATCH] spi: sirf: Avoid duplicate code in various bits_per_word cases From: Axel Lin To: Mark Brown Cc: Zhiwu Song , Barry Song , Qipan Li , linux-spi@vger.kernel.org Date: Wed, 15 Jan 2014 15:57:16 +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=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Trivial cleanup to avoid duplicate code in various bits_per_word cases. Signed-off-by: Axel Lin --- drivers/spi/spi-sirf.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index ed5e501..787683d 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c @@ -459,11 +459,6 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) regval |= SIRFSOC_SPI_TRAN_DAT_FORMAT_8; sspi->rx_word = spi_sirfsoc_rx_word_u8; sspi->tx_word = spi_sirfsoc_tx_word_u8; - txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | - SIRFSOC_SPI_FIFO_WIDTH_BYTE; - rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | - SIRFSOC_SPI_FIFO_WIDTH_BYTE; - sspi->word_width = 1; break; case 12: case 16: @@ -471,26 +466,22 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) SIRFSOC_SPI_TRAN_DAT_FORMAT_16; sspi->rx_word = spi_sirfsoc_rx_word_u16; sspi->tx_word = spi_sirfsoc_tx_word_u16; - txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | - SIRFSOC_SPI_FIFO_WIDTH_WORD; - rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | - SIRFSOC_SPI_FIFO_WIDTH_WORD; - sspi->word_width = 2; break; case 32: regval |= SIRFSOC_SPI_TRAN_DAT_FORMAT_32; sspi->rx_word = spi_sirfsoc_rx_word_u32; sspi->tx_word = spi_sirfsoc_tx_word_u32; - txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | - SIRFSOC_SPI_FIFO_WIDTH_DWORD; - rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | - SIRFSOC_SPI_FIFO_WIDTH_DWORD; - sspi->word_width = 4; break; default: BUG(); } + txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | + SIRFSOC_SPI_FIFO_WIDTH_WORD; + rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | + SIRFSOC_SPI_FIFO_WIDTH_WORD; + sspi->word_width = DIV_ROUND_UP(bits_per_word, 8); + if (!(spi->mode & SPI_CS_HIGH)) regval |= SIRFSOC_SPI_CS_IDLE_STAT; if (!(spi->mode & SPI_LSB_FIRST))