From patchwork Tue Jul 18 19:24:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 122208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1967482vqt; Tue, 18 Jul 2023 12:39:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlG200iCbmahE7Rdx6cUB7AB9aac5G5vbFDu0cIZVQt7y3TJAT2xsw4iSJ4UTngArD2PPKi6 X-Received: by 2002:a05:6512:2384:b0:4f8:7781:9870 with SMTP id c4-20020a056512238400b004f877819870mr13723223lfv.60.1689709145500; Tue, 18 Jul 2023 12:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689709145; cv=none; d=google.com; s=arc-20160816; b=ACaSiucmafLdFoBoY8qK9HmQaCdWUfsw3roir6u/grI+q2+ovcX8H46JBktpq2QTR0 UU7BhNpF77JP9pkGlPIlRuC+KsyB22H1XgVNxdQdk3K9F9ZgukMw6yIGOyPv6k59OEAu wXSIi25DV8nWvbF5wazAbO0aQyjvf01F6dj8PH5gAR89Jn77M+/aEPMakiaQ0NYbpqcK OQc3wmhvY/X+CoSl8SsKCRJxZ10x6Cg15dUYeih+I4ePfp+q40KLt0JDW9Nr5R2P8XTi KtaQbVD+XLV3KRjZCnAPQbp6QpEGNXJ7wekjS/t/i+ucDUhSJNcafwseAiqhjZAt+Ba3 /9iw== 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:from; bh=ENvebFhUGalFOvoFIx+6b6xRDi4NrrM52euRcb8ZswU=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=vVcl/JV7GsxATAhKRH+L7FZa7Vu/2Z8bA+JSl+ezoXMLoxJfXwzdXLCictS3n6SX5r 1ptn03cRCacaRRzP8VvAvokfRF6oO6l10wwCdzkORDS/UMcx/XGNZ4tXqRcNLd4+joFh T3FyuoIXBNhZAErFYqhmMd9KWoBOeIu/NfEGSlIIH5XPLxdJH1eZ3mZXdEWyinIRutgb 8vs+V6GQdk2je/LRP72iNcyRcu+W3kX2v5hKS8yRmCD5cp68mF9SSo2y79loe9E579Ev xXCyyyyBWZUT7uzcailuGUtrUpQwVyMXBFKkF8Z90WBPlTX+mauGqixYidrsD+DII1ns KOSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a05640208d100b0051de088f170si1689075edz.127.2023.07.18.12.38.41; Tue, 18 Jul 2023 12:39:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbjGRTZN (ORCPT + 99 others); Tue, 18 Jul 2023 15:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjGRTZJ (ORCPT ); Tue, 18 Jul 2023 15:25:09 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F51D19AF; Tue, 18 Jul 2023 12:25:06 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,214,1684767600"; d="scan'208";a="169810329" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 19 Jul 2023 04:25:05 +0900 Received: from mulinux.home (unknown [10.226.93.62]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id CD2E44067F07; Wed, 19 Jul 2023 04:25:02 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 1/4] spi: rzv2m-csi: Squash timing settings into one statement Date: Tue, 18 Jul 2023 20:24:50 +0100 Message-Id: <20230718192453.543549-2-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> References: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771788456672489193 X-GMAIL-MSGID: 1771788456672489193 Register CLKSEL hosts the configuration for both clock polarity and data phase, and both values can be set in one write operation. Squash the clock polarity and data phase register writes into one statement, for efficiency. Signed-off-by: Fabrizio Castro Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko --- v2: No change. drivers/spi/spi-rzv2m-csi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 038f1486b7d7..faf5898bc3e0 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -38,6 +38,7 @@ /* CSI_CLKSEL */ #define CSI_CLKSEL_CKP BIT(17) #define CSI_CLKSEL_DAP BIT(16) +#define CSI_CLKSEL_MODE (CSI_CLKSEL_CKP|CSI_CLKSEL_DAP) #define CSI_CLKSEL_SLAVE BIT(15) #define CSI_CLKSEL_CKS GENMASK(14, 1) @@ -408,10 +409,8 @@ static int rzv2m_csi_setup(struct spi_device *spi) writel(CSI_MODE_SETUP, csi->base + CSI_MODE); /* Setup clock polarity and phase timing */ - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_CKP, - !(spi->mode & SPI_CPOL)); - rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_DAP, - !(spi->mode & SPI_CPHA)); + rzv2m_csi_reg_write_bit(csi, CSI_CLKSEL, CSI_CLKSEL_MODE, + ~spi->mode & SPI_MODE_X_MASK); /* Setup serial data order */ rzv2m_csi_reg_write_bit(csi, CSI_MODE, CSI_MODE_DIR, From patchwork Tue Jul 18 19:24:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 122206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1963825vqt; Tue, 18 Jul 2023 12:31:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlFJfsAdGZ8NTAdFFNrL3COEWawMAeS7tzIQQAF8Be0AN7KcTejKnvNLhxe1v/DGSpHCABny X-Received: by 2002:a17:903:32c9:b0:1b5:5162:53bd with SMTP id i9-20020a17090332c900b001b5516253bdmr18663497plr.33.1689708690515; Tue, 18 Jul 2023 12:31:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689708690; cv=none; d=google.com; s=arc-20160816; b=urpVwXkPQ+jmEvscBc7XcI2kpnwca9k3NpAIQuWW+8VhiNP22SqvJOWR/nJ8FeK8vG TZ45Xa+vYM0hXUgdE0nkNycuCTnT7/OkGCLXXAaSbOak0ykg6BHFrzCZ9RvNQJzvZjeA EUF2Cuz67OktVFsP68tV80kT8OoOxM5D3IKEfIgzMr0/BQ7bdc72OmoXBfxanIFpC2/d dRFL5Mf954e5prByuoY4X/0yUcYMuuj0Gmp2lxQmEkJphFZeF6ixKHKeHJTVmwut6Av3 CmC7YOGjXNYLCsRXrw4ib9ep3vMg37XLj/64UM8Tdhax2zIe4pjgIIspOB2U6lXGY1Bi YwdA== 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:from; bh=/fO/+4mqLh1mIksqGFwgLmieo8t6RFOMOsd7lBgBZks=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=OcWgM4eV8zLV534W3TEXzZP4rsUDRx/e4T2cVMr/J7DrZz+F39OQMmezqYkqTXd+r3 rMDWwz3e1cXXlNFf/4fTsZNNbZuB61zwsERbvistHwyA+hbM6LxB8wxyNj2jI77aqrFs EDo96zbLlV6N5Miw6OSEo/nzxNCyy+glrBZJkR5IG9efRbX637GeHhNrjz6ygew1khsc iiGn++QHTFLqolJ/8EN/7tAYnal6voARYoclGA5ayZSgCYLmy1OyUZEfV6xjrjYVF5Nf qzrIlTtjgaarVTzZ3EfjFLIajPlnxCNKLtRLI2bgKuBz3wsXrYu+3gysCTvKrI+KeRys JM3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a170902ac9000b001b5656e7d76si2013659plr.293.2023.07.18.12.31.15; Tue, 18 Jul 2023 12:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230375AbjGRTZT (ORCPT + 99 others); Tue, 18 Jul 2023 15:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjGRTZN (ORCPT ); Tue, 18 Jul 2023 15:25:13 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E602B19A5; Tue, 18 Jul 2023 12:25:09 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,214,1684767600"; d="scan'208";a="169810348" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 19 Jul 2023 04:25:09 +0900 Received: from mulinux.home (unknown [10.226.93.62]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 76FB04067F07; Wed, 19 Jul 2023 04:25:06 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 2/4] spi: rzv2m-csi: Improve data types, casting and alignment Date: Tue, 18 Jul 2023 20:24:51 +0100 Message-Id: <20230718192453.543549-3-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> References: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771787980274646789 X-GMAIL-MSGID: 1771787980274646789 "unsigned int" is more appropriate than "int" for the members of "struct rzv2m_csi_priv". Using void* rather than u8* for txbuf and rxbuf allows for the removal of some type casting. Remove the unnecessary casting of "data" to "struct rzv2m_csi_priv*" in function "rzv2m_csi_irq_handler". Also, members "bytes_per_word" and "errors" introduce gaps in the structure. Adjust "struct rzv2m_csi_priv" and its members usage accordingly. Signed-off-by: Fabrizio Castro Suggested-by: Geert Uytterhoeven Reviewed-by: Geert Uytterhoeven --- v2: This is basically v1 with the addition of changes to the data types of txbuf and rxbuf and related touches. Also, both the title of this patch and its changelog have been changed to reflect the new additions. Although both Geert and Andy kindly allowed for their Reviewed-by tags to used for this patch, I have dropped them in case they want to jump in. drivers/spi/spi-rzv2m-csi.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index faf5898bc3e0..4dbb8c185a8a 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -63,8 +63,8 @@ /* CSI_FIFOTRG */ #define CSI_FIFOTRG_R_TRG GENMASK(2, 0) -#define CSI_FIFO_SIZE_BYTES 32 -#define CSI_FIFO_HALF_SIZE 16 +#define CSI_FIFO_SIZE_BYTES 32U +#define CSI_FIFO_HALF_SIZE 16U #define CSI_EN_DIS_TIMEOUT_US 100 /* * Clock "csiclk" gets divided by 2 * CSI_CLKSEL_CKS in order to generate the @@ -86,16 +86,16 @@ struct rzv2m_csi_priv { struct clk *pclk; struct device *dev; struct spi_controller *controller; - const u8 *txbuf; - u8 *rxbuf; - int buffer_len; - int bytes_sent; - int bytes_received; - int bytes_to_transfer; - int words_to_transfer; - unsigned char bytes_per_word; + const void *txbuf; + void *rxbuf; + unsigned int buffer_len; + unsigned int bytes_sent; + unsigned int bytes_received; + unsigned int bytes_to_transfer; + unsigned int words_to_transfer; + unsigned int bytes_per_word; wait_queue_head_t wait; - u8 errors; + u32 errors; u32 status; }; @@ -157,18 +157,18 @@ static int rzv2m_csi_start_stop_operation(const struct rzv2m_csi_priv *csi, static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi) { - int i; + unsigned int i; if (readl(csi->base + CSI_OFIFOL)) return -EIO; if (csi->bytes_per_word == 2) { - u16 *buf = (u16 *)csi->txbuf; + const u16 *buf = csi->txbuf; for (i = 0; i < csi->words_to_transfer; i++) writel(buf[i], csi->base + CSI_OFIFO); } else { - u8 *buf = (u8 *)csi->txbuf; + const u8 *buf = csi->txbuf; for (i = 0; i < csi->words_to_transfer; i++) writel(buf[i], csi->base + CSI_OFIFO); @@ -182,18 +182,18 @@ static int rzv2m_csi_fill_txfifo(struct rzv2m_csi_priv *csi) static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi) { - int i; + unsigned int i; if (readl(csi->base + CSI_IFIFOL) != csi->bytes_to_transfer) return -EIO; if (csi->bytes_per_word == 2) { - u16 *buf = (u16 *)csi->rxbuf; + u16 *buf = csi->rxbuf; for (i = 0; i < csi->words_to_transfer; i++) buf[i] = (u16)readl(csi->base + CSI_IFIFO); } else { - u8 *buf = (u8 *)csi->rxbuf; + u8 *buf = csi->rxbuf; for (i = 0; i < csi->words_to_transfer; i++) buf[i] = (u8)readl(csi->base + CSI_IFIFO); @@ -207,9 +207,9 @@ static int rzv2m_csi_read_rxfifo(struct rzv2m_csi_priv *csi) static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) { - int bytes_transferred = max_t(int, csi->bytes_received, csi->bytes_sent); - int bytes_remaining = csi->buffer_len - bytes_transferred; - int to_transfer; + unsigned int bytes_transferred = max(csi->bytes_received, csi->bytes_sent); + unsigned int bytes_remaining = csi->buffer_len - bytes_transferred; + unsigned int to_transfer; if (csi->txbuf) /* @@ -217,9 +217,9 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) * hard to raise an overflow error (which is only possible * when IP transmits and receives at the same time). */ - to_transfer = min_t(int, CSI_FIFO_HALF_SIZE, bytes_remaining); + to_transfer = min(CSI_FIFO_HALF_SIZE, bytes_remaining); else - to_transfer = min_t(int, CSI_FIFO_SIZE_BYTES, bytes_remaining); + to_transfer = min(CSI_FIFO_SIZE_BYTES, bytes_remaining); if (csi->bytes_per_word == 2) to_transfer >>= 1; @@ -339,7 +339,7 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi) static irqreturn_t rzv2m_csi_irq_handler(int irq, void *data) { - struct rzv2m_csi_priv *csi = (struct rzv2m_csi_priv *)data; + struct rzv2m_csi_priv *csi = data; csi->status = readl(csi->base + CSI_INT); rzv2m_csi_disable_irqs(csi, csi->status); From patchwork Tue Jul 18 19:24:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 122209 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1971056vqt; Tue, 18 Jul 2023 12:46:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlHB7gWZ2rx4631Kd/rsHTaN/GepR1qegYCQZgyXeNwJhhqsVfqj8j4D8UWl6Nu/bHbLnIta X-Received: by 2002:a05:6512:311a:b0:4fb:94fd:6465 with SMTP id n26-20020a056512311a00b004fb94fd6465mr15076390lfb.15.1689709594623; Tue, 18 Jul 2023 12:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689709594; cv=none; d=google.com; s=arc-20160816; b=Ym3jY39BMFHL8AHg+tTHUC40HH06fKTAJatduI5o9Fu3OaQHUysPX53mSFtPfNNCT1 FYJCSpq45ov9U5B392yAtyHrjiydScgu9DyCAGOTBShhIBC5shiWRCbdkNW2FlfXL3kE 83EpzvBfLEFCl9nKfhWw4Zq5vGXKg5kg5ZrC7KCBM3Kr2zDaHBjApQU1gIMkuiUGZaK+ vHvuo/DUMlDAJPODGyn2lmRfrh5wfmoL+L9Xwm086zSUopA3yWirNi2wJU2MRpB3qsn0 MNLKnQ9P5+Hoq1AiwXIfDPh/2B3X/nTeSK529GvxQtJm6gbnFORmRPTDvLjOpOkaYjL7 rFgg== 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:from; bh=7xhqNgjEsDk/RrfbOBrzAsOPMn1Gi0yNgTt8kph7mXI=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=aDgsI8T6VGZtgT4VnF+hTQ5f/tcRv8TSLtDdkVbD0D8DMYu/4UGyPbNHVPw3VDW6nW UvRwkkXPsjjPloHEx+g3tMFFt9AYXMdijlGQWwEjptwFKWFS/Ep+U+Fy0UN9L3Z1xuXN BZ4J3HzlRXgR8wGG0fIe8cKqMIFawss7MBjwkXeEVIuxPaJnXtCXVJO+hZRPfv1DqefD wwzzaNSGwLSMiYJ827UrzSJGUe7+W7KEx8qWPFUuIOwJb7d8at6pu4niV4bZWRf8nIMe RW1i6PyiggLmp6ujnq8RYnQUWYCIa4KbD8A4vfI5BdY/Zf1KNN8BYy7RhQvNMltYcxXU 2Nsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a056402120c00b005219817ce65si1767774edw.673.2023.07.18.12.46.10; Tue, 18 Jul 2023 12:46:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjGRTZ3 (ORCPT + 99 others); Tue, 18 Jul 2023 15:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230461AbjGRTZU (ORCPT ); Tue, 18 Jul 2023 15:25:20 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0280A1995; Tue, 18 Jul 2023 12:25:13 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,214,1684767600"; d="scan'208";a="173456548" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 19 Jul 2023 04:25:13 +0900 Received: from mulinux.home (unknown [10.226.93.62]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 2A4ED4067FA9; Wed, 19 Jul 2023 04:25:09 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 3/4] spi: rzv2m-csi: Get rid of the x_trg{_words} tables Date: Tue, 18 Jul 2023 20:24:52 +0100 Message-Id: <20230718192453.543549-4-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> References: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771788927511305142 X-GMAIL-MSGID: 1771788927511305142 Table x_trg can be replaced with ilog2(), and table x_trg_words can be replaced with rounddown_pow_of_two(). Replace the tables usage with the corresponding macros. While at it, remove a couple of unnecessary empty lines. Signed-off-by: Fabrizio Castro Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven --- v2: No change. drivers/spi/spi-rzv2m-csi.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 4dbb8c185a8a..62575a61608a 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -99,20 +100,6 @@ struct rzv2m_csi_priv { u32 status; }; -static const unsigned char x_trg[] = { - 0, 1, 1, 2, 2, 2, 2, 3, - 3, 3, 3, 3, 3, 3, 3, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 5 -}; - -static const unsigned char x_trg_words[] = { - 1, 2, 2, 4, 4, 4, 4, 8, - 8, 8, 8, 8, 8, 8, 8, 16, - 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 32 -}; - static void rzv2m_csi_reg_write_bit(const struct rzv2m_csi_priv *csi, int reg_offs, int bit_mask, u32 value) { @@ -230,7 +217,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) * less than or equal to the number of bytes we need to transfer. * This may result in multiple smaller transfers. */ - csi->words_to_transfer = x_trg_words[to_transfer - 1]; + csi->words_to_transfer = rounddown_pow_of_two(to_transfer); if (csi->bytes_per_word == 2) csi->bytes_to_transfer = csi->words_to_transfer << 1; @@ -241,7 +228,7 @@ static inline void rzv2m_csi_calc_current_transfer(struct rzv2m_csi_priv *csi) static inline void rzv2m_csi_set_rx_fifo_trigger_level(struct rzv2m_csi_priv *csi) { rzv2m_csi_reg_write_bit(csi, CSI_FIFOTRG, CSI_FIFOTRG_R_TRG, - x_trg[csi->words_to_transfer - 1]); + ilog2(csi->words_to_transfer)); } static inline void rzv2m_csi_enable_rx_trigger(struct rzv2m_csi_priv *csi, @@ -314,7 +301,6 @@ static int rzv2m_csi_wait_for_tx_empty(struct rzv2m_csi_priv *csi) return 0; ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_TREND, CSI_CNT_TREND_E); - if (ret == -ETIMEDOUT) csi->errors |= TX_TIMEOUT_ERROR; @@ -330,7 +316,6 @@ static inline int rzv2m_csi_wait_for_rx_ready(struct rzv2m_csi_priv *csi) ret = rzv2m_csi_wait_for_interrupt(csi, CSI_INT_R_TRGR, CSI_CNT_R_TRGR_E); - if (ret == -ETIMEDOUT) csi->errors |= RX_TIMEOUT_ERROR; From patchwork Tue Jul 18 19:24:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 122207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1964916vqt; Tue, 18 Jul 2023 12:33:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlFx+NYyReOvg0vzNMUAbpM3go3V/yUyC0LObBQJhEqc8M3BNbepvpRDup9XRZo7sBhJfMy5 X-Received: by 2002:a17:902:c405:b0:1b6:783d:9ba7 with SMTP id k5-20020a170902c40500b001b6783d9ba7mr19008830plk.27.1689708818316; Tue, 18 Jul 2023 12:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689708818; cv=none; d=google.com; s=arc-20160816; b=Q3t00/86XCO3Ihhibii896cFZ9Z4EFKODFoMWfNSUDVxj3IUiTQK4XwCeMrplwN66J nNc2Fn8psDo3KPf//WV1Di6eNtt4ckA/yOgeKgf0O7Ll5ggyTLt5nMtpDtc37jZaX6qs vmS9XJJoJCqxjtANHXVDe02qceC6p3va6MkL0wavr5vlIeRPPYIt5IRERGrP3Zn3ZQcW KZhYHxofGCNPQcv6Zhj8BiEQhJtqoeJCBV5It9GJCCvFNkjVZ1F/RJevE7j/BhggMyor MnMzSrZhMjGQ8H30sicD5e75Smb76PBVokGIfyvOU8LHvgA7nAPwZ3Z/NpTytpN/zUqX 2eLA== 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:from; bh=aPCjjgna0nH74NVgoZ5Fpp2cqN8+5spHkZ3J1hnITPU=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=xy57vxBu0J/rFaCYXyDFCXmebnufHlRtDP/ZxJCID301jQQ8g0aMHTme5mW/YwtGAX flujlnuRGNrYbiVsmHuI/CFPLif97Tzplx+VQZZiKCV9wO9rDUDJIYLVlsUEIv3mTzcV LD0/gafh7no64t5tJJNbnKoPuQ/0kSFW/9aWdhZ3gqUpqe6RAVKATIjx2FIFv4l8+1k8 6Srrm70oVUGNAAWO1obzeA+Q9gJTkV7lnGBCW0hzB700g5R7wePWIGIMK5BR7SoN1emj 8VkM9Sm2L1b71HjnMrDUPkGA6j4HAHEcX0OscaIf9KL4H6wXOMsmCjGWB857x+IpVTxl SiVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a170902d54600b001aaf1734d1dsi2006753plf.241.2023.07.18.12.33.23; Tue, 18 Jul 2023 12:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbjGRTZd (ORCPT + 99 others); Tue, 18 Jul 2023 15:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbjGRTZW (ORCPT ); Tue, 18 Jul 2023 15:25:22 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 199D81BDA; Tue, 18 Jul 2023 12:25:16 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,214,1684767600"; d="scan'208";a="173456562" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 19 Jul 2023 04:25:16 +0900 Received: from mulinux.home (unknown [10.226.93.62]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id C674C4067F07; Wed, 19 Jul 2023 04:25:13 +0900 (JST) From: Fabrizio Castro To: Mark Brown , Geert Uytterhoeven Cc: Fabrizio Castro , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Paterson , Biju Das , Lad Prabhakar , linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 4/4] spi: rzv2m-csi: Make use of device_set_node Date: Tue, 18 Jul 2023 20:24:53 +0100 Message-Id: <20230718192453.543549-5-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> References: <20230718192453.543549-1-fabrizio.castro.jz@renesas.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771788113644837942 X-GMAIL-MSGID: 1771788113644837942 Use device_set_node instead of assigning controller->dev.of_node directly because it also sets the firmware node. Signed-off-by: Fabrizio Castro Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko --- v2: Edited the changelog and added include of property.h, according to the feedback received from Andy. drivers/spi/spi-rzv2m-csi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-rzv2m-csi.c b/drivers/spi/spi-rzv2m-csi.c index 62575a61608a..d098aefa370d 100644 --- a/drivers/spi/spi-rzv2m-csi.c +++ b/drivers/spi/spi-rzv2m-csi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -589,12 +590,13 @@ static int rzv2m_csi_probe(struct platform_device *pdev) init_waitqueue_head(&csi->wait); controller->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; - controller->dev.of_node = pdev->dev.of_node; controller->bits_per_word_mask = SPI_BPW_MASK(16) | SPI_BPW_MASK(8); controller->setup = rzv2m_csi_setup; controller->transfer_one = rzv2m_csi_transfer_one; controller->use_gpio_descriptors = true; + device_set_node(&controller->dev, dev_fwnode(dev)); + ret = devm_request_irq(dev, irq, rzv2m_csi_irq_handler, 0, dev_name(dev), csi); if (ret)