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;