@@ -90,6 +90,14 @@ static const struct phy_ops ops = {
.owner = THIS_MODULE,
};
+static void rockchip_usb_phy_action(void *data)
+{
+ struct rockchip_usb_phy *rk_phy = data;
+
+ if (rk_phy->clk)
+ clk_put(rk_phy->clk);
+}
+
static int rockchip_usb_phy_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -124,6 +132,13 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
if (IS_ERR(rk_phy->clk))
rk_phy->clk = NULL;
+ err = devm_add_action(dev, rockchip_usb_phy_action, rk_phy);
+ if (err) {
+ if (rk_phy->clk)
+ clk_put(rk_phy->clk);
+ return err;
+ }
+
rk_phy->phy = devm_phy_create(dev, child, &ops);
if (IS_ERR(rk_phy->phy)) {
dev_err(dev, "failed to create PHY\n");