From patchwork Sun Feb 2 06:59:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 3566531 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2A035C02DC for ; Sun, 2 Feb 2014 07:00:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 560832013D for ; Sun, 2 Feb 2014 07:00:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 843642012F for ; Sun, 2 Feb 2014 07:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751010AbaBBHAk (ORCPT ); Sun, 2 Feb 2014 02:00:40 -0500 Received: from fallback5.mail.ru ([94.100.176.59]:46320 "EHLO fallback5.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750920AbaBBHAj (ORCPT ); Sun, 2 Feb 2014 02:00:39 -0500 Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) by fallback5.mail.ru (mPOP.Fallback_MX) with ESMTP id 559C010BA1FB8 for ; Sun, 2 Feb 2014 11:00:20 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=VYNgSaZFKIZNZbngXLAqw5/R1MxLhLLZJqbqhRMsTcQ=; b=WpqEpBu4IIBbmGSEtaoCmbV0wtsL5k502FLkOF+gYQof2ocdm7jS94Y9yLw+1MF5Xe+wThd0LaWOz45ls3zcdizv/kJqCi6Ksy2kWrFLw6OY1JU0AueCo3pkwS6WZWRW3dpyyPOlV27VVE2SH8SypySWAAPNTFehxpqhXD63btU=; Received: from [188.134.40.128] (port=62912 helo=shc.zet) by smtp40.i.mail.ru with esmtpa (envelope-from ) id 1W9r2G-0001vA-DV; Sun, 02 Feb 2014 11:00:08 +0400 From: Alexander Shiyan To: linux-spi@vger.kernel.org Cc: Mark Brown , Alexander Shiyan Subject: [PATCH 1/3] spi: clps711x: Simplify handling of RX & TX buffers Date: Sun, 2 Feb 2014 10:59:48 +0400 Message-Id: <1391324390-17547-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.3.2 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Mras: Ok Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RDNS_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no 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 Signed-off-by: Alexander Shiyan --- drivers/spi/spi-clps711x.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-clps711x.c b/drivers/spi/spi-clps711x.c index bee864d..0b80624 100644 --- a/drivers/spi/spi-clps711x.c +++ b/drivers/spi/spi-clps711x.c @@ -31,7 +31,6 @@ struct spi_clps711x_data { u8 *tx_buf; u8 *rx_buf; - int count; int len; int chipselect[0]; @@ -92,11 +91,12 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, struct spi_clps711x_data *hw = spi_master_get_devdata(master); struct spi_transfer *xfer; int status = 0, cs = hw->chipselect[msg->spi->chip_select]; - u32 data; spi_clps711x_setup_mode(msg->spi); list_for_each_entry(xfer, &msg->transfers, transfer_list) { + u8 data; + if (spi_clps711x_setup_xfer(msg->spi, xfer)) { status = -EINVAL; goto out_xfr; @@ -106,13 +106,12 @@ static int spi_clps711x_transfer_one_message(struct spi_master *master, reinit_completion(&hw->done); - hw->count = 0; hw->len = xfer->len; hw->tx_buf = (u8 *)xfer->tx_buf; hw->rx_buf = (u8 *)xfer->rx_buf; /* Initiate transfer */ - data = hw->tx_buf ? hw->tx_buf[hw->count] : 0; + data = hw->tx_buf ? *hw->tx_buf++ : 0; clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); wait_for_completion(&hw->done); @@ -137,18 +136,16 @@ out_xfr: static irqreturn_t spi_clps711x_isr(int irq, void *dev_id) { struct spi_clps711x_data *hw = (struct spi_clps711x_data *)dev_id; - u32 data; + u8 data; /* Handle RX */ data = clps_readb(SYNCIO); if (hw->rx_buf) - hw->rx_buf[hw->count] = (u8)data; - - hw->count++; + *hw->rx_buf++ = data; /* Handle TX */ - if (hw->count < hw->len) { - data = hw->tx_buf ? hw->tx_buf[hw->count] : 0; + if (--hw->len > 0) { + data = hw->tx_buf ? *hw->tx_buf++ : 0; clps_writel(data | SYNCIO_FRMLEN(8) | SYNCIO_TXFRMEN, SYNCIO); } else complete(&hw->done);