mirror of
https://github.com/torvalds/linux.git
synced 2026-11-23 23:11:40 +00:00
phy: renesas: phy-rcar-gen3-usb2: Fix devm action registration for disabled VBUS regulator
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: 24843404ef ("phy: renesas: phy-rcar-gen3-usb2: Control VBUS for RZ/G2L SoCs")
Signed-off-by: Biju Das <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user