Re: [PATCH 2/2] usb: gadget: pxa27x_udc: use devm_* helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 06/09/2014 11:52 PM, Robert Jarzmik wrote:

Use devm_* helpers in the probe function to simplify the error path and
the remove path.

Signed-off-by: Robert Jarzmik <robert.jarzmik@xxxxxxx>
---
  drivers/usb/gadget/pxa27x_udc.c | 51 +++++++++++------------------------------
  1 file changed, 14 insertions(+), 37 deletions(-)

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 6236848..f6843a8 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -2478,8 +2478,9 @@ static int pxa_udc_probe(struct platform_device *pdev)
  		pxa_udc_probe_pdata(pdev, udc);

  	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	udc->regs = devm_request_and_ioremap(&pdev->dev, regs);

   Isn't this function deprecated in favor of devm_ioremap_resource()?

  	if (!regs)

   s/regs/udc->regs/.

-		return -ENXIO;
+		return -EADDRNOTAVAIL;
  	udc->irq = platform_get_irq(pdev, 0);
  	if (udc->irq < 0)
  		return udc->irq;
[...]
@@ -2523,34 +2517,23 @@ static int pxa_udc_probe(struct platform_device *pdev)
  	pxa_eps_setup(udc);

  	/* irq setup after old hardware state is cleaned up */
-	retval = request_irq(udc->irq, pxa_udc_irq,
-			IRQF_SHARED, driver_name, udc);
+	retval = devm_request_irq(&pdev->dev, udc->irq, pxa_udc_irq,
+				  IRQF_SHARED, driver_name, udc);
  	if (retval != 0) {
  		dev_err(udc->dev, "%s: can't get irq %i, err %d\n",
  			driver_name, udc->irq, retval);
-		goto err_irq;
+		goto err;

   Why not just *return*?

  	}

  	retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
  	if (retval)
-		goto err_add_udc;
+		goto err;

   Likewise.


  	pxa_init_debugfs(udc);

  	return 0;

-err_add_udc:
-	free_irq(udc->irq, udc);
-err_irq:
-	iounmap(udc->regs);
-err_map:
-	clk_unprepare(udc->clk);
-err_clk_prepare:
-	clk_put(udc->clk);
-	udc->clk = NULL;
-err_clk:
-	if (gpio_is_valid(udc->gpio_pullup))
-		gpio_free(udc->gpio_pullup);
+err:
  	return retval;
  }

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux