Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp103479pxb; Fri, 5 Mar 2021 15:55:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVxFh9BEpM4MGqnA6FLhLTdeNJlaI+hXlvMVrJnY4FcdquQ/cwEZJJpKVMGRbioefBPBMt X-Received: by 2002:aa7:d484:: with SMTP id b4mr11683443edr.63.1614988508711; Fri, 05 Mar 2021 15:55:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614988508; cv=none; d=google.com; s=arc-20160816; b=N3aTbg9jvMfGr5fGe68FzXE1C3qYR682SHn5ImRUOM00OEaA/f1rTsuWP3Ua386hEV bVqJAnlTFn10cb3+SYVpHM4yzt4lgq6OESopxysrdmxwDAhhF4qEq72BKPiHb9KKijbc v9QvzOZuGtnuUZtdz0kGCqMJUpBdGCToUyEYq1S+TvnTrPpZ9or8iSXKJIxUG51Dg5bf NVb2TTIJXdOZ/O0nJ47MDsx0oIvAD6mTn5+W04QaqZgfuKTyc5KpolqGZrafVSTtHqok It2r/TCPt30vfIB49yCmCKDXHy1IneF0odzylftbCtlh88pNWA/1uYDEznRPgCI/q5XC tmuA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=eN73zw785LDN9Maeb4EKVdz3vl/qy3K7dluHlBvPFMk=; b=YIfBc97xGbhR5POjLnmpdSNJGbkEPHMC7gdzHpLXcgWjy3Id9COMJmhCa1q4OlOmsA spZe4pdsc/L/WAm/75M8K8kWuESsK1kvUyLocFm15Aobb9Gbkag5dzDsq1lxybHYTjJI Qvh1Dvf0133UEiatJqwSOuIVmMWOXhpFVdRpXYBgj2I3jfdAHS3UH+/XwR0mbYcR2fNc mBJz6+hJH0nQANfVOkh5lz+muU9e5eRuQdkWVcXGQhJFrlYTH0kHgORugjVAlWi3ilrr Trp0O6C8R8NhBwJJ+Alemd4QfWstW42zkTZ6UCw0GT3TgXRIY4SX2Gc+6+hGz93ZXNIz 7itg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=C21hvFv5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y4si2306954edm.19.2021.03.05.15.54.46; Fri, 05 Mar 2021 15:55:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=C21hvFv5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbhCEXqQ (ORCPT + 99 others); Fri, 5 Mar 2021 18:46:16 -0500 Received: from ssl.serverraum.org ([176.9.125.105]:33397 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbhCEXqF (ORCPT ); Fri, 5 Mar 2021 18:46:05 -0500 Received: from mwalle01.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:fa59:71ff:fe9b:b851]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 6C2BD22172; Sat, 6 Mar 2021 00:46:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1614987964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eN73zw785LDN9Maeb4EKVdz3vl/qy3K7dluHlBvPFMk=; b=C21hvFv5AvHFAKzlLETGUAPy+zSKh7Gbr9wZeOEcMLzMI0wxnGDaurc3hoPxM5dvbsryi/ pR9HFxa9aBByDCZBvCIUMWvR+plslxrddbYSMwpBQ4Fypwd2QSlRwU3XapccSQWxyNWX9E KY2TaCucxZXx0wP+pTp0CxN6rsXhNvU= From: Michael Walle To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Michael Walle Subject: [PATCH] mtd: spi-nor: use is_power_of_2() Date: Sat, 6 Mar 2021 00:45:52 +0100 Message-Id: <20210305234552.19204-1-michael@walle.cc> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is already a function to check if an integer is a power of 2. Use it. Signed-off-by: Michael Walle --- drivers/mtd/spi-nor/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0522304f52fa..4a315cb1c4db 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2336,11 +2336,8 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, * If page_size is a power of two, the offset can be quickly * calculated with an AND operation. On the other cases we * need to do a modulus operation (more expensive). - * Power of two numbers have only one bit set and we can use - * the instruction hweight32 to detect if we need to do a - * modulus (do_div()) or not. */ - if (hweight32(nor->page_size) == 1) { + if (is_power_of_2(nor->page_size)) { page_offset = addr & (nor->page_size - 1); } else { uint64_t aux = addr; -- 2.20.1