Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1589121pxb; Mon, 8 Mar 2021 01:03:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfWW2RzquJlwoJ36IaMTzYvmrTd9csU0UM5TnYBrn1MpN/tG5+h0PgieTIHIsBhnirVnrT X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr20855783edb.133.1615194208161; Mon, 08 Mar 2021 01:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615194208; cv=none; d=google.com; s=arc-20160816; b=YoTiLbtEENRgrnD/jwvXjy431yUgWe56ygT0AnHaUBjx3Thz/s67PyOvMoCUSzylG1 2VQdC3ygb+zRospFiNUPyMwh+ODjW86xyWz8obvWdFC/7x0c5LlUXQloSbNQOlAF6hel IhMw58vBq0eiEZJ+yJwd3KriJbplsTTX30rArKkepDeko0DTMOhK83o188yEpNEV5deG EBfsCg26Kh6uPEIWGDEeoAiSSiwMCkQqhyJHtxXkSGGCt1H8KYDbs/1OVC2mONA7qM0d DGt0z0Mral9b/KAsT1dP3taBqldgncH6ppnFA71CF9fyxD8uMO1GXKAm7oNPjcwakiBg GHhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=SBc4yIYAS87btCmSKNU3cwCzlARC1dC5epWFyEK4swc=; b=jIsl6y9LFgTjWWXfDYAkgqBHX2e8UkSiQ0l6rmwhLDzp/a3BYlrcL/PsD6LQaVN5T5 hy/kNFEF9UG2UIHwFbGi8EZWYerGW+WfwLBl9zsj9R9tx/7bp7rVEf/CyjyGI3zi8Te2 Phstik4sBBjzm9cSbDoP1RZmWofDCwI9YlcW+0eMHIf5T3Lpa+nZzEJViDmw6Ms/2Jal eHvAYroKq2LMc7upbtH9rvzVrThN797arUKhEif0kBwf/KCas42X551SN/8LRA92VYK2 +fKewe7Cni+Vvnmabp0aopBHxl/JObt/6BptAdbt0e6ODifKm9J+kBKXweahYxmFnLp4 jAgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CrRU1R4L; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bh4si6543853ejb.554.2021.03.08.01.03.04; Mon, 08 Mar 2021 01:03:28 -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=@ti.com header.s=ti-com-17Q1 header.b=CrRU1R4L; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229740AbhCHJCI (ORCPT + 99 others); Mon, 8 Mar 2021 04:02:08 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:35588 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbhCHJBn (ORCPT ); Mon, 8 Mar 2021 04:01:43 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12891Udw040839; Mon, 8 Mar 2021 03:01:30 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1615194090; bh=SBc4yIYAS87btCmSKNU3cwCzlARC1dC5epWFyEK4swc=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=CrRU1R4LXw0lZ6GKiU8VGPr7D1yUCi7kVXJ2nCN+s+tgIF3I93LyyMWIF4GSuVoca iwJdw/7vzuaA467dRhvjhgxORgFO6LRdsmrQN67xtAfNV1bH84pp8WMS1IuaFtLMcy KJCCUweSYACPft1Gm42F/JU2dKpheSQ3vzPtWShA= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12891U3S060588 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Mar 2021 03:01:30 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 8 Mar 2021 03:01:30 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 8 Mar 2021 03:01:30 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12891TdT085976; Mon, 8 Mar 2021 03:01:30 -0600 Date: Mon, 8 Mar 2021 14:31:28 +0530 From: Pratyush Yadav To: Michael Walle CC: , , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Subject: Re: [PATCH] mtd: spi-nor: use is_power_of_2() Message-ID: <20210308090126.y3scr752sdm6oi5e@ti.com> References: <20210305234552.19204-1-michael@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210305234552.19204-1-michael@walle.cc> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/03/21 12:45AM, Michael Walle wrote: > 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; Reviewed-by: Pratyush Yadav -- Regards, Pratyush Yadav Texas Instruments Inc.