From patchwork Tue Dec 14 11:41:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 1567684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=LfMEqetJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JCxQL1qbfz9sR4 for ; Tue, 14 Dec 2021 22:45:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fT+i77fV4zf2UJV5gPskRAWKxuF9K112+/a7nu48w2c=; b=LfMEqetJNM5OiY QwdjWWb9tmUmvg2i+6pXEB1jNAzJCSwZ1iYK4yfqiXHf0JXxPqm74rOoIDH9fZh8sW8VkaYfqpG8W +0FtHOTFGibbjGzuArKM7TbIQlFr/lmcvrGx6+yM16MXAW8EH4pHj1TU2E/5GW10+Y5Tk3U8gQFek UO5Sd+3XqR4DvqRkyQERR85+iMEVqAGldlRBfJj85QNvD9Y4Z3GWc440YIhi8DwopJF0PQUHN47No dgIU5ptWjAayVcX0v0oWZ/05o6snfbm/JL4BcugdpALsQVLQfzuf+UTtm9UHkljyjYFRsyr3j8PlM RZSO6MKr3pa+l7VLtbKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mx6Eo-00DkdY-3L; Tue, 14 Dec 2021 11:44:54 +0000 Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mx6Bw-00Djb9-Ge for linux-mtd@lists.infradead.org; Tue, 14 Dec 2021 11:41:58 +0000 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 2A9D3240009; Tue, 14 Dec 2021 11:41:53 +0000 (UTC) From: Miquel Raynal To: Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus , Pratyush Yadav , Michael Walle , , Mark Brown , Cc: Julien Su , Jaime Liao , Thomas Petazzoni , Boris Brezillon , Xiangsheng Hou , Miquel Raynal Subject: [PATCH v5 05/13] spi: spi-mem: Export the spi_mem_generic_supports_op() helper Date: Tue, 14 Dec 2021 12:41:32 +0100 Message-Id: <20211214114140.54629-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211214114140.54629-1-miquel.raynal@bootlin.com> References: <20211214114140.54629-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211214_034156_730956_00827687 X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The combination of checks against the number of supported operations is going to increase exponentially each time we add a new parameter. So far we only had a dtr parameter. Now we are introducing an [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [217.70.183.193 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [217.70.183.193 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The combination of checks against the number of supported operations is going to increase exponentially each time we add a new parameter. So far we only had a dtr parameter. Now we are introducing an ECC parameter. We need to make this helper available for drivers with specific needs, instead of creating yet another set of helpers each time we want to check something new. In the future if we see that many different drivers use the same parameter values, we might be tempted to create a specific helper for that. But for now, let's just make the generic one available. Signed-off-by: Miquel Raynal --- drivers/spi/spi-mem.c | 7 ++++--- include/linux/spi/spi-mem.h | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 4c6944d7b174..df2ec2c8ce31 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -160,9 +160,9 @@ static bool spi_mem_check_buswidth(struct spi_mem *mem, return true; } -static bool spi_mem_generic_supports_op(struct spi_mem *mem, - const struct spi_mem_op *op, - struct spi_mem_controller_caps *caps) +bool spi_mem_generic_supports_op(struct spi_mem *mem, + const struct spi_mem_op *op, + struct spi_mem_controller_caps *caps) { if (!caps->dtr) { if (op->cmd.dtr || op->addr.dtr || @@ -178,6 +178,7 @@ static bool spi_mem_generic_supports_op(struct spi_mem *mem, return spi_mem_check_buswidth(mem, op); } +EXPORT_SYMBOL_GPL(spi_mem_generic_supports_op); bool spi_mem_dtr_supports_op(struct spi_mem *mem, const struct spi_mem_op *op) diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h index f365efcfb719..a17dd5035530 100644 --- a/include/linux/spi/spi-mem.h +++ b/include/linux/spi/spi-mem.h @@ -325,6 +325,10 @@ void spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr, const struct spi_mem_op *op, struct sg_table *sg); +bool spi_mem_generic_supports_op(struct spi_mem *mem, + const struct spi_mem_op *op, + struct spi_mem_controller_caps *caps); + bool spi_mem_default_supports_op(struct spi_mem *mem, const struct spi_mem_op *op); @@ -347,6 +351,14 @@ spi_controller_dma_unmap_mem_op_data(struct spi_controller *ctlr, { } +static inline +bool spi_mem_generic_supports_op(struct spi_mem *mem, + const struct spi_mem_op *op, + struct spi_mem_controller_caps *caps) +{ + return false; +} + static inline bool spi_mem_default_supports_op(struct spi_mem *mem, const struct spi_mem_op *op)