* [PATCH v4 0/3] usb: ohci-at91: various improvements
@ 2013-12-08 15:02 Boris BREZILLON
2013-12-08 15:02 ` [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource Boris BREZILLON
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-12-08 15:02 UTC (permalink / raw)
To: Douglas Gilbert, Nicolas Ferre, Tomasz Figa, Alan Stern,
Greg Kroah-Hartman, Sergei Shtylyov
Cc: Grant Likely, linux-usb, linux-kernel, linux-arm-kernel,
Boris BREZILLON
Hello,
This patch series moves the different driver resources (clks and iomem)
retrieval to the device managed versions (devm_ functions).
Best Regards,
Boris
Changes since v3:
- replace devm_request_and_ioremap call by devm_ioremap_resource
Changes since v2:
- split urgent fix and resource retrieval improvements
Boris BREZILLON (3):
usb: ohci-at91: replace request_mem_region + ioremap by
devm_ioremap_resource
usb: ohci-at91: use dev variable instead of &pdev->dev
usb: ohci-at91: use device managed clk retrieval
drivers/usb/host/ohci-at91.c | 68 ++++++++++++------------------------------
1 file changed, 19 insertions(+), 49 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource
2013-12-08 15:02 [PATCH v4 0/3] usb: ohci-at91: various improvements Boris BREZILLON
@ 2013-12-08 15:02 ` Boris BREZILLON
2013-12-08 18:31 ` Sergei Shtylyov
2013-12-08 15:02 ` [PATCH v4 2/3] usb: ohci-at91: use dev variable instead of &pdev->dev Boris BREZILLON
2013-12-08 15:03 ` [PATCH v4 3/3] usb: ohci-at91: use device managed clk retrieval Boris BREZILLON
2 siblings, 1 reply; 6+ messages in thread
From: Boris BREZILLON @ 2013-12-08 15:02 UTC (permalink / raw)
To: Douglas Gilbert, Nicolas Ferre, Tomasz Figa, Alan Stern,
Greg Kroah-Hartman, Sergei Shtylyov
Cc: Grant Likely, linux-usb, linux-kernel, linux-arm-kernel,
Boris BREZILLON
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 | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 8c356af..fe2ecc5 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -158,24 +158,18 @@ 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)) {
+ dev_dbg(dev, "devm_ioremap_resource failed\n");
+ 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 +213,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 +236,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))
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] usb: ohci-at91: use dev variable instead of &pdev->dev
2013-12-08 15:02 [PATCH v4 0/3] usb: ohci-at91: various improvements Boris BREZILLON
2013-12-08 15:02 ` [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource Boris BREZILLON
@ 2013-12-08 15:02 ` Boris BREZILLON
2013-12-08 15:03 ` [PATCH v4 3/3] usb: ohci-at91: use device managed clk retrieval Boris BREZILLON
2 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-12-08 15:02 UTC (permalink / raw)
To: Douglas Gilbert, Nicolas Ferre, Tomasz Figa, Alan Stern,
Greg Kroah-Hartman, Sergei Shtylyov
Cc: Grant Likely, linux-usb, linux-kernel, linux-arm-kernel,
Boris BREZILLON
Make use of the dev variable instead of referencing the dev field of the
pdev struct.
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 | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index fe2ecc5..30f1445 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -152,7 +152,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
return irq;
}
- hcd = usb_create_hcd(driver, &pdev->dev, "at91");
+ hcd = usb_create_hcd(driver, dev, "at91");
if (!hcd)
return -ENOMEM;
hcd->rsrc_start = res->start;
@@ -165,28 +165,28 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
goto err;
}
- iclk = clk_get(&pdev->dev, "ohci_clk");
+ iclk = clk_get(dev, "ohci_clk");
if (IS_ERR(iclk)) {
- dev_err(&pdev->dev, "failed to get ohci_clk\n");
+ dev_err(dev, "failed to get ohci_clk\n");
retval = PTR_ERR(iclk);
goto err;
}
- fclk = clk_get(&pdev->dev, "uhpck");
+ fclk = clk_get(dev, "uhpck");
if (IS_ERR(fclk)) {
- dev_err(&pdev->dev, "failed to get uhpck\n");
+ dev_err(dev, "failed to get uhpck\n");
retval = PTR_ERR(fclk);
goto err4;
}
- hclk = clk_get(&pdev->dev, "hclk");
+ hclk = clk_get(dev, "hclk");
if (IS_ERR(hclk)) {
- dev_err(&pdev->dev, "failed to get hclk\n");
+ dev_err(dev, "failed to get hclk\n");
retval = PTR_ERR(hclk);
goto err5;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
- uclk = clk_get(&pdev->dev, "usb_clk");
+ uclk = clk_get(dev, "usb_clk");
if (IS_ERR(uclk)) {
- dev_err(&pdev->dev, "failed to get uclk\n");
+ dev_err(dev, "failed to get uclk\n");
retval = PTR_ERR(uclk);
goto err6;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] usb: ohci-at91: use device managed clk retrieval
2013-12-08 15:02 [PATCH v4 0/3] usb: ohci-at91: various improvements Boris BREZILLON
2013-12-08 15:02 ` [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource Boris BREZILLON
2013-12-08 15:02 ` [PATCH v4 2/3] usb: ohci-at91: use dev variable instead of &pdev->dev Boris BREZILLON
@ 2013-12-08 15:03 ` Boris BREZILLON
2 siblings, 0 replies; 6+ messages in thread
From: Boris BREZILLON @ 2013-12-08 15:03 UTC (permalink / raw)
To: Douglas Gilbert, Nicolas Ferre, Tomasz Figa, Alan Stern,
Greg Kroah-Hartman, Sergei Shtylyov
Cc: Grant Likely, linux-usb, linux-kernel, linux-arm-kernel,
Boris BREZILLON
Replace clk_get calls by devm_clk_get calls.
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 | 30 +++++++-----------------------
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 30f1445..9db3954 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -165,30 +165,30 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
goto err;
}
- iclk = clk_get(dev, "ohci_clk");
+ iclk = devm_clk_get(dev, "ohci_clk");
if (IS_ERR(iclk)) {
dev_err(dev, "failed to get ohci_clk\n");
retval = PTR_ERR(iclk);
goto err;
}
- fclk = clk_get(dev, "uhpck");
+ fclk = devm_clk_get(dev, "uhpck");
if (IS_ERR(fclk)) {
dev_err(dev, "failed to get uhpck\n");
retval = PTR_ERR(fclk);
- goto err4;
+ goto err;
}
- hclk = clk_get(dev, "hclk");
+ hclk = devm_clk_get(dev, "hclk");
if (IS_ERR(hclk)) {
dev_err(dev, "failed to get hclk\n");
retval = PTR_ERR(hclk);
- goto err5;
+ goto err;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
- uclk = clk_get(dev, "usb_clk");
+ uclk = devm_clk_get(dev, "usb_clk");
if (IS_ERR(uclk)) {
dev_err(dev, "failed to get uclk\n");
retval = PTR_ERR(uclk);
- goto err6;
+ goto err;
}
}
@@ -204,15 +204,6 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
/* Error handling */
at91_stop_hc(pdev);
- if (IS_ENABLED(CONFIG_COMMON_CLK))
- clk_put(uclk);
- err6:
- clk_put(hclk);
- err5:
- clk_put(fclk);
- err4:
- clk_put(iclk);
-
err:
usb_put_hcd(hcd);
return retval;
@@ -237,13 +228,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
usb_put_hcd(hcd);
-
- if (IS_ENABLED(CONFIG_COMMON_CLK))
- clk_put(uclk);
- clk_put(hclk);
- clk_put(fclk);
- clk_put(iclk);
- fclk = iclk = hclk = NULL;
}
/*-------------------------------------------------------------------------*/
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource
2013-12-08 15:02 ` [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource Boris BREZILLON
@ 2013-12-08 18:31 ` Sergei Shtylyov
2013-12-08 18:52 ` boris brezillon
0 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2013-12-08 18:31 UTC (permalink / raw)
To: Boris BREZILLON, Douglas Gilbert, Nicolas Ferre, Tomasz Figa,
Alan Stern, Greg Kroah-Hartman
Cc: Grant Likely, linux-usb, linux-kernel, linux-arm-kernel
Hello.
On 12/08/2013 06:02 PM, Boris BREZILLON 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>
> ---
> drivers/usb/host/ohci-at91.c | 28 +++++++---------------------
> 1 file changed, 7 insertions(+), 21 deletions(-)
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index 8c356af..fe2ecc5 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -158,24 +158,18 @@ 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)) {
> + dev_dbg(dev, "devm_ioremap_resource failed\n");
I've already told you devm_ioremap_resource() prints the detailed error
message. No need to duplicate it.
> + retval = PTR_ERR(hcd->regs);
> + goto err;
> }
WBR, Sergei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource
2013-12-08 18:31 ` Sergei Shtylyov
@ 2013-12-08 18:52 ` boris brezillon
0 siblings, 0 replies; 6+ messages in thread
From: boris brezillon @ 2013-12-08 18:52 UTC (permalink / raw)
To: Sergei Shtylyov, Douglas Gilbert, Nicolas Ferre, Tomasz Figa,
Alan Stern, Greg Kroah-Hartman
Cc: Grant Likely, linux-usb, linux-kernel, linux-arm-kernel
Hello,
Le 08/12/2013 19:31, Sergei Shtylyov a écrit :
> Hello.
>
> On 12/08/2013 06:02 PM, Boris BREZILLON 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>
>> ---
>> drivers/usb/host/ohci-at91.c | 28 +++++++---------------------
>> 1 file changed, 7 insertions(+), 21 deletions(-)
>
>> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
>> index 8c356af..fe2ecc5 100644
>> --- a/drivers/usb/host/ohci-at91.c
>> +++ b/drivers/usb/host/ohci-at91.c
>> @@ -158,24 +158,18 @@ 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)) {
>> + dev_dbg(dev, "devm_ioremap_resource failed\n");
>
> I've already told you devm_ioremap_resource() prints the detailed
> error message. No need to duplicate it.
>
Oops, sorry, this is an oversight.
I'll send a new version removing this line.
Best Regards,
Boris
>> + retval = PTR_ERR(hcd->regs);
>> + goto err;
>> }
>
> WBR, Sergei
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-12-08 18:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-08 15:02 [PATCH v4 0/3] usb: ohci-at91: various improvements Boris BREZILLON
2013-12-08 15:02 ` [PATCH v4 1/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_ioremap_resource Boris BREZILLON
2013-12-08 18:31 ` Sergei Shtylyov
2013-12-08 18:52 ` boris brezillon
2013-12-08 15:02 ` [PATCH v4 2/3] usb: ohci-at91: use dev variable instead of &pdev->dev Boris BREZILLON
2013-12-08 15:03 ` [PATCH v4 3/3] usb: ohci-at91: use device managed clk retrieval Boris BREZILLON
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox