diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-02-28 16:32:39 -0500 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-03-04 16:28:42 -0500 |
commit | 475d9e3ebf869cc637342b74af20632551769902 (patch) | |
tree | 88dd5bc792c4ac1a9027e49163dbc72fe8db3bf4 | |
parent | fcdb7c8f5019f77b1f55739a1caf9168d3b455d4 (diff) |
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>
-rw-r--r-- | drivers/mmc/host/sdhci-spear.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index d89267eb14b6..fc6eac5b1064 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c | |||
@@ -108,20 +108,6 @@ static int sdhci_probe(struct platform_device *pdev) | |||
108 | struct device *dev; | 108 | struct device *dev; |
109 | int ret; | 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 | dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev; | 111 | dev = pdev->dev.parent ? pdev->dev.parent : &pdev->dev; |
126 | host = sdhci_alloc_host(dev, sizeof(*sdhci)); | 112 | host = sdhci_alloc_host(dev, sizeof(*sdhci)); |
127 | if (IS_ERR(host)) { | 113 | if (IS_ERR(host)) { |
@@ -130,6 +116,19 @@ static int sdhci_probe(struct platform_device *pdev) | |||
130 | goto err; | 116 | goto err; |
131 | } | 117 | } |
132 | 118 | ||
119 | iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
120 | host->ioaddr = devm_ioremap_resource(&pdev->dev, iomem); | ||
121 | if (IS_ERR(host->ioaddr)) { | ||
122 | ret = PTR_ERR(host->ioaddr); | ||
123 | dev_dbg(&pdev->dev, "unable to map iomem: %d\n", ret); | ||
124 | goto err_host; | ||
125 | } | ||
126 | |||
127 | host->hw_name = "sdhci"; | ||
128 | host->ops = &sdhci_pltfm_ops; | ||
129 | host->irq = platform_get_irq(pdev, 0); | ||
130 | host->quirks = SDHCI_QUIRK_BROKEN_ADMA; | ||
131 | |||
133 | sdhci = sdhci_priv(host); | 132 | sdhci = sdhci_priv(host); |
134 | 133 | ||
135 | /* clk enable */ | 134 | /* clk enable */ |
@@ -161,19 +160,6 @@ static int sdhci_probe(struct platform_device *pdev) | |||
161 | sdhci->data = dev_get_platdata(&pdev->dev); | 160 | sdhci->data = dev_get_platdata(&pdev->dev); |
162 | } | 161 | } |
163 | 162 | ||
164 | host->hw_name = "sdhci"; | ||
165 | host->ops = &sdhci_pltfm_ops; | ||
166 | host->irq = platform_get_irq(pdev, 0); | ||
167 | host->quirks = SDHCI_QUIRK_BROKEN_ADMA; | ||
168 | |||
169 | host->ioaddr = devm_ioremap(&pdev->dev, iomem->start, | ||
170 | resource_size(iomem)); | ||
171 | if (!host->ioaddr) { | ||
172 | ret = -ENOMEM; | ||
173 | dev_dbg(&pdev->dev, "failed to remap registers\n"); | ||
174 | goto disable_clk; | ||
175 | } | ||
176 | |||
177 | ret = sdhci_add_host(host); | 163 | ret = sdhci_add_host(host); |
178 | if (ret) { | 164 | if (ret) { |
179 | dev_dbg(&pdev->dev, "error adding host\n"); | 165 | dev_dbg(&pdev->dev, "error adding host\n"); |