diff options
author | Russell King - ARM Linux <linux@arm.linux.org.uk> | 2009-03-29 14:23:42 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-11-09 02:30:11 -0500 |
commit | da4f007375197d6683461b995d404b01a7fdf2f5 (patch) | |
tree | 310c773abd405610c2dfcb952c1dead23885e6d9 /drivers/pcmcia | |
parent | be85458edce0f165cff62622f5e73b1d17b1e228 (diff) |
PCMCIA: soc_common: push socket probe down into SoC specific support
Move the individual socket probing and initialization down into the
SoC specific support files, thereby allowing soc_common_drv_pcmcia_probe
to be eliminated. soc_common.c now no longer deals with distinct groups
of sockets.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/pxa2xx_base.c | 77 | ||||
-rw-r--r-- | drivers/pcmcia/sa11xx_base.c | 91 | ||||
-rw-r--r-- | drivers/pcmcia/soc_common.c | 37 | ||||
-rw-r--r-- | drivers/pcmcia/soc_common.h | 2 |
4 files changed, 103 insertions, 104 deletions
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 8a91106056fc..3cb4fd21cc2f 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -228,6 +228,31 @@ static const char *skt_names[] = { | |||
228 | #define SKT_DEV_INFO_SIZE(n) \ | 228 | #define SKT_DEV_INFO_SIZE(n) \ |
229 | (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket)) | 229 | (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket)) |
230 | 230 | ||
231 | static int pxa2xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt) | ||
232 | { | ||
233 | skt->res_skt.start = _PCMCIA(skt->nr); | ||
234 | skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1; | ||
235 | skt->res_skt.name = skt_names[skt->nr]; | ||
236 | skt->res_skt.flags = IORESOURCE_MEM; | ||
237 | |||
238 | skt->res_io.start = _PCMCIAIO(skt->nr); | ||
239 | skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1; | ||
240 | skt->res_io.name = "io"; | ||
241 | skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
242 | |||
243 | skt->res_mem.start = _PCMCIAMem(skt->nr); | ||
244 | skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1; | ||
245 | skt->res_mem.name = "memory"; | ||
246 | skt->res_mem.flags = IORESOURCE_MEM; | ||
247 | |||
248 | skt->res_attr.start = _PCMCIAAttr(skt->nr); | ||
249 | skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1; | ||
250 | skt->res_attr.name = "attribute"; | ||
251 | skt->res_attr.flags = IORESOURCE_MEM; | ||
252 | |||
253 | return soc_pcmcia_add_one(skt); | ||
254 | } | ||
255 | |||
231 | int __pxa2xx_drv_pcmcia_probe(struct device *dev) | 256 | int __pxa2xx_drv_pcmcia_probe(struct device *dev) |
232 | { | 257 | { |
233 | int i, ret; | 258 | int i, ret; |
@@ -240,6 +265,12 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev) | |||
240 | 265 | ||
241 | ops = (struct pcmcia_low_level *)dev->platform_data; | 266 | ops = (struct pcmcia_low_level *)dev->platform_data; |
242 | 267 | ||
268 | /* Provide our PXA2xx specific timing routines. */ | ||
269 | ops->set_timing = pxa2xx_pcmcia_set_timing; | ||
270 | #ifdef CONFIG_CPU_FREQ | ||
271 | ops->frequency_change = pxa2xx_pcmcia_frequency_change; | ||
272 | #endif | ||
273 | |||
243 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); | 274 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL); |
244 | if (!sinfo) | 275 | if (!sinfo) |
245 | return -ENOMEM; | 276 | return -ENOMEM; |
@@ -250,40 +281,26 @@ int __pxa2xx_drv_pcmcia_probe(struct device *dev) | |||
250 | for (i = 0; i < ops->nr; i++) { | 281 | for (i = 0; i < ops->nr; i++) { |
251 | skt = &sinfo->skt[i]; | 282 | skt = &sinfo->skt[i]; |
252 | 283 | ||
253 | skt->nr = ops->first + i; | 284 | skt->nr = ops->first + i; |
254 | skt->irq = NO_IRQ; | 285 | skt->irq = NO_IRQ; |
255 | 286 | skt->dev = dev; | |
256 | skt->res_skt.start = _PCMCIA(skt->nr); | 287 | skt->ops = ops; |
257 | skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1; | 288 | skt->socket.owner = ops->owner; |
258 | skt->res_skt.name = skt_names[skt->nr]; | 289 | skt->socket.dev.parent = dev; |
259 | skt->res_skt.flags = IORESOURCE_MEM; | ||
260 | 290 | ||
261 | skt->res_io.start = _PCMCIAIO(skt->nr); | 291 | ret = pxa2xx_drv_pcmcia_add_one(skt); |
262 | skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1; | 292 | if (ret) |
263 | skt->res_io.name = "io"; | 293 | break; |
264 | skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
265 | |||
266 | skt->res_mem.start = _PCMCIAMem(skt->nr); | ||
267 | skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1; | ||
268 | skt->res_mem.name = "memory"; | ||
269 | skt->res_mem.flags = IORESOURCE_MEM; | ||
270 | |||
271 | skt->res_attr.start = _PCMCIAAttr(skt->nr); | ||
272 | skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1; | ||
273 | skt->res_attr.name = "attribute"; | ||
274 | skt->res_attr.flags = IORESOURCE_MEM; | ||
275 | } | 294 | } |
276 | 295 | ||
277 | /* Provide our PXA2xx specific timing routines. */ | 296 | if (ret) { |
278 | ops->set_timing = pxa2xx_pcmcia_set_timing; | 297 | while (--i >= 0) |
279 | #ifdef CONFIG_CPU_FREQ | 298 | soc_pcmcia_remove_one(&sinfo->skt[i]); |
280 | ops->frequency_change = pxa2xx_pcmcia_frequency_change; | 299 | kfree(sinfo); |
281 | #endif | 300 | } else { |
282 | |||
283 | ret = soc_common_drv_pcmcia_probe(dev, ops, sinfo); | ||
284 | |||
285 | if (!ret) | ||
286 | pxa2xx_configure_sockets(dev); | 301 | pxa2xx_configure_sockets(dev); |
302 | dev_set_drvdata(dev, sinfo); | ||
303 | } | ||
287 | 304 | ||
288 | return ret; | 305 | return ret; |
289 | } | 306 | } |
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c index e15d59f2d8a9..92a43486adc6 100644 --- a/drivers/pcmcia/sa11xx_base.c +++ b/drivers/pcmcia/sa11xx_base.c | |||
@@ -171,6 +171,31 @@ static const char *skt_names[] = { | |||
171 | #define SKT_DEV_INFO_SIZE(n) \ | 171 | #define SKT_DEV_INFO_SIZE(n) \ |
172 | (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket)) | 172 | (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket)) |
173 | 173 | ||
174 | static int sa11xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt) | ||
175 | { | ||
176 | skt->res_skt.start = _PCMCIA(skt->nr); | ||
177 | skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1; | ||
178 | skt->res_skt.name = skt_names[skt->nr]; | ||
179 | skt->res_skt.flags = IORESOURCE_MEM; | ||
180 | |||
181 | skt->res_io.start = _PCMCIAIO(skt->nr); | ||
182 | skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1; | ||
183 | skt->res_io.name = "io"; | ||
184 | skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
185 | |||
186 | skt->res_mem.start = _PCMCIAMem(skt->nr); | ||
187 | skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1; | ||
188 | skt->res_mem.name = "memory"; | ||
189 | skt->res_mem.flags = IORESOURCE_MEM; | ||
190 | |||
191 | skt->res_attr.start = _PCMCIAAttr(skt->nr); | ||
192 | skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1; | ||
193 | skt->res_attr.name = "attribute"; | ||
194 | skt->res_attr.flags = IORESOURCE_MEM; | ||
195 | |||
196 | return soc_pcmcia_add_one(skt); | ||
197 | } | ||
198 | |||
174 | int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, | 199 | int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, |
175 | int first, int nr) | 200 | int first, int nr) |
176 | { | 201 | { |
@@ -178,40 +203,6 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, | |||
178 | struct soc_pcmcia_socket *skt; | 203 | struct soc_pcmcia_socket *skt; |
179 | int i; | 204 | int i; |
180 | 205 | ||
181 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); | ||
182 | if (!sinfo) | ||
183 | return -ENOMEM; | ||
184 | |||
185 | sinfo->nskt = nr; | ||
186 | |||
187 | /* Initiliaze processor specific parameters */ | ||
188 | for (i = 0; i < nr; i++) { | ||
189 | skt = &sinfo->skt[i]; | ||
190 | |||
191 | skt->nr = first + i; | ||
192 | skt->irq = NO_IRQ; | ||
193 | |||
194 | skt->res_skt.start = _PCMCIA(skt->nr); | ||
195 | skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1; | ||
196 | skt->res_skt.name = skt_names[skt->nr]; | ||
197 | skt->res_skt.flags = IORESOURCE_MEM; | ||
198 | |||
199 | skt->res_io.start = _PCMCIAIO(skt->nr); | ||
200 | skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1; | ||
201 | skt->res_io.name = "io"; | ||
202 | skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
203 | |||
204 | skt->res_mem.start = _PCMCIAMem(skt->nr); | ||
205 | skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1; | ||
206 | skt->res_mem.name = "memory"; | ||
207 | skt->res_mem.flags = IORESOURCE_MEM; | ||
208 | |||
209 | skt->res_attr.start = _PCMCIAAttr(skt->nr); | ||
210 | skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1; | ||
211 | skt->res_attr.name = "attribute"; | ||
212 | skt->res_attr.flags = IORESOURCE_MEM; | ||
213 | } | ||
214 | |||
215 | /* | 206 | /* |
216 | * set default MECR calculation if the board specific | 207 | * set default MECR calculation if the board specific |
217 | * code did not specify one... | 208 | * code did not specify one... |
@@ -226,7 +217,37 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, | |||
226 | ops->frequency_change = sa1100_pcmcia_frequency_change; | 217 | ops->frequency_change = sa1100_pcmcia_frequency_change; |
227 | #endif | 218 | #endif |
228 | 219 | ||
229 | return soc_common_drv_pcmcia_probe(dev, ops, sinfo); | 220 | sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); |
221 | if (!sinfo) | ||
222 | return -ENOMEM; | ||
223 | |||
224 | sinfo->nskt = nr; | ||
225 | |||
226 | /* Initiliaze processor specific parameters */ | ||
227 | for (i = 0; i < nr; i++) { | ||
228 | skt = &sinfo->skt[i]; | ||
229 | |||
230 | skt->nr = first + i; | ||
231 | skt->irq = NO_IRQ; | ||
232 | skt->dev = dev; | ||
233 | skt->ops = ops; | ||
234 | skt->socket.owner = ops->owner; | ||
235 | skt->socket.dev.parent = dev; | ||
236 | |||
237 | ret = sa11xx_drv_pcmcia_add_one(skt); | ||
238 | if (ret) | ||
239 | break; | ||
240 | } | ||
241 | |||
242 | if (ret) { | ||
243 | while (--i >= 0) | ||
244 | soc_pcmcia_remove_one(&sinfo->skt[i]); | ||
245 | kfree(sinfo); | ||
246 | } else { | ||
247 | dev_set_drvdata(dev, sinfo); | ||
248 | } | ||
249 | |||
250 | return ret; | ||
230 | } | 251 | } |
231 | EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe); | 252 | EXPORT_SYMBOL(sa11xx_drv_pcmcia_probe); |
232 | 253 | ||
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index fb5377d17af4..6bc60f84a44a 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c | |||
@@ -741,43 +741,6 @@ int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt) | |||
741 | } | 741 | } |
742 | EXPORT_SYMBOL(soc_pcmcia_add_one); | 742 | EXPORT_SYMBOL(soc_pcmcia_add_one); |
743 | 743 | ||
744 | int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, | ||
745 | struct skt_dev_info *sinfo) | ||
746 | { | ||
747 | struct soc_pcmcia_socket *skt; | ||
748 | int ret, i; | ||
749 | |||
750 | /* | ||
751 | * Initialise the per-socket structure. | ||
752 | */ | ||
753 | for (i = ret = 0; i < sinfo->nskt; i++) { | ||
754 | skt = &sinfo->skt[i]; | ||
755 | |||
756 | skt->socket.owner = ops->owner; | ||
757 | skt->socket.dev.parent = dev; | ||
758 | |||
759 | skt->dev = dev; | ||
760 | skt->ops = ops; | ||
761 | |||
762 | ret = soc_pcmcia_add_one(skt); | ||
763 | if (ret) | ||
764 | break; | ||
765 | |||
766 | WARN_ON(skt->socket.sock != i); | ||
767 | } | ||
768 | |||
769 | if (ret) { | ||
770 | while (--i >= 0) | ||
771 | soc_pcmcia_remove_one(&sinfo->skt[i]); | ||
772 | kfree(sinfo); | ||
773 | } else { | ||
774 | dev_set_drvdata(dev, sinfo); | ||
775 | } | ||
776 | |||
777 | return ret; | ||
778 | } | ||
779 | EXPORT_SYMBOL(soc_common_drv_pcmcia_probe); | ||
780 | |||
781 | MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>"); | 744 | MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>"); |
782 | MODULE_DESCRIPTION("Linux PCMCIA Card Services: Common SoC support"); | 745 | MODULE_DESCRIPTION("Linux PCMCIA Card Services: Common SoC support"); |
783 | MODULE_LICENSE("Dual MPL/GPL"); | 746 | MODULE_LICENSE("Dual MPL/GPL"); |
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h index c33b8c314fb0..8a755c1a949a 100644 --- a/drivers/pcmcia/soc_common.h +++ b/drivers/pcmcia/soc_common.h | |||
@@ -138,8 +138,6 @@ extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_ | |||
138 | void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt); | 138 | void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt); |
139 | int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt); | 139 | int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt); |
140 | 140 | ||
141 | extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, struct skt_dev_info *sinfo); | ||
142 | |||
143 | 141 | ||
144 | #ifdef CONFIG_PCMCIA_DEBUG | 142 | #ifdef CONFIG_PCMCIA_DEBUG |
145 | 143 | ||