From patchwork Thu Apr 6 19:41:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 671831 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59CC8C76196 for ; Thu, 6 Apr 2023 19:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238096AbjDFTmk (ORCPT ); Thu, 6 Apr 2023 15:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237472AbjDFTm0 (ORCPT ); Thu, 6 Apr 2023 15:42:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0AAAA245; Thu, 6 Apr 2023 12:42:21 -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 81D2866031ED; Thu, 6 Apr 2023 20:42:20 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680810140; bh=3rBxNv391K3rouaSGtWY3Lj00PK9hBEW9sLwGyEnlTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EUXiqy5XrwJiWDpluiGuRSuDuPcb2xZLn6UTsz5p1jUmRonWnMEBji9XPm6hGS0Nu bCatyGmEkkJTjWin7L5ipoW694UikATPzvbvBaEY3BeR4mxb0Xor5s+EOjFwDApodX D7EG+UkH7xFKFEuSRD2mYgFRh1dR2NEIy3jQoYvW0S4L21BFvl6gWZCoTeJa7QU8us 4qjppkApegQMDfF2oSHdJQAgNT3BYYPLfMUP2xGLwIYvzKquDf9fkXSVr1c/vWe8Ai qjHnT4eqyp7bvuW1g1NiSCV0r1qeazVzlQtPbucscHhSlqHZ24t+9XPw6fhw4V6jV/ lcoqXnRCFwA8Q== 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 v3 6/8] regulator: fan53555: Improve vsel_mask computation Date: Thu, 6 Apr 2023 22:41:56 +0300 Message-Id: <20230406194158.963352-7-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230406194158.963352-1-cristian.ciocaltea@collabora.com> References: <20230406194158.963352-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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;