Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35539463rwd; Mon, 10 Jul 2023 08:51:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlEcMrnCqY3WoQpnsZji5+WU0iOCQr7WJqEBsxDF7biOxQ6W9RGxNkK0jSFkaZm3D/i572le X-Received: by 2002:a05:6a00:847:b0:680:d00c:b164 with SMTP id q7-20020a056a00084700b00680d00cb164mr17825229pfk.34.1689004302955; Mon, 10 Jul 2023 08:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689004302; cv=none; d=google.com; s=arc-20160816; b=V8TDjNASD/YqkEiQb7J/QZSNWymaQFvWXUjX5PipZaaPveEvF5CZO0uq5PwHIVaK/X /5UYGADnEJ8qPC+0/Ns43CQIjHLyMUHMJdrl2eRGNbzL2256n5HKl1Xf0pVDY06g7E5A 1uVVrMHN+WJjfaZ+qkP6JFNv3alxwyVfiU88TSoiDISdd8MzInflBRU/WL3oXaqCsGY6 fY7sJi50w59W03/lCsHwIHRSwDLDT9nY0xBHukGPsZ3WXjp0grzAZ0Mo4CdcV0EL/JXu aUBtHFDMDk0zrtAjEx+k2bblmLDCHPINq8iDmwy2/+vRSum/Uow0dWEGkyEr17jrjOrv jG+A== 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 :dkim-signature; bh=w39HcD/C+m8DBdOohl92QIDnMjeqtcf1GqHEJ0IQ5f4=; fh=CWfEt6/vd4IsHMc+T8W3bMkH4b5uOoX72TeJSijIGlU=; b=Cp/76UrVF5wLTUsghAwzs9qCK5uummVb6UwoRkWX/1hFUlmMsBlktVqvmwL9/xSNFc vZYER36xRzUy56QUdvJa1+IuLaIPxFgEFPpI7OqrJX8aD2T4ovTGiOyRe1zTYzj9dqJu e/w7Xnn6AB4j9h0AGfANf9iuz73T9Yz4ZVrb0QY89vPXdIAF8SNPRS230LxKA/44rOyP KRw5ByE+ElKdAjkGi9Csf1JuuUV4AjqDouhQYhP863/4Mf91o96srpM3pqbIj3KezWFD 8050ZhL+0h5Fs0AVBN+piRzULeE0B5gK6g72WDu1+YvalFPVWddr8Oh551Vd80rl97By EZUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="c9A/RJz0"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv127-20020a632e85000000b0054fd6863325si8925071pgb.726.2023.07.10.08.51.28; Mon, 10 Jul 2023 08:51:42 -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; dkim=pass header.i=@intel.com header.s=Intel header.b="c9A/RJz0"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbjGJPt7 (ORCPT + 99 others); Mon, 10 Jul 2023 11:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233590AbjGJPtt (ORCPT ); Mon, 10 Jul 2023 11:49:49 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2854187; Mon, 10 Jul 2023 08:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689004186; x=1720540186; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vBn0rQkEvhyNS8x5dx+OCo1BBkRa+6Quzvw7Xp2sQ+U=; b=c9A/RJz0XWvj4cFFGeif9AVCOZqiLSpQ8sgFktP0B1GyWNDV5yWYliDS 05KHFZC0+Aflt2QmRPURtcDynjEaHW0HtKYmn7JgxRIdS69U8fQUvtIdQ xGDcodwh1/1ESHelVNJzE0XQf4QzaMkifWvrZv5dQnVM5KALB92pYSyHZ sJZNiGxVw2IWpqBpTRECRpr5+8TZd+Dg9aNkjFTt0ZaMWNhZKAqNlPJBi 0mW8MNdcg6jq5LVKgknka2ruzDX1thNg60GNqMSUQ9Z0ok40Ui05s1brE pYcayTM9fWpDrbi/5/jBIfdKzI2yLH+YHa5B1uGZhoCVni9drxZO/H2/W A==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="349185378" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="349185378" 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:44 -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=20Kleine-K=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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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); -- 2.40.0.1.gaa8946217a0b