Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp406835pxb; Wed, 3 Mar 2021 06:22:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/fukwOFw2mXG3R2wc0RPK3E562gSTTykjHcsj6AOB/LtPYF3w3vgI9dQzRaD9vDcS0OsU X-Received: by 2002:a05:6402:4313:: with SMTP id m19mr25866918edc.124.1614781360645; Wed, 03 Mar 2021 06:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614781360; cv=none; d=google.com; s=arc-20160816; b=sL9byDZUeaomEdmgkGJDmF4oXTJc1ktgvOs0pfnKMrLUmc3FPOBSJHGgW0RcpqbF5J V4Gn7qP6EktEfwT2j1eZBtGmus+g0jo9IhkVM5gHe4fJSysfd/OUXUrF7FtW0MOCgEoI 2PulvnKy7wj4u5h0Z3Ki6Zt1RAplzxIAXm02G8SN86yqx1H7zALOvtta4C33pZR5lm+g Dlu9mcu859vi4KrYu02tlheofD/73GoVtP1gAllZDNGWN9xcSHk4D4IUaKYynrxMug8w UZPMBcI0c3e1j3K+A58GdSj8LEOXrA64+yf151lzYMrlFiQ34CoODHvq+1rTMPHUnEnZ hIdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vi63iWTNsY650XAcIzpIBeLdD21fJ2B9HzivF1bwgG8=; b=XDDHu2KmpWhVsTrkVhZLbk9S2mUlVwQuvnPAvkRLhFv3xSxQhf5QT4BCeTy5/AhK4k I5HFfuNu1Bb8l2MVST/Y5yOsFCu5qjDaFsH4QSHBdA4ibyMeuw2qjJSRoipfvElcto89 Gyj3UqDa6P9iZyLA37Nf0nDT5xioThqcY9bQWBpS1PLTwSfv+H8F5YOutDJmdixIE/84 QBug56BUUP+CyUj1cjHgZUSnbACQ6mioIVUjCOkjIjhAhGD9nsKVy0Pi2XTNQzxueVeC E/3V1F1Be7PtpTZMW/e0v5gXStkQ00n9ZU0i4jBkjXCDlq1F8BtBmpi6g6xnSRPXEOQw kLTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mVc9uAMN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si14900778edu.119.2021.03.03.06.21.43; Wed, 03 Mar 2021 06:22:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mVc9uAMN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243790AbhCAUsT (ORCPT + 99 others); Mon, 1 Mar 2021 15:48:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:37784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236672AbhCARIk (ORCPT ); Mon, 1 Mar 2021 12:08:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CDE365014; Mon, 1 Mar 2021 16:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616928; bh=PJsmq/Ddg+PlM5b97T82Ls8Dq66aWqp2lQVLQHWD2ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVc9uAMNbD7IGlgsoxCfrEQuEtKVcwC/dc2k78baP0XmjelczDAx+YaCGgmcub/2f AnP7pJUC8fwX5M52BFCUtLGkUgvxRU61D4Xt04ZQO9MoPktoCFfQ/bJVT7hLLu7qHt EYiQ7PCnQkYjJtGOJ98VrZ7m/gjn531aMT6lzS60= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alain Volmat , Mark Brown , Sasha Levin Subject: [PATCH 4.19 143/247] spi: stm32: properly handle 0 byte transfer Date: Mon, 1 Mar 2021 17:12:43 +0100 Message-Id: <20210301161038.671675464@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alain Volmat [ Upstream commit 2269f5a8b1a7b38651d62676b98182828f29d11a ] On 0 byte transfer request, return straight from the xfer function after finalizing the transfer. Fixes: dcbe0d84dfa5 ("spi: add driver for STM32 SPI controller") Signed-off-by: Alain Volmat Link: https://lore.kernel.org/r/1612551572-495-2-git-send-email-alain.volmat@foss.st.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-stm32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 8eb2644506dd3..8d692f16d90ac 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -992,6 +992,10 @@ static int stm32_spi_transfer_one(struct spi_master *master, struct stm32_spi *spi = spi_master_get_devdata(master); int ret; + /* Don't do anything on 0 bytes transfers */ + if (transfer->len == 0) + return 0; + spi->tx_buf = transfer->tx_buf; spi->rx_buf = transfer->rx_buf; spi->tx_len = spi->tx_buf ? transfer->len : 0; -- 2.27.0