From patchwork Fri Feb 28 14:03:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atsushi Nemoto X-Patchwork-Id: 3741601 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 A519F9F2ED for ; Fri, 28 Feb 2014 14:03:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B6ADE20225 for ; Fri, 28 Feb 2014 14:03:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F3FB202A7 for ; Fri, 28 Feb 2014 14:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752389AbaB1ODW (ORCPT ); Fri, 28 Feb 2014 09:03:22 -0500 Received: from mv-drv-hcb003.ocn.ad.jp ([118.23.109.133]:44633 "EHLO mv-drv-hcb003.ocn.ad.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751679AbaB1ODW (ORCPT ); Fri, 28 Feb 2014 09:03:22 -0500 Received: from vcmba.ocn.ne.jp (localhost.localdomain [127.0.0.1]) by mv-drv-hcb003.ocn.ad.jp (Postfix) with ESMTP id 2299F5642D8; Fri, 28 Feb 2014 23:03:20 +0900 (JST) Received: from anemo-PC-VJ22.flets-east.jp (p27017-ipngn1301funabasi.chiba.ocn.ne.jp [180.35.78.17]) by vcmba.ocn.ne.jp (Postfix) with ESMTP; Fri, 28 Feb 2014 23:03:19 +0900 (JST) From: Atsushi Nemoto To: Mark Brown Cc: iivanov@mm-sol.com, gsi@denx.de, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: core: make zero length transfer valid again Date: Fri, 28 Feb 2014 23:03:16 +0900 Message-Id: <1393596196-8652-1-git-send-email-anemo@mba.ocn.ne.jp> X-Mailer: git-send-email 1.7.9.5 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Zero length transfer becomes invalid since "spi: core: Validate length of the transfers in message" commit, but it should be valid to support an odd device, for example, which requires long delay between chipselect and the first transfer, etc. Signed-off-by: Atsushi Nemoto Tested-by: Thierry Reding --- drivers/spi/spi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index c2605aa..454a523 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1808,7 +1808,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) { struct spi_master *master = spi->master; struct spi_transfer *xfer; - int w_size, n_words; + int w_size; if (list_empty(&message->transfers)) return -EINVAL; @@ -1871,9 +1871,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) else w_size = 4; - n_words = xfer->len / w_size; /* No partial transfers accepted */ - if (!n_words || xfer->len % w_size) + if (xfer->len % w_size) return -EINVAL; if (xfer->speed_hz && master->min_speed_hz &&