diff mbox

[v3,1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_request_and_ioremap

Message ID 1386237282-22385-2-git-send-email-b.brezillon@overkiz.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boris BREZILLON Dec. 5, 2013, 9:54 a.m. UTC
Replace the request_mem_region + ioremap calls by the
devm_request_and_ioremap call which does the same things but with device
managed resources.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/host/ohci-at91.c |   24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

Comments

Sergei Shtylyov Dec. 5, 2013, 8:33 p.m. UTC | #1
Hello.

On 12/05/2013 12:54 PM, Boris BREZILLON wrote:

> Replace the request_mem_region + ioremap calls by the
> devm_request_and_ioremap call which does the same things but with device
> managed resources.

> Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> ---
>   drivers/usb/host/ohci-at91.c |   24 +++++-------------------
>   1 file changed, 5 insertions(+), 19 deletions(-)

> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 7aec6ca..8528895 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -157,24 +157,18 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
>   	hcd->rsrc_start = mem_r->start;
>   	hcd->rsrc_len = resource_size(mem_r);
>
> -	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
> -		pr_debug("request_mem_region failed\n");
> -		retval = -EBUSY;
> -		goto err1;
> -	}
> -
> -	hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
> +	hcd->regs = devm_request_and_ioremap(dev, mem_r);

    This function is already deprecated, use devm_ioremap_resource() instead 
(it returns error pointer, not NULL on error).

>   	if (!hcd->regs) {
> -		pr_debug("ioremap failed\n");
> +		dev_dbg(dev, "devm_request_and_ioremap failed\n");

    There's no need -- those functions print error messages themselves.

>   		retval = -EIO;
> -		goto err2;
> +		goto err;
>   	}
[...]

WBR, Sergei
diff mbox

Patch

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 7aec6ca..8528895 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -157,24 +157,18 @@  static int usb_hcd_at91_probe(const struct hc_driver *driver,
 	hcd->rsrc_start = mem_r->start;
 	hcd->rsrc_len = resource_size(mem_r);
 
-	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
-		pr_debug("request_mem_region failed\n");
-		retval = -EBUSY;
-		goto err1;
-	}
-
-	hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
+	hcd->regs = devm_request_and_ioremap(dev, mem_r);
 	if (!hcd->regs) {
-		pr_debug("ioremap failed\n");
+		dev_dbg(dev, "devm_request_and_ioremap failed\n");
 		retval = -EIO;
-		goto err2;
+		goto err;
 	}
 
 	iclk = clk_get(&pdev->dev, "ohci_clk");
 	if (IS_ERR(iclk)) {
 		dev_err(&pdev->dev, "failed to get ohci_clk\n");
 		retval = PTR_ERR(iclk);
-		goto err3;
+		goto err;
 	}
 	fclk = clk_get(&pdev->dev, "uhpck");
 	if (IS_ERR(fclk)) {
@@ -218,13 +212,7 @@  static int usb_hcd_at91_probe(const struct hc_driver *driver,
  err4:
 	clk_put(iclk);
 
- err3:
-	iounmap(hcd->regs);
-
- err2:
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-
- err1:
+ err:
 	usb_put_hcd(hcd);
 	return retval;
 }
@@ -247,8 +235,6 @@  static void usb_hcd_at91_remove(struct usb_hcd *hcd,
 {
 	usb_remove_hcd(hcd);
 	at91_stop_hc(pdev);
-	iounmap(hcd->regs);
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
 	usb_put_hcd(hcd);
 
 	if (IS_ENABLED(CONFIG_COMMON_CLK))