From patchwork Wed Jan 15 09:07:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3490821 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 E9AD79F169 for ; Wed, 15 Jan 2014 09:07:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAE2520176 for ; Wed, 15 Jan 2014 09:07:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5335201B9 for ; Wed, 15 Jan 2014 09:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751132AbaAOJHx (ORCPT ); Wed, 15 Jan 2014 04:07:53 -0500 Received: from mail-pd0-f178.google.com ([209.85.192.178]:63041 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbaAOJHu (ORCPT ); Wed, 15 Jan 2014 04:07:50 -0500 Received: by mail-pd0-f178.google.com with SMTP id y13so858709pdi.9 for ; Wed, 15 Jan 2014 01:07:49 -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=FGE/0YL3XOA0kTVjDHXxVYL6G/4JEkxUc6c9jUxhUi0=; b=Jn0kZCPLQl+zvs5AIRDG0kxb+gnkkzZEsfrpCpus//ZwlgCdgaeEzS/4e+4dZBHNZU HXpdlbxHfqiPGJZh/EkvF1D9JcCGTaxCPruC1gGG3MDjrJW9NVR5JqkO0ilbK8am0W89 iO3g0eHQJPNCmhx2U6miAbutcLb8MZYPByCApXZSNtUrHaT2eHAQG32RDvHxSIuOlZw9 IORKjA5y0V1deTUQzK7m8m65yd0TDqpoitFDI1dCiqGm/3nG80o1g8DxVBuWC+XDGjDb TUqs1+whuiNcNSm1vGn3seJIzwGgXOq4TX85Rgp15N7xO94W66k9o2C5zixZQa3+E8pM ZlZQ== X-Gm-Message-State: ALoCoQkAjyI26CLHueCc4ZR+NPvHVCG+nTLGOKSpFeONE7ILwgc8PnvF8PQqe74+n3ZMBBzqt4JT X-Received: by 10.66.144.227 with SMTP id sp3mr1356631pab.100.1389776869311; Wed, 15 Jan 2014 01:07:49 -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 kk1sm6628946pbd.22.2014.01.15.01.07.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 01:07:48 -0800 (PST) Message-ID: <1389776863.28509.0.camel@phoenix> Subject: [PATCH v2] 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 17:07:43 +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 Reviewed-by: Barry Song --- 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..4b43310 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(); } + sspi->word_width = DIV_ROUND_UP(bits_per_word, 8); + txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | + sspi->word_width; + rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | + sspi->word_width; + if (!(spi->mode & SPI_CS_HIGH)) regval |= SIRFSOC_SPI_CS_IDLE_STAT; if (!(spi->mode & SPI_LSB_FIRST))