usb: host: xhci-plat: use devm_functions
Subsystems (2)
PATCH 1/1 usb: host: xhci-plat: use devm_functions
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.
--- drivers/usb/host/xhci-plat.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/usb/host/xhci-plat.c +5 -20
@@ -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);
Signature · 1 line
1.9.1
Hi,
Quoted 19 lines · Himangi Saraogi
This patch introduces the use of managed interface
devm_ioremap_resourceforioremap_nocacheandrequest_mem_regionand removes the corresponding free functions in the probe and remove functions.Signed-off-by Himangi Saraogi <[email protected]>--- drivers/usb/host/xhci-plat.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)drivers/usb/host/xhci-plat.c +0
-2@@ -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)) {
drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 145
Quoted 10 lines
drivers/usb/host/xhci-plat.c +2
-7-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().
Signature · 1 line
balbi
Hello.
Quoted 19 lines · Himangi Saraogi
This patch introduces the use of managed interface
devm_ioremap_resourceforioremap_nocacheandrequest_mem_regionand removes the corresponding free functions in the probe and remove functions.Signed-off-by Himangi Saraogi <[email protected]>--- drivers/usb/host/xhci-plat.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)drivers/usb/host/xhci-plat.c +0
-2@@ -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)) {
drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 145
Quoted 10 lines
drivers/usb/host/xhci-plat.c +2
-7-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.
drivers/usb/host/xhci-plat.c static int xhci_plat_probe(struct platform_device *pdev) · line 148
Quoted 5 lines
drivers/usb/host/xhci-plat.c +2
-2- ret = -EFAULT ; - goto release_mem_region; + ret =PTR_ERR (hcd->regs); + goto put_hcd; }
WBR, Sergei