All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: dwc3: use local copy of resource to fix-up register offset
@ 2018-03-15 11:39 ` Masahiro Yamada
  0 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2018-03-15 11:39 UTC (permalink / raw)
  To: Felipe Balbi, linux-usb
  Cc: Masami Hiramatsu, Jassi Brar, Kunihiko Hayashi, Masahiro Yamada,
	Greg Kroah-Hartman, Felipe Balbi, linux-kernel

It is not a good idea to modify the resource from the platform device.
Modify its local copy to pass it to devm_ioremap_resource() so that we
do not need to restore it in the failure path and the remove hook.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/usb/dwc3/core.c | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index f1d838a..e9083a3 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1164,7 +1164,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
 static int dwc3_probe(struct platform_device *pdev)
 {
 	struct device		*dev = &pdev->dev;
-	struct resource		*res;
+	struct resource		*res, dwc_res;
 	struct dwc3		*dwc;
 
 	int			ret;
@@ -1189,20 +1189,19 @@ static int dwc3_probe(struct platform_device *pdev)
 	dwc->xhci_resources[0].flags = res->flags;
 	dwc->xhci_resources[0].name = res->name;
 
-	res->start += DWC3_GLOBALS_REGS_START;
-
 	/*
 	 * Request memory region but exclude xHCI regs,
 	 * since it will be requested by the xhci-plat driver.
 	 */
-	regs = devm_ioremap_resource(dev, res);
-	if (IS_ERR(regs)) {
-		ret = PTR_ERR(regs);
-		goto err0;
-	}
+	dwc_res = *res;
+	dwc_res.start += DWC3_GLOBALS_REGS_START;
+
+	regs = devm_ioremap_resource(dev, &dwc_res);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	dwc->regs	= regs;
-	dwc->regs_size	= resource_size(res);
+	dwc->regs_size	= resource_size(&dwc_res);
 
 	dwc3_get_properties(dwc);
 
@@ -1269,29 +1268,14 @@ static int dwc3_probe(struct platform_device *pdev)
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-err0:
-	/*
-	 * restore res->start back to its original value so that, in case the
-	 * probe is deferred, we don't end up getting error in request the
-	 * memory region the next time probe is called.
-	 */
-	res->start -= DWC3_GLOBALS_REGS_START;
-
 	return ret;
 }
 
 static int dwc3_remove(struct platform_device *pdev)
 {
 	struct dwc3	*dwc = platform_get_drvdata(pdev);
-	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
 	pm_runtime_get_sync(&pdev->dev);
-	/*
-	 * restore res->start back to its original value so that, in case the
-	 * probe is deferred, we don't end up getting error in request the
-	 * memory region the next time probe is called.
-	 */
-	res->start -= DWC3_GLOBALS_REGS_START;
 
 	dwc3_debugfs_exit(dwc);
 	dwc3_core_exit_mode(dwc);
-- 
2.7.4


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

end of thread, other threads:[~2018-04-09 13:32 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15 11:39 [PATCH 1/2] usb: dwc3: use local copy of resource to fix-up register offset Masahiro Yamada
2018-03-15 11:39 ` [1/2] " Masahiro Yamada
2018-03-15 11:39 ` [PATCH 2/2] usb: dwc3: add clock and resets Masahiro Yamada
2018-03-15 11:39   ` [2/2] " Masahiro Yamada
2018-03-16  2:28   ` [PATCH 2/2] " Masami Hiramatsu
2018-03-16  2:28     ` [2/2] " Masami Hiramatsu
2018-03-16 20:33   ` [PATCH 2/2] " kbuild test robot
2018-03-16 20:33     ` [2/2] " kbuild test robot
2018-03-16 20:33     ` [PATCH 2/2] " kbuild test robot
2018-03-18 12:52   ` Rob Herring
2018-03-18 12:52     ` [2/2] " Rob Herring
2018-03-18 22:37     ` [PATCH 2/2] " Masahiro Yamada
2018-03-18 22:37       ` [2/2] " Masahiro Yamada
2018-03-29  4:32       ` [PATCH 2/2] " Masahiro Yamada
2018-03-29  4:32         ` [2/2] " Masahiro Yamada
2018-04-09 13:32         ` [PATCH 2/2] " Rob Herring
2018-04-09 13:32           ` [2/2] " Rob Herring
2018-03-16  1:46 ` [PATCH 1/2] usb: dwc3: use local copy of resource to fix-up register offset Masami Hiramatsu
2018-03-16  1:46   ` [1/2] " Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.