mirror of
https://github.com/torvalds/linux.git
synced 2024-11-05 19:41:54 +00:00
usb: gadget: pxa25x_udc: use devm_ functions
This patch introduces the use of devm_request_irq, devm_gpio_request, devm_clk_get etc. instead of the corresponding unmanaged interfaces. The calls to the functions like free_irq to free the allocated resources are removed as they are no longer required. Some labels in the probe function are also done away with and the name of the label err_gpio_pullup is changed to make it less specific to the context. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
fc7af215f9
commit
c63d2225e7
@ -2105,11 +2105,9 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
|
|||||||
if (irq < 0)
|
if (irq < 0)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
dev->clk = clk_get(&pdev->dev, NULL);
|
dev->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(dev->clk)) {
|
if (IS_ERR(dev->clk))
|
||||||
retval = PTR_ERR(dev->clk);
|
return PTR_ERR(dev->clk);
|
||||||
goto err_clk;
|
|
||||||
}
|
|
||||||
|
|
||||||
pr_debug("%s: IRQ %d%s%s\n", driver_name, irq,
|
pr_debug("%s: IRQ %d%s%s\n", driver_name, irq,
|
||||||
dev->has_cfr ? "" : " (!cfr)",
|
dev->has_cfr ? "" : " (!cfr)",
|
||||||
@ -2120,15 +2118,16 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
|
|||||||
dev->dev = &pdev->dev;
|
dev->dev = &pdev->dev;
|
||||||
dev->mach = dev_get_platdata(&pdev->dev);
|
dev->mach = dev_get_platdata(&pdev->dev);
|
||||||
|
|
||||||
dev->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
|
dev->transceiver = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2);
|
||||||
|
|
||||||
if (gpio_is_valid(dev->mach->gpio_pullup)) {
|
if (gpio_is_valid(dev->mach->gpio_pullup)) {
|
||||||
if ((retval = gpio_request(dev->mach->gpio_pullup,
|
retval = devm_gpio_request(&pdev->dev, dev->mach->gpio_pullup,
|
||||||
"pca25x_udc GPIO PULLUP"))) {
|
"pca25x_udc GPIO PULLUP");
|
||||||
|
if (retval) {
|
||||||
dev_dbg(&pdev->dev,
|
dev_dbg(&pdev->dev,
|
||||||
"can't get pullup gpio %d, err: %d\n",
|
"can't get pullup gpio %d, err: %d\n",
|
||||||
dev->mach->gpio_pullup, retval);
|
dev->mach->gpio_pullup, retval);
|
||||||
goto err_gpio_pullup;
|
goto err;
|
||||||
}
|
}
|
||||||
gpio_direction_output(dev->mach->gpio_pullup, 0);
|
gpio_direction_output(dev->mach->gpio_pullup, 0);
|
||||||
}
|
}
|
||||||
@ -2146,30 +2145,32 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
|
|||||||
dev->vbus = 0;
|
dev->vbus = 0;
|
||||||
|
|
||||||
/* irq setup after old hardware state is cleaned up */
|
/* irq setup after old hardware state is cleaned up */
|
||||||
retval = request_irq(irq, pxa25x_udc_irq,
|
retval = devm_request_irq(&pdev->dev, irq, pxa25x_udc_irq, 0,
|
||||||
0, driver_name, dev);
|
driver_name, dev);
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
pr_err("%s: can't get irq %d, err %d\n",
|
pr_err("%s: can't get irq %d, err %d\n",
|
||||||
driver_name, irq, retval);
|
driver_name, irq, retval);
|
||||||
goto err_irq1;
|
goto err;
|
||||||
}
|
}
|
||||||
dev->got_irq = 1;
|
dev->got_irq = 1;
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_LUBBOCK
|
#ifdef CONFIG_ARCH_LUBBOCK
|
||||||
if (machine_is_lubbock()) {
|
if (machine_is_lubbock()) {
|
||||||
retval = request_irq(LUBBOCK_USB_DISC_IRQ, lubbock_vbus_irq,
|
retval = devm_request_irq(&pdev->dev, LUBBOCK_USB_DISC_IRQ,
|
||||||
0, driver_name, dev);
|
lubbock_vbus_irq, 0, driver_name,
|
||||||
|
dev);
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
pr_err("%s: can't get irq %i, err %d\n",
|
pr_err("%s: can't get irq %i, err %d\n",
|
||||||
driver_name, LUBBOCK_USB_DISC_IRQ, retval);
|
driver_name, LUBBOCK_USB_DISC_IRQ, retval);
|
||||||
goto err_irq_lub;
|
goto err;
|
||||||
}
|
}
|
||||||
retval = request_irq(LUBBOCK_USB_IRQ, lubbock_vbus_irq,
|
retval = devm_request_irq(&pdev->dev, LUBBOCK_USB_IRQ,
|
||||||
0, driver_name, dev);
|
lubbock_vbus_irq, 0, driver_name,
|
||||||
|
dev);
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
pr_err("%s: can't get irq %i, err %d\n",
|
pr_err("%s: can't get irq %i, err %d\n",
|
||||||
driver_name, LUBBOCK_USB_IRQ, retval);
|
driver_name, LUBBOCK_USB_IRQ, retval);
|
||||||
goto lubbock_fail0;
|
goto err;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@ -2180,22 +2181,9 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
|
|||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
remove_debug_files(dev);
|
remove_debug_files(dev);
|
||||||
#ifdef CONFIG_ARCH_LUBBOCK
|
err:
|
||||||
lubbock_fail0:
|
if (!IS_ERR_OR_NULL(dev->transceiver))
|
||||||
free_irq(LUBBOCK_USB_DISC_IRQ, dev);
|
|
||||||
err_irq_lub:
|
|
||||||
free_irq(irq, dev);
|
|
||||||
#endif
|
|
||||||
err_irq1:
|
|
||||||
if (gpio_is_valid(dev->mach->gpio_pullup))
|
|
||||||
gpio_free(dev->mach->gpio_pullup);
|
|
||||||
err_gpio_pullup:
|
|
||||||
if (!IS_ERR_OR_NULL(dev->transceiver)) {
|
|
||||||
usb_put_phy(dev->transceiver);
|
|
||||||
dev->transceiver = NULL;
|
dev->transceiver = NULL;
|
||||||
}
|
|
||||||
clk_put(dev->clk);
|
|
||||||
err_clk:
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2217,25 +2205,8 @@ static int pxa25x_udc_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
remove_debug_files(dev);
|
remove_debug_files(dev);
|
||||||
|
|
||||||
if (dev->got_irq) {
|
if (!IS_ERR_OR_NULL(dev->transceiver))
|
||||||
free_irq(platform_get_irq(pdev, 0), dev);
|
|
||||||
dev->got_irq = 0;
|
|
||||||
}
|
|
||||||
#ifdef CONFIG_ARCH_LUBBOCK
|
|
||||||
if (machine_is_lubbock()) {
|
|
||||||
free_irq(LUBBOCK_USB_DISC_IRQ, dev);
|
|
||||||
free_irq(LUBBOCK_USB_IRQ, dev);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (gpio_is_valid(dev->mach->gpio_pullup))
|
|
||||||
gpio_free(dev->mach->gpio_pullup);
|
|
||||||
|
|
||||||
clk_put(dev->clk);
|
|
||||||
|
|
||||||
if (!IS_ERR_OR_NULL(dev->transceiver)) {
|
|
||||||
usb_put_phy(dev->transceiver);
|
|
||||||
dev->transceiver = NULL;
|
dev->transceiver = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
the_controller = NULL;
|
the_controller = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user