From patchwork Mon Jul 10 15:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13307319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B012FEB64DA for ; Mon, 10 Jul 2023 15:50:04 +0000 (UTC) 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=jdCXJjuw2QySrOH7loO/oUQJzwJ3INo0cI1NkyR8ays=; b=uJk8Xk0FVe1sxx Kz9ZPf00jbHfBGzhaBw1SGY2Jz9y+Vc/58e5bxnGTBJGtYQHY9v3ZEqu6hoqkpWQOOYJYX9qk9oaG dAtDtRfC2eFjAktDFjs/yAZdpNdp7Fb2FJBLbpWUF9qLgdaKwluI8zmPxa94aAmYdSN1CWkHIeG4N LUa248ji1HQpeVT7CiIp8GR1F7ibp2KM0SeX3iFEZzy7rkoQ2wkhwQeuI+Aw04ifAeNPKxhWFU4g3 KaGKkhfonhma0wlz2kVh9+aKhUZaUDjD8YB9x8wrbq7HYclNSbmMEjUR14H1N+pBXeY06Fzk+J4i+ 0OEIJjhk1EJ6WMX8jufw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qIt9E-00C3sS-0X; Mon, 10 Jul 2023 15:50:00 +0000 Received: from mga18.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qIt8y-00C3dD-2s; Mon, 10 Jul 2023 15:49:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689004184; x=1720540184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vBn0rQkEvhyNS8x5dx+OCo1BBkRa+6Quzvw7Xp2sQ+U=; b=V33IaE2mXpiIpnQTcrmlzcAUutwU1uXSFTkWKsrjNX8sEsdkFJ2at3r0 gP97/z8BNwBd9r4I2maWR/aXDQiutwYk56V7va0rgbcshjivkirl9gxO5 z/Xm4Rdf0vpntZNpH10w7oZx3JgyNeG0xV7SMVYwHxcfQpBijwYg3oX0X rRcmhkhGW+NJbHX6TLe+7NsrSrVfN6fSqbz7uhlmCe8hG6Znxm4GfbUMs eSLspUfwYLfgzlWjdfNsenTg5/rbxdLKgu67LRng/d4zjsZuVATId9KE1 PJepFNRRwAKzvCn22PdQPDBMrGjq2oGjZe9rCtlyCcO76wtTKoJkNRef+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="349185371" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="349185371" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 08:49:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="844921835" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="844921835" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 10 Jul 2023 08:49:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4B00D3E3; Mon, 10 Jul 2023 18:49:34 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Cristian Ciocaltea , Yang Yingliang , Andy Shevchenko , Amit Kumar Mahapatra via Alsa-devel , Neil Armstrong , Tharun Kumar P , Vijaya Krishna Nivarthi , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Sanjay R Mehta , Radu Pirea , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Tudor Ambarus , Serge Semin , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Matthias Brugger , AngeloGioacchino Del Regno , Andy Gross , Bjorn Andersson , Konrad Dybcio , Heiko Stuebner , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Max Filippov , Steven Rostedt , Masami Hiramatsu , Richard Cochran Subject: [PATCH v2 03/15] spi: Replace if-else-if by bitops and multiplications Date: Mon, 10 Jul 2023 18:49:20 +0300 Message-Id: <20230710154932.68377-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230710154932.68377-1-andriy.shevchenko@linux.intel.com> References: <20230710154932.68377-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230710_084944_984489_FE94A55D X-CRM114-Status: GOOD ( 11.29 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Instead of if-else-if, simply call roundup_pow_of_two(BITS_PER_BYTES()). Note, there is no division assumed as compiler may optimize it away. Signed-off-by: Andy Shevchenko --- drivers/spi/spi.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 6d74218cf38e..125dea8fae00 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -3643,13 +3643,7 @@ int spi_split_transfers_maxwords(struct spi_controller *ctlr, size_t maxsize; int ret; - if (xfer->bits_per_word <= 8) - maxsize = maxwords; - else if (xfer->bits_per_word <= 16) - maxsize = 2 * maxwords; - else - maxsize = 4 * maxwords; - + maxsize = maxwords * roundup_pow_of_two(BITS_TO_BYTES(xfer->bits_per_word)); if (xfer->len > maxsize) { ret = __spi_split_transfer_maxsize(ctlr, msg, &xfer, maxsize, gfp);