From patchwork Wed Jan 28 12:23:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 5735041 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 CB8D59F1AF for ; Thu, 29 Jan 2015 02:31:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D8D8201ED for ; Thu, 29 Jan 2015 02:31:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4D81920160 for ; Thu, 29 Jan 2015 02:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754075AbbA2Brr (ORCPT ); Wed, 28 Jan 2015 20:47:47 -0500 Received: from mail-lb0-f179.google.com ([209.85.217.179]:52773 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755288AbbA2Bra (ORCPT ); Wed, 28 Jan 2015 20:47:30 -0500 Received: by mail-lb0-f179.google.com with SMTP id 10so23179855lbg.10; Wed, 28 Jan 2015 17:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1c30JdmDdPz9SSlIbjcWBToFK6EU1sEyi7CN0VyA71c=; b=a8b1vlTqXN2mFWqe5cKEmCrpJIoEiRHls0S7jvMi9BYjgbRu9SyOC8MsPA9rHjIoZC M329dp8/e9O+F74OuMQ4p1isxJ+9UXo3B0y2Q/RsOjengdasRGQivKTDWX2bcedYL+ZY NrBiLZFO/SknKr7tQ2AaTslOSYWdykYG5WY4TgmIzGJVfyrv+l/5e5V9Vl/SpG2GgG8W S5xbAFkqvU0x8adD7o3qHMRVlxnKbjq17aS7c38151hYtv0jDYhCyXl8/6732ZuaX3MQ c0CmM4lcaTcXXoR0DlyLGYTMbj61S22mIyTerDVg2XutXEb+/fCyLjse2t9BgAWbkBfb T2aQ== X-Received: by 10.112.52.229 with SMTP id w5mr7612077lbo.52.1422447841552; Wed, 28 Jan 2015 04:24:01 -0800 (PST) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by mx.google.com with ESMTPSA id xh7sm1293741lbb.17.2015.01.28.04.24.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jan 2015 04:24:00 -0800 (PST) From: Ricardo Ribalda Delgado To: Mark Brown , Michal Simek , =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v2 03/15] spi/xilinx: Code cleanup Date: Wed, 28 Jan 2015 13:23:42 +0100 Message-Id: <1422447834-23116-4-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422447834-23116-1-git-send-email-ricardo.ribalda@gmail.com> References: <1422447834-23116-1-git-send-email-ricardo.ribalda@gmail.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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 On the transmission loop, check for remaining bytes at the loop condition. This way we can handle transmissions of 0 bytes and clean the code. Signed-off-by: Ricardo Ribalda Delgado --- v2: Changes Requested by Mark Brown Improve description drivers/spi/spi-xilinx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index d933207..a0f7c9d 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c @@ -248,7 +248,7 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) xspi->remaining_bytes = t->len; reinit_completion(&xspi->done); - for (;;) { + while (xspi->remaining_bytes) { u16 cr; int n_words; @@ -278,10 +278,6 @@ static int xilinx_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) /* Read out all the data from the Rx FIFO */ while (n_words--) xspi->rx_fn(xspi); - - /* See if there is more data to send */ - if (xspi->remaining_bytes <= 0) - break; } return t->len - xspi->remaining_bytes;