Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4578231rdh; Wed, 29 Nov 2023 05:32:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG8nXTXq6aUQUt1NXD2UDDEh/OKqEjHnDBURLbjREMe8ua7nG+8kWcEXd6BRtiRoTIIUuD X-Received: by 2002:a05:6808:bd6:b0:3b2:e520:dfab with SMTP id o22-20020a0568080bd600b003b2e520dfabmr23745944oik.44.1701264778420; Wed, 29 Nov 2023 05:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701264778; cv=none; d=google.com; s=arc-20160816; b=xFlg3PYR2hiyIxZHHqGQ1/M3n6HAdcqyD45VyMh+XYoncIGVFrL8z3gcY7YwqAuE54 OeLryUeFDcmbOcu5ZlG5skoHggTrRE2CPEeReF15efQwmhyDUISUHvT1dKNQLK6X4TGk wI52bNFt2pdoc3uRqeh2YjZxkTNNzQN7Co81IXcovTZdINhymHKvO+RNZoYl/LtGQovp oetlhc/aG4elnOfS9ADpQoLWXCTHaSeIPAPNQlIuZbIwbGXU0saN6YWiyYR+kzZtJtxi O9WhCMlrsO1FnkfFhw7ozqAImoN2wAxRFdvvVgaYorOiCe66E2xdlkOpT4MjItDJIq0m beFA== 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 :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Kzdtc8JyJA+/FCzC+xiv8TQYBEoRzlUz4DduhP6xQ4M=; fh=FpEFgSTsD9KOdZrv5i/8e/czx6Pnhsq5lU2kOotSX/I=; b=FE3ErfiFr7QlutJowDOwyaSo0btNVC8ur2rWrO+MyPOEppcVi+5+eL6UyVeRpRb9AM 849xBtRbhnXqGVCMTHi6MwuUXJR7KnNqRF2HbjpRjkWRr6Kqbbr1HaCtDkTnf3RHgdBf jof8DEIhzOOdw6an8Z/m2eJ5DTEjOHl3Y7de/B+n6CmM0DsBtNTrT7rnpNgincqtjuFS PURr/+pLUYBiEVskBpENqjwQ6d73kQHZa5n64HaEtY7n4ELi81yQCsgLwHC+u7G35JlX wJEQESOzyNTq4J3GKomIRyKGDY0RpYN+8bQZ/lFUnQ7/xHFiNjkESfhkC1ZV1JIOdThw YyIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xjZXDnVc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z14-20020a630a4e000000b005bdbea1c477si14869987pgk.203.2023.11.29.05.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:32:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xjZXDnVc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B69B981EE3B2; Wed, 29 Nov 2023 05:32:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234027AbjK2NcW (ORCPT + 99 others); Wed, 29 Nov 2023 08:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjK2NcU (ORCPT ); Wed, 29 Nov 2023 08:32:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E212A3; Wed, 29 Nov 2023 05:32:27 -0800 (PST) From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701264746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kzdtc8JyJA+/FCzC+xiv8TQYBEoRzlUz4DduhP6xQ4M=; b=xjZXDnVc0ovq0TSW9b98/h3ZELuqA15QueP8c+dXzxKrIp8wNN7O1hmf/fCD5G1ylI26hz L78xZrMJbXnMTnK4MwFl7UaEv6UC6TD6OiuD1WAloGWy2cCqstcLxlL+EzR27OeGfiaHps zEgFQsjk8zvX3J/Em2oUdtOQg7g0F6+DVllqfJTVLdWNW1nj61t3Ej3zmqGq3VSjEGiURF arpkYa25kNCMGOlwDcmjxBEZtKi2d2kCXws/LdoXN9T/B+8JWn/Hz+fPQhRYD97kf84rLE JBx7rP99mf602Yh9t+VkfGeeM07HXz55wyYrKBCojpKIJBZbnoid5NEhwAeO0w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701264746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kzdtc8JyJA+/FCzC+xiv8TQYBEoRzlUz4DduhP6xQ4M=; b=9i9b/NsWVbiv7sXSCvMncA5ugNF88CKqDLw3PPHnZ19aS2mRShIgLjpvAt6g0iEmGa65Ei P5CxPjuDEvsuJqDA== To: linus.walleij@linaro.org, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 1/2] spi: introduce SPI_TRANS_FAIL_IO for error reporting Date: Wed, 29 Nov 2023 14:32:18 +0100 Message-Id: <361901574eec1271c0969edba6492d3f2132fade.1701264413.git.namcao@linutronix.de> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:32:55 -0800 (PST) The default message transfer implementation - spi_transfer_one_message - invokes the specific device driver's transfer_one(), then waits for completion. However, there is no mechanism for the device driver to report failure in the middle of the transfer. Introduce SPI_TRANS_FAIL_IO for drivers to report transfer failure. Signed-off-by: Nam Cao --- drivers/spi/spi.c | 3 +++ include/linux/spi/spi.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 8ead7acb99f3..a4b8c07c5951 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1361,6 +1361,9 @@ static int spi_transfer_wait(struct spi_controller *c= tlr, "SPI transfer timed out\n"); return -ETIMEDOUT; } + + if (xfer->error & SPI_TRANS_FAIL_IO) + return -EIO; } =20 return 0; diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 7b4baff63c5c..ddadae2e1ead 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1040,6 +1040,7 @@ struct spi_transfer { unsigned len; =20 #define SPI_TRANS_FAIL_NO_START BIT(0) +#define SPI_TRANS_FAIL_IO BIT(1) u16 error; =20 dma_addr_t tx_dma; --=20 2.39.2