diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-02 09:30:31 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2008-08-22 19:22:00 -0400 |
commit | 8e2fc39ddea7fe8c6798837da282db88a09af793 (patch) | |
tree | 7cba37b5b86f4ff25562012a14e29424e3872de0 /drivers/net/wireless/airo_cs.c | |
parent | 498ac1899b62626bf6879a251d75c22ec564c559 (diff) |
pcmcia: pcmcia_config_loop() default CIS entry handling
Many drivers use the default CIS entry within their pcmcia_config_loop()
callback function. Therefore, factor the default CIS entry handling out.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless/airo_cs.c')
-rw-r--r-- | drivers/net/wireless/airo_cs.c | 51 |
1 files changed, 22 insertions, 29 deletions
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index d7216730f18e..657adf85ab77 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c | |||
@@ -206,19 +206,12 @@ static void airo_detach(struct pcmcia_device *link) | |||
206 | #define CS_CHECK(fn, ret) \ | 206 | #define CS_CHECK(fn, ret) \ |
207 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 207 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
208 | 208 | ||
209 | struct airo_cs_config_data { | ||
210 | cistpl_cftable_entry_t dflt; | ||
211 | win_req_t req; | ||
212 | }; | ||
213 | |||
214 | static int airo_cs_config_check(struct pcmcia_device *p_dev, | 209 | static int airo_cs_config_check(struct pcmcia_device *p_dev, |
215 | cistpl_cftable_entry_t *cfg, | 210 | cistpl_cftable_entry_t *cfg, |
211 | cistpl_cftable_entry_t *dflt, | ||
216 | void *priv_data) | 212 | void *priv_data) |
217 | { | 213 | { |
218 | struct airo_cs_config_data *cfg_mem = priv_data; | 214 | win_req_t *req = priv_data; |
219 | |||
220 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
221 | cfg_mem->dflt = *cfg; | ||
222 | 215 | ||
223 | if (cfg->index == 0) | 216 | if (cfg->index == 0) |
224 | return -ENODEV; | 217 | return -ENODEV; |
@@ -233,17 +226,17 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev, | |||
233 | /* Note that the CIS values need to be rescaled */ | 226 | /* Note that the CIS values need to be rescaled */ |
234 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | 227 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) |
235 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | 228 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; |
236 | else if (cfg_mem->dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | 229 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) |
237 | p_dev->conf.Vpp = cfg_mem->dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | 230 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; |
238 | 231 | ||
239 | /* Do we need to allocate an interrupt? */ | 232 | /* Do we need to allocate an interrupt? */ |
240 | if (cfg->irq.IRQInfo1 || cfg_mem->dflt.irq.IRQInfo1) | 233 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) |
241 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | 234 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; |
242 | 235 | ||
243 | /* IO window settings */ | 236 | /* IO window settings */ |
244 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | 237 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; |
245 | if ((cfg->io.nwin > 0) || (cfg_mem->dflt.io.nwin > 0)) { | 238 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { |
246 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &cfg_mem->dflt.io; | 239 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; |
247 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 240 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
248 | if (!(io->flags & CISTPL_IO_8BIT)) | 241 | if (!(io->flags & CISTPL_IO_8BIT)) |
249 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 242 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
@@ -273,14 +266,14 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev, | |||
273 | needs to be mapped to virtual space with ioremap() before it | 266 | needs to be mapped to virtual space with ioremap() before it |
274 | is used. | 267 | is used. |
275 | */ | 268 | */ |
276 | if ((cfg->mem.nwin > 0) || (cfg_mem->dflt.mem.nwin > 0)) { | 269 | if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { |
277 | cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &cfg_mem->dflt.mem; | 270 | cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; |
278 | memreq_t map; | 271 | memreq_t map; |
279 | cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | 272 | req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; |
280 | cfg_mem->req.Base = mem->win[0].host_addr; | 273 | req->Base = mem->win[0].host_addr; |
281 | cfg_mem->req.Size = mem->win[0].len; | 274 | req->Size = mem->win[0].len; |
282 | cfg_mem->req.AccessSpeed = 0; | 275 | req->AccessSpeed = 0; |
283 | if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0) | 276 | if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) |
284 | return -ENODEV; | 277 | return -ENODEV; |
285 | map.Page = 0; | 278 | map.Page = 0; |
286 | map.CardOffset = mem->win[0].card_addr; | 279 | map.CardOffset = mem->win[0].card_addr; |
@@ -295,15 +288,15 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev, | |||
295 | static int airo_config(struct pcmcia_device *link) | 288 | static int airo_config(struct pcmcia_device *link) |
296 | { | 289 | { |
297 | local_info_t *dev; | 290 | local_info_t *dev; |
298 | struct airo_cs_config_data *cfg_mem; | 291 | win_req_t *req; |
299 | int last_fn, last_ret; | 292 | int last_fn, last_ret; |
300 | 293 | ||
301 | dev = link->priv; | 294 | dev = link->priv; |
302 | 295 | ||
303 | DEBUG(0, "airo_config(0x%p)\n", link); | 296 | DEBUG(0, "airo_config(0x%p)\n", link); |
304 | 297 | ||
305 | cfg_mem = kzalloc(sizeof(struct airo_cs_config_data), GFP_KERNEL); | 298 | req = kzalloc(sizeof(win_req_t), GFP_KERNEL); |
306 | if (!cfg_mem) | 299 | if (!req) |
307 | return -ENOMEM; | 300 | return -ENOMEM; |
308 | 301 | ||
309 | /* | 302 | /* |
@@ -320,7 +313,7 @@ static int airo_config(struct pcmcia_device *link) | |||
320 | * and most client drivers will only use the CIS to fill in | 313 | * and most client drivers will only use the CIS to fill in |
321 | * implementation-defined details. | 314 | * implementation-defined details. |
322 | */ | 315 | */ |
323 | last_ret = pcmcia_loop_config(link, airo_cs_config_check, cfg_mem); | 316 | last_ret = pcmcia_loop_config(link, airo_cs_config_check, req); |
324 | if (last_ret) | 317 | if (last_ret) |
325 | goto failed; | 318 | goto failed; |
326 | 319 | ||
@@ -365,17 +358,17 @@ static int airo_config(struct pcmcia_device *link) | |||
365 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | 358 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, |
366 | link->io.BasePort2+link->io.NumPorts2-1); | 359 | link->io.BasePort2+link->io.NumPorts2-1); |
367 | if (link->win) | 360 | if (link->win) |
368 | printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, | 361 | printk(", mem 0x%06lx-0x%06lx", req->Base, |
369 | cfg_mem->req.Base+cfg_mem->req.Size-1); | 362 | req->Base+req->Size-1); |
370 | printk("\n"); | 363 | printk("\n"); |
371 | kfree(cfg_mem); | 364 | kfree(req); |
372 | return 0; | 365 | return 0; |
373 | 366 | ||
374 | cs_failed: | 367 | cs_failed: |
375 | cs_error(link, last_fn, last_ret); | 368 | cs_error(link, last_fn, last_ret); |
376 | failed: | 369 | failed: |
377 | airo_release(link); | 370 | airo_release(link); |
378 | kfree(cfg_mem); | 371 | kfree(req); |
379 | return -ENODEV; | 372 | return -ENODEV; |
380 | } /* airo_config */ | 373 | } /* airo_config */ |
381 | 374 | ||