From patchwork Thu Apr 6 17:18:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 80369 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1192823vqo; Thu, 6 Apr 2023 10:34:34 -0700 (PDT) X-Google-Smtp-Source: AKy350bOJPxjcNzzf7KxwccbVt/SayrhtknB72+MsSbt9SubBESr20DdCB80a+uBoc/QWtW8KxTH X-Received: by 2002:a17:902:e846:b0:19e:d6f2:feea with SMTP id t6-20020a170902e84600b0019ed6f2feeamr57906plg.9.1680802474605; Thu, 06 Apr 2023 10:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680802474; cv=none; d=google.com; s=arc-20160816; b=X286I5XjGnXTw2UsedB9WRE8RVQOCzyn4RjwyRrr6eRSfg793ox2fwiAI54Jw/49uY poAnh4YUIb7jVN1iT2ndTuh+1THJ/GAgr8Pf45TmV+CPlG56Bnj5zmAAYd4FVbxr/NBq A3QxnF6w/Kn6ROLy0EUxxVxxpZXcdPkg2SPxGZdPmhLnCSX1RFtLL5MLnqZ+OZp/J4+/ tMKulX59byzjPR7VJf+if2zV9h9FOJZjbJerQyE9uMl1Ka8HshcSzh64EYWXdwP4nV2p E/sbzMu/ZL9nA3paUfqk0OCpEr1bbte0f2k9IoA4hid9j9owY3PZqdyJT0NgbOSdfge4 +CXQ== 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=r6HQuJYz3S7upD6Si1oKW6NxL2CDwgRYaLryBFTMKHaPWTUUQP4FiqTtNmKwuiXxwd tWO7MA2FpuLVFntB6oAvaf89L9fGzvWMdpET93XFS+G3Tr0SXhE4tu5DgW3hKy3w5dB4 e8sVsWL+VadPcdxWAB+rXn7VPAGUUCZZg0YogiBKX8Mpo1PxCH24F5cJJt20Hw0Tcxll HR2tCDrRhJg+49Nkl/0+B24cfluIvoAQ3xFQFYQ6FScAkMvvl1KeGzxPbq6BXavrdJo8 QqQdBFA9SR5TTZb5jTIQVgOWuZ5cJCIDNzAJH+NgI1uJbbUThBRDLqyCL/OP7Ur9QZUP 2o/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bl4w6nXZ; 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 x12-20020a17090300cc00b001a0767b58e7si2024054plc.68.2023.04.06.10.34.22; Thu, 06 Apr 2023 10:34:34 -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=bl4w6nXZ; 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 S239985AbjDFRTC (ORCPT + 99 others); Thu, 6 Apr 2023 13:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239681AbjDFRSk (ORCPT ); Thu, 6 Apr 2023 13:18:40 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3094E8A63; Thu, 6 Apr 2023 10:18:31 -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 698F566031C8; Thu, 6 Apr 2023 18:18:29 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680801509; bh=3rBxNv391K3rouaSGtWY3Lj00PK9hBEW9sLwGyEnlTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bl4w6nXZGqf18D4iiH+vG/e5Wf4FQyayN1k9plwSHhE78gG9RyfROQ7nmV1gBSyBF rgOvHtGwhraHpJGDVCKzvmN0upDAX6/J0FpWxPvmSrnIywJ4IucS1x87tGWs6Muzaw tSd1O3yeOlxtyPnKMnFUEEO/d4fMWchz0gSyR4PHoD5iyyF5ncm5Qfn80NkvcSx0SG +D6XWEg+5ty4LEReXeUBtUyCE0IAIKZk9GVEqnYDBQOJCwrknCfVIV5PGXx4r/RXsV u0TAWwWMCshNiuHxxNbJop+XX7gPT+lAz1CPIhaKmCxjBkDK58NEODNcylatt2nFGv hGcvfIsDgZzPA== 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 v2 6/8] regulator: fan53555: Improve vsel_mask computation Date: Thu, 6 Apr 2023 20:18:04 +0300 Message-Id: <20230406171806.948290-7-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230406171806.948290-1-cristian.ciocaltea@collabora.com> References: <20230406171806.948290-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?1762449135507612946?= X-GMAIL-MSGID: =?utf-8?q?1762449135507612946?= 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;