]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: dwc3: Keeping 'resource' related code together
authorVivek Gautam <gautam.vivek@samsung.com>
Wed, 4 Jun 2014 09:04:52 +0000 (14:34 +0530)
committerFelipe Balbi <balbi@ti.com>
Mon, 30 Jun 2014 17:26:36 +0000 (12:26 -0500)
Putting together the code related to getting the 'IORESOURCE_MEM'
and assigning the same to dwc->xhci_resources, for increasing
the readability.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/core.c

index eb69eb9f06c8f580c70cc2dd2ee62f7870782492..fbe446350e28d821b481bd642135274e48597a31 100644 (file)
@@ -656,6 +656,31 @@ static int dwc3_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
+       dwc->xhci_resources[0].start = res->start;
+       dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
+                                       DWC3_XHCI_REGS_END;
+       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))
+               return PTR_ERR(regs);
+
+       dwc->regs       = regs;
+       dwc->regs_size  = resource_size(res);
+       /*
+        * 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;
+
        if (node) {
                dwc->maximum_speed = of_usb_get_maximum_speed(node);
 
@@ -676,28 +701,9 @@ static int dwc3_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       dwc->xhci_resources[0].start = res->start;
-       dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
-                                       DWC3_XHCI_REGS_END;
-       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))
-               return PTR_ERR(regs);
-
        spin_lock_init(&dwc->lock);
        platform_set_drvdata(pdev, dwc);
 
-       dwc->regs       = regs;
-       dwc->regs_size  = resource_size(res);
-
        dev->dma_mask   = dev->parent->dma_mask;
        dev->dma_parms  = dev->parent->dma_parms;
        dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);