mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:04:51 +01:00
usb: phy: generic: Convert to devm_clk_get_optional()
The generic USB PHY driver uses the existence of the "clocks" property to see if a clock is optional or not. Use devm_clk_get_optional() instead, which exists for this purpose. As usb_phy_generic.clk is now either a valid clock pointer or NULL, and all clock operations handle NULL pointers gracefully, several IS_ERR() checks can be removed, simplifying the code. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> ... Link: https://patch.msgid.link/5cc21d821edf5d40f56a74cd251bb1b982876b72.1769004444.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
62b718d233
commit
300034f97b
1 changed files with 9 additions and 19 deletions
|
|
@ -49,15 +49,13 @@ static int nop_set_suspend(struct usb_phy *x, int suspend)
|
|||
int ret = 0;
|
||||
|
||||
if (suspend) {
|
||||
if (!IS_ERR(nop->clk))
|
||||
clk_disable_unprepare(nop->clk);
|
||||
clk_disable_unprepare(nop->clk);
|
||||
if (!IS_ERR(nop->vcc) && !device_may_wakeup(x->dev))
|
||||
ret = regulator_disable(nop->vcc);
|
||||
} else {
|
||||
if (!IS_ERR(nop->vcc) && !device_may_wakeup(x->dev))
|
||||
ret = regulator_enable(nop->vcc);
|
||||
if (!IS_ERR(nop->clk))
|
||||
clk_prepare_enable(nop->clk);
|
||||
clk_prepare_enable(nop->clk);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
@ -137,11 +135,9 @@ int usb_gen_phy_init(struct usb_phy *phy)
|
|||
dev_err(phy->dev, "Failed to enable power\n");
|
||||
}
|
||||
|
||||
if (!IS_ERR(nop->clk)) {
|
||||
ret = clk_prepare_enable(nop->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
ret = clk_prepare_enable(nop->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
nop_reset(nop);
|
||||
|
||||
|
|
@ -155,8 +151,7 @@ void usb_gen_phy_shutdown(struct usb_phy *phy)
|
|||
|
||||
gpiod_set_value_cansleep(nop->gpiod_reset, 1);
|
||||
|
||||
if (!IS_ERR(nop->clk))
|
||||
clk_disable_unprepare(nop->clk);
|
||||
clk_disable_unprepare(nop->clk);
|
||||
|
||||
if (!IS_ERR(nop->vcc)) {
|
||||
if (regulator_disable(nop->vcc))
|
||||
|
|
@ -202,17 +197,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
|
|||
{
|
||||
enum usb_phy_type type = USB_PHY_TYPE_USB2;
|
||||
int err = 0;
|
||||
|
||||
u32 clk_rate = 0;
|
||||
bool needs_clk = false;
|
||||
|
||||
if (dev->of_node) {
|
||||
struct device_node *node = dev->of_node;
|
||||
|
||||
if (of_property_read_u32(node, "clock-frequency", &clk_rate))
|
||||
clk_rate = 0;
|
||||
|
||||
needs_clk = of_property_present(node, "clocks");
|
||||
}
|
||||
nop->gpiod_reset = devm_gpiod_get_optional(dev, "reset",
|
||||
GPIOD_ASIS);
|
||||
|
|
@ -235,15 +226,14 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop)
|
|||
if (!nop->phy.otg)
|
||||
return -ENOMEM;
|
||||
|
||||
nop->clk = devm_clk_get(dev, "main_clk");
|
||||
nop->clk = devm_clk_get_optional(dev, "main_clk");
|
||||
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);
|
||||
return PTR_ERR(nop->clk);
|
||||
}
|
||||
|
||||
if (!IS_ERR(nop->clk) && clk_rate) {
|
||||
if (clk_rate) {
|
||||
err = clk_set_rate(nop->clk, clk_rate);
|
||||
if (err) {
|
||||
dev_err(dev, "Error setting clock rate\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue