From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD6CF448CED for ; Thu, 6 Aug 2026 10:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786011770; cv=none; b=MkGaTHAod+XZwPoGuPz+tkBWnY8vV7p3U28FWFo5CX/OeGBTETanoTtZUC62KLv1zGotyiPU+Nn00MimFH137GTQTzlgdWYHfK61xoKO8juI5swqOx4dhPZhMbpqwUgSKhh4AGtdLAq9oP/9ChR9Bo8NDQr4hf8kPdU49tmRPVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786011770; c=relaxed/simple; bh=9zrffylo8jvqTayCDjjN90RWF+HfDIBw5zjL1pOp9mk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dnCA1gmRZ74Uu3AqKgQH/MUb+rP+Y1mJLILwm0pRDbXuTrlWUHUEsP5fqzhVq3KgSG4mItRxcJirmwiqPSR8grVrNuc+UU3muW3LCuWFDUxdZXpuUFw3Cgzkb6lCzHpnQEMx49ZSuP9UpkvgdrLh0mDFw6fECCf0pFR074qgqmM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GSNw2yR6; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GSNw2yR6" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-47f7027ca11so1409121f8f.3 for ; Thu, 06 Aug 2026 03:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786011766; x=1786616566; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WwgSPPFxW8r6f/Mf04pgxVIGLx/CCmkzEAjLQ+ITnU8=; b=GSNw2yR6wqHACp0lr9Kr42caByEqhs4CQmqvr97UvOWMk+a2/t8DV2bTEPtrxZJ84N NTkH6XiOk0S/v0bB8BBudYD10OuoaSOdJGzYhCmfRfoxhbv5Rs4mmScgbuGNxV1VRocb DNHBLMDcQZk6M0d5gSAh8hJiSJp+CfpO4EJel03SDdGGudb2FVko07FV5sQTSGdekGEN YPnD/z02De4WJCNGzZizwMJZB4zX+WPIdFoaBoc12EiHZZSUy8Rpl0LMg/7RdcVdxuAe U830qnjmg5RmSrcJF50bpwz+VCPlIK7qAkHpDpWjPZFGRXqN4VdiqVxqLbJHxFWeb5XX A0Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786011766; x=1786616566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WwgSPPFxW8r6f/Mf04pgxVIGLx/CCmkzEAjLQ+ITnU8=; b=qx00u8mtHEKvM7CfBWdCcAqXcwXnX6aHTKRTSpnbD/RGODiZUS221vlZ88Z2miAt2N O2zz4ppjJu5idZ3PM/TInLMhflK/ymT/JT1QD77meUYvMcvLy9Aqd5iRiQ6GFjPcGHsS XIIErpE9ocfXNxMjVlM4HrjTRRZVbuN9iMoszU0vJLGipjgpArzJEQ7SZPdBkfJAwmRO FUsm4t/ZAiUNLwyWAg/uNL1BZqQDClN3x4YlXpswn74aQgIK7VNKB9Rrc0tz+FU0u1NJ w4loH0c0N2J6AqYEXFAumHJaLN05l1OGkRReWbSZTjq9h6IbgP6N9oMK12UC2g4G3a2a gzKA== X-Forwarded-Encrypted: i=1; AHgh+RqHlkvd5QCqZSt9UrlQMWNjxAG0EiJMsUYmRwTRVRhqgycOx8B2ApMQ2CqpP7ENbblGkiB538uDuH+x6bM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9leDcLe5GYinUTsOuN6h9nx407cK7NVVMNp0NOxkfiI7PO9BJ IO/NVG1FuWvFQaQY1jzUqYNoDaTnSHFoL6yUNIYAltxPx2CA312yNrUF X-Gm-Gg: AR+sD117IXUt7fymwOMD7WBOC8eik6wsFR4FlNtd7Za3qO6OTW1cRTstpvfQQ3dKrY/ wyZSXuZUzXSPj4HaktGvh0MP044l6qMT2VRC5pV8pPX2RrvaXhyRqFBDPg1LWJl9hs3aP97IoAA 63gkC9CHQ/0Jb4UK0uQ7pRX3bWDSj2IGeQwrOC3dwXIMj2ZepdxSlh4oBm9/2bN4NiVjBPXbxve IvcycMLvcMR+LTGYuLybM5fGj6t1y8sTeoZ0jac6UY8b+Hvy3UqCcHL+WrGeOsCui193XSZmdt2 7UTpVdBQy0OdV8/+kEcqmPNShf/F3UHVSVCBfd9lpzZ4u9PU7HndMCLdHfPZuBbCOlLRt7/6Q2U VQ+5ghktEbSOjdNAGbRGY+282cZYb66WXj/0kCBiZcuCMSZbwhgw+q29rg2/ngrJOqNOBNQfr2O 7vfqZOw3/+GVw+A4mrx27dU0DjV55OVXaqkKb/jZ/srA9TRZcmFWU4Z7NwD1CHg9bFBn27rxqX1 d5vTEgM60Da X-Received: by 2002:a5d:5e08:0:b0:47f:826c:7422 with SMTP id ffacd0b85a97d-47fec532920mr22349820f8f.17.1786011766127; Thu, 06 Aug 2026 03:22:46 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a702:d301:a173:17cc:14ec:8d1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47ff7b183b2sm5634553f8f.24.2026.08.06.03.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 03:22:45 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: Yoshihiro Shimoda , Vinod Koul , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , Neil Armstrong , Philipp Zabel , linux-renesas-soc@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v6 08/10] phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator Date: Thu, 6 Aug 2026 11:22:27 +0100 Message-ID: <20260806102236.149159-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260806102236.149159-1-biju.das.jz@bp.renesas.com> References: <20260806102236.149159-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Biju Das devm_regulator_get_exclusive() initialises the regulator with enable_count = 1, requiring the consumer to disable it before release. The devm disable action was previously only registered when the caller explicitly requested enable, so when the regulator was left in its initial enabled state without an explicit enable call, the cleanup path skipped decrementing enable_count, triggering a WARN_ON during regulator release on device removal. Fix this by always registering the devm disable action based on the actual enabled state via regulator_is_enabled(), regardless of whether the caller requested an explicit enable. This covers both the explicitly enabled case and the initial state set by devm_regulator_get_exclusive(). Fixes: 24843404efe4 ("phy: renesas: phy-rcar-gen3-usb2: Control VBUS for RZ/G2L SoCs") Signed-off-by: Biju Das --- v5->v6: * No change. v4->v5: * No change. v3->v4: * No change. v2->v3: * No change. v1->v2: * Updated commit description. --- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c index d06fb52ed5f1..ef38c3b365d4 100644 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c @@ -905,15 +905,17 @@ static int rcar_gen3_phy_usb2_vbus_regulator_get_exclusive_enable(struct rcar_ge if (IS_ERR(channel->vbus)) return PTR_ERR(channel->vbus); - if (!enable) - return 0; + if (enable) { + ret = regulator_enable(channel->vbus); + if (ret) + return ret; + } - ret = regulator_enable(channel->vbus); - if (ret) - return ret; + if (regulator_is_enabled(channel->vbus)) + return devm_add_action_or_reset(dev, rcar_gen3_phy_usb2_vbus_disable_action, + channel->vbus); - return devm_add_action_or_reset(dev, rcar_gen3_phy_usb2_vbus_disable_action, - channel->vbus); + return 0; } static int rcar_gen3_phy_usb2_vbus_regulator_register(struct rcar_gen3_chan *channel) -- 2.43.0