linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: host: xhci-plat: use devm_functions
@ 2014-06-20 16:48 Himangi Saraogi
  2014-06-20 16:57 ` Felipe Balbi
  2014-06-20 18:03 ` Sergei Shtylyov
  0 siblings, 2 replies; 5+ messages in thread
From: Himangi Saraogi @ 2014-06-20 16:48 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel; +Cc: julia.lawall

This patch introduces the use of managed interface devm_ioremap_resource
for ioremap_nocache and request_mem_region and removes the corresponding
free functions in the probe and remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
 drivers/usb/host/xhci-plat.c | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 29d8adb..31d14a5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -140,18 +140,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-				driver->description)) {
-		dev_dbg(&pdev->dev, "controller already in use\n");
-		ret = -EBUSY;
-		goto put_hcd;
-	}
-
-	hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-	if (!hcd->regs) {
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
 		dev_dbg(&pdev->dev, "error mapping memory\n");
-		ret = -EFAULT;
-		goto release_mem_region;
+		ret = PTR_ERR(hcd->regs);
+		goto put_hcd;
 	}
 
 	/*
@@ -162,7 +155,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	if (!IS_ERR(clk)) {
 		ret = clk_prepare_enable(clk);
 		if (ret)
-			goto unmap_registers;
+			goto put_hcd;
 	}
 
 	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
@@ -207,12 +200,6 @@ disable_clk:
 	if (!IS_ERR(clk))
 		clk_disable_unprepare(clk);
 
-unmap_registers:
-	iounmap(hcd->regs);
-
-release_mem_region:
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-
 put_hcd:
 	usb_put_hcd(hcd);
 
@@ -231,8 +218,6 @@ static int xhci_plat_remove(struct platform_device *dev)
 	usb_remove_hcd(hcd);
 	if (!IS_ERR(clk))
 		clk_disable_unprepare(clk);
-	iounmap(hcd->regs);
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
 	usb_put_hcd(hcd);
 	kfree(xhci);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: host: xhci-plat: use devm_functions
  2014-06-20 16:48 [PATCH] usb: host: xhci-plat: use devm_functions Himangi Saraogi
@ 2014-06-20 16:57 ` Felipe Balbi
  2014-06-20 18:03 ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2014-06-20 16:57 UTC (permalink / raw)
  To: Himangi Saraogi
  Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel,
	julia.lawall

[-- Attachment #1: Type: text/plain, Size: 1350 bytes --]

Hi,

On Fri, Jun 20, 2014 at 10:18:53PM +0530, Himangi Saraogi wrote:
> This patch introduces the use of managed interface devm_ioremap_resource
> for ioremap_nocache and request_mem_region and removes the corresponding
> free functions in the probe and remove functions.
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> ---
>  drivers/usb/host/xhci-plat.c | 25 +++++--------------------
>  1 file changed, 5 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 29d8adb..31d14a5 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -140,18 +140,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  	hcd->rsrc_start = res->start;
>  	hcd->rsrc_len = resource_size(res);
>  
> -	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
> -				driver->description)) {
> -		dev_dbg(&pdev->dev, "controller already in use\n");
> -		ret = -EBUSY;
> -		goto put_hcd;
> -	}
> -
> -	hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
> -	if (!hcd->regs) {
> +	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(hcd->regs)) {
>  		dev_dbg(&pdev->dev, "error mapping memory\n");

you can remove this dev_dbg() message now that you're using
devm_ioremap_resource().

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] usb: host: xhci-plat: use devm_functions
@ 2014-06-20 17:41 Himangi Saraogi
  2014-06-20 17:55 ` Felipe Balbi
  0 siblings, 1 reply; 5+ messages in thread
From: Himangi Saraogi @ 2014-06-20 17:41 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel; +Cc: julia.lawall

This patch introduces the use of managed interface devm_ioremap_resource
for ioremap_nocache and request_mem_region and removes the corresponding
free functions in the probe and remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/usb/host/xhci-plat.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 29d8adb..23eeb15 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -140,20 +140,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-				driver->description)) {
-		dev_dbg(&pdev->dev, "controller already in use\n");
-		ret = -EBUSY;
+	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(hcd->regs)) {
+		ret = PTR_ERR(hcd->regs);
 		goto put_hcd;
 	}
 
-	hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-	if (!hcd->regs) {
-		dev_dbg(&pdev->dev, "error mapping memory\n");
-		ret = -EFAULT;
-		goto release_mem_region;
-	}
-
 	/*
 	 * Not all platforms have a clk so it is not an error if the
 	 * clock does not exists.
@@ -162,7 +154,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	if (!IS_ERR(clk)) {
 		ret = clk_prepare_enable(clk);
 		if (ret)
-			goto unmap_registers;
+			goto put_hcd;
 	}
 
 	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
@@ -207,12 +199,6 @@ disable_clk:
 	if (!IS_ERR(clk))
 		clk_disable_unprepare(clk);
 
-unmap_registers:
-	iounmap(hcd->regs);
-
-release_mem_region:
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-
 put_hcd:
 	usb_put_hcd(hcd);
 
@@ -231,8 +217,6 @@ static int xhci_plat_remove(struct platform_device *dev)
 	usb_remove_hcd(hcd);
 	if (!IS_ERR(clk))
 		clk_disable_unprepare(clk);
-	iounmap(hcd->regs);
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
 	usb_put_hcd(hcd);
 	kfree(xhci);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: host: xhci-plat: use devm_functions
  2014-06-20 17:41 Himangi Saraogi
@ 2014-06-20 17:55 ` Felipe Balbi
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2014-06-20 17:55 UTC (permalink / raw)
  To: Himangi Saraogi
  Cc: Mathias Nyman, Greg Kroah-Hartman, linux-usb, linux-kernel,
	julia.lawall

[-- Attachment #1: Type: text/plain, Size: 2647 bytes --]

On Fri, Jun 20, 2014 at 11:11:23PM +0530, Himangi Saraogi wrote:
> This patch introduces the use of managed interface devm_ioremap_resource
> for ioremap_nocache and request_mem_region and removes the corresponding
> free functions in the probe and remove functions.
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Reviewed-by: Felipe Balbi <balbi@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>

> ---
>  drivers/usb/host/xhci-plat.c | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 29d8adb..23eeb15 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -140,20 +140,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  	hcd->rsrc_start = res->start;
>  	hcd->rsrc_len = resource_size(res);
>  
> -	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
> -				driver->description)) {
> -		dev_dbg(&pdev->dev, "controller already in use\n");
> -		ret = -EBUSY;
> +	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(hcd->regs)) {
> +		ret = PTR_ERR(hcd->regs);
>  		goto put_hcd;
>  	}
>  
> -	hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
> -	if (!hcd->regs) {
> -		dev_dbg(&pdev->dev, "error mapping memory\n");
> -		ret = -EFAULT;
> -		goto release_mem_region;
> -	}
> -
>  	/*
>  	 * Not all platforms have a clk so it is not an error if the
>  	 * clock does not exists.
> @@ -162,7 +154,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  	if (!IS_ERR(clk)) {
>  		ret = clk_prepare_enable(clk);
>  		if (ret)
> -			goto unmap_registers;
> +			goto put_hcd;
>  	}
>  
>  	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
> @@ -207,12 +199,6 @@ disable_clk:
>  	if (!IS_ERR(clk))
>  		clk_disable_unprepare(clk);
>  
> -unmap_registers:
> -	iounmap(hcd->regs);
> -
> -release_mem_region:
> -	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
> -
>  put_hcd:
>  	usb_put_hcd(hcd);
>  
> @@ -231,8 +217,6 @@ static int xhci_plat_remove(struct platform_device *dev)
>  	usb_remove_hcd(hcd);
>  	if (!IS_ERR(clk))
>  		clk_disable_unprepare(clk);
> -	iounmap(hcd->regs);
> -	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
>  	usb_put_hcd(hcd);
>  	kfree(xhci);
>  
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: host: xhci-plat: use devm_functions
  2014-06-20 16:48 [PATCH] usb: host: xhci-plat: use devm_functions Himangi Saraogi
  2014-06-20 16:57 ` Felipe Balbi
@ 2014-06-20 18:03 ` Sergei Shtylyov
  1 sibling, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2014-06-20 18:03 UTC (permalink / raw)
  To: Himangi Saraogi, Mathias Nyman, Greg Kroah-Hartman, linux-usb,
	linux-kernel
  Cc: julia.lawall

Hello.

On 06/20/2014 08:48 PM, Himangi Saraogi wrote:

> This patch introduces the use of managed interface devm_ioremap_resource
> for ioremap_nocache and request_mem_region and removes the corresponding
> free functions in the probe and remove functions.

> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> ---
>   drivers/usb/host/xhci-plat.c | 25 +++++--------------------
>   1 file changed, 5 insertions(+), 20 deletions(-)

> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 29d8adb..31d14a5 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -140,18 +140,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   	hcd->rsrc_start = res->start;
>   	hcd->rsrc_len = resource_size(res);
>
> -	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
> -				driver->description)) {
> -		dev_dbg(&pdev->dev, "controller already in use\n");
> -		ret = -EBUSY;
> -		goto put_hcd;
> -	}
> -
> -	hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
> -	if (!hcd->regs) {
> +	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(hcd->regs)) {
>   		dev_dbg(&pdev->dev, "error mapping memory\n");

    This line is worth removing -- devm_ioremap_resource() complains loudly on 
errors.

> -		ret = -EFAULT;
> -		goto release_mem_region;
> +		ret = PTR_ERR(hcd->regs);
> +		goto put_hcd;
>   	}

WBR, Sergei


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-20 18:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-20 16:48 [PATCH] usb: host: xhci-plat: use devm_functions Himangi Saraogi
2014-06-20 16:57 ` Felipe Balbi
2014-06-20 18:03 ` Sergei Shtylyov
  -- strict thread matches above, loose matches on Subject: below --
2014-06-20 17:41 Himangi Saraogi
2014-06-20 17:55 ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).