Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7278302rwp; Tue, 18 Jul 2023 12:46:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwP1/1jtTo15r18NJxPOXyD/yTorYVFQBdQLg372sx1LEk7zjxG1hTkmEvWAiHzrGy3vQO X-Received: by 2002:a2e:9890:0:b0:2b5:7fba:18ac with SMTP id b16-20020a2e9890000000b002b57fba18acmr15136264ljj.48.1689709579884; Tue, 18 Jul 2023 12:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689709579; cv=none; d=google.com; s=arc-20160816; b=n45RB5+celLPFx5P7nghOivRbHE50LO3tgyvO2uUAfQA6OyMXpNc2lAnxDv9Sjs0dG YcjbfHK2tAYq9/vUcdMmGuqco5J7KBEEJPyYyvk++hxy5VTPWfzdOybXqvMz53bWW2aK iUC0QpyQWp7Z74RHQpZhDS2eEncUMW3ZpJOC7ZW/Xnh2KyF1OMrk0MInKsXF7Ad9br2G Pl46EWEJYaYaLhgU92rywzT+6uAg4V4OptczXgmMZlhcbuPelCCvClU6jbDNRd8Wpbmt iKTKZ0Rc7DJqr/4qCDLGGM9QwLzNmVQv2kB05qDkxD6AgeTwT5bjQJa0T5g7efxx1h1y l5xg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l23-20020a170906415700b00993b3881ecdsi1574923ejk.687.2023.07.18.12.45.55; Tue, 18 Jul 2023 12:46:19 -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 S230266AbjGRTZ2 (ORCPT + 99 others); Tue, 18 Jul 2023 15:25:28 -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 Content-Transfer-Encoding: 8bit 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 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; -- 2.34.1