diff mbox

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

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

Commit Message

Boris BREZILLON Dec. 9, 2013, 8:51 a.m. UTC
Replace the request_mem_region + ioremap calls by the
devm_ioremap_resource 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 |   27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

Comments

Olof Johansson Jan. 6, 2014, 6:08 p.m. UTC | #1
Boris,

On Mon, Dec 9, 2013 at 12:51 AM, Boris BREZILLON
<b.brezillon@overkiz.com> wrote:
> Replace the request_mem_region + ioremap calls by the
> devm_ioremap_resource 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>

Did you build these patches? There's several breakages due to them in
last night's next. I'm a little puzzled how they passed testing before
you submitted?

This one fails with:

drivers/usb/host/ohci-at91.c: In function 'usb_hcd_at91_probe':
drivers/usb/host/ohci-at91.c:157:36: error: 'dev' undeclared (first
use in this function)
  hcd->regs = devm_ioremap_resource(dev, res);
                                    ^
drivers/usb/host/ohci-at91.c:157:36: note: each undeclared identifier
is reported only once for each function it appears in
drivers/usb/host/ohci-at91.c:157:41: error: 'res' undeclared (first
use in this function)
  hcd->regs = devm_ioremap_resource(dev, res);

There are more too, the original one I was bisecting for was the below
one, but the above hit first:

drivers/usb/host/ohci-at91.c: In function 'usb_hcd_at91_probe':
drivers/usb/host/ohci-at91.c:190:4: error: label 'err' used but not defined
drivers/usb/host/ohci-at91.c: At top level:
drivers/usb/host/ohci-at91.c:206:2: warning: data definition has no
type or storage class [enabled by default]
drivers/usb/host/ohci-at91.c:206:2: error: type defaults to 'int' in
declaration of 'at91_stop_hc' [-Werror=implicit-int]
drivers/usb/host/ohci-at91.c:206:2: warning: parameter names (without
types) in function declaration [enabled by default]
drivers/usb/host/ohci-at91.c:206:2: error: conflicting types for 'at91_stop_hc'
drivers/usb/host/ohci-at91.c:97:13: note: previous definition of
'at91_stop_hc' was here
drivers/usb/host/ohci-at91.c:208:5: error: expected '=', ',', ';',
'asm' or '__attribute__' before ':' token
drivers/usb/host/ohci-at91.c:210:2: error: expected identifier or '('
before 'return'
drivers/usb/host/ohci-at91.c:211:1: error: expected identifier or '('
before '}' token
drivers/usb/host/ohci-at91.c:97:13: warning: 'at91_stop_hc' defined
but not used [-Wunused-function]
 static void at91_stop_hc(struct platform_device *pdev)


Somewhat spectacular.  Greg, can you please drop these until he's
sorted out his submission? :(


-Olof
Boris BREZILLON Jan. 6, 2014, 6:51 p.m. UTC | #2
Hello Olof,

On 06/01/2014 19:08, Olof Johansson wrote:
> Boris,
>
> On Mon, Dec 9, 2013 at 12:51 AM, Boris BREZILLON
> <b.brezillon@overkiz.com> wrote:
>> Replace the request_mem_region + ioremap calls by the
>> devm_ioremap_resource 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>
> Did you build these patches?

Yes, I did.

> There's several breakages due to them in
> last night's next. I'm a little puzzled how they passed testing before
> you submitted?
> This one fails with:
>
> drivers/usb/host/ohci-at91.c: In function 'usb_hcd_at91_probe':
> drivers/usb/host/ohci-at91.c:157:36: error: 'dev' undeclared (first
> use in this function)
>    hcd->regs = devm_ioremap_resource(dev, res);
>                                      ^
> drivers/usb/host/ohci-at91.c:157:36: note: each undeclared identifier
> is reported only once for each function it appears in
> drivers/usb/host/ohci-at91.c:157:41: error: 'res' undeclared (first
> use in this function)
>    hcd->regs = devm_ioremap_resource(dev, res);

Actually this patch series depends on another patch :
"usb: ohci-at91: fix irq and iomem resource retrieval"
commit fb5f1834c3221e459324c6885eaad75429f722a5.

This patch was taken out to ease integration in 3.13-rc5.

Sorry, I should have stated it in my cover letter.

Which next are you using ?
I took a look at linux-next and the dev variable is declared.

> There are more too, the original one I was bisecting for was the below
> one, but the above hit first:
>
> drivers/usb/host/ohci-at91.c: In function 'usb_hcd_at91_probe':
> drivers/usb/host/ohci-at91.c:190:4: error: label 'err' used but not defined
> drivers/usb/host/ohci-at91.c: At top level:
> drivers/usb/host/ohci-at91.c:206:2: warning: data definition has no
> type or storage class [enabled by default]
> drivers/usb/host/ohci-at91.c:206:2: error: type defaults to 'int' in
> declaration of 'at91_stop_hc' [-Werror=implicit-int]
> drivers/usb/host/ohci-at91.c:206:2: warning: parameter names (without
> types) in function declaration [enabled by default]
> drivers/usb/host/ohci-at91.c:206:2: error: conflicting types for 'at91_stop_hc'
> drivers/usb/host/ohci-at91.c:97:13: note: previous definition of
> 'at91_stop_hc' was here
> drivers/usb/host/ohci-at91.c:208:5: error: expected '=', ',', ';',
> 'asm' or '__attribute__' before ':' token
> drivers/usb/host/ohci-at91.c:210:2: error: expected identifier or '('
> before 'return'
> drivers/usb/host/ohci-at91.c:211:1: error: expected identifier or '('
> before '}' token
> drivers/usb/host/ohci-at91.c:97:13: warning: 'at91_stop_hc' defined
> but not used [-Wunused-function]
>   static void at91_stop_hc(struct platform_device *pdev)

These errors come from merge commit 
99f14bd4d1b2a1b1b6cd508e08efdbc5e3919198.

There is a missing brace on the last retval test.

Best Regards,

Boris
> Somewhat spectacular.  Greg, can you please drop these until he's
> sorted out his submission? :(
>
>
> -Olof
diff mbox

Patch

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 8c356af..9dc50f8 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -158,24 +158,17 @@  static int usb_hcd_at91_probe(const struct hc_driver *driver,
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 
-	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);
-	if (!hcd->regs) {
-		pr_debug("ioremap failed\n");
-		retval = -EIO;
-		goto err2;
+	hcd->regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(hcd->regs)) {
+		retval = PTR_ERR(hcd->regs);
+		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)) {
@@ -219,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;
 }
@@ -248,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))