Skip to content

Commit 662bb17

Browse files
tititiou36vinodkoul
authored andcommitted
phy: renesas: rcar-gen3-usb2: Fix an error handling path in rcar_gen3_phy_usb2_probe()
If an error occurs after the reset_control_deassert(), reset_control_assert() must be called, as already done in the remove function. Use devm_add_action_or_reset() to add the missing call and simplify the .remove() function accordingly. While at it, drop struct rcar_gen3_chan::rstc as it is not used aymore. [claudiu.beznea: removed "struct reset_control *rstc = data;" from rcar_gen3_reset_assert(), dropped struct rcar_gen3_chan::rstc] Fixes: 4eae163 ("phy: renesas: rcar-gen3-usb2: Add support to initialize the bus") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://patch.msgid.link/20251023135810.1688415-3-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent bc6f8b7 commit 662bb17

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

drivers/phy/renesas/phy-rcar-gen3-usb2.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ struct rcar_gen3_chan {
134134
struct extcon_dev *extcon;
135135
struct rcar_gen3_phy rphys[NUM_OF_PHYS];
136136
struct regulator *vbus;
137-
struct reset_control *rstc;
138137
struct work_struct work;
139138
spinlock_t lock; /* protects access to hardware and driver data structure. */
140139
enum usb_dr_mode dr_mode;
@@ -771,21 +770,31 @@ static enum usb_dr_mode rcar_gen3_get_dr_mode(struct device_node *np)
771770
return candidate;
772771
}
773772

773+
static void rcar_gen3_reset_assert(void *data)
774+
{
775+
reset_control_assert(data);
776+
}
777+
774778
static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel)
775779
{
776780
struct device *dev = channel->dev;
781+
struct reset_control *rstc;
777782
int ret;
778783
u32 val;
779784

780-
channel->rstc = devm_reset_control_array_get_shared(dev);
781-
if (IS_ERR(channel->rstc))
782-
return PTR_ERR(channel->rstc);
785+
rstc = devm_reset_control_array_get_shared(dev);
786+
if (IS_ERR(rstc))
787+
return PTR_ERR(rstc);
783788

784789
ret = pm_runtime_resume_and_get(dev);
785790
if (ret)
786791
return ret;
787792

788-
ret = reset_control_deassert(channel->rstc);
793+
ret = reset_control_deassert(rstc);
794+
if (ret)
795+
goto rpm_put;
796+
797+
ret = devm_add_action_or_reset(dev, rcar_gen3_reset_assert, rstc);
789798
if (ret)
790799
goto rpm_put;
791800

@@ -924,7 +933,6 @@ static void rcar_gen3_phy_usb2_remove(struct platform_device *pdev)
924933
if (channel->is_otg_channel)
925934
device_remove_file(&pdev->dev, &dev_attr_role);
926935

927-
reset_control_assert(channel->rstc);
928936
pm_runtime_disable(&pdev->dev);
929937
};
930938

0 commit comments

Comments
 (0)