Commit 411c4597 authored by Yang Yingliang's avatar Yang Yingliang Committed by Greg Kroah-Hartman
Browse files

USB: PHY: JZ4770: Switch to use dev_err_probe() helper



In the probe path, dev_err() can be replaced with dev_err_probe()
which will check if error code is -EPROBE_DEFER and prints the
error name. It also sets the defer probe reason which can be
checked later through debugfs. It's more simple in error path.

Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20220922133323.2135494-2-yangyingliang@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e0b27d38
Loading
Loading
Loading
Loading
+8 −17
Original line number Diff line number Diff line
@@ -321,27 +321,18 @@ static int jz4770_phy_probe(struct platform_device *pdev)
	}

	priv->clk = devm_clk_get(dev, NULL);
	if (IS_ERR(priv->clk)) {
		err = PTR_ERR(priv->clk);
		if (err != -EPROBE_DEFER)
			dev_err(dev, "Failed to get clock\n");
		return err;
	}
	if (IS_ERR(priv->clk))
		return dev_err_probe(dev, PTR_ERR(priv->clk),
				     "Failed to get clock\n");

	priv->vcc_supply = devm_regulator_get(dev, "vcc");
	if (IS_ERR(priv->vcc_supply)) {
		err = PTR_ERR(priv->vcc_supply);
		if (err != -EPROBE_DEFER)
			dev_err(dev, "Failed to get regulator\n");
		return err;
	}
	if (IS_ERR(priv->vcc_supply))
		return dev_err_probe(dev, PTR_ERR(priv->vcc_supply),
				     "Failed to get regulator\n");

	err = usb_add_phy(&priv->phy, USB_PHY_TYPE_USB2);
	if (err) {
		if (err != -EPROBE_DEFER)
			dev_err(dev, "Unable to register PHY\n");
		return err;
	}
	if (err)
		return dev_err_probe(dev, err, "Unable to register PHY\n");

	return devm_add_action_or_reset(dev, ingenic_usb_phy_remove, &priv->phy);
}