Skip to content

Commit

Permalink
usb: phy: phy-generic: propagate clk_get error if clock is required
Browse files Browse the repository at this point in the history
If the clock handle is given in the DT, it means the clock is required
for proper operation of the PHY. In that case a failure to obtain the
clock must be propagated to stop the driver from probing. This fixes
working with clocks, which request probe deferral.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
  • Loading branch information
Lucas Stach authored and Felipe Balbi committed Oct 19, 2017
1 parent bbb1cc0 commit f9c5d1d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/usb/phy/phy-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
int err = 0;

u32 clk_rate = 0;
bool needs_vcc = false;
bool needs_vcc = false, needs_clk = false;

if (dev->of_node) {
struct device_node *node = dev->of_node;
Expand All @@ -233,6 +233,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
clk_rate = 0;

needs_vcc = of_property_read_bool(node, "vcc-supply");
needs_clk = of_property_read_bool(node, "clocks");
nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
GPIOD_ASIS);
err = PTR_ERR_OR_ZERO(nop->gpiod_reset);
Expand Down Expand Up @@ -275,6 +276,8 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
if (IS_ERR(nop->clk)) {
dev_dbg(dev, "Can't get phy clock: %ld\n",
PTR_ERR(nop->clk));
if (needs_clk)
return PTR_ERR(nop->clk);
}

if (!IS_ERR(nop->clk) && clk_rate) {
Expand Down

0 comments on commit f9c5d1d

Please sign in to comment.