diff options
Diffstat (limited to 'drivers/usb/musb/phy-am335x-control.c')
-rw-r--r-- | drivers/usb/musb/phy-am335x-control.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/drivers/usb/musb/phy-am335x-control.c b/drivers/usb/musb/phy-am335x-control.c index c84525ec7e..313c67ef7e 100644 --- a/drivers/usb/musb/phy-am335x-control.c +++ b/drivers/usb/musb/phy-am335x-control.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only #include <common.h> #include <init.h> #include <io.h> @@ -7,7 +8,7 @@ #include "am35x-phy-control.h" struct am335x_control_usb { - struct device_d *dev; + struct device *dev; void __iomem *phy_reg; void __iomem *wkup; spinlock_t lock; @@ -101,30 +102,31 @@ static __maybe_unused struct of_device_id omap_control_usb_dt_ids[] = { /* sentinel */ }, }; +MODULE_DEVICE_TABLE(of, omap_control_usb_dt_ids); -struct phy_control *am335x_get_phy_control(struct device_d *dev) +struct phy_control *am335x_get_phy_control(struct device *dev) { struct device_node *node; struct am335x_control_usb *ctrl_usb; - node = of_parse_phandle(dev->device_node, "ti,ctrl_mod", 0); + node = of_parse_phandle(dev->of_node, "ti,ctrl_mod", 0); if (!node) - return NULL; + return ERR_PTR(-ENOENT); dev = of_find_device_by_node(node); if (!dev) - return NULL; + return ERR_PTR(-EPROBE_DEFER); ctrl_usb = dev->priv; if (!ctrl_usb) - return NULL; + return ERR_PTR(-EPROBE_DEFER); return &ctrl_usb->phy_ctrl; } EXPORT_SYMBOL(am335x_get_phy_control); -static int am335x_control_usb_probe(struct device_d *dev) +static int am335x_control_usb_probe(struct device *dev) { struct resource *iores; /*struct resource *res;*/ @@ -141,13 +143,17 @@ static int am335x_control_usb_probe(struct device_d *dev) ctrl_usb->dev = dev; iores = dev_request_mem_resource(dev, 0); - if (IS_ERR(iores)) - return PTR_ERR(iores); + if (IS_ERR(iores)) { + ret = PTR_ERR(iores); + goto free_ctrl; + } ctrl_usb->phy_reg = IOMEM(iores->start); iores = dev_request_mem_resource(dev, 1); - if (IS_ERR(iores)) - return PTR_ERR(iores); + if (IS_ERR(iores)) { + ret = PTR_ERR(iores); + goto release_resource; + } ctrl_usb->wkup = IOMEM(iores->start); spin_lock_init(&ctrl_usb->lock); @@ -155,9 +161,16 @@ static int am335x_control_usb_probe(struct device_d *dev) dev->priv = ctrl_usb; return 0; + +release_resource: + release_region(iores); +free_ctrl: + free(ctrl_usb); + + return 0; }; -static struct driver_d am335x_control_driver = { +static struct driver am335x_control_driver = { .name = "am335x-control-usb", .probe = am335x_control_usb_probe, .of_compatible = DRV_OF_COMPAT(omap_control_usb_dt_ids), |