Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp931899lql; Tue, 12 Mar 2024 02:20:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXfszgqW7dmPxh1VsNk9hGVGKZghliCqqewUXPkWiWiBDiqWLZZqpX8TRj364t7bGJhDY9nKR4sHCo/zvc6I345/ZHKlEctnNlEtzKTg== X-Google-Smtp-Source: AGHT+IGvbPmKtknsLKFuvCQbVWuoVgmwQjwhgja2ug4zwHdBx37kIvTKnxUouUZ4jkvGjjrGsEhJ X-Received: by 2002:a25:6c09:0:b0:dd0:453b:485e with SMTP id h9-20020a256c09000000b00dd0453b485emr5096108ybc.58.1710235229588; Tue, 12 Mar 2024 02:20:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710235229; cv=pass; d=google.com; s=arc-20160816; b=GDuaXG5cHjYz/7CjU1TnpfyZEiys/vvS3Ab6H9z7TrLhAoaXFEN78sv2k782ueGkJ0 5fR0qPwiS9z+LgCdZyPqqMUylF/V//4uS7Xmwz2N9SNFrVQTjCt1oi8sRTjNH52U8F5a VcqMw8m0ZnD4W6k5v/zH24rlDLIe4BCsoizk6bISK8BzloubUH6Gi/XgOG+pjv0WoyaM XQQr5MA6pb7bfXh5M+Vm5nopjLDYZWg/6mZVb8c+iHpyak3kviuTyqJHAMVP48ZCDR+T 3QltShw2tpvr64GQcH05/kPMgV8mJnkha72OR1rtRBVhoW/dDtNqJcZJCR347bA5Gp5V p6Ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=NLQUNOLqCOUn2wdFP82EZjhVPZ0pd7rP48tSbRo2xXM=; fh=EcHGoTkoUb1TdQDyE7nwrrwJRFDn2WmOP/IoKGHM/zo=; b=bG9DZbsxgfgATWuwd3XmVA2hB1Tu0eWdIGqcAVvImcBFW9skbZHsrKM2iYSzYUKxSp ZsVbw7AT7shrKPZdwhFHHzeBBHV2GejZwIlyIBL/t+1v1nVUpltRlMDRuC0puWJHIf07 5rlgmuG+XzNLWSZFgnWd42+Regd+/NMUdbuDg6V4c08LeIbkYzFFHA0AnJikSmZBGd4G Qg5LPF35iajGNoU0Et3zFUfWlOgW+DAw26GE+DsI4KC80oqYLcMtJIrcnquZwvygOT6Y IbxLxCgHZGUzZcnmfeEpoYFFO0CikaTKzPzO0eWjXiNTmy1N5PlX/av7LQoEOxqrcySe C9Ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iEMB7xDZ; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-100005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u3-20020ac858c3000000b0042f20f2c840si6956030qta.704.2024.03.12.02.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 02:20:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iEMB7xDZ; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-100005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 51A2C1C21D81 for ; Tue, 12 Mar 2024 09:20:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 822587AE4F; Tue, 12 Mar 2024 09:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iEMB7xDZ" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518997A15A for ; Tue, 12 Mar 2024 09:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710235056; cv=none; b=kax37p7XhqY022f38YihhdHhkTgdZ66HPW20rvbwEKZUXfB8cTeg1Ck5KJjLLd72nv9UCJpJLYgdmkxsC44f53icM2ixKITjrTrpnKXUwAgGKSi4EHCBeswgVp0uArP+Unk3do/+M3oqltWLdwilk0PAKDVsw53LGwFH+SmsswU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710235056; c=relaxed/simple; bh=96gu/HF0E/TqgKrIVV5r7UQM0Lg+1Xe5Ztq6xGJ0d8A=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=QKom9KRMvluvb56kDP23EX1fK0vbRuicg16etGcbEwFsi9CC+BYuQAuGEk5nyj9mDC51PfvZ68i72y79o82E6TPSx0D3QYmqNBA3GOQMhthYNIYswTy0zjgO6ifUzWb+QxIA8uomCiUvWnENid86i3HLsBvwlM9lnaPJ3+BW+kw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iEMB7xDZ; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C2D4F1BF20A; Tue, 12 Mar 2024 09:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710235046; 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=NLQUNOLqCOUn2wdFP82EZjhVPZ0pd7rP48tSbRo2xXM=; b=iEMB7xDZHZg+RIx3cNrgdZUXBvVhD1jDSy0HKUHSL49fNiYgqr8MqsOk/+9FpEoCASyRI0 Q+wlFk/QM5fvMF0nL865qkyoUGy8IqdFPVYyF2PTpaOeysDF8Uc2/2B61v3a4gvknIK9yS N4rDPTDEfl/bnKNB+5LcsmqRLdfd20Gzc7sIq5kDX6TmG4JyFbqsVDBgS6UC2E0FMQwicO VWf74WLvQ377NiAFDHlPslbyfX60PdKXFINQb+CtAhT+ATOFr8egTSMXJawbo+ybtZ2Dv2 C4XoUeHpgDnjsexamJjNsyDPvSxv0OSsv2pQ2/ccvjigxWdFr3u6cxj3p/fMHw== From: Kory Maincent To: linux-kernel@vger.kernel.org Cc: Kory Maincent , thomas.petazzoni@bootlin.com, Liam Girdwood , Mark Brown Subject: [PATCH] regulator: core: Propagate the regulator state in case of exclusive get Date: Tue, 12 Mar 2024 10:16:38 +0100 Message-Id: <20240312091638.1266167-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: kory.maincent@bootlin.com Previously, performing an exclusive get on an already-enabled regulator resulted in inconsistent state initialization between child and parent regulators. While the child's counts were updated, its parent's counters remained unaffected. Consequently, attempting to disable an already-enabled exclusive regulator triggered unbalanced disables warnings from its parent regulator. This commit addresses the issue by propagating the enable state to the parent regulator using a regulator_enable call. This ensures consistent state management across the regulator hierarchy, preventing warnings! Signed-off-by: Kory Maincent --- drivers/regulator/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a968dabb48f5..3f499761f8b0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2274,6 +2274,17 @@ struct regulator *_regulator_get(struct device *dev, const char *id, if (ret > 0) { rdev->use_count = 1; regulator->enable_count = 1; + + /* Propagate the regulator state to its supply */ + if (rdev->supply) { + ret = regulator_enable(rdev->supply); + if (ret < 0) { + destroy_regulator(regulator); + module_put(rdev->owner); + put_device(&rdev->dev); + return ERR_PTR(ret); + } + } } else { rdev->use_count = 0; regulator->enable_count = 0; -- 2.25.1