From patchwork Wed Apr 5 19:47:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 79892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp552855vqo; Wed, 5 Apr 2023 12:52:21 -0700 (PDT) X-Google-Smtp-Source: AKy350Z6p3ktLA7oEn0dw8EmDWomJSC55IOsTpQmzz1iionZC4hdJgkooFvHKc1/kWW1DXDVP7kE X-Received: by 2002:a17:906:d8c6:b0:8e9:afb1:65c6 with SMTP id re6-20020a170906d8c600b008e9afb165c6mr3272557ejb.13.1680724341715; Wed, 05 Apr 2023 12:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680724341; cv=none; d=google.com; s=arc-20160816; b=cIXKXQa+AlufPDBZWrMTtLyBJWzFTKIgjsHwyEWQDr3my/KFlZJyjCZV0qJdOT4hkg aT0987zEuW+tNXX5Kl2rcAODlzSm4W2r+uVuZdTPWcmE5VKhTBvWLlRoNC8NeJbg1BDL IiGoDtdI5UkeueB/2fOuDo5IQcCBYRWkWPfA4XscKOiZsYiBaYXhRJhBaQUBm9S3plhj pRHIb+8tsFnJUjarLWryAjIW7vI2TUPi2P1Cw49BKZRkNo6hE/OvaWZo3C2lkU4vimrx hV3+l6jijKZ5pXTvKsQogtVcsTOezcK5S+N7wN6VokaLAFCAsStRvGaAQdF6Axh24xd4 O4NQ== 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=/cXCL/lhl2q9N+8AhilWbHqXjXE0F8hhkrOWrfcURFM=; b=i/SwyFacF6oMKT79zLf8EpR+p0kP7n52UzUrRHbgpyaU1wxqLhNY4hUUNHI8tDWe2r pJtBWBSYIFl461hxUG5+Gx79sYJBf+o1DEDLJdujv0eAVK4rAdYzF5BOVz2YukMGgmXr n0fvtEblS6A/FX1H4jofLYitYivqqK+MEA09xc7mk4dVjX2PtzJTuZ/vadKqAnlcMnEc cME9266yzPBMgd6djo/hv1gG3mjlaNIAKtNE4u7bhC0Cftf1ODvL+r6wvdu0SMgxUCe6 PyJe68ohmndc4m6Jl+1xMrUY6Vq34Fj7ecCH0nwj2YPX03nlALMwzBIcAew6czI6DLno drlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EnhXiLNm; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n20-20020a1709067b5400b00939d46bb776si5023586ejo.60.2023.04.05.12.51.57; Wed, 05 Apr 2023 12:52:21 -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=@collabora.com header.s=mail header.b=EnhXiLNm; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234009AbjDETsr (ORCPT + 99 others); Wed, 5 Apr 2023 15:48:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234248AbjDETsZ (ORCPT ); Wed, 5 Apr 2023 15:48:25 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB18B126; Wed, 5 Apr 2023 12:48:07 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id A5592660319A; Wed, 5 Apr 2023 20:48:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680724085; bh=3rBxNv391K3rouaSGtWY3Lj00PK9hBEW9sLwGyEnlTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EnhXiLNmJCUAUTpemSZKRY6QGx5m8BuVXFtUZHtmDPKjHE8BGmqcB/1U4cWOywysj feO9LKSQNtsbWg5ZOuQ/SuQEjQFeqftQ8LHI3iL3NTYzj296jWJcbf6+uke8JIpa2g mMrz8y6OoSiJjMGAr0//NYoURi3l1qPrCr3WnjL/EqimSo868HwgY/mD4ibbsXjB+B 9cYIdsNoEMME6b475woL7TVaKliMpdeZjlj94uam2NelYt8yYB8WetxvvvdnlermSI SCYPGD2Al88qM2VicPFs3s4jxfLDvyi5JF2vZocNkWsPBOWDUu6nwEYW5bgz6hSMsJ I77fmCpMfTv6A== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Bjorn Andersson , Joseph Chen , Ezequiel Garcia Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel@collabora.com Subject: [PATCH 6/8] regulator: fan53555: Improve vsel_mask computation Date: Wed, 5 Apr 2023 22:47:19 +0300 Message-Id: <20230405194721.821536-7-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405194721.821536-1-cristian.ciocaltea@collabora.com> References: <20230405194721.821536-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762367207131224073?= X-GMAIL-MSGID: =?utf-8?q?1762367207131224073?= In preparation for introducing support for additional regulators which do not use the maximum number of voltage selectors available for a given mask, improve the mask computation formula by using fls(). Note fls() requires the bitops header, hence include it explicitly and drop bits.h which is already pulled by bitops.h. Signed-off-by: Cristian Ciocaltea --- drivers/regulator/fan53555.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 181e5eb00e7a..39c9c29f4ff6 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -8,7 +8,7 @@ // Copyright (c) 2012 Marvell Technology Ltd. // Yunfan Zhang -#include +#include #include #include #include @@ -486,7 +486,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, rdesc->min_uV = di->vsel_min; rdesc->uV_step = di->vsel_step; rdesc->vsel_reg = di->vol_reg; - rdesc->vsel_mask = di->vsel_count - 1; + rdesc->vsel_mask = BIT(fls(di->vsel_count - 1)) - 1; rdesc->ramp_reg = di->slew_reg; rdesc->ramp_mask = di->slew_mask; rdesc->ramp_delay_table = di->ramp_delay_table;