Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: sdhci-spear: simplify resource handling

Use devm_ioremap_resource() to simplify iomem resource handling in the
probe path.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Chris Ball <chris@printf.net>

authored by

Russell King and committed by
Chris Ball
475d9e3e fcdb7c8f

+13 -27
+13 -27
drivers/mmc/host/sdhci-spear.c
··· 108 108 struct device *dev; 109 109 int ret; 110 110 111 - iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 112 - if (!iomem) { 113 - ret = -ENOMEM; 114 - dev_dbg(&pdev->dev, "memory resource not defined\n"); 115 - goto err; 116 - } 117 - 118 - if (!devm_request_mem_region(&pdev->dev, iomem->start, 119 - resource_size(iomem), "spear-sdhci")) { 120 - ret = -EBUSY; 121 - dev_dbg(&pdev->dev, "cannot request region\n"); 122 - goto err; 123 - } 124 - 125 111 dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev; 126 112 host = sdhci_alloc_host(dev, sizeof(*sdhci)); 127 113 if (IS_ERR(host)) { ··· 115 129 dev_dbg(&pdev->dev, "cannot allocate memory for sdhci\n"); 116 130 goto err; 117 131 } 132 + 133 + iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 134 + host->ioaddr = devm_ioremap_resource(&pdev->dev, iomem); 135 + if (IS_ERR(host->ioaddr)) { 136 + ret = PTR_ERR(host->ioaddr); 137 + dev_dbg(&pdev->dev, "unable to map iomem: %d\n", ret); 138 + goto err_host; 139 + } 140 + 141 + host->hw_name = "sdhci"; 142 + host->ops = &sdhci_pltfm_ops; 143 + host->irq = platform_get_irq(pdev, 0); 144 + host->quirks = SDHCI_QUIRK_BROKEN_ADMA; 118 145 119 146 sdhci = sdhci_priv(host); 120 147 ··· 158 159 } 159 160 } else { 160 161 sdhci->data = dev_get_platdata(&pdev->dev); 161 - } 162 - 163 - host->hw_name = "sdhci"; 164 - host->ops = &sdhci_pltfm_ops; 165 - host->irq = platform_get_irq(pdev, 0); 166 - host->quirks = SDHCI_QUIRK_BROKEN_ADMA; 167 - 168 - host->ioaddr = devm_ioremap(&pdev->dev, iomem->start, 169 - resource_size(iomem)); 170 - if (!host->ioaddr) { 171 - ret = -ENOMEM; 172 - dev_dbg(&pdev->dev, "failed to remap registers\n"); 173 - goto disable_clk; 174 162 } 175 163 176 164 ret = sdhci_add_host(host);