From patchwork Sat Aug 16 15:30:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 35478 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8EEDA202E4 for ; Sat, 16 Aug 2014 21:33:32 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp18sf24665797obc.1 for ; Sat, 16 Aug 2014 14:33:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:date :message-id:subject:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Tpd7SAdiq1qYZEMIvqAQ/fBlK5Mn9YioXq3FKT7VZK8=; b=L1FYOvc0enn38NkyOsayNVeT5zEsowHsLrOysgmjXLKZ7VNOBQheY8b96GtGIt6jaU 22ViPB4aoUJZRfukP/l/TjwvbKkGQlGDOTnx+El9pswYVGk4iljxfB6i/ZeqEOVPhwgT 6v+yn+eg9HMe34zr4yv8wdRvSksHhpg4SVm607Np+5tTi3DBslX76JEJQfEnUjS3LRpP sEd5UuO4uajBWZy0KJvUeGjjoFly2PHVmQL+FCu0YPrqw45uZjXN0a8LMSx/O70xMIx1 c6nE2YD8SuC/fvKvYoGomG5rzxd9b8+aI54iSkQ73heVR0OXtmeefOXhMZbCt+FK9LtT EDvQ== X-Gm-Message-State: ALoCoQmreeuRv2TPTvs7qMXy5kWxqP7hnnHh/G/JvhWlBb8SzJgAxj0Ujg3XyQSDgCq67CuRSHkV X-Received: by 10.42.85.142 with SMTP id q14mr14529959icl.16.1408224812144; Sat, 16 Aug 2014 14:33:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.98 with SMTP id 89ls1934064qgi.1.gmail; Sat, 16 Aug 2014 14:33:32 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr6865987vdb.8.1408224812025; Sat, 16 Aug 2014 14:33:32 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id u7si5774802vdc.40.2014.08.16.14.33.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Aug 2014 14:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ik5so4358363vcb.34 for ; Sat, 16 Aug 2014 14:33:31 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr17174354vcb.5.1408224811822; Sat, 16 Aug 2014 14:33:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp39831vcb; Sat, 16 Aug 2014 14:33:31 -0700 (PDT) X-Received: by 10.66.122.3 with SMTP id lo3mr23028699pab.7.1408224810862; Sat, 16 Aug 2014 14:33:30 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xl7si14620847pab.68.2014.08.16.14.33.30 for ; Sat, 16 Aug 2014 14:33:30 -0700 (PDT) Received-SPF: none (google.com: linux-spi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751857AbaHPVd3 (ORCPT + 2 others); Sat, 16 Aug 2014 17:33:29 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:38855 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbaHPVd3 (ORCPT ); Sat, 16 Aug 2014 17:33:29 -0400 Received: from 216-80-70-240.c3-0.alc-ubr4.chi-alc.il.cable.rcn.com ([216.80.70.240] helo=finisterre) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XIlb8-0001os-JY; Sat, 16 Aug 2014 21:33:18 +0000 Received: from broonie by finisterre with local (Exim 4.84_RC1) (envelope-from ) id 1XIfve-0006sU-Mi; Sat, 16 Aug 2014 16:30:02 +0100 From: Mark Brown To: Addy Ke , Doug Anderson Cc: linux-spi@vger.kernel.org, olof@lixiom.net, linaro-kernel@lists.linaro.org, Mark Brown Date: Sat, 16 Aug 2014 16:30:02 +0100 Message-Id: <1408203002-26403-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 2.1.0.rc1 X-SA-Exim-Connect-IP: 216.80.70.240 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_PAST_06_12,TVD_RCVD_IP autolearn=no version=3.3.2 Subject: [PATCH] spi: Only call transfer_one() if we have buffers to transfer X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-spi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: broonie@kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mark Brown Client drivers such as the ChomeOS EC driver sometimes use transfers with no buffers and only a delay specified in order to allow a delay after the assertion of /CS. Rather than require controller drivers handle this noop case gracefully put checks in the core to ensure that we don't call into the controller for such transfers. Reported-by: Addy Ke Signed-off-by: Mark Brown Tested-by: Doug Anderson Reviewed-by: Doug Anderson --- Completely untested at this point. drivers/spi/spi.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ca935df..95cfe3b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -789,27 +789,35 @@ static int spi_transfer_one_message(struct spi_master *master, list_for_each_entry(xfer, &msg->transfers, transfer_list) { trace_spi_transfer_start(msg, xfer); - reinit_completion(&master->xfer_completion); - - ret = master->transfer_one(master, msg->spi, xfer); - if (ret < 0) { - dev_err(&msg->spi->dev, - "SPI transfer failed: %d\n", ret); - goto out; - } + if (xfer->tx_buf || xfer->rx_buf) { + reinit_completion(&master->xfer_completion); + + ret = master->transfer_one(master, msg->spi, xfer); + if (ret < 0) { + dev_err(&msg->spi->dev, + "SPI transfer failed: %d\n", ret); + goto out; + } - if (ret > 0) { - ret = 0; - ms = xfer->len * 8 * 1000 / xfer->speed_hz; - ms += ms + 100; /* some tolerance */ + if (ret > 0) { + ret = 0; + ms = xfer->len * 8 * 1000 / xfer->speed_hz; + ms += ms + 100; /* some tolerance */ - ms = wait_for_completion_timeout(&master->xfer_completion, - msecs_to_jiffies(ms)); - } + ms = wait_for_completion_timeout(&master->xfer_completion, + msecs_to_jiffies(ms)); + } - if (ms == 0) { - dev_err(&msg->spi->dev, "SPI transfer timed out\n"); - msg->status = -ETIMEDOUT; + if (ms == 0) { + dev_err(&msg->spi->dev, + "SPI transfer timed out\n"); + msg->status = -ETIMEDOUT; + } + } else { + if (xfer->len) + dev_err(&msg->spi->dev, + "Bufferless transfer has length %u\n", + xfer->len); } trace_spi_transfer_stop(msg, xfer);