From patchwork Sat Jul 15 01:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 120726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2836870vqm; Fri, 14 Jul 2023 19:48:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEb4G8bYesV09Xyd7B1gvX5ZIeXdftkrkNRGavt9QIu8WyJf91HG4cjWI9xC7MPsf3XlX79 X-Received: by 2002:a17:907:900e:b0:982:bbc7:15c0 with SMTP id ay14-20020a170907900e00b00982bbc715c0mr4821644ejc.66.1689389308269; Fri, 14 Jul 2023 19:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689389308; cv=none; d=google.com; s=arc-20160816; b=ddrRTXROwScPOJEMM+MN1Zw1SEydvXvbPvMq8j+lur1mHik4in1hW1TDQAM2eMs7bK gcF2nZqpslMuCS9sVT0gmAObvzYlPcfY76Bjktzm20AOm7hEon03cIEJSowsgdBnv+I8 G+BKXPoCy5lgXnjA3aQWwlNM2VX8tdBu9LlCn8Ruclk0O9viCOvX2fYInF1dRKBHAQg9 8M76KBWHovMY87j1LVzWqrUkIcAiWyTqDCHzHWgiGMWyVVVhvPn+ZZRVIj8mwBvWEEFQ CJ0GSLkp6Mh10y6OFXpMsJEgx9NNm2KaRU4QdC9s5/T5sUdVcsQWTaPJdn8Z6+nRltIM Ks6A== 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=HL+D4nQeb+xia0gyg0Jdz6AiVpSz2jaeXqr0qVO/GYE=; fh=8SPOXdXcsbbrdLjCtKFrhdDDaSSTCLFzjvpt84tri9w=; b=0K7u0iVDxTeIGW03PuuzZPjJ/rSX+5JkekrfcZchoPDwxGAGOkSeJwtIsXoNDZxVNs EYa3Z0WfkYLyp+Z4ylgCiPK/jgSJ84aceKUq3DBRm6ca3/Eix4Cs/vbeagyJ0uqT/lMQ 36DC9lGhX3q4kVgbauo5xNnbhu9B7CP/jtKfPmXQaUwxMbVSYq/aijstFWiGaI9O+Dzf nZNyXHLzyagNdJ11WiaFYDxwDMOijBfqCCkcc3vAvul/KXvmoYBHg0fymmsdsdPUecYs Gk9jgrMpYE4angVgNYqt9l67mL3xdaQrhFr0kHULteGHFOM0exs6YiYSyT/qFppRow4s 5YGg== 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 i20-20020a170906115400b00992acfbcee1si9489286eja.851.2023.07.14.19.48.05; Fri, 14 Jul 2023 19:48:28 -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 S229821AbjGOBFW (ORCPT + 99 others); Fri, 14 Jul 2023 21:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbjGOBFS (ORCPT ); Fri, 14 Jul 2023 21:05:18 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53DA43C3F; Fri, 14 Jul 2023 18:04:55 -0700 (PDT) X-IronPort-AV: E=Sophos;i="6.01,206,1684767600"; d="scan'208";a="172657879" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 15 Jul 2023 10:04:47 +0900 Received: from mulinux.home (unknown [10.226.92.194]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9AA9B40C4DAF; Sat, 15 Jul 2023 10:04:44 +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 09/10] spi: rzv2m-csi: Get rid of the x_trg{_words} tables Date: Sat, 15 Jul 2023 02:04:06 +0100 Message-Id: <20230715010407.1751715-10-fabrizio.castro.jz@renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230715010407.1751715-1-fabrizio.castro.jz@renesas.com> References: <20230715010407.1751715-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: 1771453083006673363 X-GMAIL-MSGID: 1771453083006673363 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 Reviewed-by: Geert Uytterhoeven --- 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 1e5ed1089f42..1874ca1c2747 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) { @@ -216,7 +203,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; @@ -227,7 +214,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, @@ -300,7 +287,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; @@ -316,7 +302,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;