diff options
Diffstat (limited to 'drivers')
74 files changed, 2576 insertions, 2869 deletions
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 41b4361bbf6e..02b596b9cf6a 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c | |||
@@ -148,6 +148,64 @@ static struct ata_port_operations pcmcia_8bit_port_ops = { | |||
148 | #define CS_CHECK(fn, ret) \ | 148 | #define CS_CHECK(fn, ret) \ |
149 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 149 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
150 | 150 | ||
151 | |||
152 | struct pcmcia_config_check { | ||
153 | unsigned long ctl_base; | ||
154 | int skip_vcc; | ||
155 | int is_kme; | ||
156 | }; | ||
157 | |||
158 | static int pcmcia_check_one_config(struct pcmcia_device *pdev, | ||
159 | cistpl_cftable_entry_t *cfg, | ||
160 | cistpl_cftable_entry_t *dflt, | ||
161 | unsigned int vcc, | ||
162 | void *priv_data) | ||
163 | { | ||
164 | struct pcmcia_config_check *stk = priv_data; | ||
165 | |||
166 | /* Check for matching Vcc, unless we're desperate */ | ||
167 | if (!stk->skip_vcc) { | ||
168 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
169 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
170 | return -ENODEV; | ||
171 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
172 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
173 | return -ENODEV; | ||
174 | } | ||
175 | } | ||
176 | |||
177 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
178 | pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
179 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
180 | pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
181 | |||
182 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
183 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
184 | pdev->io.BasePort1 = io->win[0].base; | ||
185 | pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
186 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
187 | pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
188 | if (io->nwin == 2) { | ||
189 | pdev->io.NumPorts1 = 8; | ||
190 | pdev->io.BasePort2 = io->win[1].base; | ||
191 | pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; | ||
192 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
193 | return -ENODEV; | ||
194 | stk->ctl_base = pdev->io.BasePort2; | ||
195 | } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { | ||
196 | pdev->io.NumPorts1 = io->win[0].len; | ||
197 | pdev->io.NumPorts2 = 0; | ||
198 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
199 | return -ENODEV; | ||
200 | stk->ctl_base = pdev->io.BasePort1 + 0x0e; | ||
201 | } else | ||
202 | return -ENODEV; | ||
203 | /* If we've got this far, we're done */ | ||
204 | return 0; | ||
205 | } | ||
206 | return -ENODEV; | ||
207 | } | ||
208 | |||
151 | /** | 209 | /** |
152 | * pcmcia_init_one - attach a PCMCIA interface | 210 | * pcmcia_init_one - attach a PCMCIA interface |
153 | * @pdev: pcmcia device | 211 | * @pdev: pcmcia device |
@@ -161,19 +219,11 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) | |||
161 | struct ata_host *host; | 219 | struct ata_host *host; |
162 | struct ata_port *ap; | 220 | struct ata_port *ap; |
163 | struct ata_pcmcia_info *info; | 221 | struct ata_pcmcia_info *info; |
164 | tuple_t tuple; | 222 | struct pcmcia_config_check *stk = NULL; |
165 | struct { | 223 | int last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p; |
166 | unsigned short buf[128]; | ||
167 | cisparse_t parse; | ||
168 | config_info_t conf; | ||
169 | cistpl_cftable_entry_t dflt; | ||
170 | } *stk = NULL; | ||
171 | cistpl_cftable_entry_t *cfg; | ||
172 | int pass, last_ret = 0, last_fn = 0, is_kme = 0, ret = -ENOMEM, p; | ||
173 | unsigned long io_base, ctl_base; | 224 | unsigned long io_base, ctl_base; |
174 | void __iomem *io_addr, *ctl_addr; | 225 | void __iomem *io_addr, *ctl_addr; |
175 | int n_ports = 1; | 226 | int n_ports = 1; |
176 | |||
177 | struct ata_port_operations *ops = &pcmcia_port_ops; | 227 | struct ata_port_operations *ops = &pcmcia_port_ops; |
178 | 228 | ||
179 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 229 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
@@ -193,96 +243,27 @@ static int pcmcia_init_one(struct pcmcia_device *pdev) | |||
193 | pdev->conf.Attributes = CONF_ENABLE_IRQ; | 243 | pdev->conf.Attributes = CONF_ENABLE_IRQ; |
194 | pdev->conf.IntType = INT_MEMORY_AND_IO; | 244 | pdev->conf.IntType = INT_MEMORY_AND_IO; |
195 | 245 | ||
196 | /* Allocate resoure probing structures */ | ||
197 | |||
198 | stk = kzalloc(sizeof(*stk), GFP_KERNEL); | ||
199 | if (!stk) | ||
200 | goto out1; | ||
201 | |||
202 | cfg = &stk->parse.cftable_entry; | ||
203 | |||
204 | /* Tuples we are walking */ | ||
205 | tuple.TupleData = (cisdata_t *)&stk->buf; | ||
206 | tuple.TupleOffset = 0; | ||
207 | tuple.TupleDataMax = 255; | ||
208 | tuple.Attributes = 0; | ||
209 | |||
210 | /* See if we have a manufacturer identifier. Use it to set is_kme for | 246 | /* See if we have a manufacturer identifier. Use it to set is_kme for |
211 | vendor quirks */ | 247 | vendor quirks */ |
212 | is_kme = ((pdev->manf_id == MANFID_KME) && | 248 | is_kme = ((pdev->manf_id == MANFID_KME) && |
213 | ((pdev->card_id == PRODID_KME_KXLC005_A) || | 249 | ((pdev->card_id == PRODID_KME_KXLC005_A) || |
214 | (pdev->card_id == PRODID_KME_KXLC005_B))); | 250 | (pdev->card_id == PRODID_KME_KXLC005_B))); |
215 | 251 | ||
216 | /* Not sure if this is right... look up the current Vcc */ | 252 | /* Allocate resoure probing structures */ |
217 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); | ||
218 | /* link->conf.Vcc = stk->conf.Vcc; */ | ||
219 | |||
220 | pass = io_base = ctl_base = 0; | ||
221 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
222 | tuple.Attributes = 0; | ||
223 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); | ||
224 | |||
225 | /* Now munch the resources looking for a suitable set */ | ||
226 | while (1) { | ||
227 | if (pcmcia_get_tuple_data(pdev, &tuple) != 0) | ||
228 | goto next_entry; | ||
229 | if (pcmcia_parse_tuple(pdev, &tuple, &stk->parse) != 0) | ||
230 | goto next_entry; | ||
231 | /* Check for matching Vcc, unless we're desperate */ | ||
232 | if (!pass) { | ||
233 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
234 | if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
235 | goto next_entry; | ||
236 | } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
237 | if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
238 | goto next_entry; | ||
239 | } | ||
240 | } | ||
241 | 253 | ||
242 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 254 | stk = kzalloc(sizeof(*stk), GFP_KERNEL); |
243 | pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 255 | if (!stk) |
244 | else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | 256 | goto out1; |
245 | pdev->conf.Vpp = stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 257 | stk->is_kme = is_kme; |
246 | 258 | stk->skip_vcc = io_base = ctl_base = 0; | |
247 | if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { | ||
248 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; | ||
249 | pdev->conf.ConfigIndex = cfg->index; | ||
250 | pdev->io.BasePort1 = io->win[0].base; | ||
251 | pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
252 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
253 | pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
254 | if (io->nwin == 2) { | ||
255 | pdev->io.NumPorts1 = 8; | ||
256 | pdev->io.BasePort2 = io->win[1].base; | ||
257 | pdev->io.NumPorts2 = (is_kme) ? 2 : 1; | ||
258 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
259 | goto next_entry; | ||
260 | io_base = pdev->io.BasePort1; | ||
261 | ctl_base = pdev->io.BasePort2; | ||
262 | } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { | ||
263 | pdev->io.NumPorts1 = io->win[0].len; | ||
264 | pdev->io.NumPorts2 = 0; | ||
265 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
266 | goto next_entry; | ||
267 | io_base = pdev->io.BasePort1; | ||
268 | ctl_base = pdev->io.BasePort1 + 0x0e; | ||
269 | } else | ||
270 | goto next_entry; | ||
271 | /* If we've got this far, we're done */ | ||
272 | break; | ||
273 | } | ||
274 | next_entry: | ||
275 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
276 | memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); | ||
277 | if (pass) { | ||
278 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(pdev, &tuple)); | ||
279 | } else if (pcmcia_get_next_tuple(pdev, &tuple) != 0) { | ||
280 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple)); | ||
281 | memset(&stk->dflt, 0, sizeof(stk->dflt)); | ||
282 | pass++; | ||
283 | } | ||
284 | } | ||
285 | 259 | ||
260 | if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) { | ||
261 | stk->skip_vcc = 1; | ||
262 | if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) | ||
263 | goto failed; /* No suitable config found */ | ||
264 | } | ||
265 | io_base = pdev->io.BasePort1; | ||
266 | ctl_base = stk->ctl_base; | ||
286 | CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); | 267 | CS_CHECK(RequestIRQ, pcmcia_request_irq(pdev, &pdev->irq)); |
287 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); | 268 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(pdev, &pdev->conf)); |
288 | 269 | ||
@@ -384,6 +365,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
384 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), | 365 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), |
385 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), | 366 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), |
386 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ | 367 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ |
368 | PCMCIA_DEVICE_MANF_CARD(0x004f, 0x0000), /* Kingston */ | ||
387 | PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ | 369 | PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ |
388 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ | 370 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ |
389 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), | 371 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), |
@@ -404,9 +386,9 @@ static struct pcmcia_device_id pcmcia_devices[] = { | |||
404 | PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), | 386 | PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), |
405 | PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), | 387 | PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), |
406 | PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), | 388 | PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), |
407 | PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), | ||
408 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), | 389 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), |
409 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), | 390 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), |
391 | PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420), | ||
410 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), | 392 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), |
411 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), | 393 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), |
412 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), | 394 | PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), |
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index bcf57927b7a8..e6ee21d99d92 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -901,23 +901,23 @@ static int bluecard_config(struct pcmcia_device *link) | |||
901 | for (n = 0; n < 0x400; n += 0x40) { | 901 | for (n = 0; n < 0x400; n += 0x40) { |
902 | link->io.BasePort1 = n ^ 0x300; | 902 | link->io.BasePort1 = n ^ 0x300; |
903 | i = pcmcia_request_io(link, &link->io); | 903 | i = pcmcia_request_io(link, &link->io); |
904 | if (i == CS_SUCCESS) | 904 | if (i == 0) |
905 | break; | 905 | break; |
906 | } | 906 | } |
907 | 907 | ||
908 | if (i != CS_SUCCESS) { | 908 | if (i != 0) { |
909 | cs_error(link, RequestIO, i); | 909 | cs_error(link, RequestIO, i); |
910 | goto failed; | 910 | goto failed; |
911 | } | 911 | } |
912 | 912 | ||
913 | i = pcmcia_request_irq(link, &link->irq); | 913 | i = pcmcia_request_irq(link, &link->irq); |
914 | if (i != CS_SUCCESS) { | 914 | if (i != 0) { |
915 | cs_error(link, RequestIRQ, i); | 915 | cs_error(link, RequestIRQ, i); |
916 | link->irq.AssignedIRQ = 0; | 916 | link->irq.AssignedIRQ = 0; |
917 | } | 917 | } |
918 | 918 | ||
919 | i = pcmcia_request_configuration(link, &link->conf); | 919 | i = pcmcia_request_configuration(link, &link->conf); |
920 | if (i != CS_SUCCESS) { | 920 | if (i != 0) { |
921 | cs_error(link, RequestConfiguration, i); | 921 | cs_error(link, RequestConfiguration, i); |
922 | goto failed; | 922 | goto failed; |
923 | } | 923 | } |
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 27058477cc8b..2cbe70b66470 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -678,101 +678,78 @@ static void bt3c_detach(struct pcmcia_device *link) | |||
678 | kfree(info); | 678 | kfree(info); |
679 | } | 679 | } |
680 | 680 | ||
681 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 681 | static int bt3c_check_config(struct pcmcia_device *p_dev, |
682 | cistpl_cftable_entry_t *cf, | ||
683 | cistpl_cftable_entry_t *dflt, | ||
684 | unsigned int vcc, | ||
685 | void *priv_data) | ||
682 | { | 686 | { |
683 | int i; | 687 | unsigned long try = (unsigned long) priv_data; |
684 | 688 | ||
685 | i = pcmcia_get_tuple_data(handle, tuple); | 689 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
686 | if (i != CS_SUCCESS) | 690 | p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
687 | return i; | 691 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && |
688 | 692 | (cf->io.win[0].base != 0)) { | |
689 | return pcmcia_parse_tuple(handle, tuple, parse); | 693 | p_dev->io.BasePort1 = cf->io.win[0].base; |
690 | } | 694 | p_dev->io.IOAddrLines = (try == 0) ? 16 : |
691 | 695 | cf->io.flags & CISTPL_IO_LINES_MASK; | |
692 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 696 | if (!pcmcia_request_io(p_dev, &p_dev->io)) |
693 | { | 697 | return 0; |
694 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) | 698 | } |
695 | return CS_NO_MORE_ITEMS; | 699 | return -ENODEV; |
696 | return get_tuple(handle, tuple, parse); | ||
697 | } | 700 | } |
698 | 701 | ||
699 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 702 | static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev, |
703 | cistpl_cftable_entry_t *cf, | ||
704 | cistpl_cftable_entry_t *dflt, | ||
705 | unsigned int vcc, | ||
706 | void *priv_data) | ||
700 | { | 707 | { |
701 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) | 708 | static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; |
702 | return CS_NO_MORE_ITEMS; | 709 | int j; |
703 | return get_tuple(handle, tuple, parse); | 710 | |
711 | if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | ||
712 | for (j = 0; j < 5; j++) { | ||
713 | p_dev->io.BasePort1 = base[j]; | ||
714 | p_dev->io.IOAddrLines = base[j] ? 16 : 3; | ||
715 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
716 | return 0; | ||
717 | } | ||
718 | } | ||
719 | return -ENODEV; | ||
704 | } | 720 | } |
705 | 721 | ||
706 | static int bt3c_config(struct pcmcia_device *link) | 722 | static int bt3c_config(struct pcmcia_device *link) |
707 | { | 723 | { |
708 | static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; | ||
709 | bt3c_info_t *info = link->priv; | 724 | bt3c_info_t *info = link->priv; |
710 | tuple_t tuple; | 725 | int i; |
711 | u_short buf[256]; | 726 | unsigned long try; |
712 | cisparse_t parse; | 727 | |
713 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | 728 | /* First pass: look for a config entry that looks normal. |
714 | int i, j, try; | 729 | Two tries: without IO aliases, then with aliases */ |
715 | 730 | for (try = 0; try < 2; try++) | |
716 | /* First pass: look for a config entry that looks normal. */ | 731 | if (!pcmcia_loop_config(link, bt3c_check_config, (void *) try)) |
717 | tuple.TupleData = (cisdata_t *)buf; | 732 | goto found_port; |
718 | tuple.TupleOffset = 0; | ||
719 | tuple.TupleDataMax = 255; | ||
720 | tuple.Attributes = 0; | ||
721 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
722 | /* Two tries: without IO aliases, then with aliases */ | ||
723 | for (try = 0; try < 2; try++) { | ||
724 | i = first_tuple(link, &tuple, &parse); | ||
725 | while (i != CS_NO_MORE_ITEMS) { | ||
726 | if (i != CS_SUCCESS) | ||
727 | goto next_entry; | ||
728 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
729 | link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
730 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { | ||
731 | link->conf.ConfigIndex = cf->index; | ||
732 | link->io.BasePort1 = cf->io.win[0].base; | ||
733 | link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; | ||
734 | i = pcmcia_request_io(link, &link->io); | ||
735 | if (i == CS_SUCCESS) | ||
736 | goto found_port; | ||
737 | } | ||
738 | next_entry: | ||
739 | i = next_tuple(link, &tuple, &parse); | ||
740 | } | ||
741 | } | ||
742 | 733 | ||
743 | /* Second pass: try to find an entry that isn't picky about | 734 | /* Second pass: try to find an entry that isn't picky about |
744 | its base address, then try to grab any standard serial port | 735 | its base address, then try to grab any standard serial port |
745 | address, and finally try to get any free port. */ | 736 | address, and finally try to get any free port. */ |
746 | i = first_tuple(link, &tuple, &parse); | 737 | if (!pcmcia_loop_config(link, bt3c_check_config_notpicky, NULL)) |
747 | while (i != CS_NO_MORE_ITEMS) { | 738 | goto found_port; |
748 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | ||
749 | link->conf.ConfigIndex = cf->index; | ||
750 | for (j = 0; j < 5; j++) { | ||
751 | link->io.BasePort1 = base[j]; | ||
752 | link->io.IOAddrLines = base[j] ? 16 : 3; | ||
753 | i = pcmcia_request_io(link, &link->io); | ||
754 | if (i == CS_SUCCESS) | ||
755 | goto found_port; | ||
756 | } | ||
757 | } | ||
758 | i = next_tuple(link, &tuple, &parse); | ||
759 | } | ||
760 | 739 | ||
761 | found_port: | 740 | BT_ERR("No usable port range found"); |
762 | if (i != CS_SUCCESS) { | 741 | cs_error(link, RequestIO, -ENODEV); |
763 | BT_ERR("No usable port range found"); | 742 | goto failed; |
764 | cs_error(link, RequestIO, i); | ||
765 | goto failed; | ||
766 | } | ||
767 | 743 | ||
744 | found_port: | ||
768 | i = pcmcia_request_irq(link, &link->irq); | 745 | i = pcmcia_request_irq(link, &link->irq); |
769 | if (i != CS_SUCCESS) { | 746 | if (i != 0) { |
770 | cs_error(link, RequestIRQ, i); | 747 | cs_error(link, RequestIRQ, i); |
771 | link->irq.AssignedIRQ = 0; | 748 | link->irq.AssignedIRQ = 0; |
772 | } | 749 | } |
773 | 750 | ||
774 | i = pcmcia_request_configuration(link, &link->conf); | 751 | i = pcmcia_request_configuration(link, &link->conf); |
775 | if (i != CS_SUCCESS) { | 752 | if (i != 0) { |
776 | cs_error(link, RequestConfiguration, i); | 753 | cs_error(link, RequestConfiguration, i); |
777 | goto failed; | 754 | goto failed; |
778 | } | 755 | } |
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 68d1d258e6a4..8e556b7ff9f6 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -607,102 +607,78 @@ static void btuart_detach(struct pcmcia_device *link) | |||
607 | kfree(info); | 607 | kfree(info); |
608 | } | 608 | } |
609 | 609 | ||
610 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 610 | static int btuart_check_config(struct pcmcia_device *p_dev, |
611 | cistpl_cftable_entry_t *cf, | ||
612 | cistpl_cftable_entry_t *dflt, | ||
613 | unsigned int vcc, | ||
614 | void *priv_data) | ||
611 | { | 615 | { |
612 | int i; | 616 | int *try = priv_data; |
613 | 617 | ||
614 | i = pcmcia_get_tuple_data(handle, tuple); | 618 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
615 | if (i != CS_SUCCESS) | 619 | p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
616 | return i; | 620 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && |
617 | 621 | (cf->io.win[0].base != 0)) { | |
618 | return pcmcia_parse_tuple(handle, tuple, parse); | 622 | p_dev->io.BasePort1 = cf->io.win[0].base; |
619 | } | 623 | p_dev->io.IOAddrLines = (*try == 0) ? 16 : |
620 | 624 | cf->io.flags & CISTPL_IO_LINES_MASK; | |
621 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 625 | if (!pcmcia_request_io(p_dev, &p_dev->io)) |
622 | { | 626 | return 0; |
623 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) | 627 | } |
624 | return CS_NO_MORE_ITEMS; | 628 | return -ENODEV; |
625 | return get_tuple(handle, tuple, parse); | ||
626 | } | 629 | } |
627 | 630 | ||
628 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 631 | static int btuart_check_config_notpicky(struct pcmcia_device *p_dev, |
632 | cistpl_cftable_entry_t *cf, | ||
633 | cistpl_cftable_entry_t *dflt, | ||
634 | unsigned int vcc, | ||
635 | void *priv_data) | ||
629 | { | 636 | { |
630 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) | 637 | static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; |
631 | return CS_NO_MORE_ITEMS; | 638 | int j; |
632 | return get_tuple(handle, tuple, parse); | 639 | |
640 | if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | ||
641 | for (j = 0; j < 5; j++) { | ||
642 | p_dev->io.BasePort1 = base[j]; | ||
643 | p_dev->io.IOAddrLines = base[j] ? 16 : 3; | ||
644 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
645 | return 0; | ||
646 | } | ||
647 | } | ||
648 | return -ENODEV; | ||
633 | } | 649 | } |
634 | 650 | ||
635 | static int btuart_config(struct pcmcia_device *link) | 651 | static int btuart_config(struct pcmcia_device *link) |
636 | { | 652 | { |
637 | static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; | ||
638 | btuart_info_t *info = link->priv; | 653 | btuart_info_t *info = link->priv; |
639 | tuple_t tuple; | 654 | int i; |
640 | u_short buf[256]; | 655 | int try; |
641 | cisparse_t parse; | 656 | |
642 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | 657 | /* First pass: look for a config entry that looks normal. |
643 | int i, j, try; | 658 | Two tries: without IO aliases, then with aliases */ |
644 | 659 | for (try = 0; try < 2; try++) | |
645 | /* First pass: look for a config entry that looks normal. */ | 660 | if (!pcmcia_loop_config(link, btuart_check_config, &try)) |
646 | tuple.TupleData = (cisdata_t *) buf; | 661 | goto found_port; |
647 | tuple.TupleOffset = 0; | ||
648 | tuple.TupleDataMax = 255; | ||
649 | tuple.Attributes = 0; | ||
650 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
651 | /* Two tries: without IO aliases, then with aliases */ | ||
652 | for (try = 0; try < 2; try++) { | ||
653 | i = first_tuple(link, &tuple, &parse); | ||
654 | while (i != CS_NO_MORE_ITEMS) { | ||
655 | if (i != CS_SUCCESS) | ||
656 | goto next_entry; | ||
657 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
658 | link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
659 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { | ||
660 | link->conf.ConfigIndex = cf->index; | ||
661 | link->io.BasePort1 = cf->io.win[0].base; | ||
662 | link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; | ||
663 | i = pcmcia_request_io(link, &link->io); | ||
664 | if (i == CS_SUCCESS) | ||
665 | goto found_port; | ||
666 | } | ||
667 | next_entry: | ||
668 | i = next_tuple(link, &tuple, &parse); | ||
669 | } | ||
670 | } | ||
671 | 662 | ||
672 | /* Second pass: try to find an entry that isn't picky about | 663 | /* Second pass: try to find an entry that isn't picky about |
673 | its base address, then try to grab any standard serial port | 664 | its base address, then try to grab any standard serial port |
674 | address, and finally try to get any free port. */ | 665 | address, and finally try to get any free port. */ |
675 | i = first_tuple(link, &tuple, &parse); | 666 | if (!pcmcia_loop_config(link, btuart_check_config_notpicky, NULL)) |
676 | while (i != CS_NO_MORE_ITEMS) { | 667 | goto found_port; |
677 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) | ||
678 | && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | ||
679 | link->conf.ConfigIndex = cf->index; | ||
680 | for (j = 0; j < 5; j++) { | ||
681 | link->io.BasePort1 = base[j]; | ||
682 | link->io.IOAddrLines = base[j] ? 16 : 3; | ||
683 | i = pcmcia_request_io(link, &link->io); | ||
684 | if (i == CS_SUCCESS) | ||
685 | goto found_port; | ||
686 | } | ||
687 | } | ||
688 | i = next_tuple(link, &tuple, &parse); | ||
689 | } | ||
690 | 668 | ||
691 | found_port: | 669 | BT_ERR("No usable port range found"); |
692 | if (i != CS_SUCCESS) { | 670 | cs_error(link, RequestIO, -ENODEV); |
693 | BT_ERR("No usable port range found"); | 671 | goto failed; |
694 | cs_error(link, RequestIO, i); | ||
695 | goto failed; | ||
696 | } | ||
697 | 672 | ||
673 | found_port: | ||
698 | i = pcmcia_request_irq(link, &link->irq); | 674 | i = pcmcia_request_irq(link, &link->irq); |
699 | if (i != CS_SUCCESS) { | 675 | if (i != 0) { |
700 | cs_error(link, RequestIRQ, i); | 676 | cs_error(link, RequestIRQ, i); |
701 | link->irq.AssignedIRQ = 0; | 677 | link->irq.AssignedIRQ = 0; |
702 | } | 678 | } |
703 | 679 | ||
704 | i = pcmcia_request_configuration(link, &link->conf); | 680 | i = pcmcia_request_configuration(link, &link->conf); |
705 | if (i != CS_SUCCESS) { | 681 | if (i != 0) { |
706 | cs_error(link, RequestConfiguration, i); | 682 | cs_error(link, RequestConfiguration, i); |
707 | goto failed; | 683 | goto failed; |
708 | } | 684 | } |
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index dae45cdf02b2..e6e6b037695a 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -590,75 +590,40 @@ static void dtl1_detach(struct pcmcia_device *link) | |||
590 | kfree(info); | 590 | kfree(info); |
591 | } | 591 | } |
592 | 592 | ||
593 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | 593 | static int dtl1_confcheck(struct pcmcia_device *p_dev, |
594 | cistpl_cftable_entry_t *cf, | ||
595 | cistpl_cftable_entry_t *dflt, | ||
596 | unsigned int vcc, | ||
597 | void *priv_data) | ||
594 | { | 598 | { |
595 | int i; | 599 | if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { |
596 | 600 | p_dev->io.BasePort1 = cf->io.win[0].base; | |
597 | i = pcmcia_get_tuple_data(handle, tuple); | 601 | p_dev->io.NumPorts1 = cf->io.win[0].len; /*yo */ |
598 | if (i != CS_SUCCESS) | 602 | p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; |
599 | return i; | 603 | if (!pcmcia_request_io(p_dev, &p_dev->io)) |
600 | 604 | return 0; | |
601 | return pcmcia_parse_tuple(handle, tuple, parse); | 605 | } |
602 | } | 606 | return -ENODEV; |
603 | |||
604 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | ||
605 | { | ||
606 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) | ||
607 | return CS_NO_MORE_ITEMS; | ||
608 | return get_tuple(handle, tuple, parse); | ||
609 | } | ||
610 | |||
611 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | ||
612 | { | ||
613 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) | ||
614 | return CS_NO_MORE_ITEMS; | ||
615 | return get_tuple(handle, tuple, parse); | ||
616 | } | 607 | } |
617 | 608 | ||
618 | static int dtl1_config(struct pcmcia_device *link) | 609 | static int dtl1_config(struct pcmcia_device *link) |
619 | { | 610 | { |
620 | dtl1_info_t *info = link->priv; | 611 | dtl1_info_t *info = link->priv; |
621 | tuple_t tuple; | ||
622 | u_short buf[256]; | ||
623 | cisparse_t parse; | ||
624 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
625 | int i; | 612 | int i; |
626 | 613 | ||
627 | tuple.TupleData = (cisdata_t *)buf; | ||
628 | tuple.TupleOffset = 0; | ||
629 | tuple.TupleDataMax = 255; | ||
630 | tuple.Attributes = 0; | ||
631 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
632 | |||
633 | /* Look for a generic full-sized window */ | 614 | /* Look for a generic full-sized window */ |
634 | link->io.NumPorts1 = 8; | 615 | link->io.NumPorts1 = 8; |
635 | i = first_tuple(link, &tuple, &parse); | 616 | if (!pcmcia_loop_config(link, dtl1_confcheck, NULL)) |
636 | while (i != CS_NO_MORE_ITEMS) { | ||
637 | if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { | ||
638 | link->conf.ConfigIndex = cf->index; | ||
639 | link->io.BasePort1 = cf->io.win[0].base; | ||
640 | link->io.NumPorts1 = cf->io.win[0].len; /*yo */ | ||
641 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | ||
642 | i = pcmcia_request_io(link, &link->io); | ||
643 | if (i == CS_SUCCESS) | ||
644 | break; | ||
645 | } | ||
646 | i = next_tuple(link, &tuple, &parse); | ||
647 | } | ||
648 | |||
649 | if (i != CS_SUCCESS) { | ||
650 | cs_error(link, RequestIO, i); | ||
651 | goto failed; | 617 | goto failed; |
652 | } | ||
653 | 618 | ||
654 | i = pcmcia_request_irq(link, &link->irq); | 619 | i = pcmcia_request_irq(link, &link->irq); |
655 | if (i != CS_SUCCESS) { | 620 | if (i != 0) { |
656 | cs_error(link, RequestIRQ, i); | 621 | cs_error(link, RequestIRQ, i); |
657 | link->irq.AssignedIRQ = 0; | 622 | link->irq.AssignedIRQ = 0; |
658 | } | 623 | } |
659 | 624 | ||
660 | i = pcmcia_request_configuration(link, &link->conf); | 625 | i = pcmcia_request_configuration(link, &link->conf); |
661 | if (i != CS_SUCCESS) { | 626 | if (i != 0) { |
662 | cs_error(link, RequestConfiguration, i); | 627 | cs_error(link, RequestConfiguration, i); |
663 | goto failed; | 628 | goto failed; |
664 | } | 629 | } |
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index f070ae7bd91a..1c5bf99895ed 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -1759,65 +1759,40 @@ static void cmm_cm4000_release(struct pcmcia_device * link) | |||
1759 | 1759 | ||
1760 | /*==== Interface to PCMCIA Layer =======================================*/ | 1760 | /*==== Interface to PCMCIA Layer =======================================*/ |
1761 | 1761 | ||
1762 | static int cm4000_config_check(struct pcmcia_device *p_dev, | ||
1763 | cistpl_cftable_entry_t *cfg, | ||
1764 | cistpl_cftable_entry_t *dflt, | ||
1765 | unsigned int vcc, | ||
1766 | void *priv_data) | ||
1767 | { | ||
1768 | if (!cfg->io.nwin) | ||
1769 | return -ENODEV; | ||
1770 | |||
1771 | /* Get the IOaddr */ | ||
1772 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
1773 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
1774 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
1775 | if (!(cfg->io.flags & CISTPL_IO_8BIT)) | ||
1776 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
1777 | if (!(cfg->io.flags & CISTPL_IO_16BIT)) | ||
1778 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
1779 | p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
1780 | |||
1781 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
1782 | } | ||
1783 | |||
1762 | static int cm4000_config(struct pcmcia_device * link, int devno) | 1784 | static int cm4000_config(struct pcmcia_device * link, int devno) |
1763 | { | 1785 | { |
1764 | struct cm4000_dev *dev; | 1786 | struct cm4000_dev *dev; |
1765 | tuple_t tuple; | ||
1766 | cisparse_t parse; | ||
1767 | u_char buf[64]; | ||
1768 | int fail_fn, fail_rc; | ||
1769 | int rc; | ||
1770 | 1787 | ||
1771 | /* read the config-tuples */ | 1788 | /* read the config-tuples */ |
1772 | tuple.Attributes = 0; | 1789 | if (pcmcia_loop_config(link, cm4000_config_check, NULL)) |
1773 | tuple.TupleData = buf; | ||
1774 | tuple.TupleDataMax = sizeof(buf); | ||
1775 | tuple.TupleOffset = 0; | ||
1776 | |||
1777 | link->io.BasePort2 = 0; | ||
1778 | link->io.NumPorts2 = 0; | ||
1779 | link->io.Attributes2 = 0; | ||
1780 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
1781 | for (rc = pcmcia_get_first_tuple(link, &tuple); | ||
1782 | rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(link, &tuple)) { | ||
1783 | |||
1784 | rc = pcmcia_get_tuple_data(link, &tuple); | ||
1785 | if (rc != CS_SUCCESS) | ||
1786 | continue; | ||
1787 | rc = pcmcia_parse_tuple(link, &tuple, &parse); | ||
1788 | if (rc != CS_SUCCESS) | ||
1789 | continue; | ||
1790 | |||
1791 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
1792 | |||
1793 | if (!parse.cftable_entry.io.nwin) | ||
1794 | continue; | ||
1795 | |||
1796 | /* Get the IOaddr */ | ||
1797 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
1798 | link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; | ||
1799 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
1800 | if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT)) | ||
1801 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
1802 | if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT)) | ||
1803 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
1804 | link->io.IOAddrLines = parse.cftable_entry.io.flags | ||
1805 | & CISTPL_IO_LINES_MASK; | ||
1806 | |||
1807 | rc = pcmcia_request_io(link, &link->io); | ||
1808 | if (rc == CS_SUCCESS) | ||
1809 | break; /* we are done */ | ||
1810 | } | ||
1811 | if (rc != CS_SUCCESS) | ||
1812 | goto cs_release; | 1790 | goto cs_release; |
1813 | 1791 | ||
1814 | link->conf.IntType = 00000002; | 1792 | link->conf.IntType = 00000002; |
1815 | 1793 | ||
1816 | if ((fail_rc = | 1794 | if (pcmcia_request_configuration(link, &link->conf)) |
1817 | pcmcia_request_configuration(link, &link->conf)) != CS_SUCCESS) { | ||
1818 | fail_fn = RequestConfiguration; | ||
1819 | goto cs_release; | 1795 | goto cs_release; |
1820 | } | ||
1821 | 1796 | ||
1822 | dev = link->priv; | 1797 | dev = link->priv; |
1823 | sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno); | 1798 | sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno); |
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 0b5934bef7a4..2d7c906435b7 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c | |||
@@ -526,65 +526,49 @@ static void cm4040_reader_release(struct pcmcia_device *link) | |||
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | 528 | ||
529 | static int reader_config(struct pcmcia_device *link, int devno) | 529 | static int cm4040_config_check(struct pcmcia_device *p_dev, |
530 | cistpl_cftable_entry_t *cfg, | ||
531 | cistpl_cftable_entry_t *dflt, | ||
532 | unsigned int vcc, | ||
533 | void *priv_data) | ||
530 | { | 534 | { |
531 | struct reader_dev *dev; | ||
532 | tuple_t tuple; | ||
533 | cisparse_t parse; | ||
534 | u_char buf[64]; | ||
535 | int fail_fn, fail_rc; | ||
536 | int rc; | 535 | int rc; |
536 | if (!cfg->io.nwin) | ||
537 | return -ENODEV; | ||
538 | |||
539 | /* Get the IOaddr */ | ||
540 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
541 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
542 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
543 | if (!(cfg->io.flags & CISTPL_IO_8BIT)) | ||
544 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
545 | if (!(cfg->io.flags & CISTPL_IO_16BIT)) | ||
546 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
547 | p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
548 | |||
549 | rc = pcmcia_request_io(p_dev, &p_dev->io); | ||
550 | dev_printk(KERN_INFO, &handle_to_dev(p_dev), | ||
551 | "pcmcia_request_io returned 0x%x\n", rc); | ||
552 | return rc; | ||
553 | } | ||
554 | |||
537 | 555 | ||
538 | tuple.Attributes = 0; | 556 | static int reader_config(struct pcmcia_device *link, int devno) |
539 | tuple.TupleData = buf; | 557 | { |
540 | tuple.TupleDataMax = sizeof(buf); | 558 | struct reader_dev *dev; |
541 | tuple.TupleOffset = 0; | 559 | int fail_rc; |
542 | 560 | ||
543 | link->io.BasePort2 = 0; | 561 | link->io.BasePort2 = 0; |
544 | link->io.NumPorts2 = 0; | 562 | link->io.NumPorts2 = 0; |
545 | link->io.Attributes2 = 0; | 563 | link->io.Attributes2 = 0; |
546 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 564 | |
547 | for (rc = pcmcia_get_first_tuple(link, &tuple); | 565 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) |
548 | rc == CS_SUCCESS; | ||
549 | rc = pcmcia_get_next_tuple(link, &tuple)) { | ||
550 | rc = pcmcia_get_tuple_data(link, &tuple); | ||
551 | if (rc != CS_SUCCESS) | ||
552 | continue; | ||
553 | rc = pcmcia_parse_tuple(link, &tuple, &parse); | ||
554 | if (rc != CS_SUCCESS) | ||
555 | continue; | ||
556 | |||
557 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
558 | |||
559 | if (!parse.cftable_entry.io.nwin) | ||
560 | continue; | ||
561 | |||
562 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
563 | link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; | ||
564 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
565 | if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT)) | ||
566 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
567 | if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT)) | ||
568 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
569 | link->io.IOAddrLines = parse.cftable_entry.io.flags | ||
570 | & CISTPL_IO_LINES_MASK; | ||
571 | rc = pcmcia_request_io(link, &link->io); | ||
572 | |||
573 | dev_printk(KERN_INFO, &handle_to_dev(link), "foo"); | ||
574 | if (rc == CS_SUCCESS) | ||
575 | break; | ||
576 | else | ||
577 | dev_printk(KERN_INFO, &handle_to_dev(link), | ||
578 | "pcmcia_request_io failed 0x%x\n", rc); | ||
579 | } | ||
580 | if (rc != CS_SUCCESS) | ||
581 | goto cs_release; | 566 | goto cs_release; |
582 | 567 | ||
583 | link->conf.IntType = 00000002; | 568 | link->conf.IntType = 00000002; |
584 | 569 | ||
585 | if ((fail_rc = pcmcia_request_configuration(link,&link->conf)) | 570 | fail_rc = pcmcia_request_configuration(link, &link->conf); |
586 | !=CS_SUCCESS) { | 571 | if (fail_rc != 0) { |
587 | fail_fn = RequestConfiguration; | ||
588 | dev_printk(KERN_INFO, &handle_to_dev(link), | 572 | dev_printk(KERN_INFO, &handle_to_dev(link), |
589 | "pcmcia_request_configuration failed 0x%x\n", | 573 | "pcmcia_request_configuration failed 0x%x\n", |
590 | fail_rc); | 574 | fail_rc); |
diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c index 5eca7a99afe6..5216fce0c62d 100644 --- a/drivers/char/pcmcia/ipwireless/main.c +++ b/drivers/char/pcmcia/ipwireless/main.c | |||
@@ -65,9 +65,9 @@ static void signalled_reboot_work(struct work_struct *work_reboot) | |||
65 | struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev, | 65 | struct ipw_dev *ipw = container_of(work_reboot, struct ipw_dev, |
66 | work_reboot); | 66 | work_reboot); |
67 | struct pcmcia_device *link = ipw->link; | 67 | struct pcmcia_device *link = ipw->link; |
68 | int ret = pccard_reset_card(link->socket); | 68 | int ret = pcmcia_reset_card(link->socket); |
69 | 69 | ||
70 | if (ret != CS_SUCCESS) | 70 | if (ret != 0) |
71 | cs_error(link, ResetCard, ret); | 71 | cs_error(link, ResetCard, ret); |
72 | } | 72 | } |
73 | 73 | ||
@@ -83,7 +83,6 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
83 | { | 83 | { |
84 | struct pcmcia_device *link = ipw->link; | 84 | struct pcmcia_device *link = ipw->link; |
85 | int ret; | 85 | int ret; |
86 | config_info_t conf; | ||
87 | tuple_t tuple; | 86 | tuple_t tuple; |
88 | unsigned short buf[64]; | 87 | unsigned short buf[64]; |
89 | cisparse_t parse; | 88 | cisparse_t parse; |
@@ -105,7 +104,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
105 | while (ret == 0) { | 104 | while (ret == 0) { |
106 | ret = pcmcia_get_tuple_data(link, &tuple); | 105 | ret = pcmcia_get_tuple_data(link, &tuple); |
107 | 106 | ||
108 | if (ret != CS_SUCCESS) { | 107 | if (ret != 0) { |
109 | cs_error(link, GetTupleData, ret); | 108 | cs_error(link, GetTupleData, ret); |
110 | goto exit0; | 109 | goto exit0; |
111 | } | 110 | } |
@@ -116,21 +115,21 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
116 | 115 | ||
117 | ret = pcmcia_get_first_tuple(link, &tuple); | 116 | ret = pcmcia_get_first_tuple(link, &tuple); |
118 | 117 | ||
119 | if (ret != CS_SUCCESS) { | 118 | if (ret != 0) { |
120 | cs_error(link, GetFirstTuple, ret); | 119 | cs_error(link, GetFirstTuple, ret); |
121 | goto exit0; | 120 | goto exit0; |
122 | } | 121 | } |
123 | 122 | ||
124 | ret = pcmcia_get_tuple_data(link, &tuple); | 123 | ret = pcmcia_get_tuple_data(link, &tuple); |
125 | 124 | ||
126 | if (ret != CS_SUCCESS) { | 125 | if (ret != 0) { |
127 | cs_error(link, GetTupleData, ret); | 126 | cs_error(link, GetTupleData, ret); |
128 | goto exit0; | 127 | goto exit0; |
129 | } | 128 | } |
130 | 129 | ||
131 | ret = pcmcia_parse_tuple(link, &tuple, &parse); | 130 | ret = pcmcia_parse_tuple(&tuple, &parse); |
132 | 131 | ||
133 | if (ret != CS_SUCCESS) { | 132 | if (ret != 0) { |
134 | cs_error(link, ParseTuple, ret); | 133 | cs_error(link, ParseTuple, ret); |
135 | goto exit0; | 134 | goto exit0; |
136 | } | 135 | } |
@@ -152,21 +151,21 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
152 | 151 | ||
153 | ret = pcmcia_get_first_tuple(link, &tuple); | 152 | ret = pcmcia_get_first_tuple(link, &tuple); |
154 | 153 | ||
155 | if (ret != CS_SUCCESS) { | 154 | if (ret != 0) { |
156 | cs_error(link, GetFirstTuple, ret); | 155 | cs_error(link, GetFirstTuple, ret); |
157 | goto exit0; | 156 | goto exit0; |
158 | } | 157 | } |
159 | 158 | ||
160 | ret = pcmcia_get_tuple_data(link, &tuple); | 159 | ret = pcmcia_get_tuple_data(link, &tuple); |
161 | 160 | ||
162 | if (ret != CS_SUCCESS) { | 161 | if (ret != 0) { |
163 | cs_error(link, GetTupleData, ret); | 162 | cs_error(link, GetTupleData, ret); |
164 | goto exit0; | 163 | goto exit0; |
165 | } | 164 | } |
166 | 165 | ||
167 | ret = pcmcia_parse_tuple(link, &tuple, &parse); | 166 | ret = pcmcia_parse_tuple(&tuple, &parse); |
168 | 167 | ||
169 | if (ret != CS_SUCCESS) { | 168 | if (ret != 0) { |
170 | cs_error(link, GetTupleData, ret); | 169 | cs_error(link, GetTupleData, ret); |
171 | goto exit0; | 170 | goto exit0; |
172 | } | 171 | } |
@@ -181,7 +180,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
181 | 180 | ||
182 | ret = pcmcia_request_io(link, &link->io); | 181 | ret = pcmcia_request_io(link, &link->io); |
183 | 182 | ||
184 | if (ret != CS_SUCCESS) { | 183 | if (ret != 0) { |
185 | cs_error(link, RequestIO, ret); | 184 | cs_error(link, RequestIO, ret); |
186 | goto exit0; | 185 | goto exit0; |
187 | } | 186 | } |
@@ -195,21 +194,21 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
195 | 194 | ||
196 | ret = pcmcia_get_first_tuple(link, &tuple); | 195 | ret = pcmcia_get_first_tuple(link, &tuple); |
197 | 196 | ||
198 | if (ret != CS_SUCCESS) { | 197 | if (ret != 0) { |
199 | cs_error(link, GetFirstTuple, ret); | 198 | cs_error(link, GetFirstTuple, ret); |
200 | goto exit1; | 199 | goto exit1; |
201 | } | 200 | } |
202 | 201 | ||
203 | ret = pcmcia_get_tuple_data(link, &tuple); | 202 | ret = pcmcia_get_tuple_data(link, &tuple); |
204 | 203 | ||
205 | if (ret != CS_SUCCESS) { | 204 | if (ret != 0) { |
206 | cs_error(link, GetTupleData, ret); | 205 | cs_error(link, GetTupleData, ret); |
207 | goto exit1; | 206 | goto exit1; |
208 | } | 207 | } |
209 | 208 | ||
210 | ret = pcmcia_parse_tuple(link, &tuple, &parse); | 209 | ret = pcmcia_parse_tuple(&tuple, &parse); |
211 | 210 | ||
212 | if (ret != CS_SUCCESS) { | 211 | if (ret != 0) { |
213 | cs_error(link, ParseTuple, ret); | 212 | cs_error(link, ParseTuple, ret); |
214 | goto exit1; | 213 | goto exit1; |
215 | } | 214 | } |
@@ -227,7 +226,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
227 | ret = pcmcia_request_window(&link, &ipw->request_common_memory, | 226 | ret = pcmcia_request_window(&link, &ipw->request_common_memory, |
228 | &ipw->handle_common_memory); | 227 | &ipw->handle_common_memory); |
229 | 228 | ||
230 | if (ret != CS_SUCCESS) { | 229 | if (ret != 0) { |
231 | cs_error(link, RequestWindow, ret); | 230 | cs_error(link, RequestWindow, ret); |
232 | goto exit1; | 231 | goto exit1; |
233 | } | 232 | } |
@@ -239,7 +238,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
239 | ret = pcmcia_map_mem_page(ipw->handle_common_memory, | 238 | ret = pcmcia_map_mem_page(ipw->handle_common_memory, |
240 | &memreq_common_memory); | 239 | &memreq_common_memory); |
241 | 240 | ||
242 | if (ret != CS_SUCCESS) { | 241 | if (ret != 0) { |
243 | cs_error(link, MapMemPage, ret); | 242 | cs_error(link, MapMemPage, ret); |
244 | goto exit1; | 243 | goto exit1; |
245 | } | 244 | } |
@@ -261,7 +260,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
261 | ret = pcmcia_request_window(&link, &ipw->request_attr_memory, | 260 | ret = pcmcia_request_window(&link, &ipw->request_attr_memory, |
262 | &ipw->handle_attr_memory); | 261 | &ipw->handle_attr_memory); |
263 | 262 | ||
264 | if (ret != CS_SUCCESS) { | 263 | if (ret != 0) { |
265 | cs_error(link, RequestWindow, ret); | 264 | cs_error(link, RequestWindow, ret); |
266 | goto exit2; | 265 | goto exit2; |
267 | } | 266 | } |
@@ -272,7 +271,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
272 | ret = pcmcia_map_mem_page(ipw->handle_attr_memory, | 271 | ret = pcmcia_map_mem_page(ipw->handle_attr_memory, |
273 | &memreq_attr_memory); | 272 | &memreq_attr_memory); |
274 | 273 | ||
275 | if (ret != CS_SUCCESS) { | 274 | if (ret != 0) { |
276 | cs_error(link, MapMemPage, ret); | 275 | cs_error(link, MapMemPage, ret); |
277 | goto exit2; | 276 | goto exit2; |
278 | } | 277 | } |
@@ -292,20 +291,11 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
292 | 291 | ||
293 | ret = pcmcia_request_irq(link, &link->irq); | 292 | ret = pcmcia_request_irq(link, &link->irq); |
294 | 293 | ||
295 | if (ret != CS_SUCCESS) { | 294 | if (ret != 0) { |
296 | cs_error(link, RequestIRQ, ret); | 295 | cs_error(link, RequestIRQ, ret); |
297 | goto exit3; | 296 | goto exit3; |
298 | } | 297 | } |
299 | 298 | ||
300 | /* Look up current Vcc */ | ||
301 | |||
302 | ret = pcmcia_get_configuration_info(link, &conf); | ||
303 | |||
304 | if (ret != CS_SUCCESS) { | ||
305 | cs_error(link, GetConfigurationInfo, ret); | ||
306 | goto exit4; | ||
307 | } | ||
308 | |||
309 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n", | 299 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME ": Card type %s\n", |
310 | ipw->is_v2_card ? "V2/V3" : "V1"); | 300 | ipw->is_v2_card ? "V2/V3" : "V1"); |
311 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME | 301 | printk(KERN_INFO IPWIRELESS_PCCARD_NAME |
@@ -341,7 +331,7 @@ static int config_ipwireless(struct ipw_dev *ipw) | |||
341 | */ | 331 | */ |
342 | ret = pcmcia_request_configuration(link, &link->conf); | 332 | ret = pcmcia_request_configuration(link, &link->conf); |
343 | 333 | ||
344 | if (ret != CS_SUCCESS) { | 334 | if (ret != 0) { |
345 | cs_error(link, RequestConfiguration, ret); | 335 | cs_error(link, RequestConfiguration, ret); |
346 | goto exit4; | 336 | goto exit4; |
347 | } | 337 | } |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index c240562c218b..9a626e50b793 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -601,7 +601,7 @@ static int mgslpc_config(struct pcmcia_device *link) | |||
601 | 601 | ||
602 | cfg = &(parse.cftable_entry); | 602 | cfg = &(parse.cftable_entry); |
603 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); | 603 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
604 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); | 604 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); |
605 | 605 | ||
606 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | 606 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; |
607 | if (cfg->index == 0) | 607 | if (cfg->index == 0) |
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index ee6fc30d5e2b..cb199c815b53 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -219,103 +219,91 @@ out_release: | |||
219 | #define CS_CHECK(fn, ret) \ | 219 | #define CS_CHECK(fn, ret) \ |
220 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 220 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
221 | 221 | ||
222 | struct pcmcia_config_check { | ||
223 | unsigned long ctl_base; | ||
224 | int skip_vcc; | ||
225 | int is_kme; | ||
226 | }; | ||
227 | |||
228 | static int pcmcia_check_one_config(struct pcmcia_device *pdev, | ||
229 | cistpl_cftable_entry_t *cfg, | ||
230 | cistpl_cftable_entry_t *dflt, | ||
231 | unsigned int vcc, | ||
232 | void *priv_data) | ||
233 | { | ||
234 | struct pcmcia_config_check *stk = priv_data; | ||
235 | |||
236 | /* Check for matching Vcc, unless we're desperate */ | ||
237 | if (!stk->skip_vcc) { | ||
238 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
239 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
240 | return -ENODEV; | ||
241 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
242 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
243 | return -ENODEV; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
248 | pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
249 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
250 | pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
251 | |||
252 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
253 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
254 | pdev->conf.ConfigIndex = cfg->index; | ||
255 | pdev->io.BasePort1 = io->win[0].base; | ||
256 | pdev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
257 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
258 | pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
259 | if (io->nwin == 2) { | ||
260 | pdev->io.NumPorts1 = 8; | ||
261 | pdev->io.BasePort2 = io->win[1].base; | ||
262 | pdev->io.NumPorts2 = (stk->is_kme) ? 2 : 1; | ||
263 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
264 | return -ENODEV; | ||
265 | stk->ctl_base = pdev->io.BasePort2; | ||
266 | } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { | ||
267 | pdev->io.NumPorts1 = io->win[0].len; | ||
268 | pdev->io.NumPorts2 = 0; | ||
269 | if (pcmcia_request_io(pdev, &pdev->io) != 0) | ||
270 | return -ENODEV; | ||
271 | stk->ctl_base = pdev->io.BasePort1 + 0x0e; | ||
272 | } else | ||
273 | return -ENODEV; | ||
274 | /* If we've got this far, we're done */ | ||
275 | return 0; | ||
276 | } | ||
277 | return -ENODEV; | ||
278 | } | ||
279 | |||
222 | static int ide_config(struct pcmcia_device *link) | 280 | static int ide_config(struct pcmcia_device *link) |
223 | { | 281 | { |
224 | ide_info_t *info = link->priv; | 282 | ide_info_t *info = link->priv; |
225 | tuple_t tuple; | 283 | struct pcmcia_config_check *stk = NULL; |
226 | struct { | 284 | int last_ret = 0, last_fn = 0, is_kme = 0; |
227 | u_short buf[128]; | ||
228 | cisparse_t parse; | ||
229 | config_info_t conf; | ||
230 | cistpl_cftable_entry_t dflt; | ||
231 | } *stk = NULL; | ||
232 | cistpl_cftable_entry_t *cfg; | ||
233 | int pass, last_ret = 0, last_fn = 0, is_kme = 0; | ||
234 | unsigned long io_base, ctl_base; | 285 | unsigned long io_base, ctl_base; |
235 | struct ide_host *host; | 286 | struct ide_host *host; |
236 | 287 | ||
237 | DEBUG(0, "ide_config(0x%p)\n", link); | 288 | DEBUG(0, "ide_config(0x%p)\n", link); |
238 | 289 | ||
239 | stk = kzalloc(sizeof(*stk), GFP_KERNEL); | ||
240 | if (!stk) goto err_mem; | ||
241 | cfg = &stk->parse.cftable_entry; | ||
242 | |||
243 | tuple.TupleData = (cisdata_t *)&stk->buf; | ||
244 | tuple.TupleOffset = 0; | ||
245 | tuple.TupleDataMax = 255; | ||
246 | tuple.Attributes = 0; | ||
247 | |||
248 | is_kme = ((link->manf_id == MANFID_KME) && | 290 | is_kme = ((link->manf_id == MANFID_KME) && |
249 | ((link->card_id == PRODID_KME_KXLC005_A) || | 291 | ((link->card_id == PRODID_KME_KXLC005_A) || |
250 | (link->card_id == PRODID_KME_KXLC005_B))); | 292 | (link->card_id == PRODID_KME_KXLC005_B))); |
251 | 293 | ||
252 | /* Not sure if this is right... look up the current Vcc */ | 294 | stk = kzalloc(sizeof(*stk), GFP_KERNEL); |
253 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); | 295 | if (!stk) |
254 | 296 | goto err_mem; | |
255 | pass = io_base = ctl_base = 0; | 297 | stk->is_kme = is_kme; |
256 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 298 | stk->skip_vcc = io_base = ctl_base = 0; |
257 | tuple.Attributes = 0; | 299 | |
258 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 300 | if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) { |
259 | while (1) { | 301 | stk->skip_vcc = 1; |
260 | if (pcmcia_get_tuple_data(link, &tuple) != 0) goto next_entry; | 302 | if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) |
261 | if (pcmcia_parse_tuple(link, &tuple, &stk->parse) != 0) goto next_entry; | 303 | goto failed; /* No suitable config found */ |
262 | |||
263 | /* Check for matching Vcc, unless we're desperate */ | ||
264 | if (!pass) { | ||
265 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
266 | if (stk->conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
267 | goto next_entry; | ||
268 | } else if (stk->dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
269 | if (stk->conf.Vcc != stk->dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) | ||
270 | goto next_entry; | ||
271 | } | ||
272 | } | ||
273 | |||
274 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
275 | link->conf.Vpp = | ||
276 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
277 | else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
278 | link->conf.Vpp = | ||
279 | stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
280 | |||
281 | if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { | ||
282 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &stk->dflt.io; | ||
283 | link->conf.ConfigIndex = cfg->index; | ||
284 | link->io.BasePort1 = io->win[0].base; | ||
285 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
286 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
287 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
288 | if (io->nwin == 2) { | ||
289 | link->io.NumPorts1 = 8; | ||
290 | link->io.BasePort2 = io->win[1].base; | ||
291 | link->io.NumPorts2 = (is_kme) ? 2 : 1; | ||
292 | if (pcmcia_request_io(link, &link->io) != 0) | ||
293 | goto next_entry; | ||
294 | io_base = link->io.BasePort1; | ||
295 | ctl_base = link->io.BasePort2; | ||
296 | } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { | ||
297 | link->io.NumPorts1 = io->win[0].len; | ||
298 | link->io.NumPorts2 = 0; | ||
299 | if (pcmcia_request_io(link, &link->io) != 0) | ||
300 | goto next_entry; | ||
301 | io_base = link->io.BasePort1; | ||
302 | ctl_base = link->io.BasePort1 + 0x0e; | ||
303 | } else goto next_entry; | ||
304 | /* If we've got this far, we're done */ | ||
305 | break; | ||
306 | } | ||
307 | |||
308 | next_entry: | ||
309 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
310 | memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); | ||
311 | if (pass) { | ||
312 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
313 | } else if (pcmcia_get_next_tuple(link, &tuple) != 0) { | ||
314 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
315 | memset(&stk->dflt, 0, sizeof(stk->dflt)); | ||
316 | pass++; | ||
317 | } | ||
318 | } | 304 | } |
305 | io_base = link->io.BasePort1; | ||
306 | ctl_base = stk->ctl_base; | ||
319 | 307 | ||
320 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 308 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
321 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 309 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
@@ -403,8 +391,10 @@ static struct pcmcia_device_id ide_ids[] = { | |||
403 | PCMCIA_DEVICE_MANF_CARD(0x000a, 0x0000), /* I-O Data CFA */ | 391 | PCMCIA_DEVICE_MANF_CARD(0x000a, 0x0000), /* I-O Data CFA */ |
404 | PCMCIA_DEVICE_MANF_CARD(0x001c, 0x0001), /* Mitsubishi CFA */ | 392 | PCMCIA_DEVICE_MANF_CARD(0x001c, 0x0001), /* Mitsubishi CFA */ |
405 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), | 393 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), |
394 | PCMCIA_DEVICE_MANF_CARD(0x0032, 0x2904), | ||
406 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ | 395 | PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), /* SanDisk CFA */ |
407 | PCMCIA_DEVICE_MANF_CARD(0x004f, 0x0000), /* Kingston */ | 396 | PCMCIA_DEVICE_MANF_CARD(0x004f, 0x0000), /* Kingston */ |
397 | PCMCIA_DEVICE_MANF_CARD(0x0097, 0x1620), /* TI emulated */ | ||
408 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ | 398 | PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ |
409 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), | 399 | PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), |
410 | PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ | 400 | PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ |
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index a5b941c327f7..c72565520e41 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c | |||
@@ -154,83 +154,50 @@ static void avmcs_detach(struct pcmcia_device *link) | |||
154 | 154 | ||
155 | ======================================================================*/ | 155 | ======================================================================*/ |
156 | 156 | ||
157 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 157 | static int avmcs_configcheck(struct pcmcia_device *p_dev, |
158 | cisparse_t *parse) | 158 | cistpl_cftable_entry_t *cf, |
159 | cistpl_cftable_entry_t *dflt, | ||
160 | unsigned int vcc, | ||
161 | void *priv_data) | ||
159 | { | 162 | { |
160 | int i = pcmcia_get_tuple_data(handle, tuple); | 163 | if (cf->io.nwin <= 0) |
161 | if (i != CS_SUCCESS) return i; | 164 | return -ENODEV; |
162 | return pcmcia_parse_tuple(handle, tuple, parse); | 165 | |
163 | } | 166 | p_dev->io.BasePort1 = cf->io.win[0].base; |
164 | 167 | p_dev->io.NumPorts1 = cf->io.win[0].len; | |
165 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 168 | p_dev->io.NumPorts2 = 0; |
166 | cisparse_t *parse) | 169 | printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n", |
167 | { | 170 | p_dev->io.BasePort1, |
168 | int i = pcmcia_get_first_tuple(handle, tuple); | 171 | p_dev->io.BasePort1+p_dev->io.NumPorts1-1); |
169 | if (i != CS_SUCCESS) return i; | 172 | return pcmcia_request_io(p_dev, &p_dev->io); |
170 | return get_tuple(handle, tuple, parse); | ||
171 | } | ||
172 | |||
173 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
174 | cisparse_t *parse) | ||
175 | { | ||
176 | int i = pcmcia_get_next_tuple(handle, tuple); | ||
177 | if (i != CS_SUCCESS) return i; | ||
178 | return get_tuple(handle, tuple, parse); | ||
179 | } | 173 | } |
180 | 174 | ||
181 | static int avmcs_config(struct pcmcia_device *link) | 175 | static int avmcs_config(struct pcmcia_device *link) |
182 | { | 176 | { |
183 | tuple_t tuple; | ||
184 | cisparse_t parse; | ||
185 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
186 | local_info_t *dev; | 177 | local_info_t *dev; |
187 | int i; | 178 | int i; |
188 | u_char buf[64]; | ||
189 | char devname[128]; | 179 | char devname[128]; |
190 | int cardtype; | 180 | int cardtype; |
191 | int (*addcard)(unsigned int port, unsigned irq); | 181 | int (*addcard)(unsigned int port, unsigned irq); |
192 | 182 | ||
193 | dev = link->priv; | 183 | dev = link->priv; |
194 | 184 | ||
195 | do { | 185 | devname[0] = 0; |
196 | devname[0] = 0; | 186 | if (link->prod_id[1]) |
197 | if (link->prod_id[1]) | 187 | strlcpy(devname, link->prod_id[1], sizeof(devname)); |
198 | strlcpy(devname, link->prod_id[1], sizeof(devname)); | ||
199 | 188 | ||
200 | /* | 189 | /* |
201 | * find IO port | 190 | * find IO port |
202 | */ | 191 | */ |
203 | tuple.TupleData = (cisdata_t *)buf; | 192 | if (pcmcia_loop_config(link, avmcs_configcheck, NULL)) |
204 | tuple.TupleOffset = 0; tuple.TupleDataMax = 255; | 193 | return -ENODEV; |
205 | tuple.Attributes = 0; | ||
206 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
207 | i = first_tuple(link, &tuple, &parse); | ||
208 | while (i == CS_SUCCESS) { | ||
209 | if (cf->io.nwin > 0) { | ||
210 | link->conf.ConfigIndex = cf->index; | ||
211 | link->io.BasePort1 = cf->io.win[0].base; | ||
212 | link->io.NumPorts1 = cf->io.win[0].len; | ||
213 | link->io.NumPorts2 = 0; | ||
214 | printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n", | ||
215 | link->io.BasePort1, | ||
216 | link->io.BasePort1+link->io.NumPorts1-1); | ||
217 | i = pcmcia_request_io(link, &link->io); | ||
218 | if (i == CS_SUCCESS) goto found_port; | ||
219 | } | ||
220 | i = next_tuple(link, &tuple, &parse); | ||
221 | } | ||
222 | |||
223 | found_port: | ||
224 | if (i != CS_SUCCESS) { | ||
225 | cs_error(link, RequestIO, i); | ||
226 | break; | ||
227 | } | ||
228 | 194 | ||
195 | do { | ||
229 | /* | 196 | /* |
230 | * allocate an interrupt line | 197 | * allocate an interrupt line |
231 | */ | 198 | */ |
232 | i = pcmcia_request_irq(link, &link->irq); | 199 | i = pcmcia_request_irq(link, &link->irq); |
233 | if (i != CS_SUCCESS) { | 200 | if (i != 0) { |
234 | cs_error(link, RequestIRQ, i); | 201 | cs_error(link, RequestIRQ, i); |
235 | /* undo */ | 202 | /* undo */ |
236 | pcmcia_disable_device(link); | 203 | pcmcia_disable_device(link); |
@@ -241,7 +208,7 @@ found_port: | |||
241 | * configure the PCMCIA socket | 208 | * configure the PCMCIA socket |
242 | */ | 209 | */ |
243 | i = pcmcia_request_configuration(link, &link->conf); | 210 | i = pcmcia_request_configuration(link, &link->conf); |
244 | if (i != CS_SUCCESS) { | 211 | if (i != 0) { |
245 | cs_error(link, RequestConfiguration, i); | 212 | cs_error(link, RequestConfiguration, i); |
246 | pcmcia_disable_device(link); | 213 | pcmcia_disable_device(link); |
247 | break; | 214 | break; |
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index fc6cc2c065b8..23560c897ec3 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c | |||
@@ -174,38 +174,29 @@ static void avma1cs_detach(struct pcmcia_device *link) | |||
174 | 174 | ||
175 | ======================================================================*/ | 175 | ======================================================================*/ |
176 | 176 | ||
177 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 177 | static int avma1cs_configcheck(struct pcmcia_device *p_dev, |
178 | cisparse_t *parse) | 178 | cistpl_cftable_entry_t *cf, |
179 | cistpl_cftable_entry_t *dflt, | ||
180 | unsigned int vcc, | ||
181 | void *priv_data) | ||
179 | { | 182 | { |
180 | int i = pcmcia_get_tuple_data(handle, tuple); | 183 | if (cf->io.nwin <= 0) |
181 | if (i != CS_SUCCESS) return i; | 184 | return -ENODEV; |
182 | return pcmcia_parse_tuple(handle, tuple, parse); | 185 | |
186 | p_dev->io.BasePort1 = cf->io.win[0].base; | ||
187 | p_dev->io.NumPorts1 = cf->io.win[0].len; | ||
188 | p_dev->io.NumPorts2 = 0; | ||
189 | printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n", | ||
190 | p_dev->io.BasePort1, | ||
191 | p_dev->io.BasePort1+p_dev->io.NumPorts1-1); | ||
192 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
183 | } | 193 | } |
184 | 194 | ||
185 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
186 | cisparse_t *parse) | ||
187 | { | ||
188 | int i = pcmcia_get_first_tuple(handle, tuple); | ||
189 | if (i != CS_SUCCESS) return i; | ||
190 | return get_tuple(handle, tuple, parse); | ||
191 | } | ||
192 | |||
193 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
194 | cisparse_t *parse) | ||
195 | { | ||
196 | int i = pcmcia_get_next_tuple(handle, tuple); | ||
197 | if (i != CS_SUCCESS) return i; | ||
198 | return get_tuple(handle, tuple, parse); | ||
199 | } | ||
200 | 195 | ||
201 | static int avma1cs_config(struct pcmcia_device *link) | 196 | static int avma1cs_config(struct pcmcia_device *link) |
202 | { | 197 | { |
203 | tuple_t tuple; | ||
204 | cisparse_t parse; | ||
205 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
206 | local_info_t *dev; | 198 | local_info_t *dev; |
207 | int i; | 199 | int i; |
208 | u_char buf[64]; | ||
209 | char devname[128]; | 200 | char devname[128]; |
210 | IsdnCard_t icard; | 201 | IsdnCard_t icard; |
211 | int busy = 0; | 202 | int busy = 0; |
@@ -214,45 +205,19 @@ static int avma1cs_config(struct pcmcia_device *link) | |||
214 | 205 | ||
215 | DEBUG(0, "avma1cs_config(0x%p)\n", link); | 206 | DEBUG(0, "avma1cs_config(0x%p)\n", link); |
216 | 207 | ||
217 | do { | 208 | devname[0] = 0; |
218 | devname[0] = 0; | 209 | if (link->prod_id[1]) |
219 | if (link->prod_id[1]) | 210 | strlcpy(devname, link->prod_id[1], sizeof(devname)); |
220 | strlcpy(devname, link->prod_id[1], sizeof(devname)); | ||
221 | 211 | ||
222 | /* | 212 | if (pcmcia_loop_config(link, avma1cs_configcheck, NULL)) |
223 | * find IO port | 213 | return -ENODEV; |
224 | */ | ||
225 | tuple.TupleData = (cisdata_t *)buf; | ||
226 | tuple.TupleOffset = 0; tuple.TupleDataMax = 255; | ||
227 | tuple.Attributes = 0; | ||
228 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
229 | i = first_tuple(link, &tuple, &parse); | ||
230 | while (i == CS_SUCCESS) { | ||
231 | if (cf->io.nwin > 0) { | ||
232 | link->conf.ConfigIndex = cf->index; | ||
233 | link->io.BasePort1 = cf->io.win[0].base; | ||
234 | link->io.NumPorts1 = cf->io.win[0].len; | ||
235 | link->io.NumPorts2 = 0; | ||
236 | printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n", | ||
237 | link->io.BasePort1, | ||
238 | link->io.BasePort1+link->io.NumPorts1 - 1); | ||
239 | i = pcmcia_request_io(link, &link->io); | ||
240 | if (i == CS_SUCCESS) goto found_port; | ||
241 | } | ||
242 | i = next_tuple(link, &tuple, &parse); | ||
243 | } | ||
244 | 214 | ||
245 | found_port: | 215 | do { |
246 | if (i != CS_SUCCESS) { | ||
247 | cs_error(link, RequestIO, i); | ||
248 | break; | ||
249 | } | ||
250 | |||
251 | /* | 216 | /* |
252 | * allocate an interrupt line | 217 | * allocate an interrupt line |
253 | */ | 218 | */ |
254 | i = pcmcia_request_irq(link, &link->irq); | 219 | i = pcmcia_request_irq(link, &link->irq); |
255 | if (i != CS_SUCCESS) { | 220 | if (i != 0) { |
256 | cs_error(link, RequestIRQ, i); | 221 | cs_error(link, RequestIRQ, i); |
257 | /* undo */ | 222 | /* undo */ |
258 | pcmcia_disable_device(link); | 223 | pcmcia_disable_device(link); |
@@ -263,7 +228,7 @@ found_port: | |||
263 | * configure the PCMCIA socket | 228 | * configure the PCMCIA socket |
264 | */ | 229 | */ |
265 | i = pcmcia_request_configuration(link, &link->conf); | 230 | i = pcmcia_request_configuration(link, &link->conf); |
266 | if (i != CS_SUCCESS) { | 231 | if (i != 0) { |
267 | cs_error(link, RequestConfiguration, i); | 232 | cs_error(link, RequestConfiguration, i); |
268 | pcmcia_disable_device(link); | 233 | pcmcia_disable_device(link); |
269 | break; | 234 | break; |
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index db7e64424afe..f4d0fe29bcf8 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c | |||
@@ -203,82 +203,55 @@ static void elsa_cs_detach(struct pcmcia_device *link) | |||
203 | device available to the system. | 203 | device available to the system. |
204 | 204 | ||
205 | ======================================================================*/ | 205 | ======================================================================*/ |
206 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
207 | cisparse_t *parse) | ||
208 | { | ||
209 | int i = pcmcia_get_tuple_data(handle, tuple); | ||
210 | if (i != CS_SUCCESS) return i; | ||
211 | return pcmcia_parse_tuple(handle, tuple, parse); | ||
212 | } | ||
213 | |||
214 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
215 | cisparse_t *parse) | ||
216 | { | ||
217 | int i = pcmcia_get_first_tuple(handle, tuple); | ||
218 | if (i != CS_SUCCESS) return i; | ||
219 | return get_tuple(handle, tuple, parse); | ||
220 | } | ||
221 | 206 | ||
222 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 207 | static int elsa_cs_configcheck(struct pcmcia_device *p_dev, |
223 | cisparse_t *parse) | 208 | cistpl_cftable_entry_t *cf, |
209 | cistpl_cftable_entry_t *dflt, | ||
210 | unsigned int vcc, | ||
211 | void *priv_data) | ||
224 | { | 212 | { |
225 | int i = pcmcia_get_next_tuple(handle, tuple); | 213 | int j; |
226 | if (i != CS_SUCCESS) return i; | 214 | |
227 | return get_tuple(handle, tuple, parse); | 215 | if ((cf->io.nwin > 0) && cf->io.win[0].base) { |
216 | printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); | ||
217 | p_dev->io.BasePort1 = cf->io.win[0].base; | ||
218 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
219 | return 0; | ||
220 | } else { | ||
221 | printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n"); | ||
222 | for (j = 0x2f0; j > 0x100; j -= 0x10) { | ||
223 | p_dev->io.BasePort1 = j; | ||
224 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
225 | return 0; | ||
226 | } | ||
227 | } | ||
228 | return -ENODEV; | ||
228 | } | 229 | } |
229 | 230 | ||
230 | static int elsa_cs_config(struct pcmcia_device *link) | 231 | static int elsa_cs_config(struct pcmcia_device *link) |
231 | { | 232 | { |
232 | tuple_t tuple; | ||
233 | cisparse_t parse; | ||
234 | local_info_t *dev; | 233 | local_info_t *dev; |
235 | int i, j, last_fn; | 234 | int i, last_fn; |
236 | u_short buf[128]; | ||
237 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
238 | IsdnCard_t icard; | 235 | IsdnCard_t icard; |
239 | 236 | ||
240 | DEBUG(0, "elsa_config(0x%p)\n", link); | 237 | DEBUG(0, "elsa_config(0x%p)\n", link); |
241 | dev = link->priv; | 238 | dev = link->priv; |
242 | 239 | ||
243 | tuple.TupleData = (cisdata_t *)buf; | 240 | i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); |
244 | tuple.TupleOffset = 0; tuple.TupleDataMax = 255; | 241 | if (i != 0) { |
245 | tuple.Attributes = 0; | ||
246 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
247 | i = first_tuple(link, &tuple, &parse); | ||
248 | while (i == CS_SUCCESS) { | ||
249 | if ( (cf->io.nwin > 0) && cf->io.win[0].base) { | ||
250 | printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); | ||
251 | link->conf.ConfigIndex = cf->index; | ||
252 | link->io.BasePort1 = cf->io.win[0].base; | ||
253 | i = pcmcia_request_io(link, &link->io); | ||
254 | if (i == CS_SUCCESS) break; | ||
255 | } else { | ||
256 | printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n"); | ||
257 | link->conf.ConfigIndex = cf->index; | ||
258 | for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) { | ||
259 | link->io.BasePort1 = j; | ||
260 | i = pcmcia_request_io(link, &link->io); | ||
261 | if (i == CS_SUCCESS) break; | ||
262 | } | ||
263 | break; | ||
264 | } | ||
265 | i = next_tuple(link, &tuple, &parse); | ||
266 | } | ||
267 | |||
268 | if (i != CS_SUCCESS) { | ||
269 | last_fn = RequestIO; | 242 | last_fn = RequestIO; |
270 | goto cs_failed; | 243 | goto cs_failed; |
271 | } | 244 | } |
272 | 245 | ||
273 | i = pcmcia_request_irq(link, &link->irq); | 246 | i = pcmcia_request_irq(link, &link->irq); |
274 | if (i != CS_SUCCESS) { | 247 | if (i != 0) { |
275 | link->irq.AssignedIRQ = 0; | 248 | link->irq.AssignedIRQ = 0; |
276 | last_fn = RequestIRQ; | 249 | last_fn = RequestIRQ; |
277 | goto cs_failed; | 250 | goto cs_failed; |
278 | } | 251 | } |
279 | 252 | ||
280 | i = pcmcia_request_configuration(link, &link->conf); | 253 | i = pcmcia_request_configuration(link, &link->conf); |
281 | if (i != CS_SUCCESS) { | 254 | if (i != 0) { |
282 | last_fn = RequestConfiguration; | 255 | last_fn = RequestConfiguration; |
283 | goto cs_failed; | 256 | goto cs_failed; |
284 | } | 257 | } |
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 439cb530def8..9a3c9f5e4fe8 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c | |||
@@ -217,101 +217,61 @@ static void sedlbauer_detach(struct pcmcia_device *link) | |||
217 | #define CS_CHECK(fn, ret) \ | 217 | #define CS_CHECK(fn, ret) \ |
218 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 218 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
219 | 219 | ||
220 | static int sedlbauer_config(struct pcmcia_device *link) | 220 | static int sedlbauer_config_check(struct pcmcia_device *p_dev, |
221 | cistpl_cftable_entry_t *cfg, | ||
222 | cistpl_cftable_entry_t *dflt, | ||
223 | unsigned int vcc, | ||
224 | void *priv_data) | ||
221 | { | 225 | { |
222 | local_info_t *dev = link->priv; | 226 | win_req_t *req = priv_data; |
223 | tuple_t tuple; | ||
224 | cisparse_t parse; | ||
225 | int last_fn, last_ret; | ||
226 | u8 buf[64]; | ||
227 | config_info_t conf; | ||
228 | win_req_t req; | ||
229 | memreq_t map; | ||
230 | IsdnCard_t icard; | ||
231 | |||
232 | DEBUG(0, "sedlbauer_config(0x%p)\n", link); | ||
233 | |||
234 | tuple.Attributes = 0; | ||
235 | tuple.TupleData = buf; | ||
236 | tuple.TupleDataMax = sizeof(buf); | ||
237 | tuple.TupleOffset = 0; | ||
238 | 227 | ||
239 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); | 228 | if (cfg->index == 0) |
229 | return -ENODEV; | ||
240 | 230 | ||
241 | /* | ||
242 | In this loop, we scan the CIS for configuration table entries, | ||
243 | each of which describes a valid card configuration, including | ||
244 | voltage, IO window, memory window, and interrupt settings. | ||
245 | |||
246 | We make no assumptions about the card to be configured: we use | ||
247 | just the information available in the CIS. In an ideal world, | ||
248 | this would work for any PCMCIA card, but it requires a complete | ||
249 | and accurate CIS. In practice, a driver usually "knows" most of | ||
250 | these things without consulting the CIS, and most client drivers | ||
251 | will only use the CIS to fill in implementation-defined details. | ||
252 | */ | ||
253 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
254 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
255 | while (1) { | ||
256 | cistpl_cftable_entry_t dflt = { 0 }; | ||
257 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
258 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
259 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
260 | goto next_entry; | ||
261 | |||
262 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
263 | if (cfg->index == 0) goto next_entry; | ||
264 | link->conf.ConfigIndex = cfg->index; | ||
265 | |||
266 | /* Does this card need audio output? */ | 231 | /* Does this card need audio output? */ |
267 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | 232 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { |
268 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 233 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; |
269 | link->conf.Status = CCSR_AUDIO_ENA; | 234 | p_dev->conf.Status = CCSR_AUDIO_ENA; |
270 | } | 235 | } |
271 | 236 | ||
272 | /* Use power settings for Vcc and Vpp if present */ | 237 | /* Use power settings for Vcc and Vpp if present */ |
273 | /* Note that the CIS values need to be rescaled */ | 238 | /* Note that the CIS values need to be rescaled */ |
274 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | 239 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { |
275 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) | 240 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) |
276 | goto next_entry; | 241 | return -ENODEV; |
277 | } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { | 242 | } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { |
278 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000) | 243 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) |
279 | goto next_entry; | 244 | return -ENODEV; |
280 | } | 245 | } |
281 | 246 | ||
282 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | 247 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) |
283 | link->conf.Vpp = | 248 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; |
284 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | 249 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) |
285 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | 250 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; |
286 | link->conf.Vpp = | 251 | |
287 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
288 | |||
289 | /* Do we need to allocate an interrupt? */ | 252 | /* Do we need to allocate an interrupt? */ |
290 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | 253 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) |
291 | link->conf.Attributes |= CONF_ENABLE_IRQ; | 254 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; |
292 | 255 | ||
293 | /* IO window settings */ | 256 | /* IO window settings */ |
294 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | 257 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; |
295 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | 258 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { |
296 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | 259 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; |
297 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 260 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
298 | if (!(io->flags & CISTPL_IO_8BIT)) | 261 | if (!(io->flags & CISTPL_IO_8BIT)) |
299 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 262 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
300 | if (!(io->flags & CISTPL_IO_16BIT)) | 263 | if (!(io->flags & CISTPL_IO_16BIT)) |
301 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 264 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
302 | /* new in dummy.cs 2001/01/28 MN | 265 | p_dev->io.BasePort1 = io->win[0].base; |
303 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | 266 | p_dev->io.NumPorts1 = io->win[0].len; |
304 | */ | 267 | if (io->nwin > 1) { |
305 | link->io.BasePort1 = io->win[0].base; | 268 | p_dev->io.Attributes2 = p_dev->io.Attributes1; |
306 | link->io.NumPorts1 = io->win[0].len; | 269 | p_dev->io.BasePort2 = io->win[1].base; |
307 | if (io->nwin > 1) { | 270 | p_dev->io.NumPorts2 = io->win[1].len; |
308 | link->io.Attributes2 = link->io.Attributes1; | 271 | } |
309 | link->io.BasePort2 = io->win[1].base; | 272 | /* This reserves IO space but doesn't actually enable it */ |
310 | link->io.NumPorts2 = io->win[1].len; | 273 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) |
311 | } | 274 | return -ENODEV; |
312 | /* This reserves IO space but doesn't actually enable it */ | ||
313 | if (pcmcia_request_io(link, &link->io) != 0) | ||
314 | goto next_entry; | ||
315 | } | 275 | } |
316 | 276 | ||
317 | /* | 277 | /* |
@@ -325,30 +285,54 @@ static int sedlbauer_config(struct pcmcia_device *link) | |||
325 | needs to be mapped to virtual space with ioremap() before it | 285 | needs to be mapped to virtual space with ioremap() before it |
326 | is used. | 286 | is used. |
327 | */ | 287 | */ |
328 | if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { | 288 | if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { |
329 | cistpl_mem_t *mem = | 289 | cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; |
330 | (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; | 290 | memreq_t map; |
331 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | 291 | req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; |
332 | req.Attributes |= WIN_ENABLE; | 292 | req->Attributes |= WIN_ENABLE; |
333 | req.Base = mem->win[0].host_addr; | 293 | req->Base = mem->win[0].host_addr; |
334 | req.Size = mem->win[0].len; | 294 | req->Size = mem->win[0].len; |
335 | /* new in dummy.cs 2001/01/28 MN | 295 | req->AccessSpeed = 0; |
336 | if (req.Size < 0x1000) | 296 | if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) |
337 | req.Size = 0x1000; | 297 | return -ENODEV; |
338 | */ | 298 | map.Page = 0; |
339 | req.AccessSpeed = 0; | 299 | map.CardOffset = mem->win[0].card_addr; |
340 | if (pcmcia_request_window(&link, &req, &link->win) != 0) | 300 | if (pcmcia_map_mem_page(p_dev->win, &map) != 0) |
341 | goto next_entry; | 301 | return -ENODEV; |
342 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; | ||
343 | if (pcmcia_map_mem_page(link->win, &map) != 0) | ||
344 | goto next_entry; | ||
345 | } | 302 | } |
346 | /* If we got this far, we're cool! */ | 303 | return 0; |
347 | break; | 304 | } |
348 | 305 | ||
349 | next_entry: | 306 | |
350 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | 307 | |
351 | } | 308 | static int sedlbauer_config(struct pcmcia_device *link) |
309 | { | ||
310 | local_info_t *dev = link->priv; | ||
311 | win_req_t *req; | ||
312 | int last_fn, last_ret; | ||
313 | IsdnCard_t icard; | ||
314 | |||
315 | DEBUG(0, "sedlbauer_config(0x%p)\n", link); | ||
316 | |||
317 | req = kzalloc(sizeof(win_req_t), GFP_KERNEL); | ||
318 | if (!req) | ||
319 | return -ENOMEM; | ||
320 | |||
321 | /* | ||
322 | In this loop, we scan the CIS for configuration table entries, | ||
323 | each of which describes a valid card configuration, including | ||
324 | voltage, IO window, memory window, and interrupt settings. | ||
325 | |||
326 | We make no assumptions about the card to be configured: we use | ||
327 | just the information available in the CIS. In an ideal world, | ||
328 | this would work for any PCMCIA card, but it requires a complete | ||
329 | and accurate CIS. In practice, a driver usually "knows" most of | ||
330 | these things without consulting the CIS, and most client drivers | ||
331 | will only use the CIS to fill in implementation-defined details. | ||
332 | */ | ||
333 | last_ret = pcmcia_loop_config(link, sedlbauer_config_check, req); | ||
334 | if (last_ret) | ||
335 | goto failed; | ||
352 | 336 | ||
353 | /* | 337 | /* |
354 | Allocate an interrupt line. Note that this does not assign a | 338 | Allocate an interrupt line. Note that this does not assign a |
@@ -387,8 +371,8 @@ static int sedlbauer_config(struct pcmcia_device *link) | |||
387 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | 371 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, |
388 | link->io.BasePort2+link->io.NumPorts2-1); | 372 | link->io.BasePort2+link->io.NumPorts2-1); |
389 | if (link->win) | 373 | if (link->win) |
390 | printk(", mem 0x%06lx-0x%06lx", req.Base, | 374 | printk(", mem 0x%06lx-0x%06lx", req->Base, |
391 | req.Base+req.Size-1); | 375 | req->Base+req->Size-1); |
392 | printk("\n"); | 376 | printk("\n"); |
393 | 377 | ||
394 | icard.para[0] = link->irq.AssignedIRQ; | 378 | icard.para[0] = link->irq.AssignedIRQ; |
@@ -409,6 +393,7 @@ static int sedlbauer_config(struct pcmcia_device *link) | |||
409 | 393 | ||
410 | cs_failed: | 394 | cs_failed: |
411 | cs_error(link, last_fn, last_ret); | 395 | cs_error(link, last_fn, last_ret); |
396 | failed: | ||
412 | sedlbauer_release(link); | 397 | sedlbauer_release(link); |
413 | return -ENODEV; | 398 | return -ENODEV; |
414 | 399 | ||
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index ab4bd455450e..623d111544d4 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c | |||
@@ -193,82 +193,55 @@ static void teles_detach(struct pcmcia_device *link) | |||
193 | device available to the system. | 193 | device available to the system. |
194 | 194 | ||
195 | ======================================================================*/ | 195 | ======================================================================*/ |
196 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
197 | cisparse_t *parse) | ||
198 | { | ||
199 | int i = pcmcia_get_tuple_data(handle, tuple); | ||
200 | if (i != CS_SUCCESS) return i; | ||
201 | return pcmcia_parse_tuple(handle, tuple, parse); | ||
202 | } | ||
203 | |||
204 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | ||
205 | cisparse_t *parse) | ||
206 | { | ||
207 | int i = pcmcia_get_first_tuple(handle, tuple); | ||
208 | if (i != CS_SUCCESS) return i; | ||
209 | return get_tuple(handle, tuple, parse); | ||
210 | } | ||
211 | 196 | ||
212 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 197 | static int teles_cs_configcheck(struct pcmcia_device *p_dev, |
213 | cisparse_t *parse) | 198 | cistpl_cftable_entry_t *cf, |
199 | cistpl_cftable_entry_t *dflt, | ||
200 | unsigned int vcc, | ||
201 | void *priv_data) | ||
214 | { | 202 | { |
215 | int i = pcmcia_get_next_tuple(handle, tuple); | 203 | int j; |
216 | if (i != CS_SUCCESS) return i; | 204 | |
217 | return get_tuple(handle, tuple, parse); | 205 | if ((cf->io.nwin > 0) && cf->io.win[0].base) { |
206 | printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); | ||
207 | p_dev->io.BasePort1 = cf->io.win[0].base; | ||
208 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
209 | return 0; | ||
210 | } else { | ||
211 | printk(KERN_INFO "(teles_cs: looks like the 97 model)\n"); | ||
212 | for (j = 0x2f0; j > 0x100; j -= 0x10) { | ||
213 | p_dev->io.BasePort1 = j; | ||
214 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
215 | return 0; | ||
216 | } | ||
217 | } | ||
218 | return -ENODEV; | ||
218 | } | 219 | } |
219 | 220 | ||
220 | static int teles_cs_config(struct pcmcia_device *link) | 221 | static int teles_cs_config(struct pcmcia_device *link) |
221 | { | 222 | { |
222 | tuple_t tuple; | ||
223 | cisparse_t parse; | ||
224 | local_info_t *dev; | 223 | local_info_t *dev; |
225 | int i, j, last_fn; | 224 | int i, last_fn; |
226 | u_short buf[128]; | ||
227 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
228 | IsdnCard_t icard; | 225 | IsdnCard_t icard; |
229 | 226 | ||
230 | DEBUG(0, "teles_config(0x%p)\n", link); | 227 | DEBUG(0, "teles_config(0x%p)\n", link); |
231 | dev = link->priv; | 228 | dev = link->priv; |
232 | 229 | ||
233 | tuple.TupleData = (cisdata_t *)buf; | 230 | i = pcmcia_loop_config(link, teles_cs_configcheck, NULL); |
234 | tuple.TupleOffset = 0; tuple.TupleDataMax = 255; | 231 | if (i != 0) { |
235 | tuple.Attributes = 0; | ||
236 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
237 | i = first_tuple(link, &tuple, &parse); | ||
238 | while (i == CS_SUCCESS) { | ||
239 | if ( (cf->io.nwin > 0) && cf->io.win[0].base) { | ||
240 | printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); | ||
241 | link->conf.ConfigIndex = cf->index; | ||
242 | link->io.BasePort1 = cf->io.win[0].base; | ||
243 | i = pcmcia_request_io(link, &link->io); | ||
244 | if (i == CS_SUCCESS) break; | ||
245 | } else { | ||
246 | printk(KERN_INFO "(teles_cs: looks like the 97 model)\n"); | ||
247 | link->conf.ConfigIndex = cf->index; | ||
248 | for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) { | ||
249 | link->io.BasePort1 = j; | ||
250 | i = pcmcia_request_io(link, &link->io); | ||
251 | if (i == CS_SUCCESS) break; | ||
252 | } | ||
253 | break; | ||
254 | } | ||
255 | i = next_tuple(link, &tuple, &parse); | ||
256 | } | ||
257 | |||
258 | if (i != CS_SUCCESS) { | ||
259 | last_fn = RequestIO; | 232 | last_fn = RequestIO; |
260 | goto cs_failed; | 233 | goto cs_failed; |
261 | } | 234 | } |
262 | 235 | ||
263 | i = pcmcia_request_irq(link, &link->irq); | 236 | i = pcmcia_request_irq(link, &link->irq); |
264 | if (i != CS_SUCCESS) { | 237 | if (i != 0) { |
265 | link->irq.AssignedIRQ = 0; | 238 | link->irq.AssignedIRQ = 0; |
266 | last_fn = RequestIRQ; | 239 | last_fn = RequestIRQ; |
267 | goto cs_failed; | 240 | goto cs_failed; |
268 | } | 241 | } |
269 | 242 | ||
270 | i = pcmcia_request_configuration(link, &link->conf); | 243 | i = pcmcia_request_configuration(link, &link->conf); |
271 | if (i != CS_SUCCESS) { | 244 | if (i != 0) { |
272 | last_fn = RequestConfiguration; | 245 | last_fn = RequestConfiguration; |
273 | goto cs_failed; | 246 | goto cs_failed; |
274 | } | 247 | } |
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 90924fb00481..d600c2deff73 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -118,7 +118,8 @@ static caddr_t remap_window(struct map_info *map, unsigned long to) | |||
118 | DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x", | 118 | DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x", |
119 | dev->offset, mrq.CardOffset); | 119 | dev->offset, mrq.CardOffset); |
120 | mrq.Page = 0; | 120 | mrq.Page = 0; |
121 | if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) { | 121 | ret = pcmcia_map_mem_page(win, &mrq); |
122 | if (ret != 0) { | ||
122 | cs_error(dev->p_dev, MapMemPage, ret); | 123 | cs_error(dev->p_dev, MapMemPage, ret); |
123 | return NULL; | 124 | return NULL; |
124 | } | 125 | } |
@@ -326,9 +327,8 @@ static void pcmciamtd_set_vpp(struct map_info *map, int on) | |||
326 | 327 | ||
327 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); | 328 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); |
328 | ret = pcmcia_modify_configuration(link, &mod); | 329 | ret = pcmcia_modify_configuration(link, &mod); |
329 | if(ret != CS_SUCCESS) { | 330 | if (ret != 0) |
330 | cs_error(link, ModifyConfiguration, ret); | 331 | cs_error(link, ModifyConfiguration, ret); |
331 | } | ||
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
@@ -368,14 +368,14 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, | |||
368 | tuple.DesiredTuple = RETURN_FIRST_TUPLE; | 368 | tuple.DesiredTuple = RETURN_FIRST_TUPLE; |
369 | 369 | ||
370 | rc = pcmcia_get_first_tuple(link, &tuple); | 370 | rc = pcmcia_get_first_tuple(link, &tuple); |
371 | while(rc == CS_SUCCESS) { | 371 | while (rc == 0) { |
372 | rc = pcmcia_get_tuple_data(link, &tuple); | 372 | rc = pcmcia_get_tuple_data(link, &tuple); |
373 | if(rc != CS_SUCCESS) { | 373 | if (rc != 0) { |
374 | cs_error(link, GetTupleData, rc); | 374 | cs_error(link, GetTupleData, rc); |
375 | break; | 375 | break; |
376 | } | 376 | } |
377 | rc = pcmcia_parse_tuple(link, &tuple, &parse); | 377 | rc = pcmcia_parse_tuple(&tuple, &parse); |
378 | if(rc != CS_SUCCESS) { | 378 | if (rc != 0) { |
379 | cs_error(link, ParseTuple, rc); | 379 | cs_error(link, ParseTuple, rc); |
380 | break; | 380 | break; |
381 | } | 381 | } |
@@ -493,18 +493,11 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
493 | int last_ret = 0, last_fn = 0; | 493 | int last_ret = 0, last_fn = 0; |
494 | int ret; | 494 | int ret; |
495 | int i; | 495 | int i; |
496 | config_info_t t; | ||
497 | static char *probes[] = { "jedec_probe", "cfi_probe" }; | 496 | static char *probes[] = { "jedec_probe", "cfi_probe" }; |
498 | int new_name = 0; | 497 | int new_name = 0; |
499 | 498 | ||
500 | DEBUG(3, "link=0x%p", link); | 499 | DEBUG(3, "link=0x%p", link); |
501 | 500 | ||
502 | DEBUG(2, "Validating CIS"); | ||
503 | ret = pcmcia_validate_cis(link, NULL); | ||
504 | if(ret != CS_SUCCESS) { | ||
505 | cs_error(link, GetTupleData, ret); | ||
506 | } | ||
507 | |||
508 | card_settings(dev, link, &new_name); | 501 | card_settings(dev, link, &new_name); |
509 | 502 | ||
510 | dev->pcmcia_map.phys = NO_XIP; | 503 | dev->pcmcia_map.phys = NO_XIP; |
@@ -571,10 +564,7 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
571 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; | 564 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; |
572 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; | 565 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; |
573 | 566 | ||
574 | DEBUG(2, "Getting configuration"); | 567 | dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; |
575 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &t)); | ||
576 | DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2); | ||
577 | dev->vpp = (vpp) ? vpp : t.Vpp1; | ||
578 | link->conf.Attributes = 0; | 568 | link->conf.Attributes = 0; |
579 | if(setvpp == 2) { | 569 | if(setvpp == 2) { |
580 | link->conf.Vpp = dev->vpp; | 570 | link->conf.Vpp = dev->vpp; |
@@ -583,16 +573,10 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
583 | } | 573 | } |
584 | 574 | ||
585 | link->conf.IntType = INT_MEMORY; | 575 | link->conf.IntType = INT_MEMORY; |
586 | link->conf.ConfigBase = t.ConfigBase; | ||
587 | link->conf.Status = t.Status; | ||
588 | link->conf.Pin = t.Pin; | ||
589 | link->conf.Copy = t.Copy; | ||
590 | link->conf.ExtStatus = t.ExtStatus; | ||
591 | link->conf.ConfigIndex = 0; | 576 | link->conf.ConfigIndex = 0; |
592 | link->conf.Present = t.Present; | ||
593 | DEBUG(2, "Setting Configuration"); | 577 | DEBUG(2, "Setting Configuration"); |
594 | ret = pcmcia_request_configuration(link, &link->conf); | 578 | ret = pcmcia_request_configuration(link, &link->conf); |
595 | if(ret != CS_SUCCESS) { | 579 | if (ret != 0) { |
596 | cs_error(link, RequestConfiguration, ret); | 580 | cs_error(link, RequestConfiguration, ret); |
597 | if (dev->win_base) { | 581 | if (dev->win_base) { |
598 | iounmap(dev->win_base); | 582 | iounmap(dev->win_base); |
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 7112fd5e0e1b..08c4dd896077 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -355,9 +355,10 @@ static int tc574_config(struct pcmcia_device *link) | |||
355 | for (i = j = 0; j < 0x400; j += 0x20) { | 355 | for (i = j = 0; j < 0x400; j += 0x20) { |
356 | link->io.BasePort1 = j ^ 0x300; | 356 | link->io.BasePort1 = j ^ 0x300; |
357 | i = pcmcia_request_io(link, &link->io); | 357 | i = pcmcia_request_io(link, &link->io); |
358 | if (i == CS_SUCCESS) break; | 358 | if (i == 0) |
359 | break; | ||
359 | } | 360 | } |
360 | if (i != CS_SUCCESS) { | 361 | if (i != 0) { |
361 | cs_error(link, RequestIO, i); | 362 | cs_error(link, RequestIO, i); |
362 | goto failed; | 363 | goto failed; |
363 | } | 364 | } |
@@ -377,7 +378,7 @@ static int tc574_config(struct pcmcia_device *link) | |||
377 | tuple.TupleDataMax = 64; | 378 | tuple.TupleDataMax = 64; |
378 | tuple.TupleOffset = 0; | 379 | tuple.TupleOffset = 0; |
379 | tuple.DesiredTuple = 0x88; | 380 | tuple.DesiredTuple = 0x88; |
380 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 381 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { |
381 | pcmcia_get_tuple_data(link, &tuple); | 382 | pcmcia_get_tuple_data(link, &tuple); |
382 | for (i = 0; i < 3; i++) | 383 | for (i = 0; i < 3; i++) |
383 | phys_addr[i] = htons(le16_to_cpu(buf[i])); | 384 | phys_addr[i] = htons(le16_to_cpu(buf[i])); |
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 549a64558420..0b28d0d8ffa8 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -278,9 +278,10 @@ static int tc589_config(struct pcmcia_device *link) | |||
278 | if (multi && (j & 0x80)) continue; | 278 | if (multi && (j & 0x80)) continue; |
279 | link->io.BasePort1 = j ^ 0x300; | 279 | link->io.BasePort1 = j ^ 0x300; |
280 | i = pcmcia_request_io(link, &link->io); | 280 | i = pcmcia_request_io(link, &link->io); |
281 | if (i == CS_SUCCESS) break; | 281 | if (i == 0) |
282 | break; | ||
282 | } | 283 | } |
283 | if (i != CS_SUCCESS) { | 284 | if (i != 0) { |
284 | cs_error(link, RequestIO, i); | 285 | cs_error(link, RequestIO, i); |
285 | goto failed; | 286 | goto failed; |
286 | } | 287 | } |
@@ -295,7 +296,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
295 | /* The 3c589 has an extra EEPROM for configuration info, including | 296 | /* The 3c589 has an extra EEPROM for configuration info, including |
296 | the hardware address. The 3c562 puts the address in the CIS. */ | 297 | the hardware address. The 3c562 puts the address in the CIS. */ |
297 | tuple.DesiredTuple = 0x88; | 298 | tuple.DesiredTuple = 0x88; |
298 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 299 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { |
299 | pcmcia_get_tuple_data(link, &tuple); | 300 | pcmcia_get_tuple_data(link, &tuple); |
300 | for (i = 0; i < 3; i++) | 301 | for (i = 0; i < 3; i++) |
301 | phys_addr[i] = htons(le16_to_cpu(buf[i])); | 302 | phys_addr[i] = htons(le16_to_cpu(buf[i])); |
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 52bf11b73c6e..b37a498939ae 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -262,7 +262,7 @@ static int try_io_port(struct pcmcia_device *link) | |||
262 | if (link->io.NumPorts2 > 0) { | 262 | if (link->io.NumPorts2 > 0) { |
263 | /* for master/slave multifunction cards */ | 263 | /* for master/slave multifunction cards */ |
264 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 264 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
265 | link->irq.Attributes = | 265 | link->irq.Attributes = |
266 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; | 266 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; |
267 | } | 267 | } |
268 | } else { | 268 | } else { |
@@ -276,7 +276,8 @@ static int try_io_port(struct pcmcia_device *link) | |||
276 | link->io.BasePort1 = j ^ 0x300; | 276 | link->io.BasePort1 = j ^ 0x300; |
277 | link->io.BasePort2 = (j ^ 0x300) + 0x10; | 277 | link->io.BasePort2 = (j ^ 0x300) + 0x10; |
278 | ret = pcmcia_request_io(link, &link->io); | 278 | ret = pcmcia_request_io(link, &link->io); |
279 | if (ret == CS_SUCCESS) return ret; | 279 | if (ret == 0) |
280 | return ret; | ||
280 | } | 281 | } |
281 | return ret; | 282 | return ret; |
282 | } else { | 283 | } else { |
@@ -284,59 +285,50 @@ static int try_io_port(struct pcmcia_device *link) | |||
284 | } | 285 | } |
285 | } | 286 | } |
286 | 287 | ||
288 | static int axnet_configcheck(struct pcmcia_device *p_dev, | ||
289 | cistpl_cftable_entry_t *cfg, | ||
290 | cistpl_cftable_entry_t *dflt, | ||
291 | unsigned int vcc, | ||
292 | void *priv_data) | ||
293 | { | ||
294 | int i; | ||
295 | cistpl_io_t *io = &cfg->io; | ||
296 | |||
297 | if (cfg->index == 0 || cfg->io.nwin == 0) | ||
298 | return -ENODEV; | ||
299 | |||
300 | p_dev->conf.ConfigIndex = 0x05; | ||
301 | /* For multifunction cards, by convention, we configure the | ||
302 | network function with window 0, and serial with window 1 */ | ||
303 | if (io->nwin > 1) { | ||
304 | i = (io->win[1].len > io->win[0].len); | ||
305 | p_dev->io.BasePort2 = io->win[1-i].base; | ||
306 | p_dev->io.NumPorts2 = io->win[1-i].len; | ||
307 | } else { | ||
308 | i = p_dev->io.NumPorts2 = 0; | ||
309 | } | ||
310 | p_dev->io.BasePort1 = io->win[i].base; | ||
311 | p_dev->io.NumPorts1 = io->win[i].len; | ||
312 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
313 | if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) | ||
314 | return try_io_port(p_dev); | ||
315 | |||
316 | return -ENODEV; | ||
317 | } | ||
318 | |||
287 | static int axnet_config(struct pcmcia_device *link) | 319 | static int axnet_config(struct pcmcia_device *link) |
288 | { | 320 | { |
289 | struct net_device *dev = link->priv; | 321 | struct net_device *dev = link->priv; |
290 | axnet_dev_t *info = PRIV(dev); | 322 | axnet_dev_t *info = PRIV(dev); |
291 | tuple_t tuple; | ||
292 | cisparse_t parse; | ||
293 | int i, j, last_ret, last_fn; | 323 | int i, j, last_ret, last_fn; |
294 | u_short buf[64]; | ||
295 | DECLARE_MAC_BUF(mac); | 324 | DECLARE_MAC_BUF(mac); |
296 | 325 | ||
297 | DEBUG(0, "axnet_config(0x%p)\n", link); | 326 | DEBUG(0, "axnet_config(0x%p)\n", link); |
298 | 327 | ||
299 | tuple.Attributes = 0; | ||
300 | tuple.TupleData = (cisdata_t *)buf; | ||
301 | tuple.TupleDataMax = sizeof(buf); | ||
302 | tuple.TupleOffset = 0; | ||
303 | |||
304 | /* don't trust the CIS on this; Linksys got it wrong */ | 328 | /* don't trust the CIS on this; Linksys got it wrong */ |
305 | link->conf.Present = 0x63; | 329 | link->conf.Present = 0x63; |
306 | 330 | last_ret = pcmcia_loop_config(link, axnet_configcheck, NULL); | |
307 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 331 | if (last_ret != 0) { |
308 | tuple.Attributes = 0; | ||
309 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
310 | while (last_ret == CS_SUCCESS) { | ||
311 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
312 | cistpl_io_t *io = &(parse.cftable_entry.io); | ||
313 | |||
314 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
315 | pcmcia_parse_tuple(link, &tuple, &parse) != 0 || | ||
316 | cfg->index == 0 || cfg->io.nwin == 0) | ||
317 | goto next_entry; | ||
318 | |||
319 | link->conf.ConfigIndex = 0x05; | ||
320 | /* For multifunction cards, by convention, we configure the | ||
321 | network function with window 0, and serial with window 1 */ | ||
322 | if (io->nwin > 1) { | ||
323 | i = (io->win[1].len > io->win[0].len); | ||
324 | link->io.BasePort2 = io->win[1-i].base; | ||
325 | link->io.NumPorts2 = io->win[1-i].len; | ||
326 | } else { | ||
327 | i = link->io.NumPorts2 = 0; | ||
328 | } | ||
329 | link->io.BasePort1 = io->win[i].base; | ||
330 | link->io.NumPorts1 = io->win[i].len; | ||
331 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
332 | if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { | ||
333 | last_ret = try_io_port(link); | ||
334 | if (last_ret == CS_SUCCESS) break; | ||
335 | } | ||
336 | next_entry: | ||
337 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
338 | } | ||
339 | if (last_ret != CS_SUCCESS) { | ||
340 | cs_error(link, RequestIO, last_ret); | 332 | cs_error(link, RequestIO, last_ret); |
341 | goto failed; | 333 | goto failed; |
342 | } | 334 | } |
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index ea9414c4d900..831090c75622 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c | |||
@@ -260,21 +260,21 @@ static int com20020_config(struct pcmcia_device *link) | |||
260 | DEBUG(0, "com20020_config(0x%p)\n", link); | 260 | DEBUG(0, "com20020_config(0x%p)\n", link); |
261 | 261 | ||
262 | DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); | 262 | DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); |
263 | i = !CS_SUCCESS; | 263 | i = -ENODEV; |
264 | if (!link->io.BasePort1) | 264 | if (!link->io.BasePort1) |
265 | { | 265 | { |
266 | for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) | 266 | for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) |
267 | { | 267 | { |
268 | link->io.BasePort1 = ioaddr; | 268 | link->io.BasePort1 = ioaddr; |
269 | i = pcmcia_request_io(link, &link->io); | 269 | i = pcmcia_request_io(link, &link->io); |
270 | if (i == CS_SUCCESS) | 270 | if (i == 0) |
271 | break; | 271 | break; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | else | 274 | else |
275 | i = pcmcia_request_io(link, &link->io); | 275 | i = pcmcia_request_io(link, &link->io); |
276 | 276 | ||
277 | if (i != CS_SUCCESS) | 277 | if (i != 0) |
278 | { | 278 | { |
279 | DEBUG(1,"arcnet: requestIO failed totally!\n"); | 279 | DEBUG(1,"arcnet: requestIO failed totally!\n"); |
280 | goto failed; | 280 | goto failed; |
@@ -287,7 +287,7 @@ static int com20020_config(struct pcmcia_device *link) | |||
287 | link->irq.AssignedIRQ, | 287 | link->irq.AssignedIRQ, |
288 | link->irq.IRQInfo1, link->irq.IRQInfo2); | 288 | link->irq.IRQInfo1, link->irq.IRQInfo2); |
289 | i = pcmcia_request_irq(link, &link->irq); | 289 | i = pcmcia_request_irq(link, &link->irq); |
290 | if (i != CS_SUCCESS) | 290 | if (i != 0) |
291 | { | 291 | { |
292 | DEBUG(1,"arcnet: requestIRQ failed totally!\n"); | 292 | DEBUG(1,"arcnet: requestIRQ failed totally!\n"); |
293 | goto failed; | 293 | goto failed; |
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index a550c9bd126f..69d916daa7bb 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c | |||
@@ -309,7 +309,8 @@ static int mfc_try_io_port(struct pcmcia_device *link) | |||
309 | printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); | 309 | printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); |
310 | } | 310 | } |
311 | ret = pcmcia_request_io(link, &link->io); | 311 | ret = pcmcia_request_io(link, &link->io); |
312 | if (ret == CS_SUCCESS) return ret; | 312 | if (ret == 0) |
313 | return ret; | ||
313 | } | 314 | } |
314 | return ret; | 315 | return ret; |
315 | } | 316 | } |
@@ -325,7 +326,7 @@ static int ungermann_try_io_port(struct pcmcia_device *link) | |||
325 | for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { | 326 | for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { |
326 | link->io.BasePort1 = ioaddr; | 327 | link->io.BasePort1 = ioaddr; |
327 | ret = pcmcia_request_io(link, &link->io); | 328 | ret = pcmcia_request_io(link, &link->io); |
328 | if (ret == CS_SUCCESS) { | 329 | if (ret == 0) { |
329 | /* calculate ConfigIndex value */ | 330 | /* calculate ConfigIndex value */ |
330 | link->conf.ConfigIndex = | 331 | link->conf.ConfigIndex = |
331 | ((link->io.BasePort1 & 0x0f0) >> 3) | 0x22; | 332 | ((link->io.BasePort1 & 0x0f0) >> 3) | 0x22; |
@@ -356,12 +357,12 @@ static int fmvj18x_config(struct pcmcia_device *link) | |||
356 | tuple.TupleOffset = 0; | 357 | tuple.TupleOffset = 0; |
357 | tuple.DesiredTuple = CISTPL_FUNCE; | 358 | tuple.DesiredTuple = CISTPL_FUNCE; |
358 | tuple.TupleOffset = 0; | 359 | tuple.TupleOffset = 0; |
359 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 360 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { |
360 | /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ | 361 | /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ |
361 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 362 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
362 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 363 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
363 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); | 364 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
364 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); | 365 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); |
365 | link->conf.ConfigIndex = parse.cftable_entry.index; | 366 | link->conf.ConfigIndex = parse.cftable_entry.index; |
366 | switch (link->manf_id) { | 367 | switch (link->manf_id) { |
367 | case MANFID_TDK: | 368 | case MANFID_TDK: |
@@ -430,10 +431,10 @@ static int fmvj18x_config(struct pcmcia_device *link) | |||
430 | link->irq.Attributes = | 431 | link->irq.Attributes = |
431 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; | 432 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; |
432 | ret = mfc_try_io_port(link); | 433 | ret = mfc_try_io_port(link); |
433 | if (ret != CS_SUCCESS) goto cs_failed; | 434 | if (ret != 0) goto cs_failed; |
434 | } else if (cardtype == UNGERMANN) { | 435 | } else if (cardtype == UNGERMANN) { |
435 | ret = ungermann_try_io_port(link); | 436 | ret = ungermann_try_io_port(link); |
436 | if (ret != CS_SUCCESS) goto cs_failed; | 437 | if (ret != 0) goto cs_failed; |
437 | } else { | 438 | } else { |
438 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); | 439 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); |
439 | } | 440 | } |
@@ -565,7 +566,7 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) | |||
565 | req.Base = 0; req.Size = 0; | 566 | req.Base = 0; req.Size = 0; |
566 | req.AccessSpeed = 0; | 567 | req.AccessSpeed = 0; |
567 | i = pcmcia_request_window(&link, &req, &link->win); | 568 | i = pcmcia_request_window(&link, &req, &link->win); |
568 | if (i != CS_SUCCESS) { | 569 | if (i != 0) { |
569 | cs_error(link, RequestWindow, i); | 570 | cs_error(link, RequestWindow, i); |
570 | return -1; | 571 | return -1; |
571 | } | 572 | } |
@@ -599,7 +600,7 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) | |||
599 | 600 | ||
600 | iounmap(base); | 601 | iounmap(base); |
601 | j = pcmcia_release_window(link->win); | 602 | j = pcmcia_release_window(link->win); |
602 | if (j != CS_SUCCESS) | 603 | if (j != 0) |
603 | cs_error(link, ReleaseWindow, j); | 604 | cs_error(link, ReleaseWindow, j); |
604 | return (i != 0x200) ? 0 : -1; | 605 | return (i != 0x200) ? 0 : -1; |
605 | 606 | ||
@@ -620,7 +621,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link) | |||
620 | req.Base = 0; req.Size = 0; | 621 | req.Base = 0; req.Size = 0; |
621 | req.AccessSpeed = 0; | 622 | req.AccessSpeed = 0; |
622 | i = pcmcia_request_window(&link, &req, &link->win); | 623 | i = pcmcia_request_window(&link, &req, &link->win); |
623 | if (i != CS_SUCCESS) { | 624 | if (i != 0) { |
624 | cs_error(link, RequestWindow, i); | 625 | cs_error(link, RequestWindow, i); |
625 | return -1; | 626 | return -1; |
626 | } | 627 | } |
@@ -642,7 +643,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link) | |||
642 | 643 | ||
643 | iounmap(base); | 644 | iounmap(base); |
644 | j = pcmcia_release_window(link->win); | 645 | j = pcmcia_release_window(link->win); |
645 | if (j != CS_SUCCESS) | 646 | if (j != 0) |
646 | cs_error(link, ReleaseWindow, j); | 647 | cs_error(link, ReleaseWindow, j); |
647 | return 0; | 648 | return 0; |
648 | 649 | ||
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 4eafa4f42cff..cf3cca4642f2 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c | |||
@@ -238,7 +238,7 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
238 | /* Try PRIMARY card at 0xA20-0xA23 */ | 238 | /* Try PRIMARY card at 0xA20-0xA23 */ |
239 | link->io.BasePort1 = 0xA20; | 239 | link->io.BasePort1 = 0xA20; |
240 | i = pcmcia_request_io(link, &link->io); | 240 | i = pcmcia_request_io(link, &link->io); |
241 | if (i != CS_SUCCESS) { | 241 | if (i != 0) { |
242 | /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ | 242 | /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ |
243 | link->io.BasePort1 = 0xA24; | 243 | link->io.BasePort1 = 0xA24; |
244 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); | 244 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); |
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index cfcbea9b7e2e..54df34f21c5f 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c | |||
@@ -925,7 +925,7 @@ static void mace_tx_timeout(struct net_device *dev) | |||
925 | printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); | 925 | printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); |
926 | #if RESET_ON_TIMEOUT | 926 | #if RESET_ON_TIMEOUT |
927 | printk("resetting card\n"); | 927 | printk("resetting card\n"); |
928 | pcmcia_reset_card(link, NULL); | 928 | pcmcia_reset_card(link->socket); |
929 | #else /* #if RESET_ON_TIMEOUT */ | 929 | #else /* #if RESET_ON_TIMEOUT */ |
930 | printk("NOT resetting card\n"); | 930 | printk("NOT resetting card\n"); |
931 | #endif /* #if RESET_ON_TIMEOUT */ | 931 | #endif /* #if RESET_ON_TIMEOUT */ |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index ebc1ae6bcbe5..e40d6301aa7a 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -310,7 +310,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
310 | req.Base = 0; req.Size = 0; | 310 | req.Base = 0; req.Size = 0; |
311 | req.AccessSpeed = 0; | 311 | req.AccessSpeed = 0; |
312 | i = pcmcia_request_window(&link, &req, &link->win); | 312 | i = pcmcia_request_window(&link, &req, &link->win); |
313 | if (i != CS_SUCCESS) { | 313 | if (i != 0) { |
314 | cs_error(link, RequestWindow, i); | 314 | cs_error(link, RequestWindow, i); |
315 | return NULL; | 315 | return NULL; |
316 | } | 316 | } |
@@ -333,7 +333,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
333 | 333 | ||
334 | iounmap(virt); | 334 | iounmap(virt); |
335 | j = pcmcia_release_window(link->win); | 335 | j = pcmcia_release_window(link->win); |
336 | if (j != CS_SUCCESS) | 336 | if (j != 0) |
337 | cs_error(link, ReleaseWindow, j); | 337 | cs_error(link, ReleaseWindow, j); |
338 | return (i < NR_INFO) ? hw_info+i : NULL; | 338 | return (i < NR_INFO) ? hw_info+i : NULL; |
339 | } /* get_hwinfo */ | 339 | } /* get_hwinfo */ |
@@ -504,7 +504,8 @@ static int try_io_port(struct pcmcia_device *link) | |||
504 | link->io.BasePort1 = j ^ 0x300; | 504 | link->io.BasePort1 = j ^ 0x300; |
505 | link->io.BasePort2 = (j ^ 0x300) + 0x10; | 505 | link->io.BasePort2 = (j ^ 0x300) + 0x10; |
506 | ret = pcmcia_request_io(link, &link->io); | 506 | ret = pcmcia_request_io(link, &link->io); |
507 | if (ret == CS_SUCCESS) return ret; | 507 | if (ret == 0) |
508 | return ret; | ||
508 | } | 509 | } |
509 | return ret; | 510 | return ret; |
510 | } else { | 511 | } else { |
@@ -512,58 +513,53 @@ static int try_io_port(struct pcmcia_device *link) | |||
512 | } | 513 | } |
513 | } | 514 | } |
514 | 515 | ||
516 | static int pcnet_confcheck(struct pcmcia_device *p_dev, | ||
517 | cistpl_cftable_entry_t *cfg, | ||
518 | cistpl_cftable_entry_t *dflt, | ||
519 | unsigned int vcc, | ||
520 | void *priv_data) | ||
521 | { | ||
522 | int *has_shmem = priv_data; | ||
523 | int i; | ||
524 | cistpl_io_t *io = &cfg->io; | ||
525 | |||
526 | if (cfg->index == 0 || cfg->io.nwin == 0) | ||
527 | return -EINVAL; | ||
528 | |||
529 | /* For multifunction cards, by convention, we configure the | ||
530 | network function with window 0, and serial with window 1 */ | ||
531 | if (io->nwin > 1) { | ||
532 | i = (io->win[1].len > io->win[0].len); | ||
533 | p_dev->io.BasePort2 = io->win[1-i].base; | ||
534 | p_dev->io.NumPorts2 = io->win[1-i].len; | ||
535 | } else { | ||
536 | i = p_dev->io.NumPorts2 = 0; | ||
537 | } | ||
538 | |||
539 | *has_shmem = ((cfg->mem.nwin == 1) && | ||
540 | (cfg->mem.win[0].len >= 0x4000)); | ||
541 | p_dev->io.BasePort1 = io->win[i].base; | ||
542 | p_dev->io.NumPorts1 = io->win[i].len; | ||
543 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
544 | if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) | ||
545 | return try_io_port(p_dev); | ||
546 | |||
547 | return 0; | ||
548 | } | ||
549 | |||
515 | static int pcnet_config(struct pcmcia_device *link) | 550 | static int pcnet_config(struct pcmcia_device *link) |
516 | { | 551 | { |
517 | struct net_device *dev = link->priv; | 552 | struct net_device *dev = link->priv; |
518 | pcnet_dev_t *info = PRIV(dev); | 553 | pcnet_dev_t *info = PRIV(dev); |
519 | tuple_t tuple; | 554 | int last_ret, last_fn, start_pg, stop_pg, cm_offset; |
520 | cisparse_t parse; | ||
521 | int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; | ||
522 | int has_shmem = 0; | 555 | int has_shmem = 0; |
523 | u_short buf[64]; | ||
524 | hw_info_t *local_hw_info; | 556 | hw_info_t *local_hw_info; |
525 | DECLARE_MAC_BUF(mac); | 557 | DECLARE_MAC_BUF(mac); |
526 | 558 | ||
527 | DEBUG(0, "pcnet_config(0x%p)\n", link); | 559 | DEBUG(0, "pcnet_config(0x%p)\n", link); |
528 | 560 | ||
529 | tuple.TupleData = (cisdata_t *)buf; | 561 | last_ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); |
530 | tuple.TupleDataMax = sizeof(buf); | 562 | if (last_ret) { |
531 | tuple.TupleOffset = 0; | ||
532 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
533 | tuple.Attributes = 0; | ||
534 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
535 | while (last_ret == CS_SUCCESS) { | ||
536 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
537 | cistpl_io_t *io = &(parse.cftable_entry.io); | ||
538 | |||
539 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
540 | pcmcia_parse_tuple(link, &tuple, &parse) != 0 || | ||
541 | cfg->index == 0 || cfg->io.nwin == 0) | ||
542 | goto next_entry; | ||
543 | |||
544 | link->conf.ConfigIndex = cfg->index; | ||
545 | /* For multifunction cards, by convention, we configure the | ||
546 | network function with window 0, and serial with window 1 */ | ||
547 | if (io->nwin > 1) { | ||
548 | i = (io->win[1].len > io->win[0].len); | ||
549 | link->io.BasePort2 = io->win[1-i].base; | ||
550 | link->io.NumPorts2 = io->win[1-i].len; | ||
551 | } else { | ||
552 | i = link->io.NumPorts2 = 0; | ||
553 | } | ||
554 | has_shmem = ((cfg->mem.nwin == 1) && | ||
555 | (cfg->mem.win[0].len >= 0x4000)); | ||
556 | link->io.BasePort1 = io->win[i].base; | ||
557 | link->io.NumPorts1 = io->win[i].len; | ||
558 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
559 | if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { | ||
560 | last_ret = try_io_port(link); | ||
561 | if (last_ret == CS_SUCCESS) break; | ||
562 | } | ||
563 | next_entry: | ||
564 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
565 | } | ||
566 | if (last_ret != CS_SUCCESS) { | ||
567 | cs_error(link, RequestIO, last_ret); | 563 | cs_error(link, RequestIO, last_ret); |
568 | goto failed; | 564 | goto failed; |
569 | } | 565 | } |
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 250eb1954c34..c74d6656d266 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -409,10 +409,13 @@ static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | |||
409 | { | 409 | { |
410 | int i; | 410 | int i; |
411 | 411 | ||
412 | if ((i = pcmcia_get_first_tuple(handle, tuple)) != CS_SUCCESS || | 412 | i = pcmcia_get_first_tuple(handle, tuple); |
413 | (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) | 413 | if (i != 0) |
414 | return i; | 414 | return i; |
415 | return pcmcia_parse_tuple(handle, tuple, parse); | 415 | i = pcmcia_get_tuple_data(handle, tuple); |
416 | if (i != 0) | ||
417 | return i; | ||
418 | return pcmcia_parse_tuple(tuple, parse); | ||
416 | } | 419 | } |
417 | 420 | ||
418 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 421 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, |
@@ -420,10 +423,10 @@ static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | |||
420 | { | 423 | { |
421 | int i; | 424 | int i; |
422 | 425 | ||
423 | if ((i = pcmcia_get_next_tuple(handle, tuple)) != CS_SUCCESS || | 426 | if ((i = pcmcia_get_next_tuple(handle, tuple)) != 0 || |
424 | (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) | 427 | (i = pcmcia_get_tuple_data(handle, tuple)) != 0) |
425 | return i; | 428 | return i; |
426 | return pcmcia_parse_tuple(handle, tuple, parse); | 429 | return pcmcia_parse_tuple(tuple, parse); |
427 | } | 430 | } |
428 | 431 | ||
429 | /*====================================================================== | 432 | /*====================================================================== |
@@ -459,27 +462,36 @@ static int mhz_3288_power(struct pcmcia_device *link) | |||
459 | return 0; | 462 | return 0; |
460 | } | 463 | } |
461 | 464 | ||
465 | static int mhz_mfc_config_check(struct pcmcia_device *p_dev, | ||
466 | cistpl_cftable_entry_t *cf, | ||
467 | cistpl_cftable_entry_t *dflt, | ||
468 | unsigned int vcc, | ||
469 | void *priv_data) | ||
470 | { | ||
471 | int k; | ||
472 | p_dev->io.BasePort2 = cf->io.win[0].base; | ||
473 | for (k = 0; k < 0x400; k += 0x10) { | ||
474 | if (k & 0x80) | ||
475 | continue; | ||
476 | p_dev->io.BasePort1 = k ^ 0x300; | ||
477 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
478 | return 0; | ||
479 | } | ||
480 | return -ENODEV; | ||
481 | } | ||
482 | |||
462 | static int mhz_mfc_config(struct pcmcia_device *link) | 483 | static int mhz_mfc_config(struct pcmcia_device *link) |
463 | { | 484 | { |
464 | struct net_device *dev = link->priv; | 485 | struct net_device *dev = link->priv; |
465 | struct smc_private *smc = netdev_priv(dev); | 486 | struct smc_private *smc = netdev_priv(dev); |
466 | struct smc_cfg_mem *cfg_mem; | 487 | struct smc_cfg_mem *cfg_mem; |
467 | tuple_t *tuple; | ||
468 | cisparse_t *parse; | ||
469 | cistpl_cftable_entry_t *cf; | ||
470 | u_char *buf; | ||
471 | win_req_t req; | 488 | win_req_t req; |
472 | memreq_t mem; | 489 | memreq_t mem; |
473 | int i, k; | 490 | int i; |
474 | 491 | ||
475 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 492 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); |
476 | if (!cfg_mem) | 493 | if (!cfg_mem) |
477 | return CS_OUT_OF_RESOURCE; | 494 | return -ENOMEM; |
478 | |||
479 | tuple = &cfg_mem->tuple; | ||
480 | parse = &cfg_mem->parse; | ||
481 | cf = &parse->cftable_entry; | ||
482 | buf = cfg_mem->buf; | ||
483 | 495 | ||
484 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 496 | link->conf.Attributes |= CONF_ENABLE_SPKR; |
485 | link->conf.Status = CCSR_AUDIO_ENA; | 497 | link->conf.Status = CCSR_AUDIO_ENA; |
@@ -489,27 +501,9 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
489 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 501 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
490 | link->io.NumPorts2 = 8; | 502 | link->io.NumPorts2 = 8; |
491 | 503 | ||
492 | tuple->Attributes = tuple->TupleOffset = 0; | ||
493 | tuple->TupleData = (cisdata_t *)buf; | ||
494 | tuple->TupleDataMax = 255; | ||
495 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
496 | |||
497 | i = first_tuple(link, tuple, parse); | ||
498 | /* The Megahertz combo cards have modem-like CIS entries, so | 504 | /* The Megahertz combo cards have modem-like CIS entries, so |
499 | we have to explicitly try a bunch of port combinations. */ | 505 | we have to explicitly try a bunch of port combinations. */ |
500 | while (i == CS_SUCCESS) { | 506 | if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL)) |
501 | link->conf.ConfigIndex = cf->index; | ||
502 | link->io.BasePort2 = cf->io.win[0].base; | ||
503 | for (k = 0; k < 0x400; k += 0x10) { | ||
504 | if (k & 0x80) continue; | ||
505 | link->io.BasePort1 = k ^ 0x300; | ||
506 | i = pcmcia_request_io(link, &link->io); | ||
507 | if (i == CS_SUCCESS) break; | ||
508 | } | ||
509 | if (i == CS_SUCCESS) break; | ||
510 | i = next_tuple(link, tuple, parse); | ||
511 | } | ||
512 | if (i != CS_SUCCESS) | ||
513 | goto free_cfg_mem; | 507 | goto free_cfg_mem; |
514 | dev->base_addr = link->io.BasePort1; | 508 | dev->base_addr = link->io.BasePort1; |
515 | 509 | ||
@@ -518,7 +512,7 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
518 | req.Base = req.Size = 0; | 512 | req.Base = req.Size = 0; |
519 | req.AccessSpeed = 0; | 513 | req.AccessSpeed = 0; |
520 | i = pcmcia_request_window(&link, &req, &link->win); | 514 | i = pcmcia_request_window(&link, &req, &link->win); |
521 | if (i != CS_SUCCESS) | 515 | if (i != 0) |
522 | goto free_cfg_mem; | 516 | goto free_cfg_mem; |
523 | smc->base = ioremap(req.Base, req.Size); | 517 | smc->base = ioremap(req.Base, req.Size); |
524 | mem.CardOffset = mem.Page = 0; | 518 | mem.CardOffset = mem.Page = 0; |
@@ -526,14 +520,14 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
526 | mem.CardOffset = link->conf.ConfigBase; | 520 | mem.CardOffset = link->conf.ConfigBase; |
527 | i = pcmcia_map_mem_page(link->win, &mem); | 521 | i = pcmcia_map_mem_page(link->win, &mem); |
528 | 522 | ||
529 | if ((i == CS_SUCCESS) | 523 | if ((i == 0) |
530 | && (smc->manfid == MANFID_MEGAHERTZ) | 524 | && (smc->manfid == MANFID_MEGAHERTZ) |
531 | && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) | 525 | && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) |
532 | mhz_3288_power(link); | 526 | mhz_3288_power(link); |
533 | 527 | ||
534 | free_cfg_mem: | 528 | free_cfg_mem: |
535 | kfree(cfg_mem); | 529 | kfree(cfg_mem); |
536 | return i; | 530 | return -ENODEV; |
537 | } | 531 | } |
538 | 532 | ||
539 | static int mhz_setup(struct pcmcia_device *link) | 533 | static int mhz_setup(struct pcmcia_device *link) |
@@ -560,12 +554,12 @@ static int mhz_setup(struct pcmcia_device *link) | |||
560 | /* Read the station address from the CIS. It is stored as the last | 554 | /* Read the station address from the CIS. It is stored as the last |
561 | (fourth) string in the Version 1 Version/ID tuple. */ | 555 | (fourth) string in the Version 1 Version/ID tuple. */ |
562 | tuple->DesiredTuple = CISTPL_VERS_1; | 556 | tuple->DesiredTuple = CISTPL_VERS_1; |
563 | if (first_tuple(link, tuple, parse) != CS_SUCCESS) { | 557 | if (first_tuple(link, tuple, parse) != 0) { |
564 | rc = -1; | 558 | rc = -1; |
565 | goto free_cfg_mem; | 559 | goto free_cfg_mem; |
566 | } | 560 | } |
567 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ | 561 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ |
568 | if (next_tuple(link, tuple, parse) != CS_SUCCESS) | 562 | if (next_tuple(link, tuple, parse) != 0) |
569 | first_tuple(link, tuple, parse); | 563 | first_tuple(link, tuple, parse); |
570 | if (parse->version_1.ns > 3) { | 564 | if (parse->version_1.ns > 3) { |
571 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; | 565 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; |
@@ -577,11 +571,11 @@ static int mhz_setup(struct pcmcia_device *link) | |||
577 | 571 | ||
578 | /* Another possibility: for the EM3288, in a special tuple */ | 572 | /* Another possibility: for the EM3288, in a special tuple */ |
579 | tuple->DesiredTuple = 0x81; | 573 | tuple->DesiredTuple = 0x81; |
580 | if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) { | 574 | if (pcmcia_get_first_tuple(link, tuple) != 0) { |
581 | rc = -1; | 575 | rc = -1; |
582 | goto free_cfg_mem; | 576 | goto free_cfg_mem; |
583 | } | 577 | } |
584 | if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) { | 578 | if (pcmcia_get_tuple_data(link, tuple) != 0) { |
585 | rc = -1; | 579 | rc = -1; |
586 | goto free_cfg_mem; | 580 | goto free_cfg_mem; |
587 | } | 581 | } |
@@ -660,46 +654,27 @@ static int mot_setup(struct pcmcia_device *link) | |||
660 | 654 | ||
661 | /*====================================================================*/ | 655 | /*====================================================================*/ |
662 | 656 | ||
657 | static int smc_configcheck(struct pcmcia_device *p_dev, | ||
658 | cistpl_cftable_entry_t *cf, | ||
659 | cistpl_cftable_entry_t *dflt, | ||
660 | unsigned int vcc, | ||
661 | void *priv_data) | ||
662 | { | ||
663 | p_dev->io.BasePort1 = cf->io.win[0].base; | ||
664 | p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | ||
665 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
666 | } | ||
667 | |||
663 | static int smc_config(struct pcmcia_device *link) | 668 | static int smc_config(struct pcmcia_device *link) |
664 | { | 669 | { |
665 | struct net_device *dev = link->priv; | 670 | struct net_device *dev = link->priv; |
666 | struct smc_cfg_mem *cfg_mem; | ||
667 | tuple_t *tuple; | ||
668 | cisparse_t *parse; | ||
669 | cistpl_cftable_entry_t *cf; | ||
670 | u_char *buf; | ||
671 | int i; | 671 | int i; |
672 | 672 | ||
673 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | ||
674 | if (!cfg_mem) | ||
675 | return CS_OUT_OF_RESOURCE; | ||
676 | |||
677 | tuple = &cfg_mem->tuple; | ||
678 | parse = &cfg_mem->parse; | ||
679 | cf = &parse->cftable_entry; | ||
680 | buf = cfg_mem->buf; | ||
681 | |||
682 | tuple->Attributes = tuple->TupleOffset = 0; | ||
683 | tuple->TupleData = (cisdata_t *)buf; | ||
684 | tuple->TupleDataMax = 255; | ||
685 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
686 | |||
687 | link->io.NumPorts1 = 16; | 673 | link->io.NumPorts1 = 16; |
688 | i = first_tuple(link, tuple, parse); | 674 | i = pcmcia_loop_config(link, smc_configcheck, NULL); |
689 | while (i != CS_NO_MORE_ITEMS) { | 675 | if (!i) |
690 | if (i == CS_SUCCESS) { | 676 | dev->base_addr = link->io.BasePort1; |
691 | link->conf.ConfigIndex = cf->index; | ||
692 | link->io.BasePort1 = cf->io.win[0].base; | ||
693 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | ||
694 | i = pcmcia_request_io(link, &link->io); | ||
695 | if (i == CS_SUCCESS) break; | ||
696 | } | ||
697 | i = next_tuple(link, tuple, parse); | ||
698 | } | ||
699 | if (i == CS_SUCCESS) | ||
700 | dev->base_addr = link->io.BasePort1; | ||
701 | 677 | ||
702 | kfree(cfg_mem); | ||
703 | return i; | 678 | return i; |
704 | } | 679 | } |
705 | 680 | ||
@@ -715,7 +690,7 @@ static int smc_setup(struct pcmcia_device *link) | |||
715 | 690 | ||
716 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 691 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); |
717 | if (!cfg_mem) | 692 | if (!cfg_mem) |
718 | return CS_OUT_OF_RESOURCE; | 693 | return -ENOMEM; |
719 | 694 | ||
720 | tuple = &cfg_mem->tuple; | 695 | tuple = &cfg_mem->tuple; |
721 | parse = &cfg_mem->parse; | 696 | parse = &cfg_mem->parse; |
@@ -728,12 +703,12 @@ static int smc_setup(struct pcmcia_device *link) | |||
728 | /* Check for a LAN function extension tuple */ | 703 | /* Check for a LAN function extension tuple */ |
729 | tuple->DesiredTuple = CISTPL_FUNCE; | 704 | tuple->DesiredTuple = CISTPL_FUNCE; |
730 | i = first_tuple(link, tuple, parse); | 705 | i = first_tuple(link, tuple, parse); |
731 | while (i == CS_SUCCESS) { | 706 | while (i == 0) { |
732 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) | 707 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) |
733 | break; | 708 | break; |
734 | i = next_tuple(link, tuple, parse); | 709 | i = next_tuple(link, tuple, parse); |
735 | } | 710 | } |
736 | if (i == CS_SUCCESS) { | 711 | if (i == 0) { |
737 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; | 712 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; |
738 | if (node_id->nb == 6) { | 713 | if (node_id->nb == 6) { |
739 | for (i = 0; i < 6; i++) | 714 | for (i = 0; i < 6; i++) |
@@ -780,9 +755,10 @@ static int osi_config(struct pcmcia_device *link) | |||
780 | for (i = j = 0; j < 4; j++) { | 755 | for (i = j = 0; j < 4; j++) { |
781 | link->io.BasePort2 = com[j]; | 756 | link->io.BasePort2 = com[j]; |
782 | i = pcmcia_request_io(link, &link->io); | 757 | i = pcmcia_request_io(link, &link->io); |
783 | if (i == CS_SUCCESS) break; | 758 | if (i == 0) |
759 | break; | ||
784 | } | 760 | } |
785 | if (i != CS_SUCCESS) { | 761 | if (i != 0) { |
786 | /* Fallback: turn off hard decode */ | 762 | /* Fallback: turn off hard decode */ |
787 | link->conf.ConfigIndex = 0x03; | 763 | link->conf.ConfigIndex = 0x03; |
788 | link->io.NumPorts2 = 0; | 764 | link->io.NumPorts2 = 0; |
@@ -815,13 +791,13 @@ static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) | |||
815 | /* Read the station address from tuple 0x90, subtuple 0x04 */ | 791 | /* Read the station address from tuple 0x90, subtuple 0x04 */ |
816 | tuple->DesiredTuple = 0x90; | 792 | tuple->DesiredTuple = 0x90; |
817 | i = pcmcia_get_first_tuple(link, tuple); | 793 | i = pcmcia_get_first_tuple(link, tuple); |
818 | while (i == CS_SUCCESS) { | 794 | while (i == 0) { |
819 | i = pcmcia_get_tuple_data(link, tuple); | 795 | i = pcmcia_get_tuple_data(link, tuple); |
820 | if ((i != CS_SUCCESS) || (buf[0] == 0x04)) | 796 | if ((i != 0) || (buf[0] == 0x04)) |
821 | break; | 797 | break; |
822 | i = pcmcia_get_next_tuple(link, tuple); | 798 | i = pcmcia_get_next_tuple(link, tuple); |
823 | } | 799 | } |
824 | if (i != CS_SUCCESS) { | 800 | if (i != 0) { |
825 | rc = -1; | 801 | rc = -1; |
826 | goto free_cfg_mem; | 802 | goto free_cfg_mem; |
827 | } | 803 | } |
@@ -959,8 +935,11 @@ static int check_sig(struct pcmcia_device *link) | |||
959 | 935 | ||
960 | ======================================================================*/ | 936 | ======================================================================*/ |
961 | 937 | ||
962 | #define CS_EXIT_TEST(ret, svc, label) \ | 938 | #define CS_EXIT_TEST(ret, svc, label) \ |
963 | if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; } | 939 | if (ret != 0) { \ |
940 | cs_error(link, svc, ret); \ | ||
941 | goto label; \ | ||
942 | } | ||
964 | 943 | ||
965 | static int smc91c92_config(struct pcmcia_device *link) | 944 | static int smc91c92_config(struct pcmcia_device *link) |
966 | { | 945 | { |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index c33a3d523566..e1fd585e7131 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -377,7 +377,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | |||
377 | 377 | ||
378 | if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 && | 378 | if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 && |
379 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) | 379 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) |
380 | err = pcmcia_parse_tuple(handle, tuple, parse); | 380 | err = pcmcia_parse_tuple(tuple, parse); |
381 | return err; | 381 | return err; |
382 | } | 382 | } |
383 | 383 | ||
@@ -388,7 +388,7 @@ next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | |||
388 | 388 | ||
389 | if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 && | 389 | if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 && |
390 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) | 390 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) |
391 | err = pcmcia_parse_tuple(handle, tuple, parse); | 391 | err = pcmcia_parse_tuple(tuple, parse); |
392 | return err; | 392 | return err; |
393 | } | 393 | } |
394 | 394 | ||
@@ -715,6 +715,47 @@ has_ce2_string(struct pcmcia_device * p_dev) | |||
715 | return 0; | 715 | return 0; |
716 | } | 716 | } |
717 | 717 | ||
718 | static int | ||
719 | xirc2ps_config_modem(struct pcmcia_device *p_dev, | ||
720 | cistpl_cftable_entry_t *cf, | ||
721 | cistpl_cftable_entry_t *dflt, | ||
722 | unsigned int vcc, | ||
723 | void *priv_data) | ||
724 | { | ||
725 | unsigned int ioaddr; | ||
726 | |||
727 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | ||
728 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | ||
729 | p_dev->io.BasePort2 = cf->io.win[0].base; | ||
730 | p_dev->io.BasePort1 = ioaddr; | ||
731 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
732 | return 0; | ||
733 | } | ||
734 | } | ||
735 | return -ENODEV; | ||
736 | } | ||
737 | |||
738 | static int | ||
739 | xirc2ps_config_check(struct pcmcia_device *p_dev, | ||
740 | cistpl_cftable_entry_t *cf, | ||
741 | cistpl_cftable_entry_t *dflt, | ||
742 | unsigned int vcc, | ||
743 | void *priv_data) | ||
744 | { | ||
745 | int *pass = priv_data; | ||
746 | |||
747 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | ||
748 | p_dev->io.BasePort2 = cf->io.win[0].base; | ||
749 | p_dev->io.BasePort1 = p_dev->io.BasePort2 | ||
750 | + (*pass ? (cf->index & 0x20 ? -24:8) | ||
751 | : (cf->index & 0x20 ? 8:-24)); | ||
752 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
753 | return 0; | ||
754 | } | ||
755 | return -ENODEV; | ||
756 | |||
757 | } | ||
758 | |||
718 | /**************** | 759 | /**************** |
719 | * xirc2ps_config() is scheduled to run after a CARD_INSERTION event | 760 | * xirc2ps_config() is scheduled to run after a CARD_INSERTION event |
720 | * is received, to configure the PCMCIA socket, and to make the | 761 | * is received, to configure the PCMCIA socket, and to make the |
@@ -725,13 +766,12 @@ xirc2ps_config(struct pcmcia_device * link) | |||
725 | { | 766 | { |
726 | struct net_device *dev = link->priv; | 767 | struct net_device *dev = link->priv; |
727 | local_info_t *local = netdev_priv(dev); | 768 | local_info_t *local = netdev_priv(dev); |
769 | unsigned int ioaddr; | ||
728 | tuple_t tuple; | 770 | tuple_t tuple; |
729 | cisparse_t parse; | 771 | cisparse_t parse; |
730 | unsigned int ioaddr; | ||
731 | int err, i; | 772 | int err, i; |
732 | u_char buf[64]; | 773 | u_char buf[64]; |
733 | cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data; | 774 | cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data; |
734 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
735 | DECLARE_MAC_BUF(mac); | 775 | DECLARE_MAC_BUF(mac); |
736 | 776 | ||
737 | local->dingo_ccr = NULL; | 777 | local->dingo_ccr = NULL; |
@@ -846,19 +886,8 @@ xirc2ps_config(struct pcmcia_device * link) | |||
846 | /* Take the Modem IO port from the CIS and scan for a free | 886 | /* Take the Modem IO port from the CIS and scan for a free |
847 | * Ethernet port */ | 887 | * Ethernet port */ |
848 | link->io.NumPorts1 = 16; /* no Mako stuff anymore */ | 888 | link->io.NumPorts1 = 16; /* no Mako stuff anymore */ |
849 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 889 | if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) |
850 | for (err = first_tuple(link, &tuple, &parse); !err; | 890 | goto port_found; |
851 | err = next_tuple(link, &tuple, &parse)) { | ||
852 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | ||
853 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | ||
854 | link->conf.ConfigIndex = cf->index ; | ||
855 | link->io.BasePort2 = cf->io.win[0].base; | ||
856 | link->io.BasePort1 = ioaddr; | ||
857 | if (!(err=pcmcia_request_io(link, &link->io))) | ||
858 | goto port_found; | ||
859 | } | ||
860 | } | ||
861 | } | ||
862 | } else { | 891 | } else { |
863 | link->io.NumPorts1 = 18; | 892 | link->io.NumPorts1 = 18; |
864 | /* We do 2 passes here: The first one uses the regular mapping and | 893 | /* We do 2 passes here: The first one uses the regular mapping and |
@@ -866,21 +895,9 @@ xirc2ps_config(struct pcmcia_device * link) | |||
866 | * mirrored every 32 bytes. Actually we use a mirrored port for | 895 | * mirrored every 32 bytes. Actually we use a mirrored port for |
867 | * the Mako if (on the first pass) the COR bit 5 is set. | 896 | * the Mako if (on the first pass) the COR bit 5 is set. |
868 | */ | 897 | */ |
869 | for (pass=0; pass < 2; pass++) { | 898 | for (pass=0; pass < 2; pass++) |
870 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 899 | if (!pcmcia_loop_config(link, xirc2ps_config_check, &pass)) |
871 | for (err = first_tuple(link, &tuple, &parse); !err; | ||
872 | err = next_tuple(link, &tuple, &parse)){ | ||
873 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ | ||
874 | link->conf.ConfigIndex = cf->index ; | ||
875 | link->io.BasePort2 = cf->io.win[0].base; | ||
876 | link->io.BasePort1 = link->io.BasePort2 | ||
877 | + (pass ? (cf->index & 0x20 ? -24:8) | ||
878 | : (cf->index & 0x20 ? 8:-24)); | ||
879 | if (!(err=pcmcia_request_io(link, &link->io))) | ||
880 | goto port_found; | 900 | goto port_found; |
881 | } | ||
882 | } | ||
883 | } | ||
884 | /* if special option: | 901 | /* if special option: |
885 | * try to configure as Ethernet only. | 902 | * try to configure as Ethernet only. |
886 | * .... */ | 903 | * .... */ |
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index fd72e427cb28..27696c20f4c2 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c | |||
@@ -206,126 +206,123 @@ 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 | static int airo_cs_config_check(struct pcmcia_device *p_dev, | ||
210 | cistpl_cftable_entry_t *cfg, | ||
211 | cistpl_cftable_entry_t *dflt, | ||
212 | unsigned int vcc, | ||
213 | void *priv_data) | ||
214 | { | ||
215 | win_req_t *req = priv_data; | ||
216 | |||
217 | if (cfg->index == 0) | ||
218 | return -ENODEV; | ||
219 | |||
220 | /* Does this card need audio output? */ | ||
221 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
222 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
223 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
224 | } | ||
225 | |||
226 | /* Use power settings for Vcc and Vpp if present */ | ||
227 | /* Note that the CIS values need to be rescaled */ | ||
228 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
229 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
230 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
231 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
232 | |||
233 | /* Do we need to allocate an interrupt? */ | ||
234 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
235 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
236 | |||
237 | /* IO window settings */ | ||
238 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
239 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
240 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
241 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
242 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
243 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
244 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
245 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
246 | p_dev->io.BasePort1 = io->win[0].base; | ||
247 | p_dev->io.NumPorts1 = io->win[0].len; | ||
248 | if (io->nwin > 1) { | ||
249 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
250 | p_dev->io.BasePort2 = io->win[1].base; | ||
251 | p_dev->io.NumPorts2 = io->win[1].len; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /* This reserves IO space but doesn't actually enable it */ | ||
256 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
257 | return -ENODEV; | ||
258 | |||
259 | /* | ||
260 | Now set up a common memory window, if needed. There is room | ||
261 | in the struct pcmcia_device structure for one memory window handle, | ||
262 | but if the base addresses need to be saved, or if multiple | ||
263 | windows are needed, the info should go in the private data | ||
264 | structure for this device. | ||
265 | |||
266 | Note that the memory window base is a physical address, and | ||
267 | needs to be mapped to virtual space with ioremap() before it | ||
268 | is used. | ||
269 | */ | ||
270 | if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { | ||
271 | cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; | ||
272 | memreq_t map; | ||
273 | req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | ||
274 | req->Base = mem->win[0].host_addr; | ||
275 | req->Size = mem->win[0].len; | ||
276 | req->AccessSpeed = 0; | ||
277 | if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) | ||
278 | return -ENODEV; | ||
279 | map.Page = 0; | ||
280 | map.CardOffset = mem->win[0].card_addr; | ||
281 | if (pcmcia_map_mem_page(p_dev->win, &map) != 0) | ||
282 | return -ENODEV; | ||
283 | } | ||
284 | /* If we got this far, we're cool! */ | ||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | |||
209 | static int airo_config(struct pcmcia_device *link) | 289 | static int airo_config(struct pcmcia_device *link) |
210 | { | 290 | { |
211 | tuple_t tuple; | ||
212 | cisparse_t parse; | ||
213 | local_info_t *dev; | 291 | local_info_t *dev; |
292 | win_req_t *req; | ||
214 | int last_fn, last_ret; | 293 | int last_fn, last_ret; |
215 | u_char buf[64]; | ||
216 | win_req_t req; | ||
217 | memreq_t map; | ||
218 | 294 | ||
219 | dev = link->priv; | 295 | dev = link->priv; |
220 | 296 | ||
221 | DEBUG(0, "airo_config(0x%p)\n", link); | 297 | DEBUG(0, "airo_config(0x%p)\n", link); |
222 | 298 | ||
299 | req = kzalloc(sizeof(win_req_t), GFP_KERNEL); | ||
300 | if (!req) | ||
301 | return -ENOMEM; | ||
302 | |||
303 | /* | ||
304 | * In this loop, we scan the CIS for configuration table | ||
305 | * entries, each of which describes a valid card | ||
306 | * configuration, including voltage, IO window, memory window, | ||
307 | * and interrupt settings. | ||
308 | * | ||
309 | * We make no assumptions about the card to be configured: we | ||
310 | * use just the information available in the CIS. In an ideal | ||
311 | * world, this would work for any PCMCIA card, but it requires | ||
312 | * a complete and accurate CIS. In practice, a driver usually | ||
313 | * "knows" most of these things without consulting the CIS, | ||
314 | * and most client drivers will only use the CIS to fill in | ||
315 | * implementation-defined details. | ||
316 | */ | ||
317 | last_ret = pcmcia_loop_config(link, airo_cs_config_check, req); | ||
318 | if (last_ret) | ||
319 | goto failed; | ||
320 | |||
223 | /* | 321 | /* |
224 | In this loop, we scan the CIS for configuration table entries, | 322 | Allocate an interrupt line. Note that this does not assign a |
225 | each of which describes a valid card configuration, including | 323 | handler to the interrupt, unless the 'Handler' member of the |
226 | voltage, IO window, memory window, and interrupt settings. | 324 | irq structure is initialized. |
227 | |||
228 | We make no assumptions about the card to be configured: we use | ||
229 | just the information available in the CIS. In an ideal world, | ||
230 | this would work for any PCMCIA card, but it requires a complete | ||
231 | and accurate CIS. In practice, a driver usually "knows" most of | ||
232 | these things without consulting the CIS, and most client drivers | ||
233 | will only use the CIS to fill in implementation-defined details. | ||
234 | */ | 325 | */ |
235 | tuple.Attributes = 0; | ||
236 | tuple.TupleData = buf; | ||
237 | tuple.TupleDataMax = sizeof(buf); | ||
238 | tuple.TupleOffset = 0; | ||
239 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
240 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
241 | while (1) { | ||
242 | cistpl_cftable_entry_t dflt = { 0 }; | ||
243 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
244 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
245 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
246 | goto next_entry; | ||
247 | |||
248 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
249 | if (cfg->index == 0) goto next_entry; | ||
250 | link->conf.ConfigIndex = cfg->index; | ||
251 | |||
252 | /* Does this card need audio output? */ | ||
253 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
254 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
255 | link->conf.Status = CCSR_AUDIO_ENA; | ||
256 | } | ||
257 | |||
258 | /* Use power settings for Vcc and Vpp if present */ | ||
259 | /* Note that the CIS values need to be rescaled */ | ||
260 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
261 | link->conf.Vpp = | ||
262 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
263 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
264 | link->conf.Vpp = | ||
265 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
266 | |||
267 | /* Do we need to allocate an interrupt? */ | ||
268 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
269 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
270 | |||
271 | /* IO window settings */ | ||
272 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
273 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
274 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
275 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
276 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
277 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
278 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
279 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
280 | link->io.BasePort1 = io->win[0].base; | ||
281 | link->io.NumPorts1 = io->win[0].len; | ||
282 | if (io->nwin > 1) { | ||
283 | link->io.Attributes2 = link->io.Attributes1; | ||
284 | link->io.BasePort2 = io->win[1].base; | ||
285 | link->io.NumPorts2 = io->win[1].len; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | /* This reserves IO space but doesn't actually enable it */ | ||
290 | if (pcmcia_request_io(link, &link->io) != 0) | ||
291 | goto next_entry; | ||
292 | |||
293 | /* | ||
294 | Now set up a common memory window, if needed. There is room | ||
295 | in the struct pcmcia_device structure for one memory window handle, | ||
296 | but if the base addresses need to be saved, or if multiple | ||
297 | windows are needed, the info should go in the private data | ||
298 | structure for this device. | ||
299 | |||
300 | Note that the memory window base is a physical address, and | ||
301 | needs to be mapped to virtual space with ioremap() before it | ||
302 | is used. | ||
303 | */ | ||
304 | if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { | ||
305 | cistpl_mem_t *mem = | ||
306 | (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; | ||
307 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | ||
308 | req.Base = mem->win[0].host_addr; | ||
309 | req.Size = mem->win[0].len; | ||
310 | req.AccessSpeed = 0; | ||
311 | if (pcmcia_request_window(&link, &req, &link->win) != 0) | ||
312 | goto next_entry; | ||
313 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; | ||
314 | if (pcmcia_map_mem_page(link->win, &map) != 0) | ||
315 | goto next_entry; | ||
316 | } | ||
317 | /* If we got this far, we're cool! */ | ||
318 | break; | ||
319 | |||
320 | next_entry: | ||
321 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
322 | } | ||
323 | |||
324 | /* | ||
325 | Allocate an interrupt line. Note that this does not assign a | ||
326 | handler to the interrupt, unless the 'Handler' member of the | ||
327 | irq structure is initialized. | ||
328 | */ | ||
329 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 326 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
330 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 327 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
331 | 328 | ||
@@ -362,14 +359,17 @@ static int airo_config(struct pcmcia_device *link) | |||
362 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | 359 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, |
363 | link->io.BasePort2+link->io.NumPorts2-1); | 360 | link->io.BasePort2+link->io.NumPorts2-1); |
364 | if (link->win) | 361 | if (link->win) |
365 | printk(", mem 0x%06lx-0x%06lx", req.Base, | 362 | printk(", mem 0x%06lx-0x%06lx", req->Base, |
366 | req.Base+req.Size-1); | 363 | req->Base+req->Size-1); |
367 | printk("\n"); | 364 | printk("\n"); |
365 | kfree(req); | ||
368 | return 0; | 366 | return 0; |
369 | 367 | ||
370 | cs_failed: | 368 | cs_failed: |
371 | cs_error(link, last_fn, last_ret); | 369 | cs_error(link, last_fn, last_ret); |
370 | failed: | ||
372 | airo_release(link); | 371 | airo_release(link); |
372 | kfree(req); | ||
373 | return -ENODEV; | 373 | return -ENODEV; |
374 | } /* airo_config */ | 374 | } /* airo_config */ |
375 | 375 | ||
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index d2388e8d179a..77406245dc7b 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c | |||
@@ -224,13 +224,58 @@ static int card_present(void *arg) | |||
224 | return 0; | 224 | return 0; |
225 | } | 225 | } |
226 | 226 | ||
227 | static int atmel_config_check(struct pcmcia_device *p_dev, | ||
228 | cistpl_cftable_entry_t *cfg, | ||
229 | cistpl_cftable_entry_t *dflt, | ||
230 | unsigned int vcc, | ||
231 | void *priv_data) | ||
232 | { | ||
233 | if (cfg->index == 0) | ||
234 | return -ENODEV; | ||
235 | |||
236 | /* Does this card need audio output? */ | ||
237 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
238 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
239 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
240 | } | ||
241 | |||
242 | /* Use power settings for Vcc and Vpp if present */ | ||
243 | /* Note that the CIS values need to be rescaled */ | ||
244 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
245 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
246 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
247 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
248 | |||
249 | /* Do we need to allocate an interrupt? */ | ||
250 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
251 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
252 | |||
253 | /* IO window settings */ | ||
254 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
255 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
256 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
257 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
258 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
259 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
260 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
261 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
262 | p_dev->io.BasePort1 = io->win[0].base; | ||
263 | p_dev->io.NumPorts1 = io->win[0].len; | ||
264 | if (io->nwin > 1) { | ||
265 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
266 | p_dev->io.BasePort2 = io->win[1].base; | ||
267 | p_dev->io.NumPorts2 = io->win[1].len; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | /* This reserves IO space but doesn't actually enable it */ | ||
272 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
273 | } | ||
274 | |||
227 | static int atmel_config(struct pcmcia_device *link) | 275 | static int atmel_config(struct pcmcia_device *link) |
228 | { | 276 | { |
229 | tuple_t tuple; | ||
230 | cisparse_t parse; | ||
231 | local_info_t *dev; | 277 | local_info_t *dev; |
232 | int last_fn, last_ret; | 278 | int last_fn, last_ret; |
233 | u_char buf[64]; | ||
234 | struct pcmcia_device_id *did; | 279 | struct pcmcia_device_id *did; |
235 | 280 | ||
236 | dev = link->priv; | 281 | dev = link->priv; |
@@ -238,11 +283,6 @@ static int atmel_config(struct pcmcia_device *link) | |||
238 | 283 | ||
239 | DEBUG(0, "atmel_config(0x%p)\n", link); | 284 | DEBUG(0, "atmel_config(0x%p)\n", link); |
240 | 285 | ||
241 | tuple.Attributes = 0; | ||
242 | tuple.TupleData = buf; | ||
243 | tuple.TupleDataMax = sizeof(buf); | ||
244 | tuple.TupleOffset = 0; | ||
245 | |||
246 | /* | 286 | /* |
247 | In this loop, we scan the CIS for configuration table entries, | 287 | In this loop, we scan the CIS for configuration table entries, |
248 | each of which describes a valid card configuration, including | 288 | each of which describes a valid card configuration, including |
@@ -255,66 +295,8 @@ static int atmel_config(struct pcmcia_device *link) | |||
255 | these things without consulting the CIS, and most client drivers | 295 | these things without consulting the CIS, and most client drivers |
256 | will only use the CIS to fill in implementation-defined details. | 296 | will only use the CIS to fill in implementation-defined details. |
257 | */ | 297 | */ |
258 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 298 | if (pcmcia_loop_config(link, atmel_config_check, NULL)) |
259 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 299 | goto failed; |
260 | while (1) { | ||
261 | cistpl_cftable_entry_t dflt = { 0 }; | ||
262 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
263 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
264 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
265 | goto next_entry; | ||
266 | |||
267 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
268 | if (cfg->index == 0) goto next_entry; | ||
269 | link->conf.ConfigIndex = cfg->index; | ||
270 | |||
271 | /* Does this card need audio output? */ | ||
272 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
273 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
274 | link->conf.Status = CCSR_AUDIO_ENA; | ||
275 | } | ||
276 | |||
277 | /* Use power settings for Vcc and Vpp if present */ | ||
278 | /* Note that the CIS values need to be rescaled */ | ||
279 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
280 | link->conf.Vpp = | ||
281 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
282 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
283 | link->conf.Vpp = | ||
284 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
285 | |||
286 | /* Do we need to allocate an interrupt? */ | ||
287 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
288 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
289 | |||
290 | /* IO window settings */ | ||
291 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
292 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
293 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
294 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
295 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
296 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
297 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
298 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
299 | link->io.BasePort1 = io->win[0].base; | ||
300 | link->io.NumPorts1 = io->win[0].len; | ||
301 | if (io->nwin > 1) { | ||
302 | link->io.Attributes2 = link->io.Attributes1; | ||
303 | link->io.BasePort2 = io->win[1].base; | ||
304 | link->io.NumPorts2 = io->win[1].len; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | /* This reserves IO space but doesn't actually enable it */ | ||
309 | if (pcmcia_request_io(link, &link->io) != 0) | ||
310 | goto next_entry; | ||
311 | |||
312 | /* If we got this far, we're cool! */ | ||
313 | break; | ||
314 | |||
315 | next_entry: | ||
316 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
317 | } | ||
318 | 300 | ||
319 | /* | 301 | /* |
320 | Allocate an interrupt line. Note that this does not assign a | 302 | Allocate an interrupt line. Note that this does not assign a |
@@ -360,6 +342,7 @@ static int atmel_config(struct pcmcia_device *link) | |||
360 | 342 | ||
361 | cs_failed: | 343 | cs_failed: |
362 | cs_error(link, last_fn, last_ret); | 344 | cs_error(link, last_fn, last_ret); |
345 | failed: | ||
363 | atmel_release(link); | 346 | atmel_release(link); |
364 | return -ENODEV; | 347 | return -ENODEV; |
365 | } | 348 | } |
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c index b8aa16307f79..3cfc30307a27 100644 --- a/drivers/net/wireless/b43/pcmcia.c +++ b/drivers/net/wireless/b43/pcmcia.c | |||
@@ -82,13 +82,13 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
82 | tuple.TupleOffset = 0; | 82 | tuple.TupleOffset = 0; |
83 | 83 | ||
84 | res = pcmcia_get_first_tuple(dev, &tuple); | 84 | res = pcmcia_get_first_tuple(dev, &tuple); |
85 | if (res != CS_SUCCESS) | 85 | if (res != 0) |
86 | goto err_kfree_ssb; | 86 | goto err_kfree_ssb; |
87 | res = pcmcia_get_tuple_data(dev, &tuple); | 87 | res = pcmcia_get_tuple_data(dev, &tuple); |
88 | if (res != CS_SUCCESS) | 88 | if (res != 0) |
89 | goto err_kfree_ssb; | 89 | goto err_kfree_ssb; |
90 | res = pcmcia_parse_tuple(dev, &tuple, &parse); | 90 | res = pcmcia_parse_tuple(&tuple, &parse); |
91 | if (res != CS_SUCCESS) | 91 | if (res != 0) |
92 | goto err_kfree_ssb; | 92 | goto err_kfree_ssb; |
93 | 93 | ||
94 | dev->conf.ConfigBase = parse.config.base; | 94 | dev->conf.ConfigBase = parse.config.base; |
@@ -107,13 +107,13 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
107 | win.Size = SSB_CORE_SIZE; | 107 | win.Size = SSB_CORE_SIZE; |
108 | win.AccessSpeed = 250; | 108 | win.AccessSpeed = 250; |
109 | res = pcmcia_request_window(&dev, &win, &dev->win); | 109 | res = pcmcia_request_window(&dev, &win, &dev->win); |
110 | if (res != CS_SUCCESS) | 110 | if (res != 0) |
111 | goto err_kfree_ssb; | 111 | goto err_kfree_ssb; |
112 | 112 | ||
113 | mem.CardOffset = 0; | 113 | mem.CardOffset = 0; |
114 | mem.Page = 0; | 114 | mem.Page = 0; |
115 | res = pcmcia_map_mem_page(dev->win, &mem); | 115 | res = pcmcia_map_mem_page(dev->win, &mem); |
116 | if (res != CS_SUCCESS) | 116 | if (res != 0) |
117 | goto err_disable; | 117 | goto err_disable; |
118 | 118 | ||
119 | dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; | 119 | dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
@@ -121,11 +121,11 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
121 | dev->irq.Handler = NULL; /* The handler is registered later. */ | 121 | dev->irq.Handler = NULL; /* The handler is registered later. */ |
122 | dev->irq.Instance = NULL; | 122 | dev->irq.Instance = NULL; |
123 | res = pcmcia_request_irq(dev, &dev->irq); | 123 | res = pcmcia_request_irq(dev, &dev->irq); |
124 | if (res != CS_SUCCESS) | 124 | if (res != 0) |
125 | goto err_disable; | 125 | goto err_disable; |
126 | 126 | ||
127 | res = pcmcia_request_configuration(dev, &dev->conf); | 127 | res = pcmcia_request_configuration(dev, &dev->conf); |
128 | if (res != CS_SUCCESS) | 128 | if (res != 0) |
129 | goto err_disable; | 129 | goto err_disable; |
130 | 130 | ||
131 | err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); | 131 | err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 3b4e55cf33cd..633740277352 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -234,7 +234,7 @@ static void sandisk_set_iobase(local_info_t *local) | |||
234 | reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; | 234 | reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; |
235 | res = pcmcia_access_configuration_register(hw_priv->link, | 235 | res = pcmcia_access_configuration_register(hw_priv->link, |
236 | ®); | 236 | ®); |
237 | if (res != CS_SUCCESS) { | 237 | if (res != 0) { |
238 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" | 238 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" |
239 | " res=%d\n", res); | 239 | " res=%d\n", res); |
240 | } | 240 | } |
@@ -246,7 +246,7 @@ static void sandisk_set_iobase(local_info_t *local) | |||
246 | reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; | 246 | reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; |
247 | res = pcmcia_access_configuration_register(hw_priv->link, | 247 | res = pcmcia_access_configuration_register(hw_priv->link, |
248 | ®); | 248 | ®); |
249 | if (res != CS_SUCCESS) { | 249 | if (res != 0) { |
250 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" | 250 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" |
251 | " res=%d\n", res); | 251 | " res=%d\n", res); |
252 | } | 252 | } |
@@ -305,7 +305,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
305 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; | 305 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; |
306 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || | 306 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || |
307 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || | 307 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || |
308 | pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || | 308 | pcmcia_parse_tuple(&tuple, parse) || |
309 | parse->longlink_mfc.nfn < 2) { | 309 | parse->longlink_mfc.nfn < 2) { |
310 | /* No multi-function links found */ | 310 | /* No multi-function links found */ |
311 | ret = -ENODEV; | 311 | ret = -ENODEV; |
@@ -322,7 +322,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
322 | reg.Value = COR_SOFT_RESET; | 322 | reg.Value = COR_SOFT_RESET; |
323 | res = pcmcia_access_configuration_register(hw_priv->link, | 323 | res = pcmcia_access_configuration_register(hw_priv->link, |
324 | ®); | 324 | ®); |
325 | if (res != CS_SUCCESS) { | 325 | if (res != 0) { |
326 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", | 326 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
327 | dev->name, res); | 327 | dev->name, res); |
328 | goto done; | 328 | goto done; |
@@ -339,7 +339,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
339 | reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; | 339 | reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; |
340 | res = pcmcia_access_configuration_register(hw_priv->link, | 340 | res = pcmcia_access_configuration_register(hw_priv->link, |
341 | ®); | 341 | ®); |
342 | if (res != CS_SUCCESS) { | 342 | if (res != 0) { |
343 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", | 343 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
344 | dev->name, res); | 344 | dev->name, res); |
345 | goto done; | 345 | goto done; |
@@ -374,7 +374,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
374 | reg.Value = 0; | 374 | reg.Value = 0; |
375 | res = pcmcia_access_configuration_register(hw_priv->link, | 375 | res = pcmcia_access_configuration_register(hw_priv->link, |
376 | ®); | 376 | ®); |
377 | if (res != CS_SUCCESS) { | 377 | if (res != 0) { |
378 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", | 378 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", |
379 | res); | 379 | res); |
380 | return; | 380 | return; |
@@ -386,7 +386,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
386 | reg.Value |= COR_SOFT_RESET; | 386 | reg.Value |= COR_SOFT_RESET; |
387 | res = pcmcia_access_configuration_register(hw_priv->link, | 387 | res = pcmcia_access_configuration_register(hw_priv->link, |
388 | ®); | 388 | ®); |
389 | if (res != CS_SUCCESS) { | 389 | if (res != 0) { |
390 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", | 390 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", |
391 | res); | 391 | res); |
392 | return; | 392 | return; |
@@ -399,7 +399,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
399 | reg.Value |= COR_IREQ_ENA; | 399 | reg.Value |= COR_IREQ_ENA; |
400 | res = pcmcia_access_configuration_register(hw_priv->link, | 400 | res = pcmcia_access_configuration_register(hw_priv->link, |
401 | ®); | 401 | ®); |
402 | if (res != CS_SUCCESS) { | 402 | if (res != 0) { |
403 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", | 403 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", |
404 | res); | 404 | res); |
405 | return; | 405 | return; |
@@ -433,7 +433,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
433 | reg.Value = 0; | 433 | reg.Value = 0; |
434 | res = pcmcia_access_configuration_register(hw_priv->link, | 434 | res = pcmcia_access_configuration_register(hw_priv->link, |
435 | ®); | 435 | ®); |
436 | if (res != CS_SUCCESS) { | 436 | if (res != 0) { |
437 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " | 437 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " |
438 | "(%d)\n", res); | 438 | "(%d)\n", res); |
439 | return; | 439 | return; |
@@ -446,7 +446,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
446 | reg.Value |= COR_SOFT_RESET; | 446 | reg.Value |= COR_SOFT_RESET; |
447 | res = pcmcia_access_configuration_register(hw_priv->link, | 447 | res = pcmcia_access_configuration_register(hw_priv->link, |
448 | ®); | 448 | ®); |
449 | if (res != CS_SUCCESS) { | 449 | if (res != 0) { |
450 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " | 450 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " |
451 | "(%d)\n", res); | 451 | "(%d)\n", res); |
452 | return; | 452 | return; |
@@ -460,7 +460,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
460 | reg.Offset = CISREG_CCSR; | 460 | reg.Offset = CISREG_CCSR; |
461 | res = pcmcia_access_configuration_register(hw_priv->link, | 461 | res = pcmcia_access_configuration_register(hw_priv->link, |
462 | ®); | 462 | ®); |
463 | if (res != CS_SUCCESS) { | 463 | if (res != 0) { |
464 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " | 464 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " |
465 | "(%d)\n", res); | 465 | "(%d)\n", res); |
466 | return; | 466 | return; |
@@ -472,7 +472,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
472 | reg.Value = old_cor & ~COR_SOFT_RESET; | 472 | reg.Value = old_cor & ~COR_SOFT_RESET; |
473 | res = pcmcia_access_configuration_register(hw_priv->link, | 473 | res = pcmcia_access_configuration_register(hw_priv->link, |
474 | ®); | 474 | ®); |
475 | if (res != CS_SUCCESS) { | 475 | if (res != 0) { |
476 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " | 476 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " |
477 | "(%d)\n", res); | 477 | "(%d)\n", res); |
478 | return; | 478 | return; |
@@ -532,145 +532,118 @@ static void prism2_detach(struct pcmcia_device *link) | |||
532 | #define CS_CHECK(fn, ret) \ | 532 | #define CS_CHECK(fn, ret) \ |
533 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 533 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
534 | 534 | ||
535 | #define CFG_CHECK2(fn, retf) \ | ||
536 | do { int _ret = (retf); \ | ||
537 | if (_ret != 0) { \ | ||
538 | PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", _ret); \ | ||
539 | cs_error(link, fn, _ret); \ | ||
540 | goto next_entry; \ | ||
541 | } \ | ||
542 | } while (0) | ||
543 | |||
544 | 535 | ||
545 | /* run after a CARD_INSERTION event is received to configure the PCMCIA | 536 | /* run after a CARD_INSERTION event is received to configure the PCMCIA |
546 | * socket and make the device available to the system */ | 537 | * socket and make the device available to the system */ |
538 | |||
539 | static int prism2_config_check(struct pcmcia_device *p_dev, | ||
540 | cistpl_cftable_entry_t *cfg, | ||
541 | cistpl_cftable_entry_t *dflt, | ||
542 | unsigned int vcc, | ||
543 | void *priv_data) | ||
544 | { | ||
545 | if (cfg->index == 0) | ||
546 | return -ENODEV; | ||
547 | |||
548 | PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " | ||
549 | "(default 0x%02X)\n", cfg->index, dflt->index); | ||
550 | |||
551 | /* Does this card need audio output? */ | ||
552 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
553 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
554 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
555 | } | ||
556 | |||
557 | /* Use power settings for Vcc and Vpp if present */ | ||
558 | /* Note that the CIS values need to be rescaled */ | ||
559 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
560 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / | ||
561 | 10000 && !ignore_cis_vcc) { | ||
562 | PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" | ||
563 | " this entry\n"); | ||
564 | return -ENODEV; | ||
565 | } | ||
566 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
567 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / | ||
568 | 10000 && !ignore_cis_vcc) { | ||
569 | PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " | ||
570 | "- skipping this entry\n"); | ||
571 | return -ENODEV; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
576 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
577 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
578 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
579 | |||
580 | /* Do we need to allocate an interrupt? */ | ||
581 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
582 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
583 | else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) { | ||
584 | /* At least Compaq WL200 does not have IRQInfo1 set, | ||
585 | * but it does not work without interrupts.. */ | ||
586 | printk(KERN_WARNING "Config has no IRQ info, but trying to " | ||
587 | "enable IRQ anyway..\n"); | ||
588 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
589 | } | ||
590 | |||
591 | /* IO window settings */ | ||
592 | PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " | ||
593 | "dflt->io.nwin=%d\n", | ||
594 | cfg->io.nwin, dflt->io.nwin); | ||
595 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
596 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
597 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
598 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
599 | PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " | ||
600 | "io.base=0x%04x, len=%d\n", io->flags, | ||
601 | io->win[0].base, io->win[0].len); | ||
602 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
603 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
604 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
605 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
606 | p_dev->io.IOAddrLines = io->flags & | ||
607 | CISTPL_IO_LINES_MASK; | ||
608 | p_dev->io.BasePort1 = io->win[0].base; | ||
609 | p_dev->io.NumPorts1 = io->win[0].len; | ||
610 | if (io->nwin > 1) { | ||
611 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
612 | p_dev->io.BasePort2 = io->win[1].base; | ||
613 | p_dev->io.NumPorts2 = io->win[1].len; | ||
614 | } | ||
615 | } | ||
616 | |||
617 | /* This reserves IO space but doesn't actually enable it */ | ||
618 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
619 | } | ||
620 | |||
547 | static int prism2_config(struct pcmcia_device *link) | 621 | static int prism2_config(struct pcmcia_device *link) |
548 | { | 622 | { |
549 | struct net_device *dev; | 623 | struct net_device *dev; |
550 | struct hostap_interface *iface; | 624 | struct hostap_interface *iface; |
551 | local_info_t *local; | 625 | local_info_t *local; |
552 | int ret = 1; | 626 | int ret = 1; |
553 | tuple_t tuple; | ||
554 | cisparse_t *parse; | ||
555 | int last_fn, last_ret; | 627 | int last_fn, last_ret; |
556 | u_char buf[64]; | ||
557 | config_info_t conf; | ||
558 | cistpl_cftable_entry_t dflt = { 0 }; | ||
559 | struct hostap_cs_priv *hw_priv; | 628 | struct hostap_cs_priv *hw_priv; |
560 | 629 | ||
561 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); | 630 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); |
562 | 631 | ||
563 | parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); | ||
564 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); | 632 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); |
565 | if (parse == NULL || hw_priv == NULL) { | 633 | if (hw_priv == NULL) { |
566 | ret = -ENOMEM; | 634 | ret = -ENOMEM; |
567 | goto failed; | 635 | goto failed; |
568 | } | 636 | } |
569 | 637 | ||
570 | tuple.Attributes = 0; | ||
571 | tuple.TupleData = buf; | ||
572 | tuple.TupleDataMax = sizeof(buf); | ||
573 | tuple.TupleOffset = 0; | ||
574 | |||
575 | CS_CHECK(GetConfigurationInfo, | ||
576 | pcmcia_get_configuration_info(link, &conf)); | ||
577 | |||
578 | /* Look for an appropriate configuration table entry in the CIS */ | 638 | /* Look for an appropriate configuration table entry in the CIS */ |
579 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 639 | last_ret = pcmcia_loop_config(link, prism2_config_check, NULL); |
580 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 640 | if (last_ret) { |
581 | for (;;) { | 641 | if (!ignore_cis_vcc) |
582 | cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); | 642 | printk(KERN_ERR "GetNextTuple(): No matching " |
583 | CFG_CHECK2(GetTupleData, | 643 | "CIS configuration. Maybe you need the " |
584 | pcmcia_get_tuple_data(link, &tuple)); | 644 | "ignore_cis_vcc=1 parameter.\n"); |
585 | CFG_CHECK2(ParseTuple, | 645 | cs_error(link, RequestIO, last_ret); |
586 | pcmcia_parse_tuple(link, &tuple, parse)); | 646 | goto failed; |
587 | |||
588 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
589 | dflt = *cfg; | ||
590 | if (cfg->index == 0) | ||
591 | goto next_entry; | ||
592 | link->conf.ConfigIndex = cfg->index; | ||
593 | PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " | ||
594 | "(default 0x%02X)\n", cfg->index, dflt.index); | ||
595 | |||
596 | /* Does this card need audio output? */ | ||
597 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
598 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
599 | link->conf.Status = CCSR_AUDIO_ENA; | ||
600 | } | ||
601 | |||
602 | /* Use power settings for Vcc and Vpp if present */ | ||
603 | /* Note that the CIS values need to be rescaled */ | ||
604 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
605 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / | ||
606 | 10000 && !ignore_cis_vcc) { | ||
607 | PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" | ||
608 | " this entry\n"); | ||
609 | goto next_entry; | ||
610 | } | ||
611 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
612 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / | ||
613 | 10000 && !ignore_cis_vcc) { | ||
614 | PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " | ||
615 | "- skipping this entry\n"); | ||
616 | goto next_entry; | ||
617 | } | ||
618 | } | ||
619 | |||
620 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
621 | link->conf.Vpp = | ||
622 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
623 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
624 | link->conf.Vpp = | ||
625 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
626 | |||
627 | /* Do we need to allocate an interrupt? */ | ||
628 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
629 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
630 | else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) { | ||
631 | /* At least Compaq WL200 does not have IRQInfo1 set, | ||
632 | * but it does not work without interrupts.. */ | ||
633 | printk("Config has no IRQ info, but trying to enable " | ||
634 | "IRQ anyway..\n"); | ||
635 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
636 | } | ||
637 | |||
638 | /* IO window settings */ | ||
639 | PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " | ||
640 | "dflt.io.nwin=%d\n", | ||
641 | cfg->io.nwin, dflt.io.nwin); | ||
642 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
643 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
644 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
645 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
646 | PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " | ||
647 | "io.base=0x%04x, len=%d\n", io->flags, | ||
648 | io->win[0].base, io->win[0].len); | ||
649 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
650 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
651 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
652 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
653 | link->io.IOAddrLines = io->flags & | ||
654 | CISTPL_IO_LINES_MASK; | ||
655 | link->io.BasePort1 = io->win[0].base; | ||
656 | link->io.NumPorts1 = io->win[0].len; | ||
657 | if (io->nwin > 1) { | ||
658 | link->io.Attributes2 = link->io.Attributes1; | ||
659 | link->io.BasePort2 = io->win[1].base; | ||
660 | link->io.NumPorts2 = io->win[1].len; | ||
661 | } | ||
662 | } | ||
663 | |||
664 | /* This reserves IO space but doesn't actually enable it */ | ||
665 | CFG_CHECK2(RequestIO, | ||
666 | pcmcia_request_io(link, &link->io)); | ||
667 | |||
668 | /* This configuration table entry is OK */ | ||
669 | break; | ||
670 | |||
671 | next_entry: | ||
672 | CS_CHECK(GetNextTuple, | ||
673 | pcmcia_get_next_tuple(link, &tuple)); | ||
674 | } | 647 | } |
675 | 648 | ||
676 | /* Need to allocate net_device before requesting IRQ handler */ | 649 | /* Need to allocate net_device before requesting IRQ handler */ |
@@ -738,14 +711,12 @@ static int prism2_config(struct pcmcia_device *link) | |||
738 | if (ret == 0 && local->ddev) | 711 | if (ret == 0 && local->ddev) |
739 | strcpy(hw_priv->node.dev_name, local->ddev->name); | 712 | strcpy(hw_priv->node.dev_name, local->ddev->name); |
740 | } | 713 | } |
741 | kfree(parse); | ||
742 | return ret; | 714 | return ret; |
743 | 715 | ||
744 | cs_failed: | 716 | cs_failed: |
745 | cs_error(link, last_fn, last_ret); | 717 | cs_error(link, last_fn, last_ret); |
746 | 718 | ||
747 | failed: | 719 | failed: |
748 | kfree(parse); | ||
749 | kfree(hw_priv); | 720 | kfree(hw_priv); |
750 | prism2_release((u_long)link); | 721 | prism2_release((u_long)link); |
751 | return ret; | 722 | return ret; |
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index e3505c110af6..842a08d1f106 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c | |||
@@ -791,7 +791,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev) | |||
791 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 791 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
792 | if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || | 792 | if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || |
793 | (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || | 793 | (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || |
794 | (ret = pcmcia_parse_tuple(p_dev, &tuple, &parse)) != 0) | 794 | (ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) |
795 | { | 795 | { |
796 | lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); | 796 | lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); |
797 | goto out1; | 797 | goto out1; |
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 25bae7933aa5..a670f36b5f3f 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c | |||
@@ -749,9 +749,10 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) { | |||
749 | for (i = j = 0x0; j < 0x400; j += 0x20) { | 749 | for (i = j = 0x0; j < 0x400; j += 0x20) { |
750 | link->io.BasePort1 = j ^ 0x300; | 750 | link->io.BasePort1 = j ^ 0x300; |
751 | i = pcmcia_request_io(link, &link->io); | 751 | i = pcmcia_request_io(link, &link->io); |
752 | if (i == CS_SUCCESS) break; | 752 | if (i == 0) |
753 | break; | ||
753 | } | 754 | } |
754 | if (i != CS_SUCCESS) { | 755 | if (i != 0) { |
755 | cs_error(link, RequestIO, i); | 756 | cs_error(link, RequestIO, i); |
756 | goto failed; | 757 | goto failed; |
757 | } | 758 | } |
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 9eaa252c2430..e585684e59a0 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c | |||
@@ -80,7 +80,7 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) | |||
80 | /* We need atomic ops here, because we're not holding the lock */ | 80 | /* We need atomic ops here, because we're not holding the lock */ |
81 | set_bit(0, &card->hard_reset_in_progress); | 81 | set_bit(0, &card->hard_reset_in_progress); |
82 | 82 | ||
83 | err = pcmcia_reset_card(link, NULL); | 83 | err = pcmcia_reset_card(link->socket); |
84 | if (err) | 84 | if (err) |
85 | return err; | 85 | return err; |
86 | 86 | ||
@@ -165,6 +165,70 @@ static void orinoco_cs_detach(struct pcmcia_device *link) | |||
165 | last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ | 165 | last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ |
166 | } while (0) | 166 | } while (0) |
167 | 167 | ||
168 | static int orinoco_cs_config_check(struct pcmcia_device *p_dev, | ||
169 | cistpl_cftable_entry_t *cfg, | ||
170 | cistpl_cftable_entry_t *dflt, | ||
171 | unsigned int vcc, | ||
172 | void *priv_data) | ||
173 | { | ||
174 | if (cfg->index == 0) | ||
175 | goto next_entry; | ||
176 | |||
177 | /* Use power settings for Vcc and Vpp if present */ | ||
178 | /* Note that the CIS values need to be rescaled */ | ||
179 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
180 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
181 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
182 | if (!ignore_cis_vcc) | ||
183 | goto next_entry; | ||
184 | } | ||
185 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
186 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
187 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
188 | if (!ignore_cis_vcc) | ||
189 | goto next_entry; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
194 | p_dev->conf.Vpp = | ||
195 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
196 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
197 | p_dev->conf.Vpp = | ||
198 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
199 | |||
200 | /* Do we need to allocate an interrupt? */ | ||
201 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
202 | |||
203 | /* IO window settings */ | ||
204 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
205 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
206 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
207 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
208 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
209 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
210 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
211 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
212 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
213 | p_dev->io.BasePort1 = io->win[0].base; | ||
214 | p_dev->io.NumPorts1 = io->win[0].len; | ||
215 | if (io->nwin > 1) { | ||
216 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
217 | p_dev->io.BasePort2 = io->win[1].base; | ||
218 | p_dev->io.NumPorts2 = io->win[1].len; | ||
219 | } | ||
220 | |||
221 | /* This reserves IO space but doesn't actually enable it */ | ||
222 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
223 | goto next_entry; | ||
224 | } | ||
225 | return 0; | ||
226 | |||
227 | next_entry: | ||
228 | pcmcia_disable_device(p_dev); | ||
229 | return -ENODEV; | ||
230 | }; | ||
231 | |||
168 | static int | 232 | static int |
169 | orinoco_cs_config(struct pcmcia_device *link) | 233 | orinoco_cs_config(struct pcmcia_device *link) |
170 | { | 234 | { |
@@ -173,16 +237,8 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
173 | struct orinoco_pccard *card = priv->card; | 237 | struct orinoco_pccard *card = priv->card; |
174 | hermes_t *hw = &priv->hw; | 238 | hermes_t *hw = &priv->hw; |
175 | int last_fn, last_ret; | 239 | int last_fn, last_ret; |
176 | u_char buf[64]; | ||
177 | config_info_t conf; | ||
178 | tuple_t tuple; | ||
179 | cisparse_t parse; | ||
180 | void __iomem *mem; | 240 | void __iomem *mem; |
181 | 241 | ||
182 | /* Look up the current Vcc */ | ||
183 | CS_CHECK(GetConfigurationInfo, | ||
184 | pcmcia_get_configuration_info(link, &conf)); | ||
185 | |||
186 | /* | 242 | /* |
187 | * In this loop, we scan the CIS for configuration table | 243 | * In this loop, we scan the CIS for configuration table |
188 | * entries, each of which describes a valid card | 244 | * entries, each of which describes a valid card |
@@ -197,94 +253,14 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
197 | * and most client drivers will only use the CIS to fill in | 253 | * and most client drivers will only use the CIS to fill in |
198 | * implementation-defined details. | 254 | * implementation-defined details. |
199 | */ | 255 | */ |
200 | tuple.Attributes = 0; | 256 | last_ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); |
201 | tuple.TupleData = buf; | 257 | if (last_ret) { |
202 | tuple.TupleDataMax = sizeof(buf); | 258 | if (!ignore_cis_vcc) |
203 | tuple.TupleOffset = 0; | ||
204 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
205 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
206 | while (1) { | ||
207 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
208 | cistpl_cftable_entry_t dflt = { .index = 0 }; | ||
209 | |||
210 | if ( (pcmcia_get_tuple_data(link, &tuple) != 0) | ||
211 | || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) | ||
212 | goto next_entry; | ||
213 | |||
214 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
215 | dflt = *cfg; | ||
216 | if (cfg->index == 0) | ||
217 | goto next_entry; | ||
218 | link->conf.ConfigIndex = cfg->index; | ||
219 | |||
220 | /* Use power settings for Vcc and Vpp if present */ | ||
221 | /* Note that the CIS values need to be rescaled */ | ||
222 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
223 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
224 | DEBUG(2, "orinoco_cs_config: Vcc mismatch (conf.Vcc = %d, cfg CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
225 | if (!ignore_cis_vcc) | ||
226 | goto next_entry; | ||
227 | } | ||
228 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
229 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
230 | DEBUG(2, "orinoco_cs_config: Vcc mismatch (conf.Vcc = %d, dflt CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
231 | if(!ignore_cis_vcc) | ||
232 | goto next_entry; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
237 | link->conf.Vpp = | ||
238 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
239 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
240 | link->conf.Vpp = | ||
241 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
242 | |||
243 | /* Do we need to allocate an interrupt? */ | ||
244 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
245 | |||
246 | /* IO window settings */ | ||
247 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
248 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
249 | cistpl_io_t *io = | ||
250 | (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
251 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
252 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
253 | link->io.Attributes1 = | ||
254 | IO_DATA_PATH_WIDTH_16; | ||
255 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
256 | link->io.Attributes1 = | ||
257 | IO_DATA_PATH_WIDTH_8; | ||
258 | link->io.IOAddrLines = | ||
259 | io->flags & CISTPL_IO_LINES_MASK; | ||
260 | link->io.BasePort1 = io->win[0].base; | ||
261 | link->io.NumPorts1 = io->win[0].len; | ||
262 | if (io->nwin > 1) { | ||
263 | link->io.Attributes2 = | ||
264 | link->io.Attributes1; | ||
265 | link->io.BasePort2 = io->win[1].base; | ||
266 | link->io.NumPorts2 = io->win[1].len; | ||
267 | } | ||
268 | |||
269 | /* This reserves IO space but doesn't actually enable it */ | ||
270 | if (pcmcia_request_io(link, &link->io) != 0) | ||
271 | goto next_entry; | ||
272 | } | ||
273 | |||
274 | |||
275 | /* If we got this far, we're cool! */ | ||
276 | |||
277 | break; | ||
278 | |||
279 | next_entry: | ||
280 | pcmcia_disable_device(link); | ||
281 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
282 | if (last_ret == CS_NO_MORE_ITEMS) { | ||
283 | printk(KERN_ERR PFX "GetNextTuple(): No matching " | 259 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
284 | "CIS configuration. Maybe you need the " | 260 | "CIS configuration. Maybe you need the " |
285 | "ignore_cis_vcc=1 parameter.\n"); | 261 | "ignore_cis_vcc=1 parameter.\n"); |
286 | goto cs_failed; | 262 | cs_error(link, RequestIO, last_ret); |
287 | } | 263 | goto failed; |
288 | } | 264 | } |
289 | 265 | ||
290 | /* | 266 | /* |
@@ -335,7 +311,6 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
335 | "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, | 311 | "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, |
336 | link->irq.AssignedIRQ, link->io.BasePort1, | 312 | link->irq.AssignedIRQ, link->io.BasePort1, |
337 | link->io.BasePort1 + link->io.NumPorts1 - 1); | 313 | link->io.BasePort1 + link->io.NumPorts1 - 1); |
338 | |||
339 | return 0; | 314 | return 0; |
340 | 315 | ||
341 | cs_failed: | 316 | cs_failed: |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 44da0d19b5c8..1404a5717520 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -798,9 +798,9 @@ static void ray_release(struct pcmcia_device *link) | |||
798 | iounmap(local->amem); | 798 | iounmap(local->amem); |
799 | /* Do bother checking to see if these succeed or not */ | 799 | /* Do bother checking to see if these succeed or not */ |
800 | i = pcmcia_release_window(local->amem_handle); | 800 | i = pcmcia_release_window(local->amem_handle); |
801 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); | 801 | if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); |
802 | i = pcmcia_release_window(local->rmem_handle); | 802 | i = pcmcia_release_window(local->rmem_handle); |
803 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); | 803 | if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); |
804 | pcmcia_disable_device(link); | 804 | pcmcia_disable_device(link); |
805 | 805 | ||
806 | DEBUG(2,"ray_release ending\n"); | 806 | DEBUG(2,"ray_release ending\n"); |
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 67b26d3c3cd5..b0c71c3be467 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c | |||
@@ -235,6 +235,70 @@ static void spectrum_cs_detach(struct pcmcia_device *link) | |||
235 | * device available to the system. | 235 | * device available to the system. |
236 | */ | 236 | */ |
237 | 237 | ||
238 | static int spectrum_cs_config_check(struct pcmcia_device *p_dev, | ||
239 | cistpl_cftable_entry_t *cfg, | ||
240 | cistpl_cftable_entry_t *dflt, | ||
241 | unsigned int vcc, | ||
242 | void *priv_data) | ||
243 | { | ||
244 | if (cfg->index == 0) | ||
245 | goto next_entry; | ||
246 | |||
247 | /* Use power settings for Vcc and Vpp if present */ | ||
248 | /* Note that the CIS values need to be rescaled */ | ||
249 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
250 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
251 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
252 | if (!ignore_cis_vcc) | ||
253 | goto next_entry; | ||
254 | } | ||
255 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
256 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
257 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
258 | if (!ignore_cis_vcc) | ||
259 | goto next_entry; | ||
260 | } | ||
261 | } | ||
262 | |||
263 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
264 | p_dev->conf.Vpp = | ||
265 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
266 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
267 | p_dev->conf.Vpp = | ||
268 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
269 | |||
270 | /* Do we need to allocate an interrupt? */ | ||
271 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
272 | |||
273 | /* IO window settings */ | ||
274 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
275 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
276 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
277 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
278 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
279 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
280 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
281 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
282 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
283 | p_dev->io.BasePort1 = io->win[0].base; | ||
284 | p_dev->io.NumPorts1 = io->win[0].len; | ||
285 | if (io->nwin > 1) { | ||
286 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
287 | p_dev->io.BasePort2 = io->win[1].base; | ||
288 | p_dev->io.NumPorts2 = io->win[1].len; | ||
289 | } | ||
290 | |||
291 | /* This reserves IO space but doesn't actually enable it */ | ||
292 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
293 | goto next_entry; | ||
294 | } | ||
295 | return 0; | ||
296 | |||
297 | next_entry: | ||
298 | pcmcia_disable_device(p_dev); | ||
299 | return -ENODEV; | ||
300 | }; | ||
301 | |||
238 | static int | 302 | static int |
239 | spectrum_cs_config(struct pcmcia_device *link) | 303 | spectrum_cs_config(struct pcmcia_device *link) |
240 | { | 304 | { |
@@ -243,16 +307,8 @@ spectrum_cs_config(struct pcmcia_device *link) | |||
243 | struct orinoco_pccard *card = priv->card; | 307 | struct orinoco_pccard *card = priv->card; |
244 | hermes_t *hw = &priv->hw; | 308 | hermes_t *hw = &priv->hw; |
245 | int last_fn, last_ret; | 309 | int last_fn, last_ret; |
246 | u_char buf[64]; | ||
247 | config_info_t conf; | ||
248 | tuple_t tuple; | ||
249 | cisparse_t parse; | ||
250 | void __iomem *mem; | 310 | void __iomem *mem; |
251 | 311 | ||
252 | /* Look up the current Vcc */ | ||
253 | CS_CHECK(GetConfigurationInfo, | ||
254 | pcmcia_get_configuration_info(link, &conf)); | ||
255 | |||
256 | /* | 312 | /* |
257 | * In this loop, we scan the CIS for configuration table | 313 | * In this loop, we scan the CIS for configuration table |
258 | * entries, each of which describes a valid card | 314 | * entries, each of which describes a valid card |
@@ -267,94 +323,14 @@ spectrum_cs_config(struct pcmcia_device *link) | |||
267 | * and most client drivers will only use the CIS to fill in | 323 | * and most client drivers will only use the CIS to fill in |
268 | * implementation-defined details. | 324 | * implementation-defined details. |
269 | */ | 325 | */ |
270 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 326 | last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); |
271 | tuple.Attributes = 0; | 327 | if (last_ret) { |
272 | tuple.TupleData = buf; | 328 | if (!ignore_cis_vcc) |
273 | tuple.TupleDataMax = sizeof(buf); | ||
274 | tuple.TupleOffset = 0; | ||
275 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
276 | while (1) { | ||
277 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
278 | cistpl_cftable_entry_t dflt = { .index = 0 }; | ||
279 | |||
280 | if ( (pcmcia_get_tuple_data(link, &tuple) != 0) | ||
281 | || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) | ||
282 | goto next_entry; | ||
283 | |||
284 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
285 | dflt = *cfg; | ||
286 | if (cfg->index == 0) | ||
287 | goto next_entry; | ||
288 | link->conf.ConfigIndex = cfg->index; | ||
289 | |||
290 | /* Use power settings for Vcc and Vpp if present */ | ||
291 | /* Note that the CIS values need to be rescaled */ | ||
292 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
293 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
294 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
295 | if (!ignore_cis_vcc) | ||
296 | goto next_entry; | ||
297 | } | ||
298 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
299 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
300 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
301 | if(!ignore_cis_vcc) | ||
302 | goto next_entry; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
307 | link->conf.Vpp = | ||
308 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
309 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
310 | link->conf.Vpp = | ||
311 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
312 | |||
313 | /* Do we need to allocate an interrupt? */ | ||
314 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
315 | |||
316 | /* IO window settings */ | ||
317 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
318 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
319 | cistpl_io_t *io = | ||
320 | (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
321 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
322 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
323 | link->io.Attributes1 = | ||
324 | IO_DATA_PATH_WIDTH_16; | ||
325 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
326 | link->io.Attributes1 = | ||
327 | IO_DATA_PATH_WIDTH_8; | ||
328 | link->io.IOAddrLines = | ||
329 | io->flags & CISTPL_IO_LINES_MASK; | ||
330 | link->io.BasePort1 = io->win[0].base; | ||
331 | link->io.NumPorts1 = io->win[0].len; | ||
332 | if (io->nwin > 1) { | ||
333 | link->io.Attributes2 = | ||
334 | link->io.Attributes1; | ||
335 | link->io.BasePort2 = io->win[1].base; | ||
336 | link->io.NumPorts2 = io->win[1].len; | ||
337 | } | ||
338 | |||
339 | /* This reserves IO space but doesn't actually enable it */ | ||
340 | if (pcmcia_request_io(link, &link->io) != 0) | ||
341 | goto next_entry; | ||
342 | } | ||
343 | |||
344 | |||
345 | /* If we got this far, we're cool! */ | ||
346 | |||
347 | break; | ||
348 | |||
349 | next_entry: | ||
350 | pcmcia_disable_device(link); | ||
351 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
352 | if (last_ret == CS_NO_MORE_ITEMS) { | ||
353 | printk(KERN_ERR PFX "GetNextTuple(): No matching " | 329 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
354 | "CIS configuration. Maybe you need the " | 330 | "CIS configuration. Maybe you need the " |
355 | "ignore_cis_vcc=1 parameter.\n"); | 331 | "ignore_cis_vcc=1 parameter.\n"); |
356 | goto cs_failed; | 332 | cs_error(link, RequestIO, last_ret); |
357 | } | 333 | goto failed; |
358 | } | 334 | } |
359 | 335 | ||
360 | /* | 336 | /* |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index b5de38a9b791..e124b1d6267a 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -3702,7 +3702,7 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3702 | #endif | 3702 | #endif |
3703 | 3703 | ||
3704 | i = pcmcia_access_configuration_register(link, ®); | 3704 | i = pcmcia_access_configuration_register(link, ®); |
3705 | if(i != CS_SUCCESS) | 3705 | if (i != 0) |
3706 | { | 3706 | { |
3707 | cs_error(link, AccessConfigurationRegister, i); | 3707 | cs_error(link, AccessConfigurationRegister, i); |
3708 | return FALSE; | 3708 | return FALSE; |
@@ -3716,7 +3716,7 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3716 | reg.Action = CS_WRITE; | 3716 | reg.Action = CS_WRITE; |
3717 | reg.Value = reg.Value | COR_SW_RESET; | 3717 | reg.Value = reg.Value | COR_SW_RESET; |
3718 | i = pcmcia_access_configuration_register(link, ®); | 3718 | i = pcmcia_access_configuration_register(link, ®); |
3719 | if(i != CS_SUCCESS) | 3719 | if (i != 0) |
3720 | { | 3720 | { |
3721 | cs_error(link, AccessConfigurationRegister, i); | 3721 | cs_error(link, AccessConfigurationRegister, i); |
3722 | return FALSE; | 3722 | return FALSE; |
@@ -3725,7 +3725,7 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3725 | reg.Action = CS_WRITE; | 3725 | reg.Action = CS_WRITE; |
3726 | reg.Value = COR_LEVEL_IRQ | COR_CONFIG; | 3726 | reg.Value = COR_LEVEL_IRQ | COR_CONFIG; |
3727 | i = pcmcia_access_configuration_register(link, ®); | 3727 | i = pcmcia_access_configuration_register(link, ®); |
3728 | if(i != CS_SUCCESS) | 3728 | if (i != 0) |
3729 | { | 3729 | { |
3730 | cs_error(link, AccessConfigurationRegister, i); | 3730 | cs_error(link, AccessConfigurationRegister, i); |
3731 | return FALSE; | 3731 | return FALSE; |
@@ -3903,7 +3903,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3903 | do | 3903 | do |
3904 | { | 3904 | { |
3905 | i = pcmcia_request_io(link, &link->io); | 3905 | i = pcmcia_request_io(link, &link->io); |
3906 | if(i != CS_SUCCESS) | 3906 | if (i != 0) |
3907 | { | 3907 | { |
3908 | cs_error(link, RequestIO, i); | 3908 | cs_error(link, RequestIO, i); |
3909 | break; | 3909 | break; |
@@ -3914,7 +3914,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3914 | * actually assign a handler to the interrupt. | 3914 | * actually assign a handler to the interrupt. |
3915 | */ | 3915 | */ |
3916 | i = pcmcia_request_irq(link, &link->irq); | 3916 | i = pcmcia_request_irq(link, &link->irq); |
3917 | if(i != CS_SUCCESS) | 3917 | if (i != 0) |
3918 | { | 3918 | { |
3919 | cs_error(link, RequestIRQ, i); | 3919 | cs_error(link, RequestIRQ, i); |
3920 | break; | 3920 | break; |
@@ -3926,7 +3926,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3926 | */ | 3926 | */ |
3927 | link->conf.ConfigIndex = 1; | 3927 | link->conf.ConfigIndex = 1; |
3928 | i = pcmcia_request_configuration(link, &link->conf); | 3928 | i = pcmcia_request_configuration(link, &link->conf); |
3929 | if(i != CS_SUCCESS) | 3929 | if (i != 0) |
3930 | { | 3930 | { |
3931 | cs_error(link, RequestConfiguration, i); | 3931 | cs_error(link, RequestConfiguration, i); |
3932 | break; | 3932 | break; |
@@ -3942,7 +3942,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3942 | req.Base = req.Size = 0; | 3942 | req.Base = req.Size = 0; |
3943 | req.AccessSpeed = mem_speed; | 3943 | req.AccessSpeed = mem_speed; |
3944 | i = pcmcia_request_window(&link, &req, &link->win); | 3944 | i = pcmcia_request_window(&link, &req, &link->win); |
3945 | if(i != CS_SUCCESS) | 3945 | if (i != 0) |
3946 | { | 3946 | { |
3947 | cs_error(link, RequestWindow, i); | 3947 | cs_error(link, RequestWindow, i); |
3948 | break; | 3948 | break; |
@@ -3954,7 +3954,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3954 | 3954 | ||
3955 | mem.CardOffset = 0; mem.Page = 0; | 3955 | mem.CardOffset = 0; mem.Page = 0; |
3956 | i = pcmcia_map_mem_page(link->win, &mem); | 3956 | i = pcmcia_map_mem_page(link->win, &mem); |
3957 | if(i != CS_SUCCESS) | 3957 | if (i != 0) |
3958 | { | 3958 | { |
3959 | cs_error(link, MapMemPage, i); | 3959 | cs_error(link, MapMemPage, i); |
3960 | break; | 3960 | break; |
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 74a5ad2f1223..68789c6e1ce9 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c | |||
@@ -1977,10 +1977,10 @@ static int wl3501_config(struct pcmcia_device *link) | |||
1977 | link->io.BasePort1 = j; | 1977 | link->io.BasePort1 = j; |
1978 | link->io.BasePort2 = link->io.BasePort1 + 0x10; | 1978 | link->io.BasePort2 = link->io.BasePort1 + 0x10; |
1979 | i = pcmcia_request_io(link, &link->io); | 1979 | i = pcmcia_request_io(link, &link->io); |
1980 | if (i == CS_SUCCESS) | 1980 | if (i == 0) |
1981 | break; | 1981 | break; |
1982 | } | 1982 | } |
1983 | if (i != CS_SUCCESS) { | 1983 | if (i != 0) { |
1984 | cs_error(link, RequestIO, i); | 1984 | cs_error(link, RequestIO, i); |
1985 | goto failed; | 1985 | goto failed; |
1986 | } | 1986 | } |
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 00e1d9620f7c..b1899e9c1f65 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c | |||
@@ -149,52 +149,44 @@ static void parport_detach(struct pcmcia_device *link) | |||
149 | #define CS_CHECK(fn, ret) \ | 149 | #define CS_CHECK(fn, ret) \ |
150 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 150 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
151 | 151 | ||
152 | static int parport_config_check(struct pcmcia_device *p_dev, | ||
153 | cistpl_cftable_entry_t *cfg, | ||
154 | cistpl_cftable_entry_t *dflt, | ||
155 | unsigned int vcc, | ||
156 | void *priv_data) | ||
157 | { | ||
158 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
159 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
160 | if (epp_mode) | ||
161 | p_dev->conf.ConfigIndex |= FORCE_EPP_MODE; | ||
162 | p_dev->io.BasePort1 = io->win[0].base; | ||
163 | p_dev->io.NumPorts1 = io->win[0].len; | ||
164 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
165 | if (io->nwin == 2) { | ||
166 | p_dev->io.BasePort2 = io->win[1].base; | ||
167 | p_dev->io.NumPorts2 = io->win[1].len; | ||
168 | } | ||
169 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
170 | return -ENODEV; | ||
171 | return 0; | ||
172 | } | ||
173 | return -ENODEV; | ||
174 | } | ||
175 | |||
152 | static int parport_config(struct pcmcia_device *link) | 176 | static int parport_config(struct pcmcia_device *link) |
153 | { | 177 | { |
154 | parport_info_t *info = link->priv; | 178 | parport_info_t *info = link->priv; |
155 | tuple_t tuple; | ||
156 | u_short buf[128]; | ||
157 | cisparse_t parse; | ||
158 | cistpl_cftable_entry_t *cfg = &parse.cftable_entry; | ||
159 | cistpl_cftable_entry_t dflt = { 0 }; | ||
160 | struct parport *p; | 179 | struct parport *p; |
161 | int last_ret, last_fn; | 180 | int last_ret, last_fn; |
162 | 181 | ||
163 | DEBUG(0, "parport_config(0x%p)\n", link); | 182 | DEBUG(0, "parport_config(0x%p)\n", link); |
164 | 183 | ||
165 | tuple.TupleData = (cisdata_t *)buf; | 184 | last_ret = pcmcia_loop_config(link, parport_config_check, NULL); |
166 | tuple.TupleOffset = 0; tuple.TupleDataMax = 255; | 185 | if (last_ret) { |
167 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 186 | cs_error(link, RequestIO, last_ret); |
168 | tuple.Attributes = 0; | 187 | goto failed; |
169 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
170 | while (1) { | ||
171 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
172 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
173 | goto next_entry; | ||
174 | |||
175 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
176 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
177 | link->conf.ConfigIndex = cfg->index; | ||
178 | if (epp_mode) | ||
179 | link->conf.ConfigIndex |= FORCE_EPP_MODE; | ||
180 | link->io.BasePort1 = io->win[0].base; | ||
181 | link->io.NumPorts1 = io->win[0].len; | ||
182 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
183 | if (io->nwin == 2) { | ||
184 | link->io.BasePort2 = io->win[1].base; | ||
185 | link->io.NumPorts2 = io->win[1].len; | ||
186 | } | ||
187 | if (pcmcia_request_io(link, &link->io) != 0) | ||
188 | goto next_entry; | ||
189 | /* If we've got this far, we're done */ | ||
190 | break; | ||
191 | } | ||
192 | |||
193 | next_entry: | ||
194 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
195 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
196 | } | 188 | } |
197 | 189 | ||
198 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 190 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
199 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 191 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
200 | 192 | ||
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index a87902de8d3b..74d1c906c5d6 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile | |||
@@ -2,10 +2,6 @@ | |||
2 | # Makefile for the kernel pcmcia subsystem (c/o David Hinds) | 2 | # Makefile for the kernel pcmcia subsystem (c/o David Hinds) |
3 | # | 3 | # |
4 | 4 | ||
5 | ifeq ($(CONFIG_PCMCIA_DEBUG),y) | ||
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | |||
9 | pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o | 5 | pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o |
10 | pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o | 6 | pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o |
11 | obj-$(CONFIG_PCCARD) += pcmcia_core.o | 7 | obj-$(CONFIG_PCCARD) += pcmcia_core.o |
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index 75e8f8505e47..fc1de46fd20a 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c | |||
@@ -292,7 +292,7 @@ au1x00_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map) | |||
292 | skt->spd_io[map->map] = speed; | 292 | skt->spd_io[map->map] = speed; |
293 | } | 293 | } |
294 | 294 | ||
295 | map->start=(ioaddr_t)(u32)skt->virt_io; | 295 | map->start=(unsigned int)(u32)skt->virt_io; |
296 | map->stop=map->start+MAP_SIZE; | 296 | map->stop=map->start+MAP_SIZE; |
297 | return 0; | 297 | return 0; |
298 | 298 | ||
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h index a53ef5902518..13a4fbc58711 100644 --- a/drivers/pcmcia/au1000_generic.h +++ b/drivers/pcmcia/au1000_generic.h | |||
@@ -116,7 +116,7 @@ struct au1000_pcmcia_socket { | |||
116 | struct resource res_attr; | 116 | struct resource res_attr; |
117 | 117 | ||
118 | void * virt_io; | 118 | void * virt_io; |
119 | ioaddr_t phys_io; | 119 | unsigned int phys_io; |
120 | unsigned int phys_attr; | 120 | unsigned int phys_attr; |
121 | unsigned int phys_mem; | 121 | unsigned int phys_mem; |
122 | unsigned short speed_io, speed_attr, speed_mem; | 122 | unsigned short speed_io, speed_attr, speed_mem; |
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c index aa1cd4d3aa29..d6b4bd1db7d7 100644 --- a/drivers/pcmcia/au1000_pb1x00.c +++ b/drivers/pcmcia/au1000_pb1x00.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <pcmcia/ss.h> | 37 | #include <pcmcia/ss.h> |
38 | #include <pcmcia/cistpl.h> | 38 | #include <pcmcia/cistpl.h> |
39 | #include <pcmcia/bus_ops.h> | 39 | #include <pcmcia/bus_ops.h> |
40 | #include "cs_internal.h" | ||
41 | 40 | ||
42 | #include <asm/io.h> | 41 | #include <asm/io.h> |
43 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c index 8a9b18cee847..9627390835ca 100644 --- a/drivers/pcmcia/au1000_xxs1500.c +++ b/drivers/pcmcia/au1000_xxs1500.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <pcmcia/ss.h> | 41 | #include <pcmcia/ss.h> |
42 | #include <pcmcia/cistpl.h> | 42 | #include <pcmcia/cistpl.h> |
43 | #include <pcmcia/bus_ops.h> | 43 | #include <pcmcia/bus_ops.h> |
44 | #include "cs_internal.h" | ||
45 | 44 | ||
46 | #include <asm/io.h> | 45 | #include <asm/io.h> |
47 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 911ca0e8dfc2..db77e1f3309a 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c | |||
@@ -238,7 +238,7 @@ int __ref cb_alloc(struct pcmcia_socket * s) | |||
238 | pci_bus_add_devices(bus); | 238 | pci_bus_add_devices(bus); |
239 | 239 | ||
240 | s->irq.AssignedIRQ = s->pci_irq; | 240 | s->irq.AssignedIRQ = s->pci_irq; |
241 | return CS_SUCCESS; | 241 | return 0; |
242 | } | 242 | } |
243 | 243 | ||
244 | void cb_free(struct pcmcia_socket * s) | 244 | void cb_free(struct pcmcia_socket * s) |
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 65129b54eb09..dcce9f5d8465 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -92,7 +92,8 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag | |||
92 | if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) { | 92 | if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) { |
93 | mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); | 93 | mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); |
94 | if (mem->res == NULL) { | 94 | if (mem->res == NULL) { |
95 | printk(KERN_NOTICE "cs: unable to map card memory!\n"); | 95 | dev_printk(KERN_NOTICE, &s->dev, |
96 | "cs: unable to map card memory!\n"); | ||
96 | return NULL; | 97 | return NULL; |
97 | } | 98 | } |
98 | s->cis_virt = NULL; | 99 | s->cis_virt = NULL; |
@@ -265,13 +266,13 @@ EXPORT_SYMBOL(pcmcia_write_cis_mem); | |||
265 | ======================================================================*/ | 266 | ======================================================================*/ |
266 | 267 | ||
267 | static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, | 268 | static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, |
268 | u_int len, void *ptr) | 269 | size_t len, void *ptr) |
269 | { | 270 | { |
270 | struct cis_cache_entry *cis; | 271 | struct cis_cache_entry *cis; |
271 | int ret; | 272 | int ret; |
272 | 273 | ||
273 | if (s->fake_cis) { | 274 | if (s->fake_cis) { |
274 | if (s->fake_cis_len > addr+len) | 275 | if (s->fake_cis_len >= addr+len) |
275 | memcpy(ptr, s->fake_cis+addr, len); | 276 | memcpy(ptr, s->fake_cis+addr, len); |
276 | else | 277 | else |
277 | memset(ptr, 0xff, len); | 278 | memset(ptr, 0xff, len); |
@@ -351,7 +352,9 @@ int verify_cis_cache(struct pcmcia_socket *s) | |||
351 | 352 | ||
352 | buf = kmalloc(256, GFP_KERNEL); | 353 | buf = kmalloc(256, GFP_KERNEL); |
353 | if (buf == NULL) | 354 | if (buf == NULL) |
354 | return -1; | 355 | dev_printk(KERN_WARNING, &s->dev, |
356 | "no memory for verifying CIS\n"); | ||
357 | return -ENOMEM; | ||
355 | list_for_each_entry(cis, &s->cis_cache, node) { | 358 | list_for_each_entry(cis, &s->cis_cache, node) { |
356 | int len = cis->len; | 359 | int len = cis->len; |
357 | 360 | ||
@@ -380,18 +383,22 @@ int verify_cis_cache(struct pcmcia_socket *s) | |||
380 | 383 | ||
381 | ======================================================================*/ | 384 | ======================================================================*/ |
382 | 385 | ||
383 | int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) | 386 | int pcmcia_replace_cis(struct pcmcia_socket *s, |
387 | const u8 *data, const size_t len) | ||
384 | { | 388 | { |
385 | kfree(s->fake_cis); | 389 | if (len > CISTPL_MAX_CIS_SIZE) { |
386 | s->fake_cis = NULL; | 390 | dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n"); |
387 | if (cis->Length > CISTPL_MAX_CIS_SIZE) | 391 | return -EINVAL; |
388 | return CS_BAD_SIZE; | 392 | } |
389 | s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); | 393 | kfree(s->fake_cis); |
390 | if (s->fake_cis == NULL) | 394 | s->fake_cis = kmalloc(len, GFP_KERNEL); |
391 | return CS_OUT_OF_RESOURCE; | 395 | if (s->fake_cis == NULL) { |
392 | s->fake_cis_len = cis->Length; | 396 | dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n"); |
393 | memcpy(s->fake_cis, cis->Data, cis->Length); | 397 | return -ENOMEM; |
394 | return CS_SUCCESS; | 398 | } |
399 | s->fake_cis_len = len; | ||
400 | memcpy(s->fake_cis, data, len); | ||
401 | return 0; | ||
395 | } | 402 | } |
396 | EXPORT_SYMBOL(pcmcia_replace_cis); | 403 | EXPORT_SYMBOL(pcmcia_replace_cis); |
397 | 404 | ||
@@ -418,9 +425,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *t | |||
418 | int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) | 425 | int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) |
419 | { | 426 | { |
420 | if (!s) | 427 | if (!s) |
421 | return CS_BAD_HANDLE; | 428 | return -EINVAL; |
422 | if (!(s->state & SOCKET_PRESENT)) | 429 | if (!(s->state & SOCKET_PRESENT)) |
423 | return CS_NO_CARD; | 430 | return -ENODEV; |
424 | tuple->TupleLink = tuple->Flags = 0; | 431 | tuple->TupleLink = tuple->Flags = 0; |
425 | #ifdef CONFIG_CARDBUS | 432 | #ifdef CONFIG_CARDBUS |
426 | if (s->state & SOCKET_CARDBUS) { | 433 | if (s->state & SOCKET_CARDBUS) { |
@@ -440,10 +447,10 @@ int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple | |||
440 | !(tuple->Attributes & TUPLE_RETURN_COMMON)) { | 447 | !(tuple->Attributes & TUPLE_RETURN_COMMON)) { |
441 | cisdata_t req = tuple->DesiredTuple; | 448 | cisdata_t req = tuple->DesiredTuple; |
442 | tuple->DesiredTuple = CISTPL_LONGLINK_MFC; | 449 | tuple->DesiredTuple = CISTPL_LONGLINK_MFC; |
443 | if (pccard_get_next_tuple(s, function, tuple) == CS_SUCCESS) { | 450 | if (pccard_get_next_tuple(s, function, tuple) == 0) { |
444 | tuple->DesiredTuple = CISTPL_LINKTARGET; | 451 | tuple->DesiredTuple = CISTPL_LINKTARGET; |
445 | if (pccard_get_next_tuple(s, function, tuple) != CS_SUCCESS) | 452 | if (pccard_get_next_tuple(s, function, tuple) != 0) |
446 | return CS_NO_MORE_ITEMS; | 453 | return -ENOSPC; |
447 | } else | 454 | } else |
448 | tuple->CISOffset = tuple->TupleLink = 0; | 455 | tuple->CISOffset = tuple->TupleLink = 0; |
449 | tuple->DesiredTuple = req; | 456 | tuple->DesiredTuple = req; |
@@ -498,9 +505,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ | |||
498 | int ofs, i, attr; | 505 | int ofs, i, attr; |
499 | 506 | ||
500 | if (!s) | 507 | if (!s) |
501 | return CS_BAD_HANDLE; | 508 | return -EINVAL; |
502 | if (!(s->state & SOCKET_PRESENT)) | 509 | if (!(s->state & SOCKET_PRESENT)) |
503 | return CS_NO_CARD; | 510 | return -ENODEV; |
504 | 511 | ||
505 | link[1] = tuple->TupleLink; | 512 | link[1] = tuple->TupleLink; |
506 | ofs = tuple->CISOffset + tuple->TupleLink; | 513 | ofs = tuple->CISOffset + tuple->TupleLink; |
@@ -519,7 +526,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ | |||
519 | /* End of chain? Follow long link if possible */ | 526 | /* End of chain? Follow long link if possible */ |
520 | if (link[0] == CISTPL_END) { | 527 | if (link[0] == CISTPL_END) { |
521 | if ((ofs = follow_link(s, tuple)) < 0) | 528 | if ((ofs = follow_link(s, tuple)) < 0) |
522 | return CS_NO_MORE_ITEMS; | 529 | return -ENOSPC; |
523 | attr = SPACE(tuple->Flags); | 530 | attr = SPACE(tuple->Flags); |
524 | read_cis_cache(s, attr, ofs, 2, link); | 531 | read_cis_cache(s, attr, ofs, 2, link); |
525 | } | 532 | } |
@@ -577,13 +584,13 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_ | |||
577 | } | 584 | } |
578 | if (i == MAX_TUPLES) { | 585 | if (i == MAX_TUPLES) { |
579 | cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n"); | 586 | cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n"); |
580 | return CS_NO_MORE_ITEMS; | 587 | return -ENOSPC; |
581 | } | 588 | } |
582 | 589 | ||
583 | tuple->TupleCode = link[0]; | 590 | tuple->TupleCode = link[0]; |
584 | tuple->TupleLink = link[1]; | 591 | tuple->TupleLink = link[1]; |
585 | tuple->CISOffset = ofs + 2; | 592 | tuple->CISOffset = ofs + 2; |
586 | return CS_SUCCESS; | 593 | return 0; |
587 | } | 594 | } |
588 | EXPORT_SYMBOL(pccard_get_next_tuple); | 595 | EXPORT_SYMBOL(pccard_get_next_tuple); |
589 | 596 | ||
@@ -596,18 +603,18 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple) | |||
596 | u_int len; | 603 | u_int len; |
597 | 604 | ||
598 | if (!s) | 605 | if (!s) |
599 | return CS_BAD_HANDLE; | 606 | return -EINVAL; |
600 | 607 | ||
601 | if (tuple->TupleLink < tuple->TupleOffset) | 608 | if (tuple->TupleLink < tuple->TupleOffset) |
602 | return CS_NO_MORE_ITEMS; | 609 | return -ENOSPC; |
603 | len = tuple->TupleLink - tuple->TupleOffset; | 610 | len = tuple->TupleLink - tuple->TupleOffset; |
604 | tuple->TupleDataLen = tuple->TupleLink; | 611 | tuple->TupleDataLen = tuple->TupleLink; |
605 | if (len == 0) | 612 | if (len == 0) |
606 | return CS_SUCCESS; | 613 | return 0; |
607 | read_cis_cache(s, SPACE(tuple->Flags), | 614 | read_cis_cache(s, SPACE(tuple->Flags), |
608 | tuple->CISOffset + tuple->TupleOffset, | 615 | tuple->CISOffset + tuple->TupleOffset, |
609 | _MIN(len, tuple->TupleDataMax), tuple->TupleData); | 616 | _MIN(len, tuple->TupleDataMax), tuple->TupleData); |
610 | return CS_SUCCESS; | 617 | return 0; |
611 | } | 618 | } |
612 | EXPORT_SYMBOL(pccard_get_tuple_data); | 619 | EXPORT_SYMBOL(pccard_get_tuple_data); |
613 | 620 | ||
@@ -640,25 +647,31 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device) | |||
640 | case 3: device->dev[i].speed = 150; break; | 647 | case 3: device->dev[i].speed = 150; break; |
641 | case 4: device->dev[i].speed = 100; break; | 648 | case 4: device->dev[i].speed = 100; break; |
642 | case 7: | 649 | case 7: |
643 | if (++p == q) return CS_BAD_TUPLE; | 650 | if (++p == q) |
651 | return -EINVAL; | ||
644 | device->dev[i].speed = SPEED_CVT(*p); | 652 | device->dev[i].speed = SPEED_CVT(*p); |
645 | while (*p & 0x80) | 653 | while (*p & 0x80) |
646 | if (++p == q) return CS_BAD_TUPLE; | 654 | if (++p == q) |
655 | return -EINVAL; | ||
647 | break; | 656 | break; |
648 | default: | 657 | default: |
649 | return CS_BAD_TUPLE; | 658 | return -EINVAL; |
650 | } | 659 | } |
651 | 660 | ||
652 | if (++p == q) return CS_BAD_TUPLE; | 661 | if (++p == q) |
653 | if (*p == 0xff) break; | 662 | return -EINVAL; |
663 | if (*p == 0xff) | ||
664 | break; | ||
654 | scale = *p & 7; | 665 | scale = *p & 7; |
655 | if (scale == 7) return CS_BAD_TUPLE; | 666 | if (scale == 7) |
667 | return -EINVAL; | ||
656 | device->dev[i].size = ((*p >> 3) + 1) * (512 << (scale*2)); | 668 | device->dev[i].size = ((*p >> 3) + 1) * (512 << (scale*2)); |
657 | device->ndev++; | 669 | device->ndev++; |
658 | if (++p == q) break; | 670 | if (++p == q) |
671 | break; | ||
659 | } | 672 | } |
660 | 673 | ||
661 | return CS_SUCCESS; | 674 | return 0; |
662 | } | 675 | } |
663 | 676 | ||
664 | /*====================================================================*/ | 677 | /*====================================================================*/ |
@@ -667,12 +680,12 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) | |||
667 | { | 680 | { |
668 | u_char *p; | 681 | u_char *p; |
669 | if (tuple->TupleDataLen < 5) | 682 | if (tuple->TupleDataLen < 5) |
670 | return CS_BAD_TUPLE; | 683 | return -EINVAL; |
671 | p = (u_char *) tuple->TupleData; | 684 | p = (u_char *) tuple->TupleData; |
672 | csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; | 685 | csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; |
673 | csum->len = get_unaligned_le16(p + 2); | 686 | csum->len = get_unaligned_le16(p + 2); |
674 | csum->sum = *(p + 4); | 687 | csum->sum = *(p + 4); |
675 | return CS_SUCCESS; | 688 | return 0; |
676 | } | 689 | } |
677 | 690 | ||
678 | /*====================================================================*/ | 691 | /*====================================================================*/ |
@@ -680,9 +693,9 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) | |||
680 | static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) | 693 | static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) |
681 | { | 694 | { |
682 | if (tuple->TupleDataLen < 4) | 695 | if (tuple->TupleDataLen < 4) |
683 | return CS_BAD_TUPLE; | 696 | return -EINVAL; |
684 | link->addr = get_unaligned_le32(tuple->TupleData); | 697 | link->addr = get_unaligned_le32(tuple->TupleData); |
685 | return CS_SUCCESS; | 698 | return 0; |
686 | } | 699 | } |
687 | 700 | ||
688 | /*====================================================================*/ | 701 | /*====================================================================*/ |
@@ -697,13 +710,13 @@ static int parse_longlink_mfc(tuple_t *tuple, | |||
697 | 710 | ||
698 | link->nfn = *p; p++; | 711 | link->nfn = *p; p++; |
699 | if (tuple->TupleDataLen <= link->nfn*5) | 712 | if (tuple->TupleDataLen <= link->nfn*5) |
700 | return CS_BAD_TUPLE; | 713 | return -EINVAL; |
701 | for (i = 0; i < link->nfn; i++) { | 714 | for (i = 0; i < link->nfn; i++) { |
702 | link->fn[i].space = *p; p++; | 715 | link->fn[i].space = *p; p++; |
703 | link->fn[i].addr = get_unaligned_le32(p); | 716 | link->fn[i].addr = get_unaligned_le32(p); |
704 | p += 4; | 717 | p += 4; |
705 | } | 718 | } |
706 | return CS_SUCCESS; | 719 | return 0; |
707 | } | 720 | } |
708 | 721 | ||
709 | /*====================================================================*/ | 722 | /*====================================================================*/ |
@@ -713,24 +726,27 @@ static int parse_strings(u_char *p, u_char *q, int max, | |||
713 | { | 726 | { |
714 | int i, j, ns; | 727 | int i, j, ns; |
715 | 728 | ||
716 | if (p == q) return CS_BAD_TUPLE; | 729 | if (p == q) |
730 | return -EINVAL; | ||
717 | ns = 0; j = 0; | 731 | ns = 0; j = 0; |
718 | for (i = 0; i < max; i++) { | 732 | for (i = 0; i < max; i++) { |
719 | if (*p == 0xff) break; | 733 | if (*p == 0xff) |
734 | break; | ||
720 | ofs[i] = j; | 735 | ofs[i] = j; |
721 | ns++; | 736 | ns++; |
722 | for (;;) { | 737 | for (;;) { |
723 | s[j++] = (*p == 0xff) ? '\0' : *p; | 738 | s[j++] = (*p == 0xff) ? '\0' : *p; |
724 | if ((*p == '\0') || (*p == 0xff)) break; | 739 | if ((*p == '\0') || (*p == 0xff)) break; |
725 | if (++p == q) return CS_BAD_TUPLE; | 740 | if (++p == q) |
741 | return -EINVAL; | ||
726 | } | 742 | } |
727 | if ((*p == 0xff) || (++p == q)) break; | 743 | if ((*p == 0xff) || (++p == q)) break; |
728 | } | 744 | } |
729 | if (found) { | 745 | if (found) { |
730 | *found = ns; | 746 | *found = ns; |
731 | return CS_SUCCESS; | 747 | return 0; |
732 | } else { | 748 | } else { |
733 | return (ns == max) ? CS_SUCCESS : CS_BAD_TUPLE; | 749 | return (ns == max) ? 0 : -EINVAL; |
734 | } | 750 | } |
735 | } | 751 | } |
736 | 752 | ||
@@ -745,7 +761,8 @@ static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1) | |||
745 | 761 | ||
746 | vers_1->major = *p; p++; | 762 | vers_1->major = *p; p++; |
747 | vers_1->minor = *p; p++; | 763 | vers_1->minor = *p; p++; |
748 | if (p >= q) return CS_BAD_TUPLE; | 764 | if (p >= q) |
765 | return -EINVAL; | ||
749 | 766 | ||
750 | return parse_strings(p, q, CISTPL_VERS_1_MAX_PROD_STRINGS, | 767 | return parse_strings(p, q, CISTPL_VERS_1_MAX_PROD_STRINGS, |
751 | vers_1->str, vers_1->ofs, &vers_1->ns); | 768 | vers_1->str, vers_1->ofs, &vers_1->ns); |
@@ -781,7 +798,7 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec) | |||
781 | p += 2; | 798 | p += 2; |
782 | } | 799 | } |
783 | jedec->nid = nid; | 800 | jedec->nid = nid; |
784 | return CS_SUCCESS; | 801 | return 0; |
785 | } | 802 | } |
786 | 803 | ||
787 | /*====================================================================*/ | 804 | /*====================================================================*/ |
@@ -789,10 +806,10 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec) | |||
789 | static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) | 806 | static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) |
790 | { | 807 | { |
791 | if (tuple->TupleDataLen < 4) | 808 | if (tuple->TupleDataLen < 4) |
792 | return CS_BAD_TUPLE; | 809 | return -EINVAL; |
793 | m->manf = get_unaligned_le16(tuple->TupleData); | 810 | m->manf = get_unaligned_le16(tuple->TupleData); |
794 | m->card = get_unaligned_le16(tuple->TupleData + 2); | 811 | m->card = get_unaligned_le16(tuple->TupleData + 2); |
795 | return CS_SUCCESS; | 812 | return 0; |
796 | } | 813 | } |
797 | 814 | ||
798 | /*====================================================================*/ | 815 | /*====================================================================*/ |
@@ -801,11 +818,11 @@ static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f) | |||
801 | { | 818 | { |
802 | u_char *p; | 819 | u_char *p; |
803 | if (tuple->TupleDataLen < 2) | 820 | if (tuple->TupleDataLen < 2) |
804 | return CS_BAD_TUPLE; | 821 | return -EINVAL; |
805 | p = (u_char *)tuple->TupleData; | 822 | p = (u_char *)tuple->TupleData; |
806 | f->func = p[0]; | 823 | f->func = p[0]; |
807 | f->sysinit = p[1]; | 824 | f->sysinit = p[1]; |
808 | return CS_SUCCESS; | 825 | return 0; |
809 | } | 826 | } |
810 | 827 | ||
811 | /*====================================================================*/ | 828 | /*====================================================================*/ |
@@ -815,12 +832,12 @@ static int parse_funce(tuple_t *tuple, cistpl_funce_t *f) | |||
815 | u_char *p; | 832 | u_char *p; |
816 | int i; | 833 | int i; |
817 | if (tuple->TupleDataLen < 1) | 834 | if (tuple->TupleDataLen < 1) |
818 | return CS_BAD_TUPLE; | 835 | return -EINVAL; |
819 | p = (u_char *)tuple->TupleData; | 836 | p = (u_char *)tuple->TupleData; |
820 | f->type = p[0]; | 837 | f->type = p[0]; |
821 | for (i = 1; i < tuple->TupleDataLen; i++) | 838 | for (i = 1; i < tuple->TupleDataLen; i++) |
822 | f->data[i-1] = p[i]; | 839 | f->data[i-1] = p[i]; |
823 | return CS_SUCCESS; | 840 | return 0; |
824 | } | 841 | } |
825 | 842 | ||
826 | /*====================================================================*/ | 843 | /*====================================================================*/ |
@@ -834,7 +851,7 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config) | |||
834 | rasz = *p & 0x03; | 851 | rasz = *p & 0x03; |
835 | rmsz = (*p & 0x3c) >> 2; | 852 | rmsz = (*p & 0x3c) >> 2; |
836 | if (tuple->TupleDataLen < rasz+rmsz+4) | 853 | if (tuple->TupleDataLen < rasz+rmsz+4) |
837 | return CS_BAD_TUPLE; | 854 | return -EINVAL; |
838 | config->last_idx = *(++p); | 855 | config->last_idx = *(++p); |
839 | p++; | 856 | p++; |
840 | config->base = 0; | 857 | config->base = 0; |
@@ -846,7 +863,7 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config) | |||
846 | for (i = 0; i <= rmsz; i++) | 863 | for (i = 0; i <= rmsz; i++) |
847 | config->rmask[i>>2] += p[i] << (8*(i%4)); | 864 | config->rmask[i>>2] += p[i] << (8*(i%4)); |
848 | config->subtuples = tuple->TupleDataLen - (rasz+rmsz+4); | 865 | config->subtuples = tuple->TupleDataLen - (rasz+rmsz+4); |
849 | return CS_SUCCESS; | 866 | return 0; |
850 | } | 867 | } |
851 | 868 | ||
852 | /*====================================================================== | 869 | /*====================================================================== |
@@ -1002,10 +1019,12 @@ static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem) | |||
1002 | 1019 | ||
1003 | static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq) | 1020 | static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq) |
1004 | { | 1021 | { |
1005 | if (p == q) return NULL; | 1022 | if (p == q) |
1023 | return NULL; | ||
1006 | irq->IRQInfo1 = *p; p++; | 1024 | irq->IRQInfo1 = *p; p++; |
1007 | if (irq->IRQInfo1 & IRQ_INFO2_VALID) { | 1025 | if (irq->IRQInfo1 & IRQ_INFO2_VALID) { |
1008 | if (p+2 > q) return NULL; | 1026 | if (p+2 > q) |
1027 | return NULL; | ||
1009 | irq->IRQInfo2 = (p[1]<<8) + p[0]; | 1028 | irq->IRQInfo2 = (p[1]<<8) + p[0]; |
1010 | p += 2; | 1029 | p += 2; |
1011 | } | 1030 | } |
@@ -1026,7 +1045,8 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1026 | if (*p & 0x40) | 1045 | if (*p & 0x40) |
1027 | entry->flags |= CISTPL_CFTABLE_DEFAULT; | 1046 | entry->flags |= CISTPL_CFTABLE_DEFAULT; |
1028 | if (*p & 0x80) { | 1047 | if (*p & 0x80) { |
1029 | if (++p == q) return CS_BAD_TUPLE; | 1048 | if (++p == q) |
1049 | return -EINVAL; | ||
1030 | if (*p & 0x10) | 1050 | if (*p & 0x10) |
1031 | entry->flags |= CISTPL_CFTABLE_BVDS; | 1051 | entry->flags |= CISTPL_CFTABLE_BVDS; |
1032 | if (*p & 0x20) | 1052 | if (*p & 0x20) |
@@ -1040,30 +1060,35 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1040 | entry->interface = 0; | 1060 | entry->interface = 0; |
1041 | 1061 | ||
1042 | /* Process optional features */ | 1062 | /* Process optional features */ |
1043 | if (++p == q) return CS_BAD_TUPLE; | 1063 | if (++p == q) |
1064 | return -EINVAL; | ||
1044 | features = *p; p++; | 1065 | features = *p; p++; |
1045 | 1066 | ||
1046 | /* Power options */ | 1067 | /* Power options */ |
1047 | if ((features & 3) > 0) { | 1068 | if ((features & 3) > 0) { |
1048 | p = parse_power(p, q, &entry->vcc); | 1069 | p = parse_power(p, q, &entry->vcc); |
1049 | if (p == NULL) return CS_BAD_TUPLE; | 1070 | if (p == NULL) |
1071 | return -EINVAL; | ||
1050 | } else | 1072 | } else |
1051 | entry->vcc.present = 0; | 1073 | entry->vcc.present = 0; |
1052 | if ((features & 3) > 1) { | 1074 | if ((features & 3) > 1) { |
1053 | p = parse_power(p, q, &entry->vpp1); | 1075 | p = parse_power(p, q, &entry->vpp1); |
1054 | if (p == NULL) return CS_BAD_TUPLE; | 1076 | if (p == NULL) |
1077 | return -EINVAL; | ||
1055 | } else | 1078 | } else |
1056 | entry->vpp1.present = 0; | 1079 | entry->vpp1.present = 0; |
1057 | if ((features & 3) > 2) { | 1080 | if ((features & 3) > 2) { |
1058 | p = parse_power(p, q, &entry->vpp2); | 1081 | p = parse_power(p, q, &entry->vpp2); |
1059 | if (p == NULL) return CS_BAD_TUPLE; | 1082 | if (p == NULL) |
1083 | return -EINVAL; | ||
1060 | } else | 1084 | } else |
1061 | entry->vpp2.present = 0; | 1085 | entry->vpp2.present = 0; |
1062 | 1086 | ||
1063 | /* Timing options */ | 1087 | /* Timing options */ |
1064 | if (features & 0x04) { | 1088 | if (features & 0x04) { |
1065 | p = parse_timing(p, q, &entry->timing); | 1089 | p = parse_timing(p, q, &entry->timing); |
1066 | if (p == NULL) return CS_BAD_TUPLE; | 1090 | if (p == NULL) |
1091 | return -EINVAL; | ||
1067 | } else { | 1092 | } else { |
1068 | entry->timing.wait = 0; | 1093 | entry->timing.wait = 0; |
1069 | entry->timing.ready = 0; | 1094 | entry->timing.ready = 0; |
@@ -1073,14 +1098,16 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1073 | /* I/O window options */ | 1098 | /* I/O window options */ |
1074 | if (features & 0x08) { | 1099 | if (features & 0x08) { |
1075 | p = parse_io(p, q, &entry->io); | 1100 | p = parse_io(p, q, &entry->io); |
1076 | if (p == NULL) return CS_BAD_TUPLE; | 1101 | if (p == NULL) |
1102 | return -EINVAL; | ||
1077 | } else | 1103 | } else |
1078 | entry->io.nwin = 0; | 1104 | entry->io.nwin = 0; |
1079 | 1105 | ||
1080 | /* Interrupt options */ | 1106 | /* Interrupt options */ |
1081 | if (features & 0x10) { | 1107 | if (features & 0x10) { |
1082 | p = parse_irq(p, q, &entry->irq); | 1108 | p = parse_irq(p, q, &entry->irq); |
1083 | if (p == NULL) return CS_BAD_TUPLE; | 1109 | if (p == NULL) |
1110 | return -EINVAL; | ||
1084 | } else | 1111 | } else |
1085 | entry->irq.IRQInfo1 = 0; | 1112 | entry->irq.IRQInfo1 = 0; |
1086 | 1113 | ||
@@ -1094,7 +1121,8 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1094 | entry->mem.win[0].card_addr = 0; | 1121 | entry->mem.win[0].card_addr = 0; |
1095 | entry->mem.win[0].host_addr = 0; | 1122 | entry->mem.win[0].host_addr = 0; |
1096 | p += 2; | 1123 | p += 2; |
1097 | if (p > q) return CS_BAD_TUPLE; | 1124 | if (p > q) |
1125 | return -EINVAL; | ||
1098 | break; | 1126 | break; |
1099 | case 0x40: | 1127 | case 0x40: |
1100 | entry->mem.nwin = 1; | 1128 | entry->mem.nwin = 1; |
@@ -1102,26 +1130,30 @@ static int parse_cftable_entry(tuple_t *tuple, | |||
1102 | entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; | 1130 | entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; |
1103 | entry->mem.win[0].host_addr = 0; | 1131 | entry->mem.win[0].host_addr = 0; |
1104 | p += 4; | 1132 | p += 4; |
1105 | if (p > q) return CS_BAD_TUPLE; | 1133 | if (p > q) |
1134 | return -EINVAL; | ||
1106 | break; | 1135 | break; |
1107 | case 0x60: | 1136 | case 0x60: |
1108 | p = parse_mem(p, q, &entry->mem); | 1137 | p = parse_mem(p, q, &entry->mem); |
1109 | if (p == NULL) return CS_BAD_TUPLE; | 1138 | if (p == NULL) |
1139 | return -EINVAL; | ||
1110 | break; | 1140 | break; |
1111 | } | 1141 | } |
1112 | 1142 | ||
1113 | /* Misc features */ | 1143 | /* Misc features */ |
1114 | if (features & 0x80) { | 1144 | if (features & 0x80) { |
1115 | if (p == q) return CS_BAD_TUPLE; | 1145 | if (p == q) |
1146 | return -EINVAL; | ||
1116 | entry->flags |= (*p << 8); | 1147 | entry->flags |= (*p << 8); |
1117 | while (*p & 0x80) | 1148 | while (*p & 0x80) |
1118 | if (++p == q) return CS_BAD_TUPLE; | 1149 | if (++p == q) |
1150 | return -EINVAL; | ||
1119 | p++; | 1151 | p++; |
1120 | } | 1152 | } |
1121 | 1153 | ||
1122 | entry->subtuples = q-p; | 1154 | entry->subtuples = q-p; |
1123 | 1155 | ||
1124 | return CS_SUCCESS; | 1156 | return 0; |
1125 | } | 1157 | } |
1126 | 1158 | ||
1127 | /*====================================================================*/ | 1159 | /*====================================================================*/ |
@@ -1132,12 +1164,12 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar) | |||
1132 | { | 1164 | { |
1133 | u_char *p; | 1165 | u_char *p; |
1134 | if (tuple->TupleDataLen < 6) | 1166 | if (tuple->TupleDataLen < 6) |
1135 | return CS_BAD_TUPLE; | 1167 | return -EINVAL; |
1136 | p = (u_char *)tuple->TupleData; | 1168 | p = (u_char *)tuple->TupleData; |
1137 | bar->attr = *p; | 1169 | bar->attr = *p; |
1138 | p += 2; | 1170 | p += 2; |
1139 | bar->size = get_unaligned_le32(p); | 1171 | bar->size = get_unaligned_le32(p); |
1140 | return CS_SUCCESS; | 1172 | return 0; |
1141 | } | 1173 | } |
1142 | 1174 | ||
1143 | static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) | 1175 | static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) |
@@ -1146,12 +1178,12 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) | |||
1146 | 1178 | ||
1147 | p = (u_char *)tuple->TupleData; | 1179 | p = (u_char *)tuple->TupleData; |
1148 | if ((*p != 3) || (tuple->TupleDataLen < 6)) | 1180 | if ((*p != 3) || (tuple->TupleDataLen < 6)) |
1149 | return CS_BAD_TUPLE; | 1181 | return -EINVAL; |
1150 | config->last_idx = *(++p); | 1182 | config->last_idx = *(++p); |
1151 | p++; | 1183 | p++; |
1152 | config->base = get_unaligned_le32(p); | 1184 | config->base = get_unaligned_le32(p); |
1153 | config->subtuples = tuple->TupleDataLen - 6; | 1185 | config->subtuples = tuple->TupleDataLen - 6; |
1154 | return CS_SUCCESS; | 1186 | return 0; |
1155 | } | 1187 | } |
1156 | 1188 | ||
1157 | static int parse_cftable_entry_cb(tuple_t *tuple, | 1189 | static int parse_cftable_entry_cb(tuple_t *tuple, |
@@ -1167,29 +1199,34 @@ static int parse_cftable_entry_cb(tuple_t *tuple, | |||
1167 | entry->flags |= CISTPL_CFTABLE_DEFAULT; | 1199 | entry->flags |= CISTPL_CFTABLE_DEFAULT; |
1168 | 1200 | ||
1169 | /* Process optional features */ | 1201 | /* Process optional features */ |
1170 | if (++p == q) return CS_BAD_TUPLE; | 1202 | if (++p == q) |
1203 | return -EINVAL; | ||
1171 | features = *p; p++; | 1204 | features = *p; p++; |
1172 | 1205 | ||
1173 | /* Power options */ | 1206 | /* Power options */ |
1174 | if ((features & 3) > 0) { | 1207 | if ((features & 3) > 0) { |
1175 | p = parse_power(p, q, &entry->vcc); | 1208 | p = parse_power(p, q, &entry->vcc); |
1176 | if (p == NULL) return CS_BAD_TUPLE; | 1209 | if (p == NULL) |
1210 | return -EINVAL; | ||
1177 | } else | 1211 | } else |
1178 | entry->vcc.present = 0; | 1212 | entry->vcc.present = 0; |
1179 | if ((features & 3) > 1) { | 1213 | if ((features & 3) > 1) { |
1180 | p = parse_power(p, q, &entry->vpp1); | 1214 | p = parse_power(p, q, &entry->vpp1); |
1181 | if (p == NULL) return CS_BAD_TUPLE; | 1215 | if (p == NULL) |
1216 | return -EINVAL; | ||
1182 | } else | 1217 | } else |
1183 | entry->vpp1.present = 0; | 1218 | entry->vpp1.present = 0; |
1184 | if ((features & 3) > 2) { | 1219 | if ((features & 3) > 2) { |
1185 | p = parse_power(p, q, &entry->vpp2); | 1220 | p = parse_power(p, q, &entry->vpp2); |
1186 | if (p == NULL) return CS_BAD_TUPLE; | 1221 | if (p == NULL) |
1222 | return -EINVAL; | ||
1187 | } else | 1223 | } else |
1188 | entry->vpp2.present = 0; | 1224 | entry->vpp2.present = 0; |
1189 | 1225 | ||
1190 | /* I/O window options */ | 1226 | /* I/O window options */ |
1191 | if (features & 0x08) { | 1227 | if (features & 0x08) { |
1192 | if (p == q) return CS_BAD_TUPLE; | 1228 | if (p == q) |
1229 | return -EINVAL; | ||
1193 | entry->io = *p; p++; | 1230 | entry->io = *p; p++; |
1194 | } else | 1231 | } else |
1195 | entry->io = 0; | 1232 | entry->io = 0; |
@@ -1197,32 +1234,37 @@ static int parse_cftable_entry_cb(tuple_t *tuple, | |||
1197 | /* Interrupt options */ | 1234 | /* Interrupt options */ |
1198 | if (features & 0x10) { | 1235 | if (features & 0x10) { |
1199 | p = parse_irq(p, q, &entry->irq); | 1236 | p = parse_irq(p, q, &entry->irq); |
1200 | if (p == NULL) return CS_BAD_TUPLE; | 1237 | if (p == NULL) |
1238 | return -EINVAL; | ||
1201 | } else | 1239 | } else |
1202 | entry->irq.IRQInfo1 = 0; | 1240 | entry->irq.IRQInfo1 = 0; |
1203 | 1241 | ||
1204 | if (features & 0x20) { | 1242 | if (features & 0x20) { |
1205 | if (p == q) return CS_BAD_TUPLE; | 1243 | if (p == q) |
1244 | return -EINVAL; | ||
1206 | entry->mem = *p; p++; | 1245 | entry->mem = *p; p++; |
1207 | } else | 1246 | } else |
1208 | entry->mem = 0; | 1247 | entry->mem = 0; |
1209 | 1248 | ||
1210 | /* Misc features */ | 1249 | /* Misc features */ |
1211 | if (features & 0x80) { | 1250 | if (features & 0x80) { |
1212 | if (p == q) return CS_BAD_TUPLE; | 1251 | if (p == q) |
1252 | return -EINVAL; | ||
1213 | entry->flags |= (*p << 8); | 1253 | entry->flags |= (*p << 8); |
1214 | if (*p & 0x80) { | 1254 | if (*p & 0x80) { |
1215 | if (++p == q) return CS_BAD_TUPLE; | 1255 | if (++p == q) |
1256 | return -EINVAL; | ||
1216 | entry->flags |= (*p << 16); | 1257 | entry->flags |= (*p << 16); |
1217 | } | 1258 | } |
1218 | while (*p & 0x80) | 1259 | while (*p & 0x80) |
1219 | if (++p == q) return CS_BAD_TUPLE; | 1260 | if (++p == q) |
1261 | return -EINVAL; | ||
1220 | p++; | 1262 | p++; |
1221 | } | 1263 | } |
1222 | 1264 | ||
1223 | entry->subtuples = q-p; | 1265 | entry->subtuples = q-p; |
1224 | 1266 | ||
1225 | return CS_SUCCESS; | 1267 | return 0; |
1226 | } | 1268 | } |
1227 | 1269 | ||
1228 | #endif | 1270 | #endif |
@@ -1248,7 +1290,7 @@ static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo) | |||
1248 | p += 6; | 1290 | p += 6; |
1249 | } | 1291 | } |
1250 | geo->ngeo = n; | 1292 | geo->ngeo = n; |
1251 | return CS_SUCCESS; | 1293 | return 0; |
1252 | } | 1294 | } |
1253 | 1295 | ||
1254 | /*====================================================================*/ | 1296 | /*====================================================================*/ |
@@ -1258,7 +1300,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2) | |||
1258 | u_char *p, *q; | 1300 | u_char *p, *q; |
1259 | 1301 | ||
1260 | if (tuple->TupleDataLen < 10) | 1302 | if (tuple->TupleDataLen < 10) |
1261 | return CS_BAD_TUPLE; | 1303 | return -EINVAL; |
1262 | 1304 | ||
1263 | p = tuple->TupleData; | 1305 | p = tuple->TupleData; |
1264 | q = p + tuple->TupleDataLen; | 1306 | q = p + tuple->TupleDataLen; |
@@ -1282,15 +1324,18 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org) | |||
1282 | 1324 | ||
1283 | p = tuple->TupleData; | 1325 | p = tuple->TupleData; |
1284 | q = p + tuple->TupleDataLen; | 1326 | q = p + tuple->TupleDataLen; |
1285 | if (p == q) return CS_BAD_TUPLE; | 1327 | if (p == q) |
1328 | return -EINVAL; | ||
1286 | org->data_org = *p; | 1329 | org->data_org = *p; |
1287 | if (++p == q) return CS_BAD_TUPLE; | 1330 | if (++p == q) |
1331 | return -EINVAL; | ||
1288 | for (i = 0; i < 30; i++) { | 1332 | for (i = 0; i < 30; i++) { |
1289 | org->desc[i] = *p; | 1333 | org->desc[i] = *p; |
1290 | if (*p == '\0') break; | 1334 | if (*p == '\0') break; |
1291 | if (++p == q) return CS_BAD_TUPLE; | 1335 | if (++p == q) |
1336 | return -EINVAL; | ||
1292 | } | 1337 | } |
1293 | return CS_SUCCESS; | 1338 | return 0; |
1294 | } | 1339 | } |
1295 | 1340 | ||
1296 | /*====================================================================*/ | 1341 | /*====================================================================*/ |
@@ -1300,7 +1345,7 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) | |||
1300 | u_char *p; | 1345 | u_char *p; |
1301 | 1346 | ||
1302 | if (tuple->TupleDataLen < 10) | 1347 | if (tuple->TupleDataLen < 10) |
1303 | return CS_BAD_TUPLE; | 1348 | return -EINVAL; |
1304 | 1349 | ||
1305 | p = tuple->TupleData; | 1350 | p = tuple->TupleData; |
1306 | 1351 | ||
@@ -1309,17 +1354,17 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) | |||
1309 | fmt->offset = get_unaligned_le32(p + 2); | 1354 | fmt->offset = get_unaligned_le32(p + 2); |
1310 | fmt->length = get_unaligned_le32(p + 6); | 1355 | fmt->length = get_unaligned_le32(p + 6); |
1311 | 1356 | ||
1312 | return CS_SUCCESS; | 1357 | return 0; |
1313 | } | 1358 | } |
1314 | 1359 | ||
1315 | /*====================================================================*/ | 1360 | /*====================================================================*/ |
1316 | 1361 | ||
1317 | int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) | 1362 | int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse) |
1318 | { | 1363 | { |
1319 | int ret = CS_SUCCESS; | 1364 | int ret = 0; |
1320 | 1365 | ||
1321 | if (tuple->TupleDataLen > tuple->TupleDataMax) | 1366 | if (tuple->TupleDataLen > tuple->TupleDataMax) |
1322 | return CS_BAD_TUPLE; | 1367 | return -EINVAL; |
1323 | switch (tuple->TupleCode) { | 1368 | switch (tuple->TupleCode) { |
1324 | case CISTPL_DEVICE: | 1369 | case CISTPL_DEVICE: |
1325 | case CISTPL_DEVICE_A: | 1370 | case CISTPL_DEVICE_A: |
@@ -1387,15 +1432,17 @@ int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) | |||
1387 | break; | 1432 | break; |
1388 | case CISTPL_NO_LINK: | 1433 | case CISTPL_NO_LINK: |
1389 | case CISTPL_LINKTARGET: | 1434 | case CISTPL_LINKTARGET: |
1390 | ret = CS_SUCCESS; | 1435 | ret = 0; |
1391 | break; | 1436 | break; |
1392 | default: | 1437 | default: |
1393 | ret = CS_UNSUPPORTED_FUNCTION; | 1438 | ret = -EINVAL; |
1394 | break; | 1439 | break; |
1395 | } | 1440 | } |
1441 | if (ret) | ||
1442 | __cs_dbg(0, "parse_tuple failed %d\n", ret); | ||
1396 | return ret; | 1443 | return ret; |
1397 | } | 1444 | } |
1398 | EXPORT_SYMBOL(pccard_parse_tuple); | 1445 | EXPORT_SYMBOL(pcmcia_parse_tuple); |
1399 | 1446 | ||
1400 | /*====================================================================== | 1447 | /*====================================================================== |
1401 | 1448 | ||
@@ -1410,18 +1457,22 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t | |||
1410 | int ret; | 1457 | int ret; |
1411 | 1458 | ||
1412 | buf = kmalloc(256, GFP_KERNEL); | 1459 | buf = kmalloc(256, GFP_KERNEL); |
1413 | if (buf == NULL) | 1460 | if (buf == NULL) { |
1414 | return CS_OUT_OF_RESOURCE; | 1461 | dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n"); |
1462 | return -ENOMEM; | ||
1463 | } | ||
1415 | tuple.DesiredTuple = code; | 1464 | tuple.DesiredTuple = code; |
1416 | tuple.Attributes = TUPLE_RETURN_COMMON; | 1465 | tuple.Attributes = TUPLE_RETURN_COMMON; |
1417 | ret = pccard_get_first_tuple(s, function, &tuple); | 1466 | ret = pccard_get_first_tuple(s, function, &tuple); |
1418 | if (ret != CS_SUCCESS) goto done; | 1467 | if (ret != 0) |
1468 | goto done; | ||
1419 | tuple.TupleData = buf; | 1469 | tuple.TupleData = buf; |
1420 | tuple.TupleOffset = 0; | 1470 | tuple.TupleOffset = 0; |
1421 | tuple.TupleDataMax = 255; | 1471 | tuple.TupleDataMax = 255; |
1422 | ret = pccard_get_tuple_data(s, &tuple); | 1472 | ret = pccard_get_tuple_data(s, &tuple); |
1423 | if (ret != CS_SUCCESS) goto done; | 1473 | if (ret != 0) |
1424 | ret = pccard_parse_tuple(&tuple, parse); | 1474 | goto done; |
1475 | ret = pcmcia_parse_tuple(&tuple, parse); | ||
1425 | done: | 1476 | done: |
1426 | kfree(buf); | 1477 | kfree(buf); |
1427 | return ret; | 1478 | return ret; |
@@ -1446,37 +1497,40 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned | |||
1446 | int ret, reserved, dev_ok = 0, ident_ok = 0; | 1497 | int ret, reserved, dev_ok = 0, ident_ok = 0; |
1447 | 1498 | ||
1448 | if (!s) | 1499 | if (!s) |
1449 | return CS_BAD_HANDLE; | 1500 | return -EINVAL; |
1450 | 1501 | ||
1451 | tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); | 1502 | tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); |
1452 | if (tuple == NULL) | 1503 | if (tuple == NULL) { |
1453 | return CS_OUT_OF_RESOURCE; | 1504 | dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); |
1505 | return -ENOMEM; | ||
1506 | } | ||
1454 | p = kmalloc(sizeof(*p), GFP_KERNEL); | 1507 | p = kmalloc(sizeof(*p), GFP_KERNEL); |
1455 | if (p == NULL) { | 1508 | if (p == NULL) { |
1456 | kfree(tuple); | 1509 | kfree(tuple); |
1457 | return CS_OUT_OF_RESOURCE; | 1510 | dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n"); |
1511 | return -ENOMEM; | ||
1458 | } | 1512 | } |
1459 | 1513 | ||
1460 | count = reserved = 0; | 1514 | count = reserved = 0; |
1461 | tuple->DesiredTuple = RETURN_FIRST_TUPLE; | 1515 | tuple->DesiredTuple = RETURN_FIRST_TUPLE; |
1462 | tuple->Attributes = TUPLE_RETURN_COMMON; | 1516 | tuple->Attributes = TUPLE_RETURN_COMMON; |
1463 | ret = pccard_get_first_tuple(s, function, tuple); | 1517 | ret = pccard_get_first_tuple(s, function, tuple); |
1464 | if (ret != CS_SUCCESS) | 1518 | if (ret != 0) |
1465 | goto done; | 1519 | goto done; |
1466 | 1520 | ||
1467 | /* First tuple should be DEVICE; we should really have either that | 1521 | /* First tuple should be DEVICE; we should really have either that |
1468 | or a CFTABLE_ENTRY of some sort */ | 1522 | or a CFTABLE_ENTRY of some sort */ |
1469 | if ((tuple->TupleCode == CISTPL_DEVICE) || | 1523 | if ((tuple->TupleCode == CISTPL_DEVICE) || |
1470 | (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) || | 1524 | (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == 0) || |
1471 | (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS)) | 1525 | (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == 0)) |
1472 | dev_ok++; | 1526 | dev_ok++; |
1473 | 1527 | ||
1474 | /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 | 1528 | /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 |
1475 | tuple, for card identification. Certain old D-Link and Linksys | 1529 | tuple, for card identification. Certain old D-Link and Linksys |
1476 | cards have only a broken VERS_2 tuple; hence the bogus test. */ | 1530 | cards have only a broken VERS_2 tuple; hence the bogus test. */ |
1477 | if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == CS_SUCCESS) || | 1531 | if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) || |
1478 | (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == CS_SUCCESS) || | 1532 | (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) || |
1479 | (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS)) | 1533 | (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC)) |
1480 | ident_ok++; | 1534 | ident_ok++; |
1481 | 1535 | ||
1482 | if (!dev_ok && !ident_ok) | 1536 | if (!dev_ok && !ident_ok) |
@@ -1484,7 +1538,8 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned | |||
1484 | 1538 | ||
1485 | for (count = 1; count < MAX_TUPLES; count++) { | 1539 | for (count = 1; count < MAX_TUPLES; count++) { |
1486 | ret = pccard_get_next_tuple(s, function, tuple); | 1540 | ret = pccard_get_next_tuple(s, function, tuple); |
1487 | if (ret != CS_SUCCESS) break; | 1541 | if (ret != 0) |
1542 | break; | ||
1488 | if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || | 1543 | if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || |
1489 | ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) || | 1544 | ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) || |
1490 | ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff))) | 1545 | ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff))) |
@@ -1499,6 +1554,6 @@ done: | |||
1499 | *info = count; | 1554 | *info = count; |
1500 | kfree(tuple); | 1555 | kfree(tuple); |
1501 | kfree(p); | 1556 | kfree(p); |
1502 | return CS_SUCCESS; | 1557 | return 0; |
1503 | } | 1558 | } |
1504 | EXPORT_SYMBOL(pccard_validate_cis); | 1559 | EXPORT_SYMBOL(pccard_validate_cis); |
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index d1207393fc3e..c68c5d338285 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c | |||
@@ -61,7 +61,7 @@ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */ | |||
61 | /* Access speed for attribute memory windows */ | 61 | /* Access speed for attribute memory windows */ |
62 | INT_MODULE_PARM(cis_speed, 300); /* ns */ | 62 | INT_MODULE_PARM(cis_speed, 300); /* ns */ |
63 | 63 | ||
64 | #ifdef DEBUG | 64 | #ifdef CONFIG_PCMCIA_DEBUG |
65 | static int pc_debug; | 65 | static int pc_debug; |
66 | 66 | ||
67 | module_param(pc_debug, int, 0644); | 67 | module_param(pc_debug, int, 0644); |
@@ -247,7 +247,8 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) | |||
247 | 247 | ||
248 | wait_for_completion(&socket->thread_done); | 248 | wait_for_completion(&socket->thread_done); |
249 | if (!socket->thread) { | 249 | if (!socket->thread) { |
250 | printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket); | 250 | dev_printk(KERN_WARNING, &socket->dev, |
251 | "PCMCIA: warning: socket thread did not start\n"); | ||
251 | return -EIO; | 252 | return -EIO; |
252 | } | 253 | } |
253 | 254 | ||
@@ -366,16 +367,16 @@ static int socket_reset(struct pcmcia_socket *skt) | |||
366 | skt->ops->get_status(skt, &status); | 367 | skt->ops->get_status(skt, &status); |
367 | 368 | ||
368 | if (!(status & SS_DETECT)) | 369 | if (!(status & SS_DETECT)) |
369 | return CS_NO_CARD; | 370 | return -ENODEV; |
370 | 371 | ||
371 | if (status & SS_READY) | 372 | if (status & SS_READY) |
372 | return CS_SUCCESS; | 373 | return 0; |
373 | 374 | ||
374 | msleep(unreset_check * 10); | 375 | msleep(unreset_check * 10); |
375 | } | 376 | } |
376 | 377 | ||
377 | cs_err(skt, "time out after reset.\n"); | 378 | cs_err(skt, "time out after reset.\n"); |
378 | return CS_GENERAL_FAILURE; | 379 | return -ETIMEDOUT; |
379 | } | 380 | } |
380 | 381 | ||
381 | /* | 382 | /* |
@@ -412,7 +413,8 @@ static void socket_shutdown(struct pcmcia_socket *s) | |||
412 | 413 | ||
413 | s->ops->get_status(s, &status); | 414 | s->ops->get_status(s, &status); |
414 | if (status & SS_POWERON) { | 415 | if (status & SS_POWERON) { |
415 | printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); | 416 | dev_printk(KERN_ERR, &s->dev, |
417 | "*** DANGER *** unable to remove socket power\n"); | ||
416 | } | 418 | } |
417 | 419 | ||
418 | cs_socket_put(s); | 420 | cs_socket_put(s); |
@@ -426,14 +428,14 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) | |||
426 | 428 | ||
427 | skt->ops->get_status(skt, &status); | 429 | skt->ops->get_status(skt, &status); |
428 | if (!(status & SS_DETECT)) | 430 | if (!(status & SS_DETECT)) |
429 | return CS_NO_CARD; | 431 | return -ENODEV; |
430 | 432 | ||
431 | msleep(initial_delay * 10); | 433 | msleep(initial_delay * 10); |
432 | 434 | ||
433 | for (i = 0; i < 100; i++) { | 435 | for (i = 0; i < 100; i++) { |
434 | skt->ops->get_status(skt, &status); | 436 | skt->ops->get_status(skt, &status); |
435 | if (!(status & SS_DETECT)) | 437 | if (!(status & SS_DETECT)) |
436 | return CS_NO_CARD; | 438 | return -ENODEV; |
437 | 439 | ||
438 | if (!(status & SS_PENDING)) | 440 | if (!(status & SS_PENDING)) |
439 | break; | 441 | break; |
@@ -443,13 +445,13 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) | |||
443 | 445 | ||
444 | if (status & SS_PENDING) { | 446 | if (status & SS_PENDING) { |
445 | cs_err(skt, "voltage interrogation timed out.\n"); | 447 | cs_err(skt, "voltage interrogation timed out.\n"); |
446 | return CS_GENERAL_FAILURE; | 448 | return -ETIMEDOUT; |
447 | } | 449 | } |
448 | 450 | ||
449 | if (status & SS_CARDBUS) { | 451 | if (status & SS_CARDBUS) { |
450 | if (!(skt->features & SS_CAP_CARDBUS)) { | 452 | if (!(skt->features & SS_CAP_CARDBUS)) { |
451 | cs_err(skt, "cardbus cards are not supported.\n"); | 453 | cs_err(skt, "cardbus cards are not supported.\n"); |
452 | return CS_BAD_TYPE; | 454 | return -EINVAL; |
453 | } | 455 | } |
454 | skt->state |= SOCKET_CARDBUS; | 456 | skt->state |= SOCKET_CARDBUS; |
455 | } | 457 | } |
@@ -463,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) | |||
463 | skt->socket.Vcc = skt->socket.Vpp = 50; | 465 | skt->socket.Vcc = skt->socket.Vpp = 50; |
464 | else { | 466 | else { |
465 | cs_err(skt, "unsupported voltage key.\n"); | 467 | cs_err(skt, "unsupported voltage key.\n"); |
466 | return CS_BAD_TYPE; | 468 | return -EIO; |
467 | } | 469 | } |
468 | 470 | ||
469 | if (skt->power_hook) | 471 | if (skt->power_hook) |
@@ -480,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) | |||
480 | skt->ops->get_status(skt, &status); | 482 | skt->ops->get_status(skt, &status); |
481 | if (!(status & SS_POWERON)) { | 483 | if (!(status & SS_POWERON)) { |
482 | cs_err(skt, "unable to apply power.\n"); | 484 | cs_err(skt, "unable to apply power.\n"); |
483 | return CS_BAD_TYPE; | 485 | return -EIO; |
484 | } | 486 | } |
485 | 487 | ||
486 | status = socket_reset(skt); | 488 | status = socket_reset(skt); |
@@ -502,15 +504,16 @@ static int socket_insert(struct pcmcia_socket *skt) | |||
502 | cs_dbg(skt, 4, "insert\n"); | 504 | cs_dbg(skt, 4, "insert\n"); |
503 | 505 | ||
504 | if (!cs_socket_get(skt)) | 506 | if (!cs_socket_get(skt)) |
505 | return CS_NO_CARD; | 507 | return -ENODEV; |
506 | 508 | ||
507 | ret = socket_setup(skt, setup_delay); | 509 | ret = socket_setup(skt, setup_delay); |
508 | if (ret == CS_SUCCESS) { | 510 | if (ret == 0) { |
509 | skt->state |= SOCKET_PRESENT; | 511 | skt->state |= SOCKET_PRESENT; |
510 | 512 | ||
511 | printk(KERN_NOTICE "pccard: %s card inserted into slot %d\n", | 513 | dev_printk(KERN_NOTICE, &skt->dev, |
512 | (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", | 514 | "pccard: %s card inserted into slot %d\n", |
513 | skt->sock); | 515 | (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", |
516 | skt->sock); | ||
514 | 517 | ||
515 | #ifdef CONFIG_CARDBUS | 518 | #ifdef CONFIG_CARDBUS |
516 | if (skt->state & SOCKET_CARDBUS) { | 519 | if (skt->state & SOCKET_CARDBUS) { |
@@ -531,7 +534,7 @@ static int socket_insert(struct pcmcia_socket *skt) | |||
531 | static int socket_suspend(struct pcmcia_socket *skt) | 534 | static int socket_suspend(struct pcmcia_socket *skt) |
532 | { | 535 | { |
533 | if (skt->state & SOCKET_SUSPEND) | 536 | if (skt->state & SOCKET_SUSPEND) |
534 | return CS_IN_USE; | 537 | return -EBUSY; |
535 | 538 | ||
536 | send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); | 539 | send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); |
537 | skt->socket = dead_socket; | 540 | skt->socket = dead_socket; |
@@ -540,7 +543,7 @@ static int socket_suspend(struct pcmcia_socket *skt) | |||
540 | skt->ops->suspend(skt); | 543 | skt->ops->suspend(skt); |
541 | skt->state |= SOCKET_SUSPEND; | 544 | skt->state |= SOCKET_SUSPEND; |
542 | 545 | ||
543 | return CS_SUCCESS; | 546 | return 0; |
544 | } | 547 | } |
545 | 548 | ||
546 | /* | 549 | /* |
@@ -553,7 +556,7 @@ static int socket_resume(struct pcmcia_socket *skt) | |||
553 | int ret; | 556 | int ret; |
554 | 557 | ||
555 | if (!(skt->state & SOCKET_SUSPEND)) | 558 | if (!(skt->state & SOCKET_SUSPEND)) |
556 | return CS_IN_USE; | 559 | return -EBUSY; |
557 | 560 | ||
558 | skt->socket = dead_socket; | 561 | skt->socket = dead_socket; |
559 | skt->ops->init(skt); | 562 | skt->ops->init(skt); |
@@ -565,7 +568,7 @@ static int socket_resume(struct pcmcia_socket *skt) | |||
565 | } | 568 | } |
566 | 569 | ||
567 | ret = socket_setup(skt, resume_delay); | 570 | ret = socket_setup(skt, resume_delay); |
568 | if (ret == CS_SUCCESS) { | 571 | if (ret == 0) { |
569 | /* | 572 | /* |
570 | * FIXME: need a better check here for cardbus cards. | 573 | * FIXME: need a better check here for cardbus cards. |
571 | */ | 574 | */ |
@@ -590,12 +593,13 @@ static int socket_resume(struct pcmcia_socket *skt) | |||
590 | 593 | ||
591 | skt->state &= ~SOCKET_SUSPEND; | 594 | skt->state &= ~SOCKET_SUSPEND; |
592 | 595 | ||
593 | return CS_SUCCESS; | 596 | return 0; |
594 | } | 597 | } |
595 | 598 | ||
596 | static void socket_remove(struct pcmcia_socket *skt) | 599 | static void socket_remove(struct pcmcia_socket *skt) |
597 | { | 600 | { |
598 | printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock); | 601 | dev_printk(KERN_NOTICE, &skt->dev, |
602 | "pccard: card ejected from slot %d\n", skt->sock); | ||
599 | socket_shutdown(skt); | 603 | socket_shutdown(skt); |
600 | } | 604 | } |
601 | 605 | ||
@@ -641,8 +645,8 @@ static int pccardd(void *__skt) | |||
641 | /* register with the device core */ | 645 | /* register with the device core */ |
642 | ret = device_register(&skt->dev); | 646 | ret = device_register(&skt->dev); |
643 | if (ret) { | 647 | if (ret) { |
644 | printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n", | 648 | dev_printk(KERN_WARNING, &skt->dev, |
645 | skt); | 649 | "PCMCIA: unable to register socket\n"); |
646 | skt->thread = NULL; | 650 | skt->thread = NULL; |
647 | complete(&skt->thread_done); | 651 | complete(&skt->thread_done); |
648 | return 0; | 652 | return 0; |
@@ -748,7 +752,7 @@ EXPORT_SYMBOL(pccard_register_pcmcia); | |||
748 | * CIS register. | 752 | * CIS register. |
749 | */ | 753 | */ |
750 | 754 | ||
751 | int pccard_reset_card(struct pcmcia_socket *skt) | 755 | int pcmcia_reset_card(struct pcmcia_socket *skt) |
752 | { | 756 | { |
753 | int ret; | 757 | int ret; |
754 | 758 | ||
@@ -757,15 +761,15 @@ int pccard_reset_card(struct pcmcia_socket *skt) | |||
757 | mutex_lock(&skt->skt_mutex); | 761 | mutex_lock(&skt->skt_mutex); |
758 | do { | 762 | do { |
759 | if (!(skt->state & SOCKET_PRESENT)) { | 763 | if (!(skt->state & SOCKET_PRESENT)) { |
760 | ret = CS_NO_CARD; | 764 | ret = -ENODEV; |
761 | break; | 765 | break; |
762 | } | 766 | } |
763 | if (skt->state & SOCKET_SUSPEND) { | 767 | if (skt->state & SOCKET_SUSPEND) { |
764 | ret = CS_IN_USE; | 768 | ret = -EBUSY; |
765 | break; | 769 | break; |
766 | } | 770 | } |
767 | if (skt->state & SOCKET_CARDBUS) { | 771 | if (skt->state & SOCKET_CARDBUS) { |
768 | ret = CS_UNSUPPORTED_FUNCTION; | 772 | ret = -EPERM; |
769 | break; | 773 | break; |
770 | } | 774 | } |
771 | 775 | ||
@@ -774,20 +778,20 @@ int pccard_reset_card(struct pcmcia_socket *skt) | |||
774 | send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); | 778 | send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); |
775 | if (skt->callback) | 779 | if (skt->callback) |
776 | skt->callback->suspend(skt); | 780 | skt->callback->suspend(skt); |
777 | if (socket_reset(skt) == CS_SUCCESS) { | 781 | if (socket_reset(skt) == 0) { |
778 | send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); | 782 | send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); |
779 | if (skt->callback) | 783 | if (skt->callback) |
780 | skt->callback->resume(skt); | 784 | skt->callback->resume(skt); |
781 | } | 785 | } |
782 | } | 786 | } |
783 | 787 | ||
784 | ret = CS_SUCCESS; | 788 | ret = 0; |
785 | } while (0); | 789 | } while (0); |
786 | mutex_unlock(&skt->skt_mutex); | 790 | mutex_unlock(&skt->skt_mutex); |
787 | 791 | ||
788 | return ret; | 792 | return ret; |
789 | } /* reset_card */ | 793 | } /* reset_card */ |
790 | EXPORT_SYMBOL(pccard_reset_card); | 794 | EXPORT_SYMBOL(pcmcia_reset_card); |
791 | 795 | ||
792 | 796 | ||
793 | /* These shut down or wake up a socket. They are sort of user | 797 | /* These shut down or wake up a socket. They are sort of user |
@@ -802,11 +806,11 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt) | |||
802 | mutex_lock(&skt->skt_mutex); | 806 | mutex_lock(&skt->skt_mutex); |
803 | do { | 807 | do { |
804 | if (!(skt->state & SOCKET_PRESENT)) { | 808 | if (!(skt->state & SOCKET_PRESENT)) { |
805 | ret = CS_NO_CARD; | 809 | ret = -ENODEV; |
806 | break; | 810 | break; |
807 | } | 811 | } |
808 | if (skt->state & SOCKET_CARDBUS) { | 812 | if (skt->state & SOCKET_CARDBUS) { |
809 | ret = CS_UNSUPPORTED_FUNCTION; | 813 | ret = -EPERM; |
810 | break; | 814 | break; |
811 | } | 815 | } |
812 | if (skt->callback) { | 816 | if (skt->callback) { |
@@ -832,11 +836,11 @@ int pcmcia_resume_card(struct pcmcia_socket *skt) | |||
832 | mutex_lock(&skt->skt_mutex); | 836 | mutex_lock(&skt->skt_mutex); |
833 | do { | 837 | do { |
834 | if (!(skt->state & SOCKET_PRESENT)) { | 838 | if (!(skt->state & SOCKET_PRESENT)) { |
835 | ret = CS_NO_CARD; | 839 | ret = -ENODEV; |
836 | break; | 840 | break; |
837 | } | 841 | } |
838 | if (skt->state & SOCKET_CARDBUS) { | 842 | if (skt->state & SOCKET_CARDBUS) { |
839 | ret = CS_UNSUPPORTED_FUNCTION; | 843 | ret = -EPERM; |
840 | break; | 844 | break; |
841 | } | 845 | } |
842 | ret = socket_resume(skt); | 846 | ret = socket_resume(skt); |
@@ -892,7 +896,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt) | |||
892 | ret = -EBUSY; | 896 | ret = -EBUSY; |
893 | break; | 897 | break; |
894 | } | 898 | } |
895 | if (socket_insert(skt) == CS_NO_CARD) { | 899 | if (socket_insert(skt) == -ENODEV) { |
896 | ret = -ENODEV; | 900 | ret = -ENODEV; |
897 | break; | 901 | break; |
898 | } | 902 | } |
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 63dc1a28bda2..79615e6d540b 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * cs_internal.h | 2 | * cs_internal.h -- definitions internal to the PCMCIA core modules |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License version 2 as | 5 | * it under the terms of the GNU General Public License version 2 as |
@@ -10,6 +10,12 @@ | |||
10 | * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. | 10 | * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. |
11 | * | 11 | * |
12 | * (C) 1999 David A. Hinds | 12 | * (C) 1999 David A. Hinds |
13 | * (C) 2003 - 2008 Dominik Brodowski | ||
14 | * | ||
15 | * | ||
16 | * This file contains definitions _only_ needed by the PCMCIA core modules. | ||
17 | * It must not be included by PCMCIA socket drivers or by PCMCIA device | ||
18 | * drivers. | ||
13 | */ | 19 | */ |
14 | 20 | ||
15 | #ifndef _LINUX_CS_INTERNAL_H | 21 | #ifndef _LINUX_CS_INTERNAL_H |
@@ -18,29 +24,24 @@ | |||
18 | #include <linux/kref.h> | 24 | #include <linux/kref.h> |
19 | 25 | ||
20 | /* Flags in client state */ | 26 | /* Flags in client state */ |
21 | #define CLIENT_CONFIG_LOCKED 0x0001 | ||
22 | #define CLIENT_IRQ_REQ 0x0002 | ||
23 | #define CLIENT_IO_REQ 0x0004 | ||
24 | #define CLIENT_UNBOUND 0x0008 | ||
25 | #define CLIENT_STALE 0x0010 | ||
26 | #define CLIENT_WIN_REQ(i) (0x1<<(i)) | 27 | #define CLIENT_WIN_REQ(i) (0x1<<(i)) |
27 | #define CLIENT_CARDBUS 0x8000 | ||
28 | 28 | ||
29 | /* Each card function gets one of these guys */ | 29 | /* Each card function gets one of these guys */ |
30 | typedef struct config_t { | 30 | typedef struct config_t { |
31 | struct kref ref; | 31 | struct kref ref; |
32 | u_int state; | 32 | unsigned int state; |
33 | u_int Attributes; | 33 | unsigned int Attributes; |
34 | u_int IntType; | 34 | unsigned int IntType; |
35 | u_int ConfigBase; | 35 | unsigned int ConfigBase; |
36 | u_char Status, Pin, Copy, Option, ExtStatus; | 36 | unsigned char Status, Pin, Copy, Option, ExtStatus; |
37 | u_int CardValues; | 37 | unsigned int CardValues; |
38 | io_req_t io; | 38 | io_req_t io; |
39 | struct { | 39 | struct { |
40 | u_int Attributes; | 40 | u_int Attributes; |
41 | } irq; | 41 | } irq; |
42 | } config_t; | 42 | } config_t; |
43 | 43 | ||
44 | |||
44 | struct cis_cache_entry { | 45 | struct cis_cache_entry { |
45 | struct list_head node; | 46 | struct list_head node; |
46 | unsigned int addr; | 47 | unsigned int addr; |
@@ -49,6 +50,30 @@ struct cis_cache_entry { | |||
49 | unsigned char cache[0]; | 50 | unsigned char cache[0]; |
50 | }; | 51 | }; |
51 | 52 | ||
53 | struct pccard_resource_ops { | ||
54 | int (*validate_mem) (struct pcmcia_socket *s); | ||
55 | int (*adjust_io_region) (struct resource *res, | ||
56 | unsigned long r_start, | ||
57 | unsigned long r_end, | ||
58 | struct pcmcia_socket *s); | ||
59 | struct resource* (*find_io) (unsigned long base, int num, | ||
60 | unsigned long align, | ||
61 | struct pcmcia_socket *s); | ||
62 | struct resource* (*find_mem) (unsigned long base, unsigned long num, | ||
63 | unsigned long align, int low, | ||
64 | struct pcmcia_socket *s); | ||
65 | int (*add_io) (struct pcmcia_socket *s, | ||
66 | unsigned int action, | ||
67 | unsigned long r_start, | ||
68 | unsigned long r_end); | ||
69 | int (*add_mem) (struct pcmcia_socket *s, | ||
70 | unsigned int action, | ||
71 | unsigned long r_start, | ||
72 | unsigned long r_end); | ||
73 | int (*init) (struct pcmcia_socket *s); | ||
74 | void (*exit) (struct pcmcia_socket *s); | ||
75 | }; | ||
76 | |||
52 | /* Flags in config state */ | 77 | /* Flags in config state */ |
53 | #define CONFIG_LOCKED 0x01 | 78 | #define CONFIG_LOCKED 0x01 |
54 | #define CONFIG_IRQ_REQ 0x02 | 79 | #define CONFIG_IRQ_REQ 0x02 |
@@ -59,7 +84,6 @@ struct cis_cache_entry { | |||
59 | #define SOCKET_INUSE 0x0010 | 84 | #define SOCKET_INUSE 0x0010 |
60 | #define SOCKET_SUSPEND 0x0080 | 85 | #define SOCKET_SUSPEND 0x0080 |
61 | #define SOCKET_WIN_REQ(i) (0x0100<<(i)) | 86 | #define SOCKET_WIN_REQ(i) (0x0100<<(i)) |
62 | #define SOCKET_REGION_INFO 0x4000 | ||
63 | #define SOCKET_CARDBUS 0x8000 | 87 | #define SOCKET_CARDBUS 0x8000 |
64 | #define SOCKET_CARDBUS_CONFIG 0x10000 | 88 | #define SOCKET_CARDBUS_CONFIG 0x10000 |
65 | 89 | ||
@@ -83,69 +107,153 @@ static inline void cs_socket_put(struct pcmcia_socket *skt) | |||
83 | } | 107 | } |
84 | } | 108 | } |
85 | 109 | ||
86 | /* In cardbus.c */ | 110 | #ifdef CONFIG_PCMCIA_DEBUG |
87 | int cb_alloc(struct pcmcia_socket *s); | 111 | extern int cs_debug_level(int); |
88 | void cb_free(struct pcmcia_socket *s); | ||
89 | int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, void *ptr); | ||
90 | 112 | ||
91 | /* In cistpl.c */ | 113 | #define cs_dbg(skt, lvl, fmt, arg...) do { \ |
92 | int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, | 114 | if (cs_debug_level(lvl)) \ |
93 | u_int addr, u_int len, void *ptr); | 115 | dev_printk(KERN_DEBUG, &skt->dev, \ |
94 | void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, | 116 | "cs: " fmt, ## arg); \ |
95 | u_int addr, u_int len, void *ptr); | 117 | } while (0) |
96 | void release_cis_mem(struct pcmcia_socket *s); | 118 | #define __cs_dbg(lvl, fmt, arg...) do { \ |
97 | void destroy_cis_cache(struct pcmcia_socket *s); | 119 | if (cs_debug_level(lvl)) \ |
120 | printk(KERN_DEBUG \ | ||
121 | "cs: " fmt, ## arg); \ | ||
122 | } while (0) | ||
123 | |||
124 | #else | ||
125 | #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0) | ||
126 | #define __cs_dbg(lvl, fmt, arg...) do { } while (0) | ||
127 | #endif | ||
128 | |||
129 | #define cs_err(skt, fmt, arg...) \ | ||
130 | dev_printk(KERN_ERR, &skt->dev, "cs: " fmt, ## arg) | ||
131 | |||
132 | |||
133 | /* | ||
134 | * Stuff internal to module "pcmcia_core": | ||
135 | */ | ||
136 | |||
137 | /* cistpl.c */ | ||
98 | int verify_cis_cache(struct pcmcia_socket *s); | 138 | int verify_cis_cache(struct pcmcia_socket *s); |
99 | int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse); | ||
100 | 139 | ||
101 | /* In rsrc_mgr */ | 140 | /* rsrc_mgr.c */ |
102 | int pcmcia_validate_mem(struct pcmcia_socket *s); | ||
103 | struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, | ||
104 | struct pcmcia_socket *s); | ||
105 | int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, | ||
106 | unsigned long r_end, struct pcmcia_socket *s); | ||
107 | struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align, | ||
108 | int low, struct pcmcia_socket *s); | ||
109 | void release_resource_db(struct pcmcia_socket *s); | 141 | void release_resource_db(struct pcmcia_socket *s); |
110 | 142 | ||
111 | /* In socket_sysfs.c */ | 143 | /* socket_sysfs.c */ |
112 | extern int pccard_sysfs_add_socket(struct device *dev); | 144 | extern int pccard_sysfs_add_socket(struct device *dev); |
113 | extern void pccard_sysfs_remove_socket(struct device *dev); | 145 | extern void pccard_sysfs_remove_socket(struct device *dev); |
114 | 146 | ||
115 | /* In cs.c */ | 147 | /* cardbus.c */ |
116 | extern struct rw_semaphore pcmcia_socket_list_rwsem; | 148 | int cb_alloc(struct pcmcia_socket *s); |
117 | extern struct list_head pcmcia_socket_list; | 149 | void cb_free(struct pcmcia_socket *s); |
118 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); | 150 | int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, |
119 | int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); | 151 | void *ptr); |
120 | int pccard_reset_card(struct pcmcia_socket *skt); | 152 | |
121 | 153 | ||
122 | 154 | ||
155 | /* | ||
156 | * Stuff exported by module "pcmcia_core" to module "pcmcia" | ||
157 | */ | ||
158 | |||
123 | struct pcmcia_callback{ | 159 | struct pcmcia_callback{ |
124 | struct module *owner; | 160 | struct module *owner; |
125 | int (*event) (struct pcmcia_socket *s, event_t event, int priority); | 161 | int (*event) (struct pcmcia_socket *s, |
162 | event_t event, int priority); | ||
126 | void (*requery) (struct pcmcia_socket *s, int new_cis); | 163 | void (*requery) (struct pcmcia_socket *s, int new_cis); |
127 | int (*suspend) (struct pcmcia_socket *s); | 164 | int (*suspend) (struct pcmcia_socket *s); |
128 | int (*resume) (struct pcmcia_socket *s); | 165 | int (*resume) (struct pcmcia_socket *s); |
129 | }; | 166 | }; |
130 | 167 | ||
168 | /* cs.c */ | ||
169 | extern struct rw_semaphore pcmcia_socket_list_rwsem; | ||
170 | extern struct list_head pcmcia_socket_list; | ||
171 | extern struct class pcmcia_socket_class; | ||
172 | |||
173 | int pcmcia_get_window(struct pcmcia_socket *s, | ||
174 | window_handle_t *handle, | ||
175 | int idx, | ||
176 | win_req_t *req); | ||
131 | int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); | 177 | int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); |
178 | struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); | ||
132 | 179 | ||
133 | #define cs_socket_name(skt) ((skt)->dev.bus_id) | 180 | int pcmcia_suspend_card(struct pcmcia_socket *skt); |
181 | int pcmcia_resume_card(struct pcmcia_socket *skt); | ||
134 | 182 | ||
135 | #ifdef DEBUG | 183 | int pcmcia_eject_card(struct pcmcia_socket *skt); |
136 | extern int cs_debug_level(int); | 184 | int pcmcia_insert_card(struct pcmcia_socket *skt); |
137 | 185 | ||
138 | #define cs_dbg(skt, lvl, fmt, arg...) do { \ | 186 | struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt); |
139 | if (cs_debug_level(lvl)) \ | 187 | void pcmcia_put_socket(struct pcmcia_socket *skt); |
140 | printk(KERN_DEBUG "cs: %s: " fmt, \ | ||
141 | cs_socket_name(skt) , ## arg); \ | ||
142 | } while (0) | ||
143 | 188 | ||
144 | #else | 189 | /* cistpl.c */ |
145 | #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0) | 190 | int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, |
146 | #endif | 191 | u_int addr, u_int len, void *ptr); |
192 | void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, | ||
193 | u_int addr, u_int len, void *ptr); | ||
194 | void release_cis_mem(struct pcmcia_socket *s); | ||
195 | void destroy_cis_cache(struct pcmcia_socket *s); | ||
196 | int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, | ||
197 | cisdata_t code, void *parse); | ||
198 | int pcmcia_replace_cis(struct pcmcia_socket *s, | ||
199 | const u8 *data, const size_t len); | ||
200 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, | ||
201 | unsigned int *count); | ||
147 | 202 | ||
148 | #define cs_err(skt, fmt, arg...) \ | 203 | /* rsrc_mgr.c */ |
149 | printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.bus_id , ## arg) | 204 | int pcmcia_validate_mem(struct pcmcia_socket *s); |
205 | struct resource *pcmcia_find_io_region(unsigned long base, | ||
206 | int num, | ||
207 | unsigned long align, | ||
208 | struct pcmcia_socket *s); | ||
209 | int pcmcia_adjust_io_region(struct resource *res, | ||
210 | unsigned long r_start, | ||
211 | unsigned long r_end, | ||
212 | struct pcmcia_socket *s); | ||
213 | struct resource *pcmcia_find_mem_region(u_long base, | ||
214 | u_long num, | ||
215 | u_long align, | ||
216 | int low, | ||
217 | struct pcmcia_socket *s); | ||
218 | |||
219 | /* | ||
220 | * Stuff internal to module "pcmcia". | ||
221 | */ | ||
222 | /* ds.c */ | ||
223 | extern struct bus_type pcmcia_bus_type; | ||
224 | |||
225 | /* pcmcia_resource.c */ | ||
226 | extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); | ||
227 | |||
228 | #ifdef CONFIG_PCMCIA_IOCTL | ||
229 | /* ds.c */ | ||
230 | extern spinlock_t pcmcia_dev_list_lock; | ||
231 | |||
232 | extern struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev); | ||
233 | extern void pcmcia_put_dev(struct pcmcia_device *p_dev); | ||
234 | |||
235 | struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, | ||
236 | unsigned int function); | ||
237 | |||
238 | /* pcmcia_ioctl.c */ | ||
239 | extern void __init pcmcia_setup_ioctl(void); | ||
240 | extern void __exit pcmcia_cleanup_ioctl(void); | ||
241 | extern void handle_event(struct pcmcia_socket *s, event_t event); | ||
242 | extern int handle_request(struct pcmcia_socket *s, event_t event); | ||
243 | |||
244 | #else /* CONFIG_PCMCIA_IOCTL */ | ||
245 | |||
246 | static inline void __init pcmcia_setup_ioctl(void) { return; } | ||
247 | static inline void __exit pcmcia_cleanup_ioctl(void) { return; } | ||
248 | static inline void handle_event(struct pcmcia_socket *s, event_t event) | ||
249 | { | ||
250 | return; | ||
251 | } | ||
252 | static inline int handle_request(struct pcmcia_socket *s, event_t event) | ||
253 | { | ||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | #endif /* CONFIG_PCMCIA_IOCTL */ | ||
150 | 258 | ||
151 | #endif /* _LINUX_CS_INTERNAL_H */ | 259 | #endif /* _LINUX_CS_INTERNAL_H */ |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 34c83d3ca0fa..795660255490 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <pcmcia/ss.h> | 32 | #include <pcmcia/ss.h> |
33 | 33 | ||
34 | #include "cs_internal.h" | 34 | #include "cs_internal.h" |
35 | #include "ds_internal.h" | ||
36 | 35 | ||
37 | /*====================================================================*/ | 36 | /*====================================================================*/ |
38 | 37 | ||
@@ -42,17 +41,22 @@ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); | |||
42 | MODULE_DESCRIPTION("PCMCIA Driver Services"); | 41 | MODULE_DESCRIPTION("PCMCIA Driver Services"); |
43 | MODULE_LICENSE("GPL"); | 42 | MODULE_LICENSE("GPL"); |
44 | 43 | ||
45 | #ifdef DEBUG | 44 | #ifdef CONFIG_PCMCIA_DEBUG |
46 | int ds_pc_debug; | 45 | int ds_pc_debug; |
47 | 46 | ||
48 | module_param_named(pc_debug, ds_pc_debug, int, 0644); | 47 | module_param_named(pc_debug, ds_pc_debug, int, 0644); |
49 | 48 | ||
50 | #define ds_dbg(lvl, fmt, arg...) do { \ | 49 | #define ds_dbg(lvl, fmt, arg...) do { \ |
51 | if (ds_pc_debug > (lvl)) \ | 50 | if (ds_pc_debug > (lvl)) \ |
52 | printk(KERN_DEBUG "ds: " fmt , ## arg); \ | 51 | printk(KERN_DEBUG "ds: " fmt , ## arg); \ |
53 | } while (0) | 52 | } while (0) |
53 | #define ds_dev_dbg(lvl, dev, fmt, arg...) do { \ | ||
54 | if (ds_pc_debug > (lvl)) \ | ||
55 | dev_printk(KERN_DEBUG, dev, "ds: " fmt , ## arg); \ | ||
56 | } while (0) | ||
54 | #else | 57 | #else |
55 | #define ds_dbg(lvl, fmt, arg...) do { } while (0) | 58 | #define ds_dbg(lvl, fmt, arg...) do { } while (0) |
59 | #define ds_dev_dbg(lvl, dev, fmt, arg...) do { } while (0) | ||
56 | #endif | 60 | #endif |
57 | 61 | ||
58 | spinlock_t pcmcia_dev_list_lock; | 62 | spinlock_t pcmcia_dev_list_lock; |
@@ -64,42 +68,19 @@ spinlock_t pcmcia_dev_list_lock; | |||
64 | /* String tables for error messages */ | 68 | /* String tables for error messages */ |
65 | 69 | ||
66 | typedef struct lookup_t { | 70 | typedef struct lookup_t { |
67 | int key; | 71 | const int key; |
68 | char *msg; | 72 | const char *msg; |
69 | } lookup_t; | 73 | } lookup_t; |
70 | 74 | ||
71 | static const lookup_t error_table[] = { | 75 | static const lookup_t error_table[] = { |
72 | { CS_SUCCESS, "Operation succeeded" }, | 76 | { 0, "Operation succeeded" }, |
73 | { CS_BAD_ADAPTER, "Bad adapter" }, | 77 | { -EIO, "Input/Output error" }, |
74 | { CS_BAD_ATTRIBUTE, "Bad attribute", }, | 78 | { -ENODEV, "No card present" }, |
75 | { CS_BAD_BASE, "Bad base address" }, | 79 | { -EINVAL, "Bad parameter" }, |
76 | { CS_BAD_EDC, "Bad EDC" }, | 80 | { -EACCES, "Configuration locked" }, |
77 | { CS_BAD_IRQ, "Bad IRQ" }, | 81 | { -EBUSY, "Resource in use" }, |
78 | { CS_BAD_OFFSET, "Bad offset" }, | 82 | { -ENOSPC, "No more items" }, |
79 | { CS_BAD_PAGE, "Bad page number" }, | 83 | { -ENOMEM, "Out of resource" }, |
80 | { CS_READ_FAILURE, "Read failure" }, | ||
81 | { CS_BAD_SIZE, "Bad size" }, | ||
82 | { CS_BAD_SOCKET, "Bad socket" }, | ||
83 | { CS_BAD_TYPE, "Bad type" }, | ||
84 | { CS_BAD_VCC, "Bad Vcc" }, | ||
85 | { CS_BAD_VPP, "Bad Vpp" }, | ||
86 | { CS_BAD_WINDOW, "Bad window" }, | ||
87 | { CS_WRITE_FAILURE, "Write failure" }, | ||
88 | { CS_NO_CARD, "No card present" }, | ||
89 | { CS_UNSUPPORTED_FUNCTION, "Usupported function" }, | ||
90 | { CS_UNSUPPORTED_MODE, "Unsupported mode" }, | ||
91 | { CS_BAD_SPEED, "Bad speed" }, | ||
92 | { CS_BUSY, "Resource busy" }, | ||
93 | { CS_GENERAL_FAILURE, "General failure" }, | ||
94 | { CS_WRITE_PROTECTED, "Write protected" }, | ||
95 | { CS_BAD_ARG_LENGTH, "Bad argument length" }, | ||
96 | { CS_BAD_ARGS, "Bad arguments" }, | ||
97 | { CS_CONFIGURATION_LOCKED, "Configuration locked" }, | ||
98 | { CS_IN_USE, "Resource in use" }, | ||
99 | { CS_NO_MORE_ITEMS, "No more items" }, | ||
100 | { CS_OUT_OF_RESOURCE, "Out of resource" }, | ||
101 | { CS_BAD_HANDLE, "Bad handle" }, | ||
102 | { CS_BAD_TUPLE, "Bad CIS tuple" } | ||
103 | }; | 84 | }; |
104 | 85 | ||
105 | 86 | ||
@@ -155,46 +136,32 @@ static const lookup_t service_table[] = { | |||
155 | { ReplaceCIS, "ReplaceCIS" } | 136 | { ReplaceCIS, "ReplaceCIS" } |
156 | }; | 137 | }; |
157 | 138 | ||
158 | 139 | const char *pcmcia_error_func(int func) | |
159 | static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err) | ||
160 | { | 140 | { |
161 | int i; | 141 | int i; |
162 | char *serv; | ||
163 | |||
164 | if (!p_dev) | ||
165 | printk(KERN_NOTICE); | ||
166 | else | ||
167 | printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id); | ||
168 | 142 | ||
169 | for (i = 0; i < ARRAY_SIZE(service_table); i++) | 143 | for (i = 0; i < ARRAY_SIZE(service_table); i++) |
170 | if (service_table[i].key == err->func) | 144 | if (service_table[i].key == func) |
171 | break; | 145 | return service_table[i].msg; |
172 | if (i < ARRAY_SIZE(service_table)) | ||
173 | serv = service_table[i].msg; | ||
174 | else | ||
175 | serv = "Unknown service number"; | ||
176 | 146 | ||
177 | for (i = 0; i < ARRAY_SIZE(error_table); i++) | 147 | return "Unknown service number"; |
178 | if (error_table[i].key == err->retcode) | 148 | } |
179 | break; | 149 | EXPORT_SYMBOL(pcmcia_error_func); |
180 | if (i < ARRAY_SIZE(error_table)) | ||
181 | printk("%s: %s\n", serv, error_table[i].msg); | ||
182 | else | ||
183 | printk("%s: Unknown error code %#x\n", serv, err->retcode); | ||
184 | 150 | ||
185 | return CS_SUCCESS; | 151 | const char *pcmcia_error_ret(int ret) |
186 | } /* report_error */ | 152 | { |
153 | int i; | ||
154 | |||
155 | for (i = 0; i < ARRAY_SIZE(error_table); i++) | ||
156 | if (error_table[i].key == ret) | ||
157 | return error_table[i].msg; | ||
187 | 158 | ||
188 | /* end of code which was in cs.c before */ | 159 | return "unknown"; |
160 | } | ||
161 | EXPORT_SYMBOL(pcmcia_error_ret); | ||
189 | 162 | ||
190 | /*======================================================================*/ | 163 | /*======================================================================*/ |
191 | 164 | ||
192 | void cs_error(struct pcmcia_device *p_dev, int func, int ret) | ||
193 | { | ||
194 | error_info_t err = { func, ret }; | ||
195 | pcmcia_report_error(p_dev, &err); | ||
196 | } | ||
197 | EXPORT_SYMBOL(cs_error); | ||
198 | 165 | ||
199 | 166 | ||
200 | static void pcmcia_check_driver(struct pcmcia_driver *p_drv) | 167 | static void pcmcia_check_driver(struct pcmcia_driver *p_drv) |
@@ -391,7 +358,7 @@ static void pcmcia_release_function(struct kref *ref) | |||
391 | static void pcmcia_release_dev(struct device *dev) | 358 | static void pcmcia_release_dev(struct device *dev) |
392 | { | 359 | { |
393 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 360 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
394 | ds_dbg(1, "releasing device %s\n", p_dev->dev.bus_id); | 361 | ds_dev_dbg(1, dev, "releasing device\n"); |
395 | pcmcia_put_socket(p_dev->socket); | 362 | pcmcia_put_socket(p_dev->socket); |
396 | kfree(p_dev->devname); | 363 | kfree(p_dev->devname); |
397 | kref_put(&p_dev->function_config->ref, pcmcia_release_function); | 364 | kref_put(&p_dev->function_config->ref, pcmcia_release_function); |
@@ -401,7 +368,7 @@ static void pcmcia_release_dev(struct device *dev) | |||
401 | static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc) | 368 | static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc) |
402 | { | 369 | { |
403 | if (!s->pcmcia_state.device_add_pending) { | 370 | if (!s->pcmcia_state.device_add_pending) { |
404 | ds_dbg(1, "scheduling to add %s secondary" | 371 | ds_dev_dbg(1, &s->dev, "scheduling to add %s secondary" |
405 | " device to %d\n", mfc ? "mfc" : "pfc", s->sock); | 372 | " device to %d\n", mfc ? "mfc" : "pfc", s->sock); |
406 | s->pcmcia_state.device_add_pending = 1; | 373 | s->pcmcia_state.device_add_pending = 1; |
407 | s->pcmcia_state.mfc_pfc = mfc; | 374 | s->pcmcia_state.mfc_pfc = mfc; |
@@ -439,8 +406,7 @@ static int pcmcia_device_probe(struct device * dev) | |||
439 | */ | 406 | */ |
440 | did = p_dev->dev.driver_data; | 407 | did = p_dev->dev.driver_data; |
441 | 408 | ||
442 | ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id, | 409 | ds_dev_dbg(1, dev, "trying to bind to %s\n", p_drv->drv.name); |
443 | p_drv->drv.name); | ||
444 | 410 | ||
445 | if ((!p_drv->probe) || (!p_dev->function_config) || | 411 | if ((!p_drv->probe) || (!p_dev->function_config) || |
446 | (!try_module_get(p_drv->owner))) { | 412 | (!try_module_get(p_drv->owner))) { |
@@ -455,15 +421,16 @@ static int pcmcia_device_probe(struct device * dev) | |||
455 | p_dev->conf.ConfigBase = cis_config.base; | 421 | p_dev->conf.ConfigBase = cis_config.base; |
456 | p_dev->conf.Present = cis_config.rmask[0]; | 422 | p_dev->conf.Present = cis_config.rmask[0]; |
457 | } else { | 423 | } else { |
458 | printk(KERN_INFO "pcmcia: could not parse base and rmask0 of CIS\n"); | 424 | dev_printk(KERN_INFO, dev, |
425 | "pcmcia: could not parse base and rmask0 of CIS\n"); | ||
459 | p_dev->conf.ConfigBase = 0; | 426 | p_dev->conf.ConfigBase = 0; |
460 | p_dev->conf.Present = 0; | 427 | p_dev->conf.Present = 0; |
461 | } | 428 | } |
462 | 429 | ||
463 | ret = p_drv->probe(p_dev); | 430 | ret = p_drv->probe(p_dev); |
464 | if (ret) { | 431 | if (ret) { |
465 | ds_dbg(1, "binding %s to %s failed with %d\n", | 432 | ds_dev_dbg(1, dev, "binding to %s failed with %d\n", |
466 | p_dev->dev.bus_id, p_drv->drv.name, ret); | 433 | p_drv->drv.name, ret); |
467 | goto put_module; | 434 | goto put_module; |
468 | } | 435 | } |
469 | 436 | ||
@@ -490,8 +457,9 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le | |||
490 | struct pcmcia_device *tmp; | 457 | struct pcmcia_device *tmp; |
491 | unsigned long flags; | 458 | unsigned long flags; |
492 | 459 | ||
493 | ds_dbg(2, "pcmcia_card_remove(%d) %s\n", s->sock, | 460 | ds_dev_dbg(2, leftover ? &leftover->dev : &s->dev, |
494 | leftover ? leftover->devname : ""); | 461 | "pcmcia_card_remove(%d) %s\n", s->sock, |
462 | leftover ? leftover->devname : ""); | ||
495 | 463 | ||
496 | if (!leftover) | 464 | if (!leftover) |
497 | s->device_count = 0; | 465 | s->device_count = 0; |
@@ -508,7 +476,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le | |||
508 | p_dev->_removed=1; | 476 | p_dev->_removed=1; |
509 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 477 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); |
510 | 478 | ||
511 | ds_dbg(2, "unregistering device %s\n", p_dev->dev.bus_id); | 479 | ds_dev_dbg(2, &p_dev->dev, "unregistering device\n"); |
512 | device_unregister(&p_dev->dev); | 480 | device_unregister(&p_dev->dev); |
513 | } | 481 | } |
514 | 482 | ||
@@ -525,7 +493,7 @@ static int pcmcia_device_remove(struct device * dev) | |||
525 | p_dev = to_pcmcia_dev(dev); | 493 | p_dev = to_pcmcia_dev(dev); |
526 | p_drv = to_pcmcia_drv(dev->driver); | 494 | p_drv = to_pcmcia_drv(dev->driver); |
527 | 495 | ||
528 | ds_dbg(1, "removing device %s\n", p_dev->dev.bus_id); | 496 | ds_dev_dbg(1, dev, "removing device\n"); |
529 | 497 | ||
530 | /* If we're removing the primary module driving a | 498 | /* If we're removing the primary module driving a |
531 | * pseudo multi-function card, we need to unbind | 499 | * pseudo multi-function card, we need to unbind |
@@ -548,13 +516,15 @@ static int pcmcia_device_remove(struct device * dev) | |||
548 | 516 | ||
549 | /* check for proper unloading */ | 517 | /* check for proper unloading */ |
550 | if (p_dev->_irq || p_dev->_io || p_dev->_locked) | 518 | if (p_dev->_irq || p_dev->_io || p_dev->_locked) |
551 | printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", | 519 | dev_printk(KERN_INFO, dev, |
552 | p_drv->drv.name); | 520 | "pcmcia: driver %s did not release config properly\n", |
521 | p_drv->drv.name); | ||
553 | 522 | ||
554 | for (i = 0; i < MAX_WIN; i++) | 523 | for (i = 0; i < MAX_WIN; i++) |
555 | if (p_dev->_win & CLIENT_WIN_REQ(i)) | 524 | if (p_dev->_win & CLIENT_WIN_REQ(i)) |
556 | printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", | 525 | dev_printk(KERN_INFO, dev, |
557 | p_drv->drv.name); | 526 | "pcmcia: driver %s did not release window properly\n", |
527 | p_drv->drv.name); | ||
558 | 528 | ||
559 | /* references from pcmcia_probe_device */ | 529 | /* references from pcmcia_probe_device */ |
560 | pcmcia_put_dev(p_dev); | 530 | pcmcia_put_dev(p_dev); |
@@ -603,8 +573,9 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) | |||
603 | } | 573 | } |
604 | if (!pccard_read_tuple(p_dev->socket, p_dev->func, | 574 | if (!pccard_read_tuple(p_dev->socket, p_dev->func, |
605 | CISTPL_DEVICE_GEO, devgeo)) { | 575 | CISTPL_DEVICE_GEO, devgeo)) { |
606 | ds_dbg(0, "mem device geometry probably means " | 576 | ds_dev_dbg(0, &p_dev->dev, |
607 | "FUNCID_MEMORY\n"); | 577 | "mem device geometry probably means " |
578 | "FUNCID_MEMORY\n"); | ||
608 | p_dev->func_id = CISTPL_FUNCID_MEMORY; | 579 | p_dev->func_id = CISTPL_FUNCID_MEMORY; |
609 | p_dev->has_func_id = 1; | 580 | p_dev->has_func_id = 1; |
610 | } | 581 | } |
@@ -685,7 +656,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
685 | if (!p_dev->devname) | 656 | if (!p_dev->devname) |
686 | goto err_free; | 657 | goto err_free; |
687 | sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); | 658 | sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); |
688 | ds_dbg(3, "devname is %s\n", p_dev->devname); | 659 | ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname); |
689 | 660 | ||
690 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 661 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); |
691 | 662 | ||
@@ -706,7 +677,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
706 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 677 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); |
707 | 678 | ||
708 | if (!p_dev->function_config) { | 679 | if (!p_dev->function_config) { |
709 | ds_dbg(3, "creating config_t for %s\n", p_dev->dev.bus_id); | 680 | ds_dev_dbg(3, &p_dev->dev, "creating config_t\n"); |
710 | p_dev->function_config = kzalloc(sizeof(struct config_t), | 681 | p_dev->function_config = kzalloc(sizeof(struct config_t), |
711 | GFP_KERNEL); | 682 | GFP_KERNEL); |
712 | if (!p_dev->function_config) | 683 | if (!p_dev->function_config) |
@@ -714,8 +685,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
714 | kref_init(&p_dev->function_config->ref); | 685 | kref_init(&p_dev->function_config->ref); |
715 | } | 686 | } |
716 | 687 | ||
717 | printk(KERN_NOTICE "pcmcia: registering new device %s\n", | 688 | dev_printk(KERN_NOTICE, &p_dev->dev, |
718 | p_dev->devname); | 689 | "pcmcia: registering new device %s\n", |
690 | p_dev->devname); | ||
719 | 691 | ||
720 | pcmcia_device_query(p_dev); | 692 | pcmcia_device_query(p_dev); |
721 | 693 | ||
@@ -750,19 +722,20 @@ static int pcmcia_card_add(struct pcmcia_socket *s) | |||
750 | int ret = 0; | 722 | int ret = 0; |
751 | 723 | ||
752 | if (!(s->resource_setup_done)) { | 724 | if (!(s->resource_setup_done)) { |
753 | ds_dbg(3, "no resources available, delaying card_add\n"); | 725 | ds_dev_dbg(3, &s->dev, |
726 | "no resources available, delaying card_add\n"); | ||
754 | return -EAGAIN; /* try again, but later... */ | 727 | return -EAGAIN; /* try again, but later... */ |
755 | } | 728 | } |
756 | 729 | ||
757 | if (pcmcia_validate_mem(s)) { | 730 | if (pcmcia_validate_mem(s)) { |
758 | ds_dbg(3, "validating mem resources failed, " | 731 | ds_dev_dbg(3, &s->dev, "validating mem resources failed, " |
759 | "delaying card_add\n"); | 732 | "delaying card_add\n"); |
760 | return -EAGAIN; /* try again, but later... */ | 733 | return -EAGAIN; /* try again, but later... */ |
761 | } | 734 | } |
762 | 735 | ||
763 | ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains); | 736 | ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains); |
764 | if (ret || !no_chains) { | 737 | if (ret || !no_chains) { |
765 | ds_dbg(0, "invalid CIS or invalid resources\n"); | 738 | ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n"); |
766 | return -ENODEV; | 739 | return -ENODEV; |
767 | } | 740 | } |
768 | 741 | ||
@@ -783,7 +756,7 @@ static void pcmcia_delayed_add_device(struct work_struct *work) | |||
783 | { | 756 | { |
784 | struct pcmcia_socket *s = | 757 | struct pcmcia_socket *s = |
785 | container_of(work, struct pcmcia_socket, device_add); | 758 | container_of(work, struct pcmcia_socket, device_add); |
786 | ds_dbg(1, "adding additional device to %d\n", s->sock); | 759 | ds_dev_dbg(1, &s->dev, "adding additional device to %d\n", s->sock); |
787 | pcmcia_device_add(s, s->pcmcia_state.mfc_pfc); | 760 | pcmcia_device_add(s, s->pcmcia_state.mfc_pfc); |
788 | s->pcmcia_state.device_add_pending = 0; | 761 | s->pcmcia_state.device_add_pending = 0; |
789 | s->pcmcia_state.mfc_pfc = 0; | 762 | s->pcmcia_state.mfc_pfc = 0; |
@@ -793,8 +766,7 @@ static int pcmcia_requery(struct device *dev, void * _data) | |||
793 | { | 766 | { |
794 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 767 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
795 | if (!p_dev->dev.driver) { | 768 | if (!p_dev->dev.driver) { |
796 | ds_dbg(1, "update device information for %s\n", | 769 | ds_dev_dbg(1, dev, "update device information\n"); |
797 | p_dev->dev.bus_id); | ||
798 | pcmcia_device_query(p_dev); | 770 | pcmcia_device_query(p_dev); |
799 | } | 771 | } |
800 | 772 | ||
@@ -808,7 +780,7 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis) | |||
808 | unsigned long flags; | 780 | unsigned long flags; |
809 | 781 | ||
810 | /* must be called with skt_mutex held */ | 782 | /* must be called with skt_mutex held */ |
811 | ds_dbg(0, "re-scanning socket %d\n", skt->sock); | 783 | ds_dev_dbg(0, &skt->dev, "re-scanning socket %d\n", skt->sock); |
812 | 784 | ||
813 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 785 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); |
814 | if (list_empty(&skt->devices_list)) | 786 | if (list_empty(&skt->devices_list)) |
@@ -859,17 +831,17 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) | |||
859 | int ret = -ENOMEM; | 831 | int ret = -ENOMEM; |
860 | int no_funcs; | 832 | int no_funcs; |
861 | int old_funcs; | 833 | int old_funcs; |
862 | cisdump_t *cis; | ||
863 | cistpl_longlink_mfc_t mfc; | 834 | cistpl_longlink_mfc_t mfc; |
864 | 835 | ||
865 | if (!filename) | 836 | if (!filename) |
866 | return -EINVAL; | 837 | return -EINVAL; |
867 | 838 | ||
868 | ds_dbg(1, "trying to load CIS file %s\n", filename); | 839 | ds_dev_dbg(1, &dev->dev, "trying to load CIS file %s\n", filename); |
869 | 840 | ||
870 | if (strlen(filename) > (FIRMWARE_NAME_MAX - 1)) { | 841 | if (strlen(filename) > (FIRMWARE_NAME_MAX - 1)) { |
871 | printk(KERN_WARNING "pcmcia: CIS filename is too long [%s]\n", | 842 | dev_printk(KERN_WARNING, &dev->dev, |
872 | filename); | 843 | "pcmcia: CIS filename is too long [%s]\n", |
844 | filename); | ||
873 | return -EINVAL; | 845 | return -EINVAL; |
874 | } | 846 | } |
875 | 847 | ||
@@ -878,23 +850,16 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) | |||
878 | if (request_firmware(&fw, path, &dev->dev) == 0) { | 850 | if (request_firmware(&fw, path, &dev->dev) == 0) { |
879 | if (fw->size >= CISTPL_MAX_CIS_SIZE) { | 851 | if (fw->size >= CISTPL_MAX_CIS_SIZE) { |
880 | ret = -EINVAL; | 852 | ret = -EINVAL; |
881 | printk(KERN_ERR "pcmcia: CIS override is too big\n"); | 853 | dev_printk(KERN_ERR, &dev->dev, |
854 | "pcmcia: CIS override is too big\n"); | ||
882 | goto release; | 855 | goto release; |
883 | } | 856 | } |
884 | 857 | ||
885 | cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); | 858 | if (!pcmcia_replace_cis(s, fw->data, fw->size)) |
886 | if (!cis) { | ||
887 | ret = -ENOMEM; | ||
888 | goto release; | ||
889 | } | ||
890 | |||
891 | cis->Length = fw->size + 1; | ||
892 | memcpy(cis->Data, fw->data, fw->size); | ||
893 | |||
894 | if (!pcmcia_replace_cis(s, cis)) | ||
895 | ret = 0; | 859 | ret = 0; |
896 | else { | 860 | else { |
897 | printk(KERN_ERR "pcmcia: CIS override failed\n"); | 861 | dev_printk(KERN_ERR, &dev->dev, |
862 | "pcmcia: CIS override failed\n"); | ||
898 | goto release; | 863 | goto release; |
899 | } | 864 | } |
900 | 865 | ||
@@ -998,14 +963,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, | |||
998 | * after it has re-checked that there is no possible module | 963 | * after it has re-checked that there is no possible module |
999 | * with a prod_id/manf_id/card_id match. | 964 | * with a prod_id/manf_id/card_id match. |
1000 | */ | 965 | */ |
1001 | ds_dbg(0, "skipping FUNC_ID match for %s until userspace " | 966 | ds_dev_dbg(0, &dev->dev, |
1002 | "interaction\n", dev->dev.bus_id); | 967 | "skipping FUNC_ID match until userspace interaction\n"); |
1003 | if (!dev->allow_func_id_match) | 968 | if (!dev->allow_func_id_match) |
1004 | return 0; | 969 | return 0; |
1005 | } | 970 | } |
1006 | 971 | ||
1007 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { | 972 | if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { |
1008 | ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id); | 973 | ds_dev_dbg(0, &dev->dev, "device needs a fake CIS\n"); |
1009 | if (!dev->socket->fake_cis) | 974 | if (!dev->socket->fake_cis) |
1010 | pcmcia_load_firmware(dev, did->cisfile); | 975 | pcmcia_load_firmware(dev, did->cisfile); |
1011 | 976 | ||
@@ -1037,11 +1002,9 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { | |||
1037 | /* match dynamic devices first */ | 1002 | /* match dynamic devices first */ |
1038 | spin_lock(&p_drv->dynids.lock); | 1003 | spin_lock(&p_drv->dynids.lock); |
1039 | list_for_each_entry(dynid, &p_drv->dynids.list, node) { | 1004 | list_for_each_entry(dynid, &p_drv->dynids.list, node) { |
1040 | ds_dbg(3, "trying to match %s to %s\n", dev->bus_id, | 1005 | ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name); |
1041 | drv->name); | ||
1042 | if (pcmcia_devmatch(p_dev, &dynid->id)) { | 1006 | if (pcmcia_devmatch(p_dev, &dynid->id)) { |
1043 | ds_dbg(0, "matched %s to %s\n", dev->bus_id, | 1007 | ds_dev_dbg(0, dev, "matched to %s\n", drv->name); |
1044 | drv->name); | ||
1045 | spin_unlock(&p_drv->dynids.lock); | 1008 | spin_unlock(&p_drv->dynids.lock); |
1046 | return 1; | 1009 | return 1; |
1047 | } | 1010 | } |
@@ -1051,18 +1014,15 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { | |||
1051 | #ifdef CONFIG_PCMCIA_IOCTL | 1014 | #ifdef CONFIG_PCMCIA_IOCTL |
1052 | /* matching by cardmgr */ | 1015 | /* matching by cardmgr */ |
1053 | if (p_dev->cardmgr == p_drv) { | 1016 | if (p_dev->cardmgr == p_drv) { |
1054 | ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id, | 1017 | ds_dev_dbg(0, dev, "cardmgr matched to %s\n", drv->name); |
1055 | drv->name); | ||
1056 | return 1; | 1018 | return 1; |
1057 | } | 1019 | } |
1058 | #endif | 1020 | #endif |
1059 | 1021 | ||
1060 | while (did && did->match_flags) { | 1022 | while (did && did->match_flags) { |
1061 | ds_dbg(3, "trying to match %s to %s\n", dev->bus_id, | 1023 | ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name); |
1062 | drv->name); | ||
1063 | if (pcmcia_devmatch(p_dev, did)) { | 1024 | if (pcmcia_devmatch(p_dev, did)) { |
1064 | ds_dbg(0, "matched %s to %s\n", dev->bus_id, | 1025 | ds_dev_dbg(0, dev, "matched to %s\n", drv->name); |
1065 | drv->name); | ||
1066 | return 1; | 1026 | return 1; |
1067 | } | 1027 | } |
1068 | did++; | 1028 | did++; |
@@ -1268,7 +1228,7 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state) | |||
1268 | if (p_dev->suspended) | 1228 | if (p_dev->suspended) |
1269 | return 0; | 1229 | return 0; |
1270 | 1230 | ||
1271 | ds_dbg(2, "suspending %s\n", dev->bus_id); | 1231 | ds_dev_dbg(2, dev, "suspending\n"); |
1272 | 1232 | ||
1273 | if (dev->driver) | 1233 | if (dev->driver) |
1274 | p_drv = to_pcmcia_drv(dev->driver); | 1234 | p_drv = to_pcmcia_drv(dev->driver); |
@@ -1279,15 +1239,16 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state) | |||
1279 | if (p_drv->suspend) { | 1239 | if (p_drv->suspend) { |
1280 | ret = p_drv->suspend(p_dev); | 1240 | ret = p_drv->suspend(p_dev); |
1281 | if (ret) { | 1241 | if (ret) { |
1282 | printk(KERN_ERR "pcmcia: device %s (driver %s) did " | 1242 | dev_printk(KERN_ERR, dev, |
1283 | "not want to go to sleep (%d)\n", | 1243 | "pcmcia: device %s (driver %s) did " |
1284 | p_dev->devname, p_drv->drv.name, ret); | 1244 | "not want to go to sleep (%d)\n", |
1245 | p_dev->devname, p_drv->drv.name, ret); | ||
1285 | goto out; | 1246 | goto out; |
1286 | } | 1247 | } |
1287 | } | 1248 | } |
1288 | 1249 | ||
1289 | if (p_dev->device_no == p_dev->func) { | 1250 | if (p_dev->device_no == p_dev->func) { |
1290 | ds_dbg(2, "releasing configuration for %s\n", dev->bus_id); | 1251 | ds_dev_dbg(2, dev, "releasing configuration\n"); |
1291 | pcmcia_release_configuration(p_dev); | 1252 | pcmcia_release_configuration(p_dev); |
1292 | } | 1253 | } |
1293 | 1254 | ||
@@ -1307,7 +1268,7 @@ static int pcmcia_dev_resume(struct device * dev) | |||
1307 | if (!p_dev->suspended) | 1268 | if (!p_dev->suspended) |
1308 | return 0; | 1269 | return 0; |
1309 | 1270 | ||
1310 | ds_dbg(2, "resuming %s\n", dev->bus_id); | 1271 | ds_dev_dbg(2, dev, "resuming\n"); |
1311 | 1272 | ||
1312 | if (dev->driver) | 1273 | if (dev->driver) |
1313 | p_drv = to_pcmcia_drv(dev->driver); | 1274 | p_drv = to_pcmcia_drv(dev->driver); |
@@ -1316,7 +1277,7 @@ static int pcmcia_dev_resume(struct device * dev) | |||
1316 | goto out; | 1277 | goto out; |
1317 | 1278 | ||
1318 | if (p_dev->device_no == p_dev->func) { | 1279 | if (p_dev->device_no == p_dev->func) { |
1319 | ds_dbg(2, "requesting configuration for %s\n", dev->bus_id); | 1280 | ds_dev_dbg(2, dev, "requesting configuration\n"); |
1320 | ret = pcmcia_request_configuration(p_dev, &p_dev->conf); | 1281 | ret = pcmcia_request_configuration(p_dev, &p_dev->conf); |
1321 | if (ret) | 1282 | if (ret) |
1322 | goto out; | 1283 | goto out; |
@@ -1358,14 +1319,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data) | |||
1358 | 1319 | ||
1359 | static int pcmcia_bus_resume(struct pcmcia_socket *skt) | 1320 | static int pcmcia_bus_resume(struct pcmcia_socket *skt) |
1360 | { | 1321 | { |
1361 | ds_dbg(2, "resuming socket %d\n", skt->sock); | 1322 | ds_dev_dbg(2, &skt->dev, "resuming socket %d\n", skt->sock); |
1362 | bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); | 1323 | bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); |
1363 | return 0; | 1324 | return 0; |
1364 | } | 1325 | } |
1365 | 1326 | ||
1366 | static int pcmcia_bus_suspend(struct pcmcia_socket *skt) | 1327 | static int pcmcia_bus_suspend(struct pcmcia_socket *skt) |
1367 | { | 1328 | { |
1368 | ds_dbg(2, "suspending socket %d\n", skt->sock); | 1329 | ds_dev_dbg(2, &skt->dev, "suspending socket %d\n", skt->sock); |
1369 | if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, | 1330 | if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, |
1370 | pcmcia_bus_suspend_callback)) { | 1331 | pcmcia_bus_suspend_callback)) { |
1371 | pcmcia_bus_resume(skt); | 1332 | pcmcia_bus_resume(skt); |
@@ -1391,13 +1352,14 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) | |||
1391 | struct pcmcia_socket *s = pcmcia_get_socket(skt); | 1352 | struct pcmcia_socket *s = pcmcia_get_socket(skt); |
1392 | 1353 | ||
1393 | if (!s) { | 1354 | if (!s) { |
1394 | printk(KERN_ERR "PCMCIA obtaining reference to socket %p " \ | 1355 | dev_printk(KERN_ERR, &skt->dev, |
1395 | "failed, event 0x%x lost!\n", skt, event); | 1356 | "PCMCIA obtaining reference to socket " \ |
1357 | "failed, event 0x%x lost!\n", event); | ||
1396 | return -ENODEV; | 1358 | return -ENODEV; |
1397 | } | 1359 | } |
1398 | 1360 | ||
1399 | ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", | 1361 | ds_dev_dbg(1, &skt->dev, "ds_event(0x%06x, %d, 0x%p)\n", |
1400 | event, priority, skt); | 1362 | event, priority, skt); |
1401 | 1363 | ||
1402 | switch (event) { | 1364 | switch (event) { |
1403 | case CS_EVENT_CARD_REMOVAL: | 1365 | case CS_EVENT_CARD_REMOVAL: |
@@ -1472,7 +1434,8 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev, | |||
1472 | 1434 | ||
1473 | socket = pcmcia_get_socket(socket); | 1435 | socket = pcmcia_get_socket(socket); |
1474 | if (!socket) { | 1436 | if (!socket) { |
1475 | printk(KERN_ERR "PCMCIA obtaining reference to socket %p failed\n", socket); | 1437 | dev_printk(KERN_ERR, dev, |
1438 | "PCMCIA obtaining reference to socket failed\n"); | ||
1476 | return -ENODEV; | 1439 | return -ENODEV; |
1477 | } | 1440 | } |
1478 | 1441 | ||
@@ -1492,7 +1455,7 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev, | |||
1492 | 1455 | ||
1493 | ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); | 1456 | ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); |
1494 | if (ret) { | 1457 | if (ret) { |
1495 | printk(KERN_ERR "PCMCIA registration PCCard core failed for socket %p\n", socket); | 1458 | dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n"); |
1496 | pcmcia_put_socket(socket); | 1459 | pcmcia_put_socket(socket); |
1497 | return (ret); | 1460 | return (ret); |
1498 | } | 1461 | } |
diff --git a/drivers/pcmcia/ds_internal.h b/drivers/pcmcia/ds_internal.h deleted file mode 100644 index 3a2b25e6ed73..000000000000 --- a/drivers/pcmcia/ds_internal.h +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | /* ds_internal.h - internal header for 16-bit PCMCIA devices management */ | ||
2 | |||
3 | extern spinlock_t pcmcia_dev_list_lock; | ||
4 | extern struct bus_type pcmcia_bus_type; | ||
5 | |||
6 | extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev); | ||
7 | extern void pcmcia_put_dev(struct pcmcia_device *p_dev); | ||
8 | |||
9 | struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function); | ||
10 | |||
11 | extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); | ||
12 | |||
13 | #ifdef CONFIG_PCMCIA_IOCTL | ||
14 | extern void __init pcmcia_setup_ioctl(void); | ||
15 | extern void __exit pcmcia_cleanup_ioctl(void); | ||
16 | extern void handle_event(struct pcmcia_socket *s, event_t event); | ||
17 | extern int handle_request(struct pcmcia_socket *s, event_t event); | ||
18 | #else | ||
19 | static inline void __init pcmcia_setup_ioctl(void) { return; } | ||
20 | static inline void __exit pcmcia_cleanup_ioctl(void) { return; } | ||
21 | static inline void handle_event(struct pcmcia_socket *s, event_t event) { return; } | ||
22 | static inline int handle_request(struct pcmcia_socket *s, event_t event) { return CS_SUCCESS; } | ||
23 | #endif | ||
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c index fb2bc1fb015d..117dc12ab438 100644 --- a/drivers/pcmcia/hd64465_ss.c +++ b/drivers/pcmcia/hd64465_ss.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include <pcmcia/cistpl.h> | 46 | #include <pcmcia/cistpl.h> |
47 | #include <pcmcia/ds.h> | 47 | #include <pcmcia/ds.h> |
48 | #include <pcmcia/ss.h> | 48 | #include <pcmcia/ss.h> |
49 | #include "cs_internal.h" | ||
50 | 49 | ||
51 | #define MODNAME "hd64465_ss" | 50 | #define MODNAME "hd64465_ss" |
52 | 51 | ||
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 68f6b2702bc4..71653ab84890 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c | |||
@@ -63,7 +63,7 @@ | |||
63 | #include "vg468.h" | 63 | #include "vg468.h" |
64 | #include "ricoh.h" | 64 | #include "ricoh.h" |
65 | 65 | ||
66 | #ifdef DEBUG | 66 | #ifdef CONFIG_PCMCIA_DEBUG |
67 | static const char version[] = | 67 | static const char version[] = |
68 | "i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)"; | 68 | "i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)"; |
69 | 69 | ||
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index 3616da227152..2ab4f22c21de 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c | |||
@@ -38,7 +38,7 @@ | |||
38 | 38 | ||
39 | #include "m32r_cfc.h" | 39 | #include "m32r_cfc.h" |
40 | 40 | ||
41 | #ifdef DEBUG | 41 | #ifdef CONFIG_PCMCIA_DEBUG |
42 | static int m32r_cfc_debug; | 42 | static int m32r_cfc_debug; |
43 | module_param(m32r_cfc_debug, int, 0644); | 43 | module_param(m32r_cfc_debug, int, 0644); |
44 | #define debug(lvl, fmt, arg...) do { \ | 44 | #define debug(lvl, fmt, arg...) do { \ |
@@ -505,7 +505,7 @@ static int _pcc_set_socket(u_short sock, socket_state_t *state) | |||
505 | pcc_set(sock,(unsigned int)PLD_CFBUFCR,1); | 505 | pcc_set(sock,(unsigned int)PLD_CFBUFCR,1); |
506 | } | 506 | } |
507 | 507 | ||
508 | #ifdef DEBUG | 508 | #ifdef CONFIG_PCMCIA_DEBUG |
509 | if(state->flags & SS_IOCARD){ | 509 | if(state->flags & SS_IOCARD){ |
510 | debug(3, ":IOCARD"); | 510 | debug(3, ":IOCARD"); |
511 | } | 511 | } |
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c index 2b42b7155e34..2f108c23dbd9 100644 --- a/drivers/pcmcia/m32r_pcc.c +++ b/drivers/pcmcia/m32r_pcc.c | |||
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | #define PCC_DEBUG_DBEX | 46 | #define PCC_DEBUG_DBEX |
47 | 47 | ||
48 | #ifdef DEBUG | 48 | #ifdef CONFIG_PCMCIA_DEBUG |
49 | static int m32r_pcc_debug; | 49 | static int m32r_pcc_debug; |
50 | module_param(m32r_pcc_debug, int, 0644); | 50 | module_param(m32r_pcc_debug, int, 0644); |
51 | #define debug(lvl, fmt, arg...) do { \ | 51 | #define debug(lvl, fmt, arg...) do { \ |
@@ -460,7 +460,7 @@ static int _pcc_set_socket(u_short sock, socket_state_t *state) | |||
460 | 460 | ||
461 | pcc_set(sock,PCCSIGCR,reg); | 461 | pcc_set(sock,PCCSIGCR,reg); |
462 | 462 | ||
463 | #ifdef DEBUG | 463 | #ifdef CONFIG_PCMCIA_DEBUG |
464 | if(state->flags & SS_IOCARD){ | 464 | if(state->flags & SS_IOCARD){ |
465 | debug(3, ":IOCARD"); | 465 | debug(3, ":IOCARD"); |
466 | } | 466 | } |
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index ff66604e90d4..d1ad0966392d 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c | |||
@@ -64,8 +64,8 @@ | |||
64 | #include <pcmcia/cs.h> | 64 | #include <pcmcia/cs.h> |
65 | #include <pcmcia/ss.h> | 65 | #include <pcmcia/ss.h> |
66 | 66 | ||
67 | #ifdef PCMCIA_DEBUG | 67 | #ifdef CONFIG_PCMCIA_DEBUG |
68 | static int pc_debug = PCMCIA_DEBUG; | 68 | static int pc_debug; |
69 | module_param(pc_debug, int, 0); | 69 | module_param(pc_debug, int, 0); |
70 | #define dprintk(args...) printk(KERN_DEBUG "m8xx_pcmcia: " args); | 70 | #define dprintk(args...) printk(KERN_DEBUG "m8xx_pcmcia: " args); |
71 | #else | 71 | #else |
diff --git a/drivers/pcmcia/o2micro.h b/drivers/pcmcia/o2micro.h index a234ce1967a3..5554015a7813 100644 --- a/drivers/pcmcia/o2micro.h +++ b/drivers/pcmcia/o2micro.h | |||
@@ -140,7 +140,8 @@ static int o2micro_override(struct yenta_socket *socket) | |||
140 | a = config_readb(socket, O2_RESERVED1); | 140 | a = config_readb(socket, O2_RESERVED1); |
141 | b = config_readb(socket, O2_RESERVED2); | 141 | b = config_readb(socket, O2_RESERVED2); |
142 | 142 | ||
143 | printk(KERN_INFO "Yenta O2: res at 0x94/0xD4: %02x/%02x\n", a, b); | 143 | dev_printk(KERN_INFO, &socket->dev->dev, |
144 | "O2: res at 0x94/0xD4: %02x/%02x\n", a, b); | ||
144 | 145 | ||
145 | switch (socket->dev->device) { | 146 | switch (socket->dev->device) { |
146 | /* | 147 | /* |
@@ -153,7 +154,9 @@ static int o2micro_override(struct yenta_socket *socket) | |||
153 | case PCI_DEVICE_ID_O2_6812: | 154 | case PCI_DEVICE_ID_O2_6812: |
154 | case PCI_DEVICE_ID_O2_6832: | 155 | case PCI_DEVICE_ID_O2_6832: |
155 | case PCI_DEVICE_ID_O2_6836: | 156 | case PCI_DEVICE_ID_O2_6836: |
156 | printk(KERN_INFO "Yenta O2: old bridge, disabling read prefetch/write burst\n"); | 157 | dev_printk(KERN_INFO, &socket->dev->dev, |
158 | "Yenta O2: old bridge, disabling read " | ||
159 | "prefetch/write burst\n"); | ||
157 | config_writeb(socket, O2_RESERVED1, | 160 | config_writeb(socket, O2_RESERVED1, |
158 | a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); | 161 | a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); |
159 | config_writeb(socket, O2_RESERVED2, | 162 | config_writeb(socket, O2_RESERVED2, |
@@ -161,7 +164,8 @@ static int o2micro_override(struct yenta_socket *socket) | |||
161 | break; | 164 | break; |
162 | 165 | ||
163 | default: | 166 | default: |
164 | printk(KERN_INFO "Yenta O2: enabling read prefetch/write burst\n"); | 167 | dev_printk(KERN_INFO , &socket->dev->dev, |
168 | "O2: enabling read prefetch/write burst\n"); | ||
165 | config_writeb(socket, O2_RESERVED1, | 169 | config_writeb(socket, O2_RESERVED1, |
166 | a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); | 170 | a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); |
167 | config_writeb(socket, O2_RESERVED2, | 171 | config_writeb(socket, O2_RESERVED2, |
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 419f97fc9a62..1703b20cad5d 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <pcmcia/ss.h> | 38 | #include <pcmcia/ss.h> |
39 | 39 | ||
40 | #include "cs_internal.h" | 40 | #include "cs_internal.h" |
41 | #include "ds_internal.h" | ||
42 | 41 | ||
43 | static int major_dev = -1; | 42 | static int major_dev = -1; |
44 | 43 | ||
@@ -58,7 +57,7 @@ typedef struct user_info_t { | |||
58 | } user_info_t; | 57 | } user_info_t; |
59 | 58 | ||
60 | 59 | ||
61 | #ifdef DEBUG | 60 | #ifdef CONFIG_PCMCIA_DEBUG |
62 | extern int ds_pc_debug; | 61 | extern int ds_pc_debug; |
63 | 62 | ||
64 | #define ds_dbg(lvl, fmt, arg...) do { \ | 63 | #define ds_dbg(lvl, fmt, arg...) do { \ |
@@ -149,7 +148,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) | |||
149 | 148 | ||
150 | irq = adj->resource.irq.IRQ; | 149 | irq = adj->resource.irq.IRQ; |
151 | if ((irq < 0) || (irq > 15)) | 150 | if ((irq < 0) || (irq > 15)) |
152 | return CS_BAD_IRQ; | 151 | return -EINVAL; |
153 | 152 | ||
154 | if (adj->Action != REMOVE_MANAGED_RESOURCE) | 153 | if (adj->Action != REMOVE_MANAGED_RESOURCE) |
155 | return 0; | 154 | return 0; |
@@ -167,7 +166,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) | |||
167 | #else | 166 | #else |
168 | 167 | ||
169 | static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { | 168 | static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { |
170 | return CS_SUCCESS; | 169 | return 0; |
171 | } | 170 | } |
172 | 171 | ||
173 | #endif | 172 | #endif |
@@ -175,7 +174,7 @@ static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { | |||
175 | static int pcmcia_adjust_resource_info(adjust_t *adj) | 174 | static int pcmcia_adjust_resource_info(adjust_t *adj) |
176 | { | 175 | { |
177 | struct pcmcia_socket *s; | 176 | struct pcmcia_socket *s; |
178 | int ret = CS_UNSUPPORTED_FUNCTION; | 177 | int ret = -ENOSYS; |
179 | unsigned long flags; | 178 | unsigned long flags; |
180 | 179 | ||
181 | down_read(&pcmcia_socket_list_rwsem); | 180 | down_read(&pcmcia_socket_list_rwsem); |
@@ -248,7 +247,7 @@ static int pccard_get_status(struct pcmcia_socket *s, | |||
248 | if (s->state & SOCKET_SUSPEND) | 247 | if (s->state & SOCKET_SUSPEND) |
249 | status->CardState |= CS_EVENT_PM_SUSPEND; | 248 | status->CardState |= CS_EVENT_PM_SUSPEND; |
250 | if (!(s->state & SOCKET_PRESENT)) | 249 | if (!(s->state & SOCKET_PRESENT)) |
251 | return CS_NO_CARD; | 250 | return -ENODEV; |
252 | 251 | ||
253 | c = (p_dev) ? p_dev->function_config : NULL; | 252 | c = (p_dev) ? p_dev->function_config : NULL; |
254 | 253 | ||
@@ -274,7 +273,7 @@ static int pccard_get_status(struct pcmcia_socket *s, | |||
274 | status->CardState |= | 273 | status->CardState |= |
275 | (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; | 274 | (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; |
276 | } | 275 | } |
277 | return CS_SUCCESS; | 276 | return 0; |
278 | } | 277 | } |
279 | status->CardState |= | 278 | status->CardState |= |
280 | (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0; | 279 | (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0; |
@@ -284,9 +283,81 @@ static int pccard_get_status(struct pcmcia_socket *s, | |||
284 | (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0; | 283 | (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0; |
285 | status->CardState |= | 284 | status->CardState |= |
286 | (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; | 285 | (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; |
287 | return CS_SUCCESS; | 286 | return 0; |
288 | } /* pccard_get_status */ | 287 | } /* pccard_get_status */ |
289 | 288 | ||
289 | int pccard_get_configuration_info(struct pcmcia_socket *s, | ||
290 | struct pcmcia_device *p_dev, | ||
291 | config_info_t *config) | ||
292 | { | ||
293 | config_t *c; | ||
294 | |||
295 | if (!(s->state & SOCKET_PRESENT)) | ||
296 | return -ENODEV; | ||
297 | |||
298 | |||
299 | #ifdef CONFIG_CARDBUS | ||
300 | if (s->state & SOCKET_CARDBUS) { | ||
301 | memset(config, 0, sizeof(config_info_t)); | ||
302 | config->Vcc = s->socket.Vcc; | ||
303 | config->Vpp1 = config->Vpp2 = s->socket.Vpp; | ||
304 | config->Option = s->cb_dev->subordinate->number; | ||
305 | if (s->state & SOCKET_CARDBUS_CONFIG) { | ||
306 | config->Attributes = CONF_VALID_CLIENT; | ||
307 | config->IntType = INT_CARDBUS; | ||
308 | config->AssignedIRQ = s->irq.AssignedIRQ; | ||
309 | if (config->AssignedIRQ) | ||
310 | config->Attributes |= CONF_ENABLE_IRQ; | ||
311 | if (s->io[0].res) { | ||
312 | config->BasePort1 = s->io[0].res->start; | ||
313 | config->NumPorts1 = s->io[0].res->end - | ||
314 | config->BasePort1 + 1; | ||
315 | } | ||
316 | } | ||
317 | return 0; | ||
318 | } | ||
319 | #endif | ||
320 | |||
321 | if (p_dev) { | ||
322 | c = p_dev->function_config; | ||
323 | config->Function = p_dev->func; | ||
324 | } else { | ||
325 | c = NULL; | ||
326 | config->Function = 0; | ||
327 | } | ||
328 | |||
329 | if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { | ||
330 | config->Attributes = 0; | ||
331 | config->Vcc = s->socket.Vcc; | ||
332 | config->Vpp1 = config->Vpp2 = s->socket.Vpp; | ||
333 | return 0; | ||
334 | } | ||
335 | |||
336 | config->Attributes = c->Attributes | CONF_VALID_CLIENT; | ||
337 | config->Vcc = s->socket.Vcc; | ||
338 | config->Vpp1 = config->Vpp2 = s->socket.Vpp; | ||
339 | config->IntType = c->IntType; | ||
340 | config->ConfigBase = c->ConfigBase; | ||
341 | config->Status = c->Status; | ||
342 | config->Pin = c->Pin; | ||
343 | config->Copy = c->Copy; | ||
344 | config->Option = c->Option; | ||
345 | config->ExtStatus = c->ExtStatus; | ||
346 | config->Present = config->CardValues = c->CardValues; | ||
347 | config->IRQAttributes = c->irq.Attributes; | ||
348 | config->AssignedIRQ = s->irq.AssignedIRQ; | ||
349 | config->BasePort1 = c->io.BasePort1; | ||
350 | config->NumPorts1 = c->io.NumPorts1; | ||
351 | config->Attributes1 = c->io.Attributes1; | ||
352 | config->BasePort2 = c->io.BasePort2; | ||
353 | config->NumPorts2 = c->io.NumPorts2; | ||
354 | config->Attributes2 = c->io.Attributes2; | ||
355 | config->IOAddrLines = c->io.IOAddrLines; | ||
356 | |||
357 | return 0; | ||
358 | } /* pccard_get_configuration_info */ | ||
359 | |||
360 | |||
290 | /*====================================================================== | 361 | /*====================================================================== |
291 | 362 | ||
292 | These manage a ring buffer of events pending for one user process | 363 | These manage a ring buffer of events pending for one user process |
@@ -764,7 +835,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
764 | case DS_GET_CONFIGURATION_INFO: | 835 | case DS_GET_CONFIGURATION_INFO: |
765 | if (buf->config.Function && | 836 | if (buf->config.Function && |
766 | (buf->config.Function >= s->functions)) | 837 | (buf->config.Function >= s->functions)) |
767 | ret = CS_BAD_ARGS; | 838 | ret = -EINVAL; |
768 | else { | 839 | else { |
769 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); | 840 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); |
770 | ret = pccard_get_configuration_info(s, p_dev, &buf->config); | 841 | ret = pccard_get_configuration_info(s, p_dev, &buf->config); |
@@ -787,15 +858,15 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
787 | break; | 858 | break; |
788 | case DS_PARSE_TUPLE: | 859 | case DS_PARSE_TUPLE: |
789 | buf->tuple.TupleData = buf->tuple_parse.data; | 860 | buf->tuple.TupleData = buf->tuple_parse.data; |
790 | ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); | 861 | ret = pcmcia_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); |
791 | break; | 862 | break; |
792 | case DS_RESET_CARD: | 863 | case DS_RESET_CARD: |
793 | ret = pccard_reset_card(s); | 864 | ret = pcmcia_reset_card(s); |
794 | break; | 865 | break; |
795 | case DS_GET_STATUS: | 866 | case DS_GET_STATUS: |
796 | if (buf->status.Function && | 867 | if (buf->status.Function && |
797 | (buf->status.Function >= s->functions)) | 868 | (buf->status.Function >= s->functions)) |
798 | ret = CS_BAD_ARGS; | 869 | ret = -EINVAL; |
799 | else { | 870 | else { |
800 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); | 871 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); |
801 | ret = pccard_get_status(s, p_dev, &buf->status); | 872 | ret = pccard_get_status(s, p_dev, &buf->status); |
@@ -826,7 +897,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
826 | goto free_out; | 897 | goto free_out; |
827 | } | 898 | } |
828 | 899 | ||
829 | ret = CS_BAD_ARGS; | 900 | ret = -EINVAL; |
830 | 901 | ||
831 | if (!(buf->conf_reg.Function && | 902 | if (!(buf->conf_reg.Function && |
832 | (buf->conf_reg.Function >= s->functions))) { | 903 | (buf->conf_reg.Function >= s->functions))) { |
@@ -867,7 +938,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
867 | &buf->win_info.map); | 938 | &buf->win_info.map); |
868 | break; | 939 | break; |
869 | case DS_REPLACE_CIS: | 940 | case DS_REPLACE_CIS: |
870 | ret = pcmcia_replace_cis(s, &buf->cisdump); | 941 | ret = pcmcia_replace_cis(s, buf->cisdump.Data, buf->cisdump.Length); |
871 | break; | 942 | break; |
872 | case DS_BIND_REQUEST: | 943 | case DS_BIND_REQUEST: |
873 | if (!capable(CAP_SYS_ADMIN)) { | 944 | if (!capable(CAP_SYS_ADMIN)) { |
@@ -889,22 +960,19 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
889 | err = -EINVAL; | 960 | err = -EINVAL; |
890 | } | 961 | } |
891 | 962 | ||
892 | if ((err == 0) && (ret != CS_SUCCESS)) { | 963 | if ((err == 0) && (ret != 0)) { |
893 | ds_dbg(2, "ds_ioctl: ret = %d\n", ret); | 964 | ds_dbg(2, "ds_ioctl: ret = %d\n", ret); |
894 | switch (ret) { | 965 | switch (ret) { |
895 | case CS_BAD_SOCKET: case CS_NO_CARD: | 966 | case -ENODEV: |
896 | err = -ENODEV; break; | 967 | case -EINVAL: |
897 | case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: | 968 | case -EBUSY: |
898 | case CS_BAD_TUPLE: | 969 | case -ENOSYS: |
899 | err = -EINVAL; break; | 970 | err = ret; |
900 | case CS_IN_USE: | 971 | break; |
901 | err = -EBUSY; break; | 972 | case -ENOMEM: |
902 | case CS_OUT_OF_RESOURCE: | ||
903 | err = -ENOSPC; break; | 973 | err = -ENOSPC; break; |
904 | case CS_NO_MORE_ITEMS: | 974 | case -ENOSPC: |
905 | err = -ENODATA; break; | 975 | err = -ENODATA; break; |
906 | case CS_UNSUPPORTED_FUNCTION: | ||
907 | err = -ENOSYS; break; | ||
908 | default: | 976 | default: |
909 | err = -EIO; break; | 977 | err = -EIO; break; |
910 | } | 978 | } |
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 4884a18cf9e6..afea2b2558b5 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <pcmcia/ds.h> | 29 | #include <pcmcia/ds.h> |
30 | 30 | ||
31 | #include "cs_internal.h" | 31 | #include "cs_internal.h" |
32 | #include "ds_internal.h" | ||
33 | 32 | ||
34 | 33 | ||
35 | /* Access speed for IO windows */ | 34 | /* Access speed for IO windows */ |
@@ -44,16 +43,17 @@ static u8 pcmcia_used_irq[NR_IRQS]; | |||
44 | #endif | 43 | #endif |
45 | 44 | ||
46 | 45 | ||
47 | #ifdef DEBUG | 46 | #ifdef CONFIG_PCMCIA_DEBUG |
48 | extern int ds_pc_debug; | 47 | extern int ds_pc_debug; |
49 | 48 | ||
50 | #define ds_dbg(skt, lvl, fmt, arg...) do { \ | 49 | #define ds_dbg(skt, lvl, fmt, arg...) do { \ |
51 | if (ds_pc_debug >= lvl) \ | 50 | if (ds_pc_debug >= lvl) \ |
52 | printk(KERN_DEBUG "pcmcia_resource: %s: " fmt, \ | 51 | dev_printk(KERN_DEBUG, &skt->dev, \ |
53 | cs_socket_name(skt) , ## arg); \ | 52 | "pcmcia_resource: " fmt, \ |
53 | ## arg); \ | ||
54 | } while (0) | 54 | } while (0) |
55 | #else | 55 | #else |
56 | #define ds_dbg(lvl, fmt, arg...) do { } while (0) | 56 | #define ds_dbg(skt, lvl, fmt, arg...) do { } while (0) |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | 59 | ||
@@ -168,13 +168,13 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | |||
168 | u_char val; | 168 | u_char val; |
169 | 169 | ||
170 | if (!p_dev || !p_dev->function_config) | 170 | if (!p_dev || !p_dev->function_config) |
171 | return CS_NO_CARD; | 171 | return -EINVAL; |
172 | 172 | ||
173 | s = p_dev->socket; | 173 | s = p_dev->socket; |
174 | c = p_dev->function_config; | 174 | c = p_dev->function_config; |
175 | 175 | ||
176 | if (!(c->state & CONFIG_LOCKED)) | 176 | if (!(c->state & CONFIG_LOCKED)) |
177 | return CS_CONFIGURATION_LOCKED; | 177 | return -EACCES; |
178 | 178 | ||
179 | addr = (c->ConfigBase + reg->Offset) >> 1; | 179 | addr = (c->ConfigBase + reg->Offset) >> 1; |
180 | 180 | ||
@@ -188,93 +188,14 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | |||
188 | pcmcia_write_cis_mem(s, 1, addr, 1, &val); | 188 | pcmcia_write_cis_mem(s, 1, addr, 1, &val); |
189 | break; | 189 | break; |
190 | default: | 190 | default: |
191 | return CS_BAD_ARGS; | 191 | return -EINVAL; |
192 | break; | 192 | break; |
193 | } | 193 | } |
194 | return CS_SUCCESS; | 194 | return 0; |
195 | } /* pcmcia_access_configuration_register */ | 195 | } /* pcmcia_access_configuration_register */ |
196 | EXPORT_SYMBOL(pcmcia_access_configuration_register); | 196 | EXPORT_SYMBOL(pcmcia_access_configuration_register); |
197 | 197 | ||
198 | 198 | ||
199 | int pccard_get_configuration_info(struct pcmcia_socket *s, | ||
200 | struct pcmcia_device *p_dev, | ||
201 | config_info_t *config) | ||
202 | { | ||
203 | config_t *c; | ||
204 | |||
205 | if (!(s->state & SOCKET_PRESENT)) | ||
206 | return CS_NO_CARD; | ||
207 | |||
208 | |||
209 | #ifdef CONFIG_CARDBUS | ||
210 | if (s->state & SOCKET_CARDBUS) { | ||
211 | memset(config, 0, sizeof(config_info_t)); | ||
212 | config->Vcc = s->socket.Vcc; | ||
213 | config->Vpp1 = config->Vpp2 = s->socket.Vpp; | ||
214 | config->Option = s->cb_dev->subordinate->number; | ||
215 | if (s->state & SOCKET_CARDBUS_CONFIG) { | ||
216 | config->Attributes = CONF_VALID_CLIENT; | ||
217 | config->IntType = INT_CARDBUS; | ||
218 | config->AssignedIRQ = s->irq.AssignedIRQ; | ||
219 | if (config->AssignedIRQ) | ||
220 | config->Attributes |= CONF_ENABLE_IRQ; | ||
221 | if (s->io[0].res) { | ||
222 | config->BasePort1 = s->io[0].res->start; | ||
223 | config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; | ||
224 | } | ||
225 | } | ||
226 | return CS_SUCCESS; | ||
227 | } | ||
228 | #endif | ||
229 | |||
230 | if (p_dev) { | ||
231 | c = p_dev->function_config; | ||
232 | config->Function = p_dev->func; | ||
233 | } else { | ||
234 | c = NULL; | ||
235 | config->Function = 0; | ||
236 | } | ||
237 | |||
238 | if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { | ||
239 | config->Attributes = 0; | ||
240 | config->Vcc = s->socket.Vcc; | ||
241 | config->Vpp1 = config->Vpp2 = s->socket.Vpp; | ||
242 | return CS_SUCCESS; | ||
243 | } | ||
244 | |||
245 | config->Attributes = c->Attributes | CONF_VALID_CLIENT; | ||
246 | config->Vcc = s->socket.Vcc; | ||
247 | config->Vpp1 = config->Vpp2 = s->socket.Vpp; | ||
248 | config->IntType = c->IntType; | ||
249 | config->ConfigBase = c->ConfigBase; | ||
250 | config->Status = c->Status; | ||
251 | config->Pin = c->Pin; | ||
252 | config->Copy = c->Copy; | ||
253 | config->Option = c->Option; | ||
254 | config->ExtStatus = c->ExtStatus; | ||
255 | config->Present = config->CardValues = c->CardValues; | ||
256 | config->IRQAttributes = c->irq.Attributes; | ||
257 | config->AssignedIRQ = s->irq.AssignedIRQ; | ||
258 | config->BasePort1 = c->io.BasePort1; | ||
259 | config->NumPorts1 = c->io.NumPorts1; | ||
260 | config->Attributes1 = c->io.Attributes1; | ||
261 | config->BasePort2 = c->io.BasePort2; | ||
262 | config->NumPorts2 = c->io.NumPorts2; | ||
263 | config->Attributes2 = c->io.Attributes2; | ||
264 | config->IOAddrLines = c->io.IOAddrLines; | ||
265 | |||
266 | return CS_SUCCESS; | ||
267 | } /* pccard_get_configuration_info */ | ||
268 | |||
269 | int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, | ||
270 | config_info_t *config) | ||
271 | { | ||
272 | return pccard_get_configuration_info(p_dev->socket, p_dev, | ||
273 | config); | ||
274 | } | ||
275 | EXPORT_SYMBOL(pcmcia_get_configuration_info); | ||
276 | |||
277 | |||
278 | /** pcmcia_get_window | 199 | /** pcmcia_get_window |
279 | */ | 200 | */ |
280 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, | 201 | int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, |
@@ -284,12 +205,12 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, | |||
284 | int w; | 205 | int w; |
285 | 206 | ||
286 | if (!s || !(s->state & SOCKET_PRESENT)) | 207 | if (!s || !(s->state & SOCKET_PRESENT)) |
287 | return CS_NO_CARD; | 208 | return -ENODEV; |
288 | for (w = idx; w < MAX_WIN; w++) | 209 | for (w = idx; w < MAX_WIN; w++) |
289 | if (s->state & SOCKET_WIN_REQ(w)) | 210 | if (s->state & SOCKET_WIN_REQ(w)) |
290 | break; | 211 | break; |
291 | if (w == MAX_WIN) | 212 | if (w == MAX_WIN) |
292 | return CS_NO_MORE_ITEMS; | 213 | return -EINVAL; |
293 | win = &s->win[w]; | 214 | win = &s->win[w]; |
294 | req->Base = win->ctl.res->start; | 215 | req->Base = win->ctl.res->start; |
295 | req->Size = win->ctl.res->end - win->ctl.res->start + 1; | 216 | req->Size = win->ctl.res->end - win->ctl.res->start + 1; |
@@ -304,7 +225,7 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, | |||
304 | if (win->ctl.flags & MAP_USE_WAIT) | 225 | if (win->ctl.flags & MAP_USE_WAIT) |
305 | req->Attributes |= WIN_USE_WAIT; | 226 | req->Attributes |= WIN_USE_WAIT; |
306 | *handle = win; | 227 | *handle = win; |
307 | return CS_SUCCESS; | 228 | return 0; |
308 | } /* pcmcia_get_window */ | 229 | } /* pcmcia_get_window */ |
309 | EXPORT_SYMBOL(pcmcia_get_window); | 230 | EXPORT_SYMBOL(pcmcia_get_window); |
310 | 231 | ||
@@ -316,10 +237,10 @@ EXPORT_SYMBOL(pcmcia_get_window); | |||
316 | int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) | 237 | int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) |
317 | { | 238 | { |
318 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) | 239 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) |
319 | return CS_BAD_HANDLE; | 240 | return -EINVAL; |
320 | req->Page = 0; | 241 | req->Page = 0; |
321 | req->CardOffset = win->ctl.card_start; | 242 | req->CardOffset = win->ctl.card_start; |
322 | return CS_SUCCESS; | 243 | return 0; |
323 | } /* pcmcia_get_mem_page */ | 244 | } /* pcmcia_get_mem_page */ |
324 | EXPORT_SYMBOL(pcmcia_get_mem_page); | 245 | EXPORT_SYMBOL(pcmcia_get_mem_page); |
325 | 246 | ||
@@ -328,14 +249,18 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) | |||
328 | { | 249 | { |
329 | struct pcmcia_socket *s; | 250 | struct pcmcia_socket *s; |
330 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) | 251 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) |
331 | return CS_BAD_HANDLE; | 252 | return -EINVAL; |
332 | if (req->Page != 0) | ||
333 | return CS_BAD_PAGE; | ||
334 | s = win->sock; | 253 | s = win->sock; |
254 | if (req->Page != 0) { | ||
255 | ds_dbg(s, 0, "failure: requested page is zero\n"); | ||
256 | return -EINVAL; | ||
257 | } | ||
335 | win->ctl.card_start = req->CardOffset; | 258 | win->ctl.card_start = req->CardOffset; |
336 | if (s->ops->set_mem_map(s, &win->ctl) != 0) | 259 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { |
337 | return CS_BAD_OFFSET; | 260 | ds_dbg(s, 0, "failed to set_mem_map\n"); |
338 | return CS_SUCCESS; | 261 | return -EIO; |
262 | } | ||
263 | return 0; | ||
339 | } /* pcmcia_map_mem_page */ | 264 | } /* pcmcia_map_mem_page */ |
340 | EXPORT_SYMBOL(pcmcia_map_mem_page); | 265 | EXPORT_SYMBOL(pcmcia_map_mem_page); |
341 | 266 | ||
@@ -354,9 +279,9 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
354 | c = p_dev->function_config; | 279 | c = p_dev->function_config; |
355 | 280 | ||
356 | if (!(s->state & SOCKET_PRESENT)) | 281 | if (!(s->state & SOCKET_PRESENT)) |
357 | return CS_NO_CARD; | 282 | return -ENODEV; |
358 | if (!(c->state & CONFIG_LOCKED)) | 283 | if (!(c->state & CONFIG_LOCKED)) |
359 | return CS_CONFIGURATION_LOCKED; | 284 | return -EACCES; |
360 | 285 | ||
361 | if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { | 286 | if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { |
362 | if (mod->Attributes & CONF_ENABLE_IRQ) { | 287 | if (mod->Attributes & CONF_ENABLE_IRQ) { |
@@ -369,20 +294,28 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
369 | s->ops->set_socket(s, &s->socket); | 294 | s->ops->set_socket(s, &s->socket); |
370 | } | 295 | } |
371 | 296 | ||
372 | if (mod->Attributes & CONF_VCC_CHANGE_VALID) | 297 | if (mod->Attributes & CONF_VCC_CHANGE_VALID) { |
373 | return CS_BAD_VCC; | 298 | ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); |
299 | return -EINVAL; | ||
300 | } | ||
374 | 301 | ||
375 | /* We only allow changing Vpp1 and Vpp2 to the same value */ | 302 | /* We only allow changing Vpp1 and Vpp2 to the same value */ |
376 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && | 303 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && |
377 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { | 304 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
378 | if (mod->Vpp1 != mod->Vpp2) | 305 | if (mod->Vpp1 != mod->Vpp2) |
379 | return CS_BAD_VPP; | 306 | ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); |
307 | return -EINVAL; | ||
380 | s->socket.Vpp = mod->Vpp1; | 308 | s->socket.Vpp = mod->Vpp1; |
381 | if (s->ops->set_socket(s, &s->socket)) | 309 | if (s->ops->set_socket(s, &s->socket)) { |
382 | return CS_BAD_VPP; | 310 | dev_printk(KERN_WARNING, &s->dev, |
311 | "Unable to set VPP\n"); | ||
312 | return -EIO; | ||
313 | } | ||
383 | } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || | 314 | } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || |
384 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) | 315 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
385 | return CS_BAD_VPP; | 316 | ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); |
317 | return -EINVAL; | ||
318 | } | ||
386 | 319 | ||
387 | if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { | 320 | if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { |
388 | pccard_io_map io_off = { 0, 0, 0, 0, 1 }; | 321 | pccard_io_map io_off = { 0, 0, 0, 0, 1 }; |
@@ -406,7 +339,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
406 | } | 339 | } |
407 | } | 340 | } |
408 | 341 | ||
409 | return CS_SUCCESS; | 342 | return 0; |
410 | } /* modify_configuration */ | 343 | } /* modify_configuration */ |
411 | EXPORT_SYMBOL(pcmcia_modify_configuration); | 344 | EXPORT_SYMBOL(pcmcia_modify_configuration); |
412 | 345 | ||
@@ -441,7 +374,7 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev) | |||
441 | } | 374 | } |
442 | } | 375 | } |
443 | 376 | ||
444 | return CS_SUCCESS; | 377 | return 0; |
445 | } /* pcmcia_release_configuration */ | 378 | } /* pcmcia_release_configuration */ |
446 | 379 | ||
447 | 380 | ||
@@ -459,7 +392,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) | |||
459 | config_t *c = p_dev->function_config; | 392 | config_t *c = p_dev->function_config; |
460 | 393 | ||
461 | if (!p_dev->_io ) | 394 | if (!p_dev->_io ) |
462 | return CS_BAD_HANDLE; | 395 | return -EINVAL; |
463 | 396 | ||
464 | p_dev->_io = 0; | 397 | p_dev->_io = 0; |
465 | 398 | ||
@@ -467,7 +400,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) | |||
467 | (c->io.NumPorts1 != req->NumPorts1) || | 400 | (c->io.NumPorts1 != req->NumPorts1) || |
468 | (c->io.BasePort2 != req->BasePort2) || | 401 | (c->io.BasePort2 != req->BasePort2) || |
469 | (c->io.NumPorts2 != req->NumPorts2)) | 402 | (c->io.NumPorts2 != req->NumPorts2)) |
470 | return CS_BAD_ARGS; | 403 | return -EINVAL; |
471 | 404 | ||
472 | c->state &= ~CONFIG_IO_REQ; | 405 | c->state &= ~CONFIG_IO_REQ; |
473 | 406 | ||
@@ -475,7 +408,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) | |||
475 | if (req->NumPorts2) | 408 | if (req->NumPorts2) |
476 | release_io_space(s, req->BasePort2, req->NumPorts2); | 409 | release_io_space(s, req->BasePort2, req->NumPorts2); |
477 | 410 | ||
478 | return CS_SUCCESS; | 411 | return 0; |
479 | } /* pcmcia_release_io */ | 412 | } /* pcmcia_release_io */ |
480 | 413 | ||
481 | 414 | ||
@@ -485,15 +418,19 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
485 | config_t *c= p_dev->function_config; | 418 | config_t *c= p_dev->function_config; |
486 | 419 | ||
487 | if (!p_dev->_irq) | 420 | if (!p_dev->_irq) |
488 | return CS_BAD_HANDLE; | 421 | return -EINVAL; |
489 | p_dev->_irq = 0; | 422 | p_dev->_irq = 0; |
490 | 423 | ||
491 | if (c->state & CONFIG_LOCKED) | 424 | if (c->state & CONFIG_LOCKED) |
492 | return CS_CONFIGURATION_LOCKED; | 425 | return -EACCES; |
493 | if (c->irq.Attributes != req->Attributes) | 426 | if (c->irq.Attributes != req->Attributes) { |
494 | return CS_BAD_ATTRIBUTE; | 427 | ds_dbg(s, 0, "IRQ attributes must match assigned ones\n"); |
495 | if (s->irq.AssignedIRQ != req->AssignedIRQ) | 428 | return -EINVAL; |
496 | return CS_BAD_IRQ; | 429 | } |
430 | if (s->irq.AssignedIRQ != req->AssignedIRQ) { | ||
431 | ds_dbg(s, 0, "IRQ must match assigned one\n"); | ||
432 | return -EINVAL; | ||
433 | } | ||
497 | if (--s->irq.Config == 0) { | 434 | if (--s->irq.Config == 0) { |
498 | c->state &= ~CONFIG_IRQ_REQ; | 435 | c->state &= ~CONFIG_IRQ_REQ; |
499 | s->irq.AssignedIRQ = 0; | 436 | s->irq.AssignedIRQ = 0; |
@@ -507,7 +444,7 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
507 | pcmcia_used_irq[req->AssignedIRQ]--; | 444 | pcmcia_used_irq[req->AssignedIRQ]--; |
508 | #endif | 445 | #endif |
509 | 446 | ||
510 | return CS_SUCCESS; | 447 | return 0; |
511 | } /* pcmcia_release_irq */ | 448 | } /* pcmcia_release_irq */ |
512 | 449 | ||
513 | 450 | ||
@@ -516,10 +453,10 @@ int pcmcia_release_window(window_handle_t win) | |||
516 | struct pcmcia_socket *s; | 453 | struct pcmcia_socket *s; |
517 | 454 | ||
518 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) | 455 | if ((win == NULL) || (win->magic != WINDOW_MAGIC)) |
519 | return CS_BAD_HANDLE; | 456 | return -EINVAL; |
520 | s = win->sock; | 457 | s = win->sock; |
521 | if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) | 458 | if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) |
522 | return CS_BAD_HANDLE; | 459 | return -EINVAL; |
523 | 460 | ||
524 | /* Shut down memory window */ | 461 | /* Shut down memory window */ |
525 | win->ctl.flags &= ~MAP_ACTIVE; | 462 | win->ctl.flags &= ~MAP_ACTIVE; |
@@ -536,7 +473,7 @@ int pcmcia_release_window(window_handle_t win) | |||
536 | 473 | ||
537 | win->magic = 0; | 474 | win->magic = 0; |
538 | 475 | ||
539 | return CS_SUCCESS; | 476 | return 0; |
540 | } /* pcmcia_release_window */ | 477 | } /* pcmcia_release_window */ |
541 | EXPORT_SYMBOL(pcmcia_release_window); | 478 | EXPORT_SYMBOL(pcmcia_release_window); |
542 | 479 | ||
@@ -551,18 +488,23 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
551 | pccard_io_map iomap; | 488 | pccard_io_map iomap; |
552 | 489 | ||
553 | if (!(s->state & SOCKET_PRESENT)) | 490 | if (!(s->state & SOCKET_PRESENT)) |
554 | return CS_NO_CARD; | 491 | return -ENODEV;; |
555 | 492 | ||
556 | if (req->IntType & INT_CARDBUS) | 493 | if (req->IntType & INT_CARDBUS) { |
557 | return CS_UNSUPPORTED_MODE; | 494 | ds_dbg(p_dev->socket, 0, "IntType may not be INT_CARDBUS\n"); |
495 | return -EINVAL; | ||
496 | } | ||
558 | c = p_dev->function_config; | 497 | c = p_dev->function_config; |
559 | if (c->state & CONFIG_LOCKED) | 498 | if (c->state & CONFIG_LOCKED) |
560 | return CS_CONFIGURATION_LOCKED; | 499 | return -EACCES; |
561 | 500 | ||
562 | /* Do power control. We don't allow changes in Vcc. */ | 501 | /* Do power control. We don't allow changes in Vcc. */ |
563 | s->socket.Vpp = req->Vpp; | 502 | s->socket.Vpp = req->Vpp; |
564 | if (s->ops->set_socket(s, &s->socket)) | 503 | if (s->ops->set_socket(s, &s->socket)) { |
565 | return CS_BAD_VPP; | 504 | dev_printk(KERN_WARNING, &s->dev, |
505 | "Unable to set socket state\n"); | ||
506 | return -EINVAL; | ||
507 | } | ||
566 | 508 | ||
567 | /* Pick memory or I/O card, DMA mode, interrupt */ | 509 | /* Pick memory or I/O card, DMA mode, interrupt */ |
568 | c->IntType = req->IntType; | 510 | c->IntType = req->IntType; |
@@ -651,7 +593,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
651 | 593 | ||
652 | c->state |= CONFIG_LOCKED; | 594 | c->state |= CONFIG_LOCKED; |
653 | p_dev->_locked = 1; | 595 | p_dev->_locked = 1; |
654 | return CS_SUCCESS; | 596 | return 0; |
655 | } /* pcmcia_request_configuration */ | 597 | } /* pcmcia_request_configuration */ |
656 | EXPORT_SYMBOL(pcmcia_request_configuration); | 598 | EXPORT_SYMBOL(pcmcia_request_configuration); |
657 | 599 | ||
@@ -667,37 +609,48 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) | |||
667 | config_t *c; | 609 | config_t *c; |
668 | 610 | ||
669 | if (!(s->state & SOCKET_PRESENT)) | 611 | if (!(s->state & SOCKET_PRESENT)) |
670 | return CS_NO_CARD; | 612 | return -ENODEV; |
671 | 613 | ||
672 | if (!req) | 614 | if (!req) |
673 | return CS_UNSUPPORTED_MODE; | 615 | return -EINVAL; |
674 | c = p_dev->function_config; | 616 | c = p_dev->function_config; |
675 | if (c->state & CONFIG_LOCKED) | 617 | if (c->state & CONFIG_LOCKED) |
676 | return CS_CONFIGURATION_LOCKED; | 618 | return -EACCES; |
677 | if (c->state & CONFIG_IO_REQ) | 619 | if (c->state & CONFIG_IO_REQ) { |
678 | return CS_IN_USE; | 620 | ds_dbg(s, 0, "IO already configured\n"); |
679 | if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) | 621 | return -EBUSY; |
680 | return CS_BAD_ATTRIBUTE; | 622 | } |
623 | if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) { | ||
624 | ds_dbg(s, 0, "bad attribute setting for IO region 1\n"); | ||
625 | return -EINVAL; | ||
626 | } | ||
681 | if ((req->NumPorts2 > 0) && | 627 | if ((req->NumPorts2 > 0) && |
682 | (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) | 628 | (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) { |
683 | return CS_BAD_ATTRIBUTE; | 629 | ds_dbg(s, 0, "bad attribute setting for IO region 2\n"); |
630 | return -EINVAL; | ||
631 | } | ||
684 | 632 | ||
633 | ds_dbg(s, 1, "trying to allocate resource 1\n"); | ||
685 | if (alloc_io_space(s, req->Attributes1, &req->BasePort1, | 634 | if (alloc_io_space(s, req->Attributes1, &req->BasePort1, |
686 | req->NumPorts1, req->IOAddrLines)) | 635 | req->NumPorts1, req->IOAddrLines)) { |
687 | return CS_IN_USE; | 636 | ds_dbg(s, 0, "allocation of resource 1 failed\n"); |
637 | return -EBUSY; | ||
638 | } | ||
688 | 639 | ||
689 | if (req->NumPorts2) { | 640 | if (req->NumPorts2) { |
641 | ds_dbg(s, 1, "trying to allocate resource 2\n"); | ||
690 | if (alloc_io_space(s, req->Attributes2, &req->BasePort2, | 642 | if (alloc_io_space(s, req->Attributes2, &req->BasePort2, |
691 | req->NumPorts2, req->IOAddrLines)) { | 643 | req->NumPorts2, req->IOAddrLines)) { |
644 | ds_dbg(s, 0, "allocation of resource 2 failed\n"); | ||
692 | release_io_space(s, req->BasePort1, req->NumPorts1); | 645 | release_io_space(s, req->BasePort1, req->NumPorts1); |
693 | return CS_IN_USE; | 646 | return -EBUSY; |
694 | } | 647 | } |
695 | } | 648 | } |
696 | 649 | ||
697 | c->io = *req; | 650 | c->io = *req; |
698 | c->state |= CONFIG_IO_REQ; | 651 | c->state |= CONFIG_IO_REQ; |
699 | p_dev->_io = 1; | 652 | p_dev->_io = 1; |
700 | return CS_SUCCESS; | 653 | return 0; |
701 | } /* pcmcia_request_io */ | 654 | } /* pcmcia_request_io */ |
702 | EXPORT_SYMBOL(pcmcia_request_io); | 655 | EXPORT_SYMBOL(pcmcia_request_io); |
703 | 656 | ||
@@ -723,16 +676,18 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
723 | { | 676 | { |
724 | struct pcmcia_socket *s = p_dev->socket; | 677 | struct pcmcia_socket *s = p_dev->socket; |
725 | config_t *c; | 678 | config_t *c; |
726 | int ret = CS_IN_USE, irq = 0; | 679 | int ret = -EINVAL, irq = 0; |
727 | int type; | 680 | int type; |
728 | 681 | ||
729 | if (!(s->state & SOCKET_PRESENT)) | 682 | if (!(s->state & SOCKET_PRESENT)) |
730 | return CS_NO_CARD; | 683 | return -ENODEV; |
731 | c = p_dev->function_config; | 684 | c = p_dev->function_config; |
732 | if (c->state & CONFIG_LOCKED) | 685 | if (c->state & CONFIG_LOCKED) |
733 | return CS_CONFIGURATION_LOCKED; | 686 | return -EACCES; |
734 | if (c->state & CONFIG_IRQ_REQ) | 687 | if (c->state & CONFIG_IRQ_REQ) { |
735 | return CS_IN_USE; | 688 | ds_dbg(s, 0, "IRQ already configured\n"); |
689 | return -EBUSY; | ||
690 | } | ||
736 | 691 | ||
737 | /* Decide what type of interrupt we are registering */ | 692 | /* Decide what type of interrupt we are registering */ |
738 | type = 0; | 693 | type = 0; |
@@ -795,15 +750,19 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
795 | } | 750 | } |
796 | 751 | ||
797 | if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { | 752 | if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { |
798 | if (request_irq(irq, req->Handler, type, p_dev->devname, req->Instance)) | 753 | ret = request_irq(irq, req->Handler, type, |
799 | return CS_IN_USE; | 754 | p_dev->devname, req->Instance); |
755 | if (ret) | ||
756 | return ret; | ||
800 | } | 757 | } |
801 | 758 | ||
802 | /* Make sure the fact the request type was overridden is passed back */ | 759 | /* Make sure the fact the request type was overridden is passed back */ |
803 | if (type == IRQF_SHARED && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) { | 760 | if (type == IRQF_SHARED && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) { |
804 | req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING; | 761 | req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING; |
805 | printk(KERN_WARNING "pcmcia: request for exclusive IRQ could not be fulfilled.\n"); | 762 | dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: " |
806 | printk(KERN_WARNING "pcmcia: the driver needs updating to supported shared IRQ lines.\n"); | 763 | "request for exclusive IRQ could not be fulfilled.\n"); |
764 | dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: the driver " | ||
765 | "needs updating to supported shared IRQ lines.\n"); | ||
807 | } | 766 | } |
808 | c->irq.Attributes = req->Attributes; | 767 | c->irq.Attributes = req->Attributes; |
809 | s->irq.AssignedIRQ = req->AssignedIRQ = irq; | 768 | s->irq.AssignedIRQ = req->AssignedIRQ = irq; |
@@ -816,7 +775,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
816 | pcmcia_used_irq[irq]++; | 775 | pcmcia_used_irq[irq]++; |
817 | #endif | 776 | #endif |
818 | 777 | ||
819 | return CS_SUCCESS; | 778 | return 0; |
820 | } /* pcmcia_request_irq */ | 779 | } /* pcmcia_request_irq */ |
821 | EXPORT_SYMBOL(pcmcia_request_irq); | 780 | EXPORT_SYMBOL(pcmcia_request_irq); |
822 | 781 | ||
@@ -834,9 +793,11 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
834 | int w; | 793 | int w; |
835 | 794 | ||
836 | if (!(s->state & SOCKET_PRESENT)) | 795 | if (!(s->state & SOCKET_PRESENT)) |
837 | return CS_NO_CARD; | 796 | return -ENODEV; |
838 | if (req->Attributes & (WIN_PAGED | WIN_SHARED)) | 797 | if (req->Attributes & (WIN_PAGED | WIN_SHARED)) { |
839 | return CS_BAD_ATTRIBUTE; | 798 | ds_dbg(s, 0, "bad attribute setting for iomem region\n"); |
799 | return -EINVAL; | ||
800 | } | ||
840 | 801 | ||
841 | /* Window size defaults to smallest available */ | 802 | /* Window size defaults to smallest available */ |
842 | if (req->Size == 0) | 803 | if (req->Size == 0) |
@@ -844,19 +805,25 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
844 | align = (((s->features & SS_CAP_MEM_ALIGN) || | 805 | align = (((s->features & SS_CAP_MEM_ALIGN) || |
845 | (req->Attributes & WIN_STRICT_ALIGN)) ? | 806 | (req->Attributes & WIN_STRICT_ALIGN)) ? |
846 | req->Size : s->map_size); | 807 | req->Size : s->map_size); |
847 | if (req->Size & (s->map_size-1)) | 808 | if (req->Size & (s->map_size-1)) { |
848 | return CS_BAD_SIZE; | 809 | ds_dbg(s, 0, "invalid map size\n"); |
810 | return -EINVAL; | ||
811 | } | ||
849 | if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || | 812 | if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || |
850 | (req->Base & (align-1))) | 813 | (req->Base & (align-1))) { |
851 | return CS_BAD_BASE; | 814 | ds_dbg(s, 0, "invalid base address\n"); |
815 | return -EINVAL; | ||
816 | } | ||
852 | if (req->Base) | 817 | if (req->Base) |
853 | align = 0; | 818 | align = 0; |
854 | 819 | ||
855 | /* Allocate system memory window */ | 820 | /* Allocate system memory window */ |
856 | for (w = 0; w < MAX_WIN; w++) | 821 | for (w = 0; w < MAX_WIN; w++) |
857 | if (!(s->state & SOCKET_WIN_REQ(w))) break; | 822 | if (!(s->state & SOCKET_WIN_REQ(w))) break; |
858 | if (w == MAX_WIN) | 823 | if (w == MAX_WIN) { |
859 | return CS_OUT_OF_RESOURCE; | 824 | ds_dbg(s, 0, "all windows are used already\n"); |
825 | return -EINVAL; | ||
826 | } | ||
860 | 827 | ||
861 | win = &s->win[w]; | 828 | win = &s->win[w]; |
862 | win->magic = WINDOW_MAGIC; | 829 | win->magic = WINDOW_MAGIC; |
@@ -867,8 +834,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
867 | if (!(s->features & SS_CAP_STATIC_MAP)) { | 834 | if (!(s->features & SS_CAP_STATIC_MAP)) { |
868 | win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, | 835 | win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, |
869 | (req->Attributes & WIN_MAP_BELOW_1MB), s); | 836 | (req->Attributes & WIN_MAP_BELOW_1MB), s); |
870 | if (!win->ctl.res) | 837 | if (!win->ctl.res) { |
871 | return CS_IN_USE; | 838 | ds_dbg(s, 0, "allocating mem region failed\n"); |
839 | return -EINVAL; | ||
840 | } | ||
872 | } | 841 | } |
873 | (*p_dev)->_win |= CLIENT_WIN_REQ(w); | 842 | (*p_dev)->_win |= CLIENT_WIN_REQ(w); |
874 | 843 | ||
@@ -885,8 +854,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
885 | if (req->Attributes & WIN_USE_WAIT) | 854 | if (req->Attributes & WIN_USE_WAIT) |
886 | win->ctl.flags |= MAP_USE_WAIT; | 855 | win->ctl.flags |= MAP_USE_WAIT; |
887 | win->ctl.card_start = 0; | 856 | win->ctl.card_start = 0; |
888 | if (s->ops->set_mem_map(s, &win->ctl) != 0) | 857 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { |
889 | return CS_BAD_ARGS; | 858 | ds_dbg(s, 0, "failed to set memory mapping\n"); |
859 | return -EIO; | ||
860 | } | ||
890 | s->state |= SOCKET_WIN_REQ(w); | 861 | s->state |= SOCKET_WIN_REQ(w); |
891 | 862 | ||
892 | /* Return window handle */ | 863 | /* Return window handle */ |
@@ -897,7 +868,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
897 | } | 868 | } |
898 | *wh = win; | 869 | *wh = win; |
899 | 870 | ||
900 | return CS_SUCCESS; | 871 | return 0; |
901 | } /* pcmcia_request_window */ | 872 | } /* pcmcia_request_window */ |
902 | EXPORT_SYMBOL(pcmcia_request_window); | 873 | EXPORT_SYMBOL(pcmcia_request_window); |
903 | 874 | ||
@@ -909,3 +880,79 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) { | |||
909 | pcmcia_release_window(p_dev->win); | 880 | pcmcia_release_window(p_dev->win); |
910 | } | 881 | } |
911 | EXPORT_SYMBOL(pcmcia_disable_device); | 882 | EXPORT_SYMBOL(pcmcia_disable_device); |
883 | |||
884 | |||
885 | struct pcmcia_cfg_mem { | ||
886 | tuple_t tuple; | ||
887 | cisparse_t parse; | ||
888 | u8 buf[256]; | ||
889 | cistpl_cftable_entry_t dflt; | ||
890 | }; | ||
891 | |||
892 | /** | ||
893 | * pcmcia_loop_config() - loop over configuration options | ||
894 | * @p_dev: the struct pcmcia_device which we need to loop for. | ||
895 | * @conf_check: function to call for each configuration option. | ||
896 | * It gets passed the struct pcmcia_device, the CIS data | ||
897 | * describing the configuration option, and private data | ||
898 | * being passed to pcmcia_loop_config() | ||
899 | * @priv_data: private data to be passed to the conf_check function. | ||
900 | * | ||
901 | * pcmcia_loop_config() loops over all configuration options, and calls | ||
902 | * the driver-specific conf_check() for each one, checking whether | ||
903 | * it is a valid one. | ||
904 | */ | ||
905 | int pcmcia_loop_config(struct pcmcia_device *p_dev, | ||
906 | int (*conf_check) (struct pcmcia_device *p_dev, | ||
907 | cistpl_cftable_entry_t *cfg, | ||
908 | cistpl_cftable_entry_t *dflt, | ||
909 | unsigned int vcc, | ||
910 | void *priv_data), | ||
911 | void *priv_data) | ||
912 | { | ||
913 | struct pcmcia_cfg_mem *cfg_mem; | ||
914 | |||
915 | tuple_t *tuple; | ||
916 | int ret = -ENODEV; | ||
917 | unsigned int vcc; | ||
918 | |||
919 | cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); | ||
920 | if (cfg_mem == NULL) | ||
921 | return -ENOMEM; | ||
922 | |||
923 | /* get the current Vcc setting */ | ||
924 | vcc = p_dev->socket->socket.Vcc; | ||
925 | |||
926 | tuple = &cfg_mem->tuple; | ||
927 | tuple->TupleData = cfg_mem->buf; | ||
928 | tuple->TupleDataMax = 255; | ||
929 | tuple->TupleOffset = 0; | ||
930 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
931 | tuple->Attributes = 0; | ||
932 | |||
933 | ret = pcmcia_get_first_tuple(p_dev, tuple); | ||
934 | while (!ret) { | ||
935 | cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry; | ||
936 | |||
937 | if (pcmcia_get_tuple_data(p_dev, tuple)) | ||
938 | goto next_entry; | ||
939 | |||
940 | if (pcmcia_parse_tuple(tuple, &cfg_mem->parse)) | ||
941 | goto next_entry; | ||
942 | |||
943 | /* default values */ | ||
944 | p_dev->conf.ConfigIndex = cfg->index; | ||
945 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
946 | cfg_mem->dflt = *cfg; | ||
947 | |||
948 | ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data); | ||
949 | if (!ret) | ||
950 | break; | ||
951 | |||
952 | next_entry: | ||
953 | ret = pcmcia_get_next_tuple(p_dev, tuple); | ||
954 | } | ||
955 | |||
956 | return ret; | ||
957 | } | ||
958 | EXPORT_SYMBOL(pcmcia_loop_config); | ||
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c index 13f1e0fd3f31..bb9ddb9532e3 100644 --- a/drivers/pcmcia/pxa2xx_base.c +++ b/drivers/pcmcia/pxa2xx_base.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <pcmcia/ss.h> | 36 | #include <pcmcia/ss.h> |
37 | #include <pcmcia/cistpl.h> | 37 | #include <pcmcia/cistpl.h> |
38 | 38 | ||
39 | #include "cs_internal.h" | ||
40 | #include "soc_common.h" | 39 | #include "soc_common.h" |
41 | #include "pxa2xx_base.h" | 40 | #include "pxa2xx_base.h" |
42 | 41 | ||
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 203e579ebbd2..17f4ecf1c0c5 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -122,19 +122,22 @@ static void free_region(struct resource *res) | |||
122 | 122 | ||
123 | static int add_interval(struct resource_map *map, u_long base, u_long num) | 123 | static int add_interval(struct resource_map *map, u_long base, u_long num) |
124 | { | 124 | { |
125 | struct resource_map *p, *q; | 125 | struct resource_map *p, *q; |
126 | 126 | ||
127 | for (p = map; ; p = p->next) { | 127 | for (p = map; ; p = p->next) { |
128 | if ((p != map) && (p->base+p->num-1 >= base)) | 128 | if ((p != map) && (p->base+p->num-1 >= base)) |
129 | return -1; | 129 | return -1; |
130 | if ((p->next == map) || (p->next->base > base+num-1)) | 130 | if ((p->next == map) || (p->next->base > base+num-1)) |
131 | break; | 131 | break; |
132 | } | 132 | } |
133 | q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); | 133 | q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); |
134 | if (!q) return CS_OUT_OF_RESOURCE; | 134 | if (!q) { |
135 | q->base = base; q->num = num; | 135 | printk(KERN_WARNING "out of memory to update resources\n"); |
136 | q->next = p->next; p->next = q; | 136 | return -ENOMEM; |
137 | return CS_SUCCESS; | 137 | } |
138 | q->base = base; q->num = num; | ||
139 | q->next = p->next; p->next = q; | ||
140 | return 0; | ||
138 | } | 141 | } |
139 | 142 | ||
140 | /*====================================================================*/ | 143 | /*====================================================================*/ |
@@ -166,7 +169,10 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num) | |||
166 | } else { | 169 | } else { |
167 | /* Split the block into two pieces */ | 170 | /* Split the block into two pieces */ |
168 | p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); | 171 | p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); |
169 | if (!p) return CS_OUT_OF_RESOURCE; | 172 | if (!p) { |
173 | printk(KERN_WARNING "out of memory to update resources\n"); | ||
174 | return -ENOMEM; | ||
175 | } | ||
170 | p->base = base+num; | 176 | p->base = base+num; |
171 | p->num = q->base+q->num - p->base; | 177 | p->num = q->base+q->num - p->base; |
172 | q->num = base - q->base; | 178 | q->num = base - q->base; |
@@ -174,7 +180,7 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num) | |||
174 | } | 180 | } |
175 | } | 181 | } |
176 | } | 182 | } |
177 | return CS_SUCCESS; | 183 | return 0; |
178 | } | 184 | } |
179 | 185 | ||
180 | /*====================================================================== | 186 | /*====================================================================== |
@@ -194,13 +200,14 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base, | |||
194 | int any; | 200 | int any; |
195 | u_char *b, hole, most; | 201 | u_char *b, hole, most; |
196 | 202 | ||
197 | printk(KERN_INFO "cs: IO port probe %#x-%#x:", | 203 | dev_printk(KERN_INFO, &s->dev, "cs: IO port probe %#x-%#x:", |
198 | base, base+num-1); | 204 | base, base+num-1); |
199 | 205 | ||
200 | /* First, what does a floating port look like? */ | 206 | /* First, what does a floating port look like? */ |
201 | b = kzalloc(256, GFP_KERNEL); | 207 | b = kzalloc(256, GFP_KERNEL); |
202 | if (!b) { | 208 | if (!b) { |
203 | printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes"); | 209 | dev_printk(KERN_ERR, &s->dev, |
210 | "do_io_probe: unable to kmalloc 256 bytes"); | ||
204 | return; | 211 | return; |
205 | } | 212 | } |
206 | for (i = base, most = 0; i < base+num; i += 8) { | 213 | for (i = base, most = 0; i < base+num; i += 8) { |
@@ -366,8 +373,8 @@ static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s) | |||
366 | struct socket_data *s_data = s->resource_data; | 373 | struct socket_data *s_data = s->resource_data; |
367 | u_long i, j, bad, fail, step; | 374 | u_long i, j, bad, fail, step; |
368 | 375 | ||
369 | printk(KERN_INFO "cs: memory probe 0x%06lx-0x%06lx:", | 376 | dev_printk(KERN_INFO, &s->dev, "cs: memory probe 0x%06lx-0x%06lx:", |
370 | base, base+num-1); | 377 | base, base+num-1); |
371 | bad = fail = 0; | 378 | bad = fail = 0; |
372 | step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff); | 379 | step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff); |
373 | /* don't allow too large steps */ | 380 | /* don't allow too large steps */ |
@@ -431,8 +438,8 @@ static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) | |||
431 | if (probe_mask & MEM_PROBE_HIGH) { | 438 | if (probe_mask & MEM_PROBE_HIGH) { |
432 | if (inv_probe(s_data->mem_db.next, s) > 0) | 439 | if (inv_probe(s_data->mem_db.next, s) > 0) |
433 | return 0; | 440 | return 0; |
434 | printk(KERN_NOTICE "cs: warning: no high memory space " | 441 | dev_printk(KERN_NOTICE, &s->dev, |
435 | "available!\n"); | 442 | "cs: warning: no high memory space available!\n"); |
436 | return -ENODEV; | 443 | return -ENODEV; |
437 | } | 444 | } |
438 | 445 | ||
@@ -794,10 +801,11 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) | |||
794 | if (res->flags & IORESOURCE_IO) { | 801 | if (res->flags & IORESOURCE_IO) { |
795 | if (res == &ioport_resource) | 802 | if (res == &ioport_resource) |
796 | continue; | 803 | continue; |
797 | printk(KERN_INFO "pcmcia: parent PCI bridge I/O " | 804 | dev_printk(KERN_INFO, &s->cb_dev->dev, |
798 | "window: 0x%llx - 0x%llx\n", | 805 | "pcmcia: parent PCI bridge I/O " |
799 | (unsigned long long)res->start, | 806 | "window: 0x%llx - 0x%llx\n", |
800 | (unsigned long long)res->end); | 807 | (unsigned long long)res->start, |
808 | (unsigned long long)res->end); | ||
801 | if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) | 809 | if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) |
802 | done |= IORESOURCE_IO; | 810 | done |= IORESOURCE_IO; |
803 | 811 | ||
@@ -806,10 +814,11 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) | |||
806 | if (res->flags & IORESOURCE_MEM) { | 814 | if (res->flags & IORESOURCE_MEM) { |
807 | if (res == &iomem_resource) | 815 | if (res == &iomem_resource) |
808 | continue; | 816 | continue; |
809 | printk(KERN_INFO "pcmcia: parent PCI bridge Memory " | 817 | dev_printk(KERN_INFO, &s->cb_dev->dev, |
810 | "window: 0x%llx - 0x%llx\n", | 818 | "pcmcia: parent PCI bridge Memory " |
811 | (unsigned long long)res->start, | 819 | "window: 0x%llx - 0x%llx\n", |
812 | (unsigned long long)res->end); | 820 | (unsigned long long)res->start, |
821 | (unsigned long long)res->end); | ||
813 | if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) | 822 | if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) |
814 | done |= IORESOURCE_MEM; | 823 | done |= IORESOURCE_MEM; |
815 | } | 824 | } |
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index da3972153226..f49ac6666153 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #include <mach/pxa-regs.h> | 54 | #include <mach/pxa-regs.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifdef DEBUG | 57 | #ifdef CONFIG_PCMCIA_DEBUG |
58 | 58 | ||
59 | static int pc_debug; | 59 | static int pc_debug; |
60 | module_param(pc_debug, int, 0644); | 60 | module_param(pc_debug, int, 0644); |
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h index 91ef6a0da3ab..38c67375f363 100644 --- a/drivers/pcmcia/soc_common.h +++ b/drivers/pcmcia/soc_common.h | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <pcmcia/cs.h> | 15 | #include <pcmcia/cs.h> |
16 | #include <pcmcia/ss.h> | 16 | #include <pcmcia/ss.h> |
17 | #include <pcmcia/cistpl.h> | 17 | #include <pcmcia/cistpl.h> |
18 | #include "cs_internal.h" | ||
19 | 18 | ||
20 | 19 | ||
21 | struct device; | 20 | struct device; |
@@ -137,7 +136,7 @@ extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_lev | |||
137 | extern int soc_common_drv_pcmcia_remove(struct device *dev); | 136 | extern int soc_common_drv_pcmcia_remove(struct device *dev); |
138 | 137 | ||
139 | 138 | ||
140 | #ifdef DEBUG | 139 | #ifdef CONFIG_PCMCIA_DEBUG |
141 | 140 | ||
142 | extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func, | 141 | extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func, |
143 | int lvl, const char *fmt, ...); | 142 | int lvl, const char *fmt, ...); |
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 006a29e91d83..ff9a3bb3c88d 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c | |||
@@ -316,27 +316,18 @@ static ssize_t pccard_store_cis(struct kobject *kobj, | |||
316 | char *buf, loff_t off, size_t count) | 316 | char *buf, loff_t off, size_t count) |
317 | { | 317 | { |
318 | struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj)); | 318 | struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj)); |
319 | cisdump_t *cis; | ||
320 | int error; | 319 | int error; |
321 | 320 | ||
322 | if (off) | 321 | if (off) |
323 | return -EINVAL; | 322 | return -EINVAL; |
324 | 323 | ||
325 | if (count >= 0x200) | 324 | if (count >= CISTPL_MAX_CIS_SIZE) |
326 | return -EINVAL; | 325 | return -EINVAL; |
327 | 326 | ||
328 | if (!(s->state & SOCKET_PRESENT)) | 327 | if (!(s->state & SOCKET_PRESENT)) |
329 | return -ENODEV; | 328 | return -ENODEV; |
330 | 329 | ||
331 | cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); | 330 | error = pcmcia_replace_cis(s, buf, count); |
332 | if (!cis) | ||
333 | return -ENOMEM; | ||
334 | |||
335 | cis->Length = count + 1; | ||
336 | memcpy(cis->Data, buf, count); | ||
337 | |||
338 | error = pcmcia_replace_cis(s, cis); | ||
339 | kfree(cis); | ||
340 | if (error) | 331 | if (error) |
341 | return -EIO; | 332 | return -EIO; |
342 | 333 | ||
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c index 5792bd5c54f9..2a613e920fd4 100644 --- a/drivers/pcmcia/tcic.c +++ b/drivers/pcmcia/tcic.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #include <pcmcia/ss.h> | 55 | #include <pcmcia/ss.h> |
56 | #include "tcic.h" | 56 | #include "tcic.h" |
57 | 57 | ||
58 | #ifdef DEBUG | 58 | #ifdef CONFIG_PCMCIA_DEBUG |
59 | static int pc_debug; | 59 | static int pc_debug; |
60 | 60 | ||
61 | module_param(pc_debug, int, 0644); | 61 | module_param(pc_debug, int, 0644); |
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h index 129db7bd06c3..aaa70227bfb0 100644 --- a/drivers/pcmcia/ti113x.h +++ b/drivers/pcmcia/ti113x.h | |||
@@ -339,8 +339,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket) | |||
339 | 339 | ||
340 | mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); | 340 | mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); |
341 | devctl = config_readb(socket, TI113X_DEVICE_CONTROL); | 341 | devctl = config_readb(socket, TI113X_DEVICE_CONTROL); |
342 | printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", | 342 | dev_printk(KERN_INFO, &socket->dev->dev, |
343 | pci_name(socket->dev), mfunc, devctl); | 343 | "TI: mfunc 0x%08x, devctl 0x%02x\n", mfunc, devctl); |
344 | 344 | ||
345 | /* make sure PCI interrupts are enabled before probing */ | 345 | /* make sure PCI interrupts are enabled before probing */ |
346 | ti_init(socket); | 346 | ti_init(socket); |
@@ -354,8 +354,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket) | |||
354 | * We're here which means PCI interrupts are _not_ delivered. try to | 354 | * We're here which means PCI interrupts are _not_ delivered. try to |
355 | * find the right setting (all serial or parallel) | 355 | * find the right setting (all serial or parallel) |
356 | */ | 356 | */ |
357 | printk(KERN_INFO "Yenta TI: socket %s probing PCI interrupt failed, trying to fix\n", | 357 | dev_printk(KERN_INFO, &socket->dev->dev, |
358 | pci_name(socket->dev)); | 358 | "TI: probing PCI interrupt failed, trying to fix\n"); |
359 | 359 | ||
360 | /* for serial PCI make sure MFUNC3 is set to IRQSER */ | 360 | /* for serial PCI make sure MFUNC3 is set to IRQSER */ |
361 | if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { | 361 | if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { |
@@ -379,8 +379,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket) | |||
379 | 379 | ||
380 | pci_irq_status = yenta_probe_cb_irq(socket); | 380 | pci_irq_status = yenta_probe_cb_irq(socket); |
381 | if (pci_irq_status == 1) { | 381 | if (pci_irq_status == 1) { |
382 | printk(KERN_INFO "Yenta TI: socket %s all-serial interrupts ok\n", | 382 | dev_printk(KERN_INFO, &socket->dev->dev, |
383 | pci_name(socket->dev)); | 383 | "TI: all-serial interrupts ok\n"); |
384 | mfunc_old = mfunc; | 384 | mfunc_old = mfunc; |
385 | goto out; | 385 | goto out; |
386 | } | 386 | } |
@@ -395,8 +395,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket) | |||
395 | } | 395 | } |
396 | 396 | ||
397 | /* serial PCI interrupts not working fall back to parallel */ | 397 | /* serial PCI interrupts not working fall back to parallel */ |
398 | printk(KERN_INFO "Yenta TI: socket %s falling back to parallel PCI interrupts\n", | 398 | dev_printk(KERN_INFO, &socket->dev->dev, |
399 | pci_name(socket->dev)); | 399 | "TI: falling back to parallel PCI interrupts\n"); |
400 | devctl &= ~TI113X_DCR_IMODE_MASK; | 400 | devctl &= ~TI113X_DCR_IMODE_MASK; |
401 | devctl |= TI113X_DCR_IMODE_SERIAL; /* serial ISA could be right */ | 401 | devctl |= TI113X_DCR_IMODE_SERIAL; /* serial ISA could be right */ |
402 | config_writeb(socket, TI113X_DEVICE_CONTROL, devctl); | 402 | config_writeb(socket, TI113X_DEVICE_CONTROL, devctl); |
@@ -427,8 +427,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket) | |||
427 | pci_irq_status = yenta_probe_cb_irq(socket); | 427 | pci_irq_status = yenta_probe_cb_irq(socket); |
428 | if (pci_irq_status == 1) { | 428 | if (pci_irq_status == 1) { |
429 | mfunc_old = mfunc; | 429 | mfunc_old = mfunc; |
430 | printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts ok\n", | 430 | dev_printk(KERN_INFO, &socket->dev->dev, |
431 | pci_name(socket->dev)); | 431 | "TI: parallel PCI interrupts ok\n"); |
432 | } else { | 432 | } else { |
433 | /* not working, back to old value */ | 433 | /* not working, back to old value */ |
434 | mfunc = mfunc_old; | 434 | mfunc = mfunc_old; |
@@ -440,8 +440,9 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket) | |||
440 | out: | 440 | out: |
441 | if (pci_irq_status < 1) { | 441 | if (pci_irq_status < 1) { |
442 | socket->cb_irq = 0; | 442 | socket->cb_irq = 0; |
443 | printk(KERN_INFO "Yenta TI: socket %s no PCI interrupts. Fish. Please report.\n", | 443 | dev_printk(KERN_INFO, &socket->dev->dev, |
444 | pci_name(socket->dev)); | 444 | "Yenta TI: no PCI interrupts. Fish. " |
445 | "Please report.\n"); | ||
445 | } | 446 | } |
446 | } | 447 | } |
447 | 448 | ||
@@ -513,8 +514,9 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket) | |||
513 | 514 | ||
514 | mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); | 515 | mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); |
515 | devctl = config_readb(socket, TI113X_DEVICE_CONTROL); | 516 | devctl = config_readb(socket, TI113X_DEVICE_CONTROL); |
516 | printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", | 517 | dev_printk(KERN_INFO, &socket->dev->dev, |
517 | pci_name(socket->dev), mfunc, devctl); | 518 | "TI: mfunc 0x%08x, devctl 0x%02x\n", |
519 | mfunc, devctl); | ||
518 | 520 | ||
519 | /* if IRQs are configured as tied, align irq of func1 with func0 */ | 521 | /* if IRQs are configured as tied, align irq of func1 with func0 */ |
520 | sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); | 522 | sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); |
@@ -533,9 +535,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket) | |||
533 | * We're here which means PCI interrupts are _not_ delivered. try to | 535 | * We're here which means PCI interrupts are _not_ delivered. try to |
534 | * find the right setting | 536 | * find the right setting |
535 | */ | 537 | */ |
536 | printk(KERN_INFO "Yenta TI: socket %s probing PCI interrupt failed, trying to fix\n", | 538 | dev_printk(KERN_INFO, &socket->dev->dev, |
537 | pci_name(socket->dev)); | 539 | "TI: probing PCI interrupt failed, trying to fix\n"); |
538 | |||
539 | 540 | ||
540 | /* if all serial: set INTRTIE, probe again */ | 541 | /* if all serial: set INTRTIE, probe again */ |
541 | if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { | 542 | if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { |
@@ -544,8 +545,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket) | |||
544 | if (ti12xx_tie_interrupts(socket, &old_irq)) { | 545 | if (ti12xx_tie_interrupts(socket, &old_irq)) { |
545 | pci_irq_status = yenta_probe_cb_irq(socket); | 546 | pci_irq_status = yenta_probe_cb_irq(socket); |
546 | if (pci_irq_status == 1) { | 547 | if (pci_irq_status == 1) { |
547 | printk(KERN_INFO "Yenta TI: socket %s all-serial interrupts, tied ok\n", | 548 | dev_printk(KERN_INFO, &socket->dev->dev, |
548 | pci_name(socket->dev)); | 549 | "TI: all-serial interrupts, tied ok\n"); |
549 | goto out; | 550 | goto out; |
550 | } | 551 | } |
551 | 552 | ||
@@ -582,8 +583,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket) | |||
582 | 583 | ||
583 | pci_irq_status = yenta_probe_cb_irq(socket); | 584 | pci_irq_status = yenta_probe_cb_irq(socket); |
584 | if (pci_irq_status == 1) { | 585 | if (pci_irq_status == 1) { |
585 | printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts ok\n", | 586 | dev_printk(KERN_INFO, &socket->dev->dev, |
586 | pci_name(socket->dev)); | 587 | "TI: parallel PCI interrupts ok\n"); |
587 | goto out; | 588 | goto out; |
588 | } | 589 | } |
589 | 590 | ||
@@ -593,13 +594,13 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket) | |||
593 | if (pci_irq_status == -1) | 594 | if (pci_irq_status == -1) |
594 | goto out; | 595 | goto out; |
595 | } | 596 | } |
596 | 597 | ||
597 | /* still nothing: set INTRTIE */ | 598 | /* still nothing: set INTRTIE */ |
598 | if (ti12xx_tie_interrupts(socket, &old_irq)) { | 599 | if (ti12xx_tie_interrupts(socket, &old_irq)) { |
599 | pci_irq_status = yenta_probe_cb_irq(socket); | 600 | pci_irq_status = yenta_probe_cb_irq(socket); |
600 | if (pci_irq_status == 1) { | 601 | if (pci_irq_status == 1) { |
601 | printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts, tied ok\n", | 602 | dev_printk(KERN_INFO, &socket->dev->dev, |
602 | pci_name(socket->dev)); | 603 | "TI: parallel PCI interrupts, tied ok\n"); |
603 | goto out; | 604 | goto out; |
604 | } | 605 | } |
605 | 606 | ||
@@ -610,8 +611,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket) | |||
610 | out: | 611 | out: |
611 | if (pci_irq_status < 1) { | 612 | if (pci_irq_status < 1) { |
612 | socket->cb_irq = 0; | 613 | socket->cb_irq = 0; |
613 | printk(KERN_INFO "Yenta TI: socket %s no PCI interrupts. Fish. Please report.\n", | 614 | dev_printk(KERN_INFO, &socket->dev->dev, |
614 | pci_name(socket->dev)); | 615 | "TI: no PCI interrupts. Fish. Please report.\n"); |
615 | } | 616 | } |
616 | } | 617 | } |
617 | 618 | ||
@@ -815,11 +816,13 @@ static int ti12xx_override(struct yenta_socket *socket) | |||
815 | /* make sure that memory burst is active */ | 816 | /* make sure that memory burst is active */ |
816 | val_orig = val = config_readl(socket, TI113X_SYSTEM_CONTROL); | 817 | val_orig = val = config_readl(socket, TI113X_SYSTEM_CONTROL); |
817 | if (disable_clkrun && PCI_FUNC(socket->dev->devfn) == 0) { | 818 | if (disable_clkrun && PCI_FUNC(socket->dev->devfn) == 0) { |
818 | printk(KERN_INFO "Yenta: Disabling CLKRUN feature\n"); | 819 | dev_printk(KERN_INFO, &socket->dev->dev, |
820 | "Disabling CLKRUN feature\n"); | ||
819 | val |= TI113X_SCR_KEEPCLK; | 821 | val |= TI113X_SCR_KEEPCLK; |
820 | } | 822 | } |
821 | if (!(val & TI122X_SCR_MRBURSTUP)) { | 823 | if (!(val & TI122X_SCR_MRBURSTUP)) { |
822 | printk(KERN_INFO "Yenta: Enabling burst memory read transactions\n"); | 824 | dev_printk(KERN_INFO, &socket->dev->dev, |
825 | "Enabling burst memory read transactions\n"); | ||
823 | val |= TI122X_SCR_MRBURSTUP; | 826 | val |= TI122X_SCR_MRBURSTUP; |
824 | } | 827 | } |
825 | if (val_orig != val) | 828 | if (val_orig != val) |
@@ -830,10 +833,12 @@ static int ti12xx_override(struct yenta_socket *socket) | |||
830 | * CSC interrupts to PCI rather than INTVAL. | 833 | * CSC interrupts to PCI rather than INTVAL. |
831 | */ | 834 | */ |
832 | val = config_readb(socket, TI1250_DIAGNOSTIC); | 835 | val = config_readb(socket, TI1250_DIAGNOSTIC); |
833 | printk(KERN_INFO "Yenta: Using %s to route CSC interrupts to PCI\n", | 836 | dev_printk(KERN_INFO, &socket->dev->dev, |
834 | (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL"); | 837 | "Using %s to route CSC interrupts to PCI\n", |
835 | printk(KERN_INFO "Yenta: Routing CardBus interrupts to %s\n", | 838 | (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL"); |
836 | (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA"); | 839 | dev_printk(KERN_INFO, &socket->dev->dev, |
840 | "Routing CardBus interrupts to %s\n", | ||
841 | (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA"); | ||
837 | 842 | ||
838 | /* do irqrouting, depending on function */ | 843 | /* do irqrouting, depending on function */ |
839 | if (PCI_FUNC(socket->dev->devfn) == 0) | 844 | if (PCI_FUNC(socket->dev->devfn) == 0) |
@@ -858,8 +863,9 @@ static int ti1250_override(struct yenta_socket *socket) | |||
858 | diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ; | 863 | diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ; |
859 | 864 | ||
860 | if (diag != old) { | 865 | if (diag != old) { |
861 | printk(KERN_INFO "Yenta: adjusting diagnostic: %02x -> %02x\n", | 866 | dev_printk(KERN_INFO, &socket->dev->dev, |
862 | old, diag); | 867 | "adjusting diagnostic: %02x -> %02x\n", |
868 | old, diag); | ||
863 | config_writeb(socket, TI1250_DIAGNOSTIC, diag); | 869 | config_writeb(socket, TI1250_DIAGNOSTIC, diag); |
864 | } | 870 | } |
865 | 871 | ||
@@ -924,7 +930,9 @@ static void ene_tune_bridge(struct pcmcia_socket *sock, struct pci_bus *bus) | |||
924 | /* default to clear TLTEnable bit, old behaviour */ | 930 | /* default to clear TLTEnable bit, old behaviour */ |
925 | test_c9 &= ~ENE_TEST_C9_TLTENABLE; | 931 | test_c9 &= ~ENE_TEST_C9_TLTENABLE; |
926 | 932 | ||
927 | printk(KERN_INFO "yenta EnE: chaning testregister 0xC9, %02x -> %02x\n", old_c9, test_c9); | 933 | dev_printk(KERN_INFO, &socket->dev->dev, |
934 | "EnE: chaning testregister 0xC9, %02x -> %02x\n", | ||
935 | old_c9, test_c9); | ||
928 | config_writeb(socket, ENE_TEST_C9, test_c9); | 936 | config_writeb(socket, ENE_TEST_C9, test_c9); |
929 | } | 937 | } |
930 | 938 | ||
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 0ab1fb65cdc3..3ecd7c99d8eb 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c | |||
@@ -38,11 +38,7 @@ static int pwr_irqs_off; | |||
38 | module_param(pwr_irqs_off, bool, 0644); | 38 | module_param(pwr_irqs_off, bool, 0644); |
39 | MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!"); | 39 | MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!"); |
40 | 40 | ||
41 | #if 0 | 41 | #define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args) |
42 | #define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args) | ||
43 | #else | ||
44 | #define debug(x,args...) | ||
45 | #endif | ||
46 | 42 | ||
47 | /* Don't ask.. */ | 43 | /* Don't ask.. */ |
48 | #define to_cycles(ns) ((ns)/120) | 44 | #define to_cycles(ns) ((ns)/120) |
@@ -69,13 +65,13 @@ MODULE_PARM_DESC (override_bios, "yenta ignore bios resource allocation"); | |||
69 | static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg) | 65 | static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg) |
70 | { | 66 | { |
71 | u32 val = readl(socket->base + reg); | 67 | u32 val = readl(socket->base + reg); |
72 | debug("%p %04x %08x\n", socket, reg, val); | 68 | debug("%04x %08x\n", socket, reg, val); |
73 | return val; | 69 | return val; |
74 | } | 70 | } |
75 | 71 | ||
76 | static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) | 72 | static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) |
77 | { | 73 | { |
78 | debug("%p %04x %08x\n", socket, reg, val); | 74 | debug("%04x %08x\n", socket, reg, val); |
79 | writel(val, socket->base + reg); | 75 | writel(val, socket->base + reg); |
80 | readl(socket->base + reg); /* avoid problems with PCI write posting */ | 76 | readl(socket->base + reg); /* avoid problems with PCI write posting */ |
81 | } | 77 | } |
@@ -84,7 +80,7 @@ static inline u8 config_readb(struct yenta_socket *socket, unsigned offset) | |||
84 | { | 80 | { |
85 | u8 val; | 81 | u8 val; |
86 | pci_read_config_byte(socket->dev, offset, &val); | 82 | pci_read_config_byte(socket->dev, offset, &val); |
87 | debug("%p %04x %02x\n", socket, offset, val); | 83 | debug("%04x %02x\n", socket, offset, val); |
88 | return val; | 84 | return val; |
89 | } | 85 | } |
90 | 86 | ||
@@ -92,7 +88,7 @@ static inline u16 config_readw(struct yenta_socket *socket, unsigned offset) | |||
92 | { | 88 | { |
93 | u16 val; | 89 | u16 val; |
94 | pci_read_config_word(socket->dev, offset, &val); | 90 | pci_read_config_word(socket->dev, offset, &val); |
95 | debug("%p %04x %04x\n", socket, offset, val); | 91 | debug("%04x %04x\n", socket, offset, val); |
96 | return val; | 92 | return val; |
97 | } | 93 | } |
98 | 94 | ||
@@ -100,32 +96,32 @@ static inline u32 config_readl(struct yenta_socket *socket, unsigned offset) | |||
100 | { | 96 | { |
101 | u32 val; | 97 | u32 val; |
102 | pci_read_config_dword(socket->dev, offset, &val); | 98 | pci_read_config_dword(socket->dev, offset, &val); |
103 | debug("%p %04x %08x\n", socket, offset, val); | 99 | debug("%04x %08x\n", socket, offset, val); |
104 | return val; | 100 | return val; |
105 | } | 101 | } |
106 | 102 | ||
107 | static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val) | 103 | static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val) |
108 | { | 104 | { |
109 | debug("%p %04x %02x\n", socket, offset, val); | 105 | debug("%04x %02x\n", socket, offset, val); |
110 | pci_write_config_byte(socket->dev, offset, val); | 106 | pci_write_config_byte(socket->dev, offset, val); |
111 | } | 107 | } |
112 | 108 | ||
113 | static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val) | 109 | static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val) |
114 | { | 110 | { |
115 | debug("%p %04x %04x\n", socket, offset, val); | 111 | debug("%04x %04x\n", socket, offset, val); |
116 | pci_write_config_word(socket->dev, offset, val); | 112 | pci_write_config_word(socket->dev, offset, val); |
117 | } | 113 | } |
118 | 114 | ||
119 | static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val) | 115 | static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val) |
120 | { | 116 | { |
121 | debug("%p %04x %08x\n", socket, offset, val); | 117 | debug("%04x %08x\n", socket, offset, val); |
122 | pci_write_config_dword(socket->dev, offset, val); | 118 | pci_write_config_dword(socket->dev, offset, val); |
123 | } | 119 | } |
124 | 120 | ||
125 | static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg) | 121 | static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg) |
126 | { | 122 | { |
127 | u8 val = readb(socket->base + 0x800 + reg); | 123 | u8 val = readb(socket->base + 0x800 + reg); |
128 | debug("%p %04x %02x\n", socket, reg, val); | 124 | debug("%04x %02x\n", socket, reg, val); |
129 | return val; | 125 | return val; |
130 | } | 126 | } |
131 | 127 | ||
@@ -134,20 +130,20 @@ static inline u8 exca_readw(struct yenta_socket *socket, unsigned reg) | |||
134 | u16 val; | 130 | u16 val; |
135 | val = readb(socket->base + 0x800 + reg); | 131 | val = readb(socket->base + 0x800 + reg); |
136 | val |= readb(socket->base + 0x800 + reg + 1) << 8; | 132 | val |= readb(socket->base + 0x800 + reg + 1) << 8; |
137 | debug("%p %04x %04x\n", socket, reg, val); | 133 | debug("%04x %04x\n", socket, reg, val); |
138 | return val; | 134 | return val; |
139 | } | 135 | } |
140 | 136 | ||
141 | static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val) | 137 | static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val) |
142 | { | 138 | { |
143 | debug("%p %04x %02x\n", socket, reg, val); | 139 | debug("%04x %02x\n", socket, reg, val); |
144 | writeb(val, socket->base + 0x800 + reg); | 140 | writeb(val, socket->base + 0x800 + reg); |
145 | readb(socket->base + 0x800 + reg); /* PCI write posting... */ | 141 | readb(socket->base + 0x800 + reg); /* PCI write posting... */ |
146 | } | 142 | } |
147 | 143 | ||
148 | static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) | 144 | static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) |
149 | { | 145 | { |
150 | debug("%p %04x %04x\n", socket, reg, val); | 146 | debug("%04x %04x\n", socket, reg, val); |
151 | writeb(val, socket->base + 0x800 + reg); | 147 | writeb(val, socket->base + 0x800 + reg); |
152 | writeb(val >> 8, socket->base + 0x800 + reg + 1); | 148 | writeb(val >> 8, socket->base + 0x800 + reg + 1); |
153 | 149 | ||
@@ -207,7 +203,7 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value) | |||
207 | 203 | ||
208 | 204 | ||
209 | if (state & CB_CBCARD) { | 205 | if (state & CB_CBCARD) { |
210 | val |= SS_CARDBUS; | 206 | val |= SS_CARDBUS; |
211 | val |= (state & CB_CARDSTS) ? SS_STSCHG : 0; | 207 | val |= (state & CB_CARDSTS) ? SS_STSCHG : 0; |
212 | val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT; | 208 | val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT; |
213 | val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0; | 209 | val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0; |
@@ -650,8 +646,10 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type | |||
650 | root = pci_find_parent_resource(socket->dev, res); | 646 | root = pci_find_parent_resource(socket->dev, res); |
651 | if (root && (request_resource(root, res) == 0)) | 647 | if (root && (request_resource(root, res) == 0)) |
652 | return 0; | 648 | return 0; |
653 | printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n", | 649 | dev_printk(KERN_INFO, &socket->dev->dev, |
654 | pci_name(socket->dev), nr); | 650 | "Preassigned resource %d busy or not available, " |
651 | "reconfiguring...\n", | ||
652 | nr); | ||
655 | } | 653 | } |
656 | 654 | ||
657 | if (type & IORESOURCE_IO) { | 655 | if (type & IORESOURCE_IO) { |
@@ -674,8 +672,9 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type | |||
674 | return 1; | 672 | return 1; |
675 | } | 673 | } |
676 | 674 | ||
677 | printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", | 675 | dev_printk(KERN_INFO, &socket->dev->dev, |
678 | pci_name(socket->dev), type); | 676 | "no resource of type %x available, trying to continue...\n", |
677 | type); | ||
679 | res->start = res->end = res->flags = 0; | 678 | res->start = res->end = res->flags = 0; |
680 | return 0; | 679 | return 0; |
681 | } | 680 | } |
@@ -923,7 +922,8 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) | |||
923 | socket->probe_status = 0; | 922 | socket->probe_status = 0; |
924 | 923 | ||
925 | if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) { | 924 | if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) { |
926 | printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n"); | 925 | dev_printk(KERN_WARNING, &socket->dev->dev, |
926 | "request_irq() in yenta_probe_cb_irq() failed!\n"); | ||
927 | return -1; | 927 | return -1; |
928 | } | 928 | } |
929 | 929 | ||
@@ -960,8 +960,9 @@ static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_i | |||
960 | else | 960 | else |
961 | socket->socket.irq_mask = 0; | 961 | socket->socket.irq_mask = 0; |
962 | 962 | ||
963 | printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n", | 963 | dev_printk(KERN_INFO, &socket->dev->dev, |
964 | socket->socket.irq_mask, socket->cb_irq); | 964 | "ISA IRQ mask 0x%04x, PCI irq %d\n", |
965 | socket->socket.irq_mask, socket->cb_irq); | ||
965 | } | 966 | } |
966 | 967 | ||
967 | /* | 968 | /* |
@@ -1051,8 +1052,9 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) | |||
1051 | 1052 | ||
1052 | /* Show that the wanted subordinate number is not possible: */ | 1053 | /* Show that the wanted subordinate number is not possible: */ |
1053 | if (cardbus_bridge->subordinate > upper_limit) | 1054 | if (cardbus_bridge->subordinate > upper_limit) |
1054 | printk(KERN_WARNING "Yenta: Upper limit for fixing this " | 1055 | dev_printk(KERN_WARNING, &cardbus_bridge->dev, |
1055 | "bridge's parent bridge: #%02x\n", upper_limit); | 1056 | "Upper limit for fixing this " |
1057 | "bridge's parent bridge: #%02x\n", upper_limit); | ||
1056 | 1058 | ||
1057 | /* If we have room to increase the bridge's subordinate number, */ | 1059 | /* If we have room to increase the bridge's subordinate number, */ |
1058 | if (bridge_to_fix->subordinate < upper_limit) { | 1060 | if (bridge_to_fix->subordinate < upper_limit) { |
@@ -1061,10 +1063,11 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge) | |||
1061 | unsigned char subordinate_to_assign = | 1063 | unsigned char subordinate_to_assign = |
1062 | min(cardbus_bridge->subordinate, upper_limit); | 1064 | min(cardbus_bridge->subordinate, upper_limit); |
1063 | 1065 | ||
1064 | printk(KERN_INFO "Yenta: Raising subordinate bus# of parent " | 1066 | dev_printk(KERN_INFO, &bridge_to_fix->dev, |
1065 | "bus (#%02x) from #%02x to #%02x\n", | 1067 | "Raising subordinate bus# of parent " |
1066 | bridge_to_fix->number, | 1068 | "bus (#%02x) from #%02x to #%02x\n", |
1067 | bridge_to_fix->subordinate, subordinate_to_assign); | 1069 | bridge_to_fix->number, |
1070 | bridge_to_fix->subordinate, subordinate_to_assign); | ||
1068 | 1071 | ||
1069 | /* Save the new subordinate in the bus struct of the bridge */ | 1072 | /* Save the new subordinate in the bus struct of the bridge */ |
1070 | bridge_to_fix->subordinate = subordinate_to_assign; | 1073 | bridge_to_fix->subordinate = subordinate_to_assign; |
@@ -1091,8 +1094,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1091 | * Bail out if so. | 1094 | * Bail out if so. |
1092 | */ | 1095 | */ |
1093 | if (!dev->subordinate) { | 1096 | if (!dev->subordinate) { |
1094 | printk(KERN_ERR "Yenta: no bus associated with %s! " | 1097 | dev_printk(KERN_ERR, &dev->dev, "no bus associated! " |
1095 | "(try 'pci=assign-busses')\n", pci_name(dev)); | 1098 | "(try 'pci=assign-busses')\n"); |
1096 | return -ENODEV; | 1099 | return -ENODEV; |
1097 | } | 1100 | } |
1098 | 1101 | ||
@@ -1127,7 +1130,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1127 | goto disable; | 1130 | goto disable; |
1128 | 1131 | ||
1129 | if (!pci_resource_start(dev, 0)) { | 1132 | if (!pci_resource_start(dev, 0)) { |
1130 | printk(KERN_ERR "No cardbus resource!\n"); | 1133 | dev_printk(KERN_ERR, &dev->dev, "No cardbus resource!\n"); |
1131 | ret = -ENODEV; | 1134 | ret = -ENODEV; |
1132 | goto release; | 1135 | goto release; |
1133 | } | 1136 | } |
@@ -1146,8 +1149,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1146 | * report the subsystem vendor and device for help debugging | 1149 | * report the subsystem vendor and device for help debugging |
1147 | * the irq stuff... | 1150 | * the irq stuff... |
1148 | */ | 1151 | */ |
1149 | printk(KERN_INFO "Yenta: CardBus bridge found at %s [%04x:%04x]\n", | 1152 | dev_printk(KERN_INFO, &dev->dev, "CardBus bridge found [%04x:%04x]\n", |
1150 | pci_name(dev), dev->subsystem_vendor, dev->subsystem_device); | 1153 | dev->subsystem_vendor, dev->subsystem_device); |
1151 | 1154 | ||
1152 | yenta_config_init(socket); | 1155 | yenta_config_init(socket); |
1153 | 1156 | ||
@@ -1179,8 +1182,12 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1179 | socket->poll_timer.data = (unsigned long)socket; | 1182 | socket->poll_timer.data = (unsigned long)socket; |
1180 | socket->poll_timer.expires = jiffies + HZ; | 1183 | socket->poll_timer.expires = jiffies + HZ; |
1181 | add_timer(&socket->poll_timer); | 1184 | add_timer(&socket->poll_timer); |
1182 | printk(KERN_INFO "Yenta: no PCI IRQ, CardBus support disabled for this socket.\n" | 1185 | dev_printk(KERN_INFO, &dev->dev, |
1183 | KERN_INFO "Yenta: check your BIOS CardBus, BIOS IRQ or ACPI settings.\n"); | 1186 | "no PCI IRQ, CardBus support disabled for this " |
1187 | "socket.\n"); | ||
1188 | dev_printk(KERN_INFO, &dev->dev, | ||
1189 | "check your BIOS CardBus, BIOS IRQ or ACPI " | ||
1190 | "settings.\n"); | ||
1184 | } else { | 1191 | } else { |
1185 | socket->socket.features |= SS_CAP_CARDBUS; | 1192 | socket->socket.features |= SS_CAP_CARDBUS; |
1186 | } | 1193 | } |
@@ -1188,7 +1195,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i | |||
1188 | /* Figure out what the dang thing can do for the PCMCIA layer... */ | 1195 | /* Figure out what the dang thing can do for the PCMCIA layer... */ |
1189 | yenta_interrogate(socket); | 1196 | yenta_interrogate(socket); |
1190 | yenta_get_socket_capabilities(socket, isa_interrupts); | 1197 | yenta_get_socket_capabilities(socket, isa_interrupts); |
1191 | printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); | 1198 | dev_printk(KERN_INFO, &dev->dev, |
1199 | "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); | ||
1192 | 1200 | ||
1193 | yenta_fixup_parent_bridge(dev->subordinate); | 1201 | yenta_fixup_parent_bridge(dev->subordinate); |
1194 | 1202 | ||
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 2dd0dc9a9aed..165ff884f48e 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c | |||
@@ -140,44 +140,41 @@ static void aha152x_detach(struct pcmcia_device *link) | |||
140 | #define CS_CHECK(fn, ret) \ | 140 | #define CS_CHECK(fn, ret) \ |
141 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 141 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
142 | 142 | ||
143 | static int aha152x_config_check(struct pcmcia_device *p_dev, | ||
144 | cistpl_cftable_entry_t *cfg, | ||
145 | cistpl_cftable_entry_t *dflt, | ||
146 | unsigned int vcc, | ||
147 | void *priv_data) | ||
148 | { | ||
149 | /* For New Media T&J, look for a SCSI window */ | ||
150 | if (cfg->io.win[0].len >= 0x20) | ||
151 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
152 | else if ((cfg->io.nwin > 1) && | ||
153 | (cfg->io.win[1].len >= 0x20)) | ||
154 | p_dev->io.BasePort1 = cfg->io.win[1].base; | ||
155 | if ((cfg->io.nwin > 0) && | ||
156 | (p_dev->io.BasePort1 < 0xffff)) { | ||
157 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
158 | return 0; | ||
159 | } | ||
160 | return -EINVAL; | ||
161 | } | ||
162 | |||
143 | static int aha152x_config_cs(struct pcmcia_device *link) | 163 | static int aha152x_config_cs(struct pcmcia_device *link) |
144 | { | 164 | { |
145 | scsi_info_t *info = link->priv; | 165 | scsi_info_t *info = link->priv; |
146 | struct aha152x_setup s; | 166 | struct aha152x_setup s; |
147 | tuple_t tuple; | 167 | int last_ret, last_fn; |
148 | cisparse_t parse; | ||
149 | int i, last_ret, last_fn; | ||
150 | u_char tuple_data[64]; | ||
151 | struct Scsi_Host *host; | 168 | struct Scsi_Host *host; |
152 | 169 | ||
153 | DEBUG(0, "aha152x_config(0x%p)\n", link); | 170 | DEBUG(0, "aha152x_config(0x%p)\n", link); |
154 | 171 | ||
155 | tuple.TupleData = tuple_data; | 172 | last_ret = pcmcia_loop_config(link, aha152x_config_check, NULL); |
156 | tuple.TupleDataMax = 64; | 173 | if (last_ret) { |
157 | tuple.TupleOffset = 0; | 174 | cs_error(link, RequestIO, last_ret); |
158 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 175 | goto failed; |
159 | tuple.Attributes = 0; | ||
160 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
161 | while (1) { | ||
162 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
163 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
164 | goto next_entry; | ||
165 | /* For New Media T&J, look for a SCSI window */ | ||
166 | if (parse.cftable_entry.io.win[0].len >= 0x20) | ||
167 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
168 | else if ((parse.cftable_entry.io.nwin > 1) && | ||
169 | (parse.cftable_entry.io.win[1].len >= 0x20)) | ||
170 | link->io.BasePort1 = parse.cftable_entry.io.win[1].base; | ||
171 | if ((parse.cftable_entry.io.nwin > 0) && | ||
172 | (link->io.BasePort1 < 0xffff)) { | ||
173 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
174 | i = pcmcia_request_io(link, &link->io); | ||
175 | if (i == CS_SUCCESS) break; | ||
176 | } | ||
177 | next_entry: | ||
178 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
179 | } | 176 | } |
180 | 177 | ||
181 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 178 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
182 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 179 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
183 | 180 | ||
@@ -208,6 +205,7 @@ static int aha152x_config_cs(struct pcmcia_device *link) | |||
208 | 205 | ||
209 | cs_failed: | 206 | cs_failed: |
210 | cs_error(link, last_fn, last_ret); | 207 | cs_error(link, last_fn, last_ret); |
208 | failed: | ||
211 | aha152x_release_cs(link); | 209 | aha152x_release_cs(link); |
212 | return -ENODEV; | 210 | return -ENODEV; |
213 | } | 211 | } |
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index d8b99351b053..06254f46a0dd 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c | |||
@@ -123,34 +123,30 @@ static void fdomain_detach(struct pcmcia_device *link) | |||
123 | #define CS_CHECK(fn, ret) \ | 123 | #define CS_CHECK(fn, ret) \ |
124 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 124 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
125 | 125 | ||
126 | static int fdomain_config_check(struct pcmcia_device *p_dev, | ||
127 | cistpl_cftable_entry_t *cfg, | ||
128 | cistpl_cftable_entry_t *dflt, | ||
129 | unsigned int vcc, | ||
130 | void *priv_data) | ||
131 | { | ||
132 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
133 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
134 | } | ||
135 | |||
136 | |||
126 | static int fdomain_config(struct pcmcia_device *link) | 137 | static int fdomain_config(struct pcmcia_device *link) |
127 | { | 138 | { |
128 | scsi_info_t *info = link->priv; | 139 | scsi_info_t *info = link->priv; |
129 | tuple_t tuple; | 140 | int last_ret, last_fn; |
130 | cisparse_t parse; | ||
131 | int i, last_ret, last_fn; | ||
132 | u_char tuple_data[64]; | ||
133 | char str[22]; | 141 | char str[22]; |
134 | struct Scsi_Host *host; | 142 | struct Scsi_Host *host; |
135 | 143 | ||
136 | DEBUG(0, "fdomain_config(0x%p)\n", link); | 144 | DEBUG(0, "fdomain_config(0x%p)\n", link); |
137 | 145 | ||
138 | tuple.TupleData = tuple_data; | 146 | last_ret = pcmcia_loop_config(link, fdomain_config_check, NULL); |
139 | tuple.TupleDataMax = 64; | 147 | if (last_ret) { |
140 | tuple.TupleOffset = 0; | 148 | cs_error(link, RequestIO, last_ret); |
141 | 149 | goto failed; | |
142 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
143 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
144 | while (1) { | ||
145 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
146 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
147 | goto next_entry; | ||
148 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
149 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
150 | i = pcmcia_request_io(link, &link->io); | ||
151 | if (i == CS_SUCCESS) break; | ||
152 | next_entry: | ||
153 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
154 | } | 150 | } |
155 | 151 | ||
156 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 152 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
@@ -181,6 +177,7 @@ static int fdomain_config(struct pcmcia_device *link) | |||
181 | 177 | ||
182 | cs_failed: | 178 | cs_failed: |
183 | cs_error(link, last_fn, last_ret); | 179 | cs_error(link, last_fn, last_ret); |
180 | failed: | ||
184 | fdomain_release(link); | 181 | fdomain_release(link); |
185 | return -ENODEV; | 182 | return -ENODEV; |
186 | } /* fdomain_config */ | 183 | } /* fdomain_config */ |
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 24e6cb8396e3..11a61ea8d5d9 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c | |||
@@ -1606,133 +1606,129 @@ static void nsp_cs_detach(struct pcmcia_device *link) | |||
1606 | is received, to configure the PCMCIA socket, and to make the | 1606 | is received, to configure the PCMCIA socket, and to make the |
1607 | ethernet device available to the system. | 1607 | ethernet device available to the system. |
1608 | ======================================================================*/ | 1608 | ======================================================================*/ |
1609 | #define CS_CHECK(fn, ret) \ | ||
1610 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | ||
1611 | /*====================================================================*/ | ||
1612 | static int nsp_cs_config(struct pcmcia_device *link) | ||
1613 | { | ||
1614 | int ret; | ||
1615 | scsi_info_t *info = link->priv; | ||
1616 | tuple_t tuple; | ||
1617 | cisparse_t parse; | ||
1618 | int last_ret, last_fn; | ||
1619 | unsigned char tuple_data[64]; | ||
1620 | config_info_t conf; | ||
1621 | win_req_t req; | ||
1622 | memreq_t map; | ||
1623 | cistpl_cftable_entry_t dflt = { 0 }; | ||
1624 | struct Scsi_Host *host; | ||
1625 | nsp_hw_data *data = &nsp_data_base; | ||
1626 | |||
1627 | nsp_dbg(NSP_DEBUG_INIT, "in"); | ||
1628 | |||
1629 | tuple.Attributes = 0; | ||
1630 | tuple.TupleData = tuple_data; | ||
1631 | tuple.TupleDataMax = sizeof(tuple_data); | ||
1632 | tuple.TupleOffset = 0; | ||
1633 | |||
1634 | /* Look up the current Vcc */ | ||
1635 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); | ||
1636 | 1609 | ||
1637 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 1610 | struct nsp_cs_configdata { |
1638 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 1611 | nsp_hw_data *data; |
1639 | while (1) { | 1612 | win_req_t req; |
1640 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | 1613 | }; |
1641 | 1614 | ||
1642 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | 1615 | static int nsp_cs_config_check(struct pcmcia_device *p_dev, |
1643 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | 1616 | cistpl_cftable_entry_t *cfg, |
1644 | goto next_entry; | 1617 | cistpl_cftable_entry_t *dflt, |
1618 | unsigned int vcc, | ||
1619 | void *priv_data) | ||
1620 | { | ||
1621 | struct nsp_cs_configdata *cfg_mem = priv_data; | ||
1645 | 1622 | ||
1646 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { dflt = *cfg; } | 1623 | if (cfg->index == 0) |
1647 | if (cfg->index == 0) { goto next_entry; } | 1624 | return -ENODEV; |
1648 | link->conf.ConfigIndex = cfg->index; | ||
1649 | 1625 | ||
1650 | /* Does this card need audio output? */ | 1626 | /* Does this card need audio output? */ |
1651 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | 1627 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { |
1652 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 1628 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; |
1653 | link->conf.Status = CCSR_AUDIO_ENA; | 1629 | p_dev->conf.Status = CCSR_AUDIO_ENA; |
1654 | } | 1630 | } |
1655 | 1631 | ||
1656 | /* Use power settings for Vcc and Vpp if present */ | 1632 | /* Use power settings for Vcc and Vpp if present */ |
1657 | /* Note that the CIS values need to be rescaled */ | 1633 | /* Note that the CIS values need to be rescaled */ |
1658 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | 1634 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { |
1659 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) { | 1635 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) |
1660 | goto next_entry; | 1636 | return -ENODEV; |
1661 | } | 1637 | else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { |
1662 | } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { | 1638 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) |
1663 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM]/10000) { | 1639 | return -ENODEV; |
1664 | goto next_entry; | ||
1665 | } | ||
1666 | } | 1640 | } |
1667 | 1641 | ||
1668 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { | 1642 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { |
1669 | link->conf.Vpp = | 1643 | p_dev->conf.Vpp = |
1670 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 1644 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
1671 | } else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { | 1645 | } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) { |
1672 | link->conf.Vpp = | 1646 | p_dev->conf.Vpp = |
1673 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | 1647 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
1674 | } | 1648 | } |
1675 | 1649 | ||
1676 | /* Do we need to allocate an interrupt? */ | 1650 | /* Do we need to allocate an interrupt? */ |
1677 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) { | 1651 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) |
1678 | link->conf.Attributes |= CONF_ENABLE_IRQ; | 1652 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; |
1679 | } | ||
1680 | 1653 | ||
1681 | /* IO window settings */ | 1654 | /* IO window settings */ |
1682 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | 1655 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; |
1683 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | 1656 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { |
1684 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | 1657 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; |
1685 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 1658 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
1686 | if (!(io->flags & CISTPL_IO_8BIT)) | 1659 | if (!(io->flags & CISTPL_IO_8BIT)) |
1687 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 1660 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
1688 | if (!(io->flags & CISTPL_IO_16BIT)) | 1661 | if (!(io->flags & CISTPL_IO_16BIT)) |
1689 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 1662 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
1690 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | 1663 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; |
1691 | link->io.BasePort1 = io->win[0].base; | 1664 | p_dev->io.BasePort1 = io->win[0].base; |
1692 | link->io.NumPorts1 = io->win[0].len; | 1665 | p_dev->io.NumPorts1 = io->win[0].len; |
1693 | if (io->nwin > 1) { | 1666 | if (io->nwin > 1) { |
1694 | link->io.Attributes2 = link->io.Attributes1; | 1667 | p_dev->io.Attributes2 = p_dev->io.Attributes1; |
1695 | link->io.BasePort2 = io->win[1].base; | 1668 | p_dev->io.BasePort2 = io->win[1].base; |
1696 | link->io.NumPorts2 = io->win[1].len; | 1669 | p_dev->io.NumPorts2 = io->win[1].len; |
1697 | } | 1670 | } |
1698 | /* This reserves IO space but doesn't actually enable it */ | 1671 | /* This reserves IO space but doesn't actually enable it */ |
1699 | if (pcmcia_request_io(link, &link->io) != 0) | 1672 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) |
1700 | goto next_entry; | 1673 | goto next_entry; |
1701 | } | 1674 | } |
1702 | 1675 | ||
1703 | if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { | 1676 | if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { |
1704 | cistpl_mem_t *mem = | 1677 | memreq_t map; |
1705 | (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; | 1678 | cistpl_mem_t *mem = |
1706 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | 1679 | (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; |
1707 | req.Attributes |= WIN_ENABLE; | 1680 | cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; |
1708 | req.Base = mem->win[0].host_addr; | 1681 | cfg_mem->req.Attributes |= WIN_ENABLE; |
1709 | req.Size = mem->win[0].len; | 1682 | cfg_mem->req.Base = mem->win[0].host_addr; |
1710 | if (req.Size < 0x1000) { | 1683 | cfg_mem->req.Size = mem->win[0].len; |
1711 | req.Size = 0x1000; | 1684 | if (cfg_mem->req.Size < 0x1000) |
1712 | } | 1685 | cfg_mem->req.Size = 0x1000; |
1713 | req.AccessSpeed = 0; | 1686 | cfg_mem->req.AccessSpeed = 0; |
1714 | if (pcmcia_request_window(&link, &req, &link->win) != 0) | 1687 | if (pcmcia_request_window(&p_dev, &cfg_mem->req, &p_dev->win) != 0) |
1715 | goto next_entry; | 1688 | goto next_entry; |
1716 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; | 1689 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; |
1717 | if (pcmcia_map_mem_page(link->win, &map) != 0) | 1690 | if (pcmcia_map_mem_page(p_dev->win, &map) != 0) |
1718 | goto next_entry; | 1691 | goto next_entry; |
1719 | 1692 | ||
1720 | data->MmioAddress = (unsigned long)ioremap_nocache(req.Base, req.Size); | 1693 | cfg_mem->data->MmioAddress = (unsigned long) ioremap_nocache(cfg_mem->req.Base, cfg_mem->req.Size); |
1721 | data->MmioLength = req.Size; | 1694 | cfg_mem->data->MmioLength = cfg_mem->req.Size; |
1722 | } | 1695 | } |
1723 | /* If we got this far, we're cool! */ | 1696 | /* If we got this far, we're cool! */ |
1724 | break; | 1697 | return 0; |
1725 | |||
1726 | next_entry: | ||
1727 | nsp_dbg(NSP_DEBUG_INIT, "next"); | ||
1728 | pcmcia_disable_device(link); | ||
1729 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
1730 | } | 1698 | } |
1731 | 1699 | ||
1700 | next_entry: | ||
1701 | nsp_dbg(NSP_DEBUG_INIT, "next"); | ||
1702 | pcmcia_disable_device(p_dev); | ||
1703 | return -ENODEV; | ||
1704 | } | ||
1705 | |||
1706 | static int nsp_cs_config(struct pcmcia_device *link) | ||
1707 | { | ||
1708 | int ret; | ||
1709 | scsi_info_t *info = link->priv; | ||
1710 | struct nsp_cs_configdata *cfg_mem; | ||
1711 | struct Scsi_Host *host; | ||
1712 | nsp_hw_data *data = &nsp_data_base; | ||
1713 | |||
1714 | nsp_dbg(NSP_DEBUG_INIT, "in"); | ||
1715 | |||
1716 | cfg_mem = kzalloc(sizeof(cfg_mem), GFP_KERNEL); | ||
1717 | if (!cfg_mem) | ||
1718 | return -ENOMEM; | ||
1719 | cfg_mem->data = data; | ||
1720 | |||
1721 | ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem); | ||
1722 | goto cs_failed; | ||
1723 | |||
1732 | if (link->conf.Attributes & CONF_ENABLE_IRQ) { | 1724 | if (link->conf.Attributes & CONF_ENABLE_IRQ) { |
1733 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 1725 | if (pcmcia_request_irq(link, &link->irq)) |
1726 | goto cs_failed; | ||
1734 | } | 1727 | } |
1735 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 1728 | |
1729 | ret = pcmcia_request_configuration(link, &link->conf); | ||
1730 | if (ret) | ||
1731 | goto cs_failed; | ||
1736 | 1732 | ||
1737 | if (free_ports) { | 1733 | if (free_ports) { |
1738 | if (link->io.BasePort1) { | 1734 | if (link->io.BasePort1) { |
@@ -1790,20 +1786,20 @@ static int nsp_cs_config(struct pcmcia_device *link) | |||
1790 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | 1786 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, |
1791 | link->io.BasePort2+link->io.NumPorts2-1); | 1787 | link->io.BasePort2+link->io.NumPorts2-1); |
1792 | if (link->win) | 1788 | if (link->win) |
1793 | printk(", mem 0x%06lx-0x%06lx", req.Base, | 1789 | printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base, |
1794 | req.Base+req.Size-1); | 1790 | cfg_mem->req.Base+cfg_mem->req.Size-1); |
1795 | printk("\n"); | 1791 | printk("\n"); |
1796 | 1792 | ||
1793 | kfree(cfg_mem); | ||
1797 | return 0; | 1794 | return 0; |
1798 | 1795 | ||
1799 | cs_failed: | 1796 | cs_failed: |
1800 | nsp_dbg(NSP_DEBUG_INIT, "config fail"); | 1797 | nsp_dbg(NSP_DEBUG_INIT, "config fail"); |
1801 | cs_error(link, last_fn, last_ret); | ||
1802 | nsp_cs_release(link); | 1798 | nsp_cs_release(link); |
1799 | kfree(cfg_mem); | ||
1803 | 1800 | ||
1804 | return -ENODEV; | 1801 | return -ENODEV; |
1805 | } /* nsp_cs_config */ | 1802 | } /* nsp_cs_config */ |
1806 | #undef CS_CHECK | ||
1807 | 1803 | ||
1808 | 1804 | ||
1809 | /*====================================================================== | 1805 | /*====================================================================== |
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 67c5a58d17df..20c3e5e6d88a 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c | |||
@@ -195,39 +195,33 @@ static void qlogic_detach(struct pcmcia_device *link) | |||
195 | #define CS_CHECK(fn, ret) \ | 195 | #define CS_CHECK(fn, ret) \ |
196 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 196 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
197 | 197 | ||
198 | static int qlogic_config_check(struct pcmcia_device *p_dev, | ||
199 | cistpl_cftable_entry_t *cfg, | ||
200 | cistpl_cftable_entry_t *dflt, | ||
201 | unsigned int vcc, | ||
202 | void *priv_data) | ||
203 | { | ||
204 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
205 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
206 | |||
207 | if (p_dev->io.BasePort1 == 0) | ||
208 | return -ENODEV; | ||
209 | |||
210 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
211 | } | ||
212 | |||
198 | static int qlogic_config(struct pcmcia_device * link) | 213 | static int qlogic_config(struct pcmcia_device * link) |
199 | { | 214 | { |
200 | scsi_info_t *info = link->priv; | 215 | scsi_info_t *info = link->priv; |
201 | tuple_t tuple; | 216 | int last_ret, last_fn; |
202 | cisparse_t parse; | ||
203 | int i, last_ret, last_fn; | ||
204 | unsigned short tuple_data[32]; | ||
205 | struct Scsi_Host *host; | 217 | struct Scsi_Host *host; |
206 | 218 | ||
207 | DEBUG(0, "qlogic_config(0x%p)\n", link); | 219 | DEBUG(0, "qlogic_config(0x%p)\n", link); |
208 | 220 | ||
209 | info->manf_id = link->manf_id; | 221 | last_ret = pcmcia_loop_config(link, qlogic_config_check, NULL); |
210 | 222 | if (last_ret) { | |
211 | tuple.TupleData = (cisdata_t *) tuple_data; | 223 | cs_error(link, RequestIO, last_ret); |
212 | tuple.TupleDataMax = 64; | 224 | goto failed; |
213 | tuple.TupleOffset = 0; | ||
214 | |||
215 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
216 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
217 | while (1) { | ||
218 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
219 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
220 | goto next_entry; | ||
221 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
222 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
223 | link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; | ||
224 | if (link->io.BasePort1 != 0) { | ||
225 | i = pcmcia_request_io(link, &link->io); | ||
226 | if (i == CS_SUCCESS) | ||
227 | break; | ||
228 | } | ||
229 | next_entry: | ||
230 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
231 | } | 225 | } |
232 | 226 | ||
233 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 227 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
@@ -262,6 +256,7 @@ static int qlogic_config(struct pcmcia_device * link) | |||
262 | cs_failed: | 256 | cs_failed: |
263 | cs_error(link, last_fn, last_ret); | 257 | cs_error(link, last_fn, last_ret); |
264 | pcmcia_disable_device(link); | 258 | pcmcia_disable_device(link); |
259 | failed: | ||
265 | return -ENODEV; | 260 | return -ENODEV; |
266 | 261 | ||
267 | } /* qlogic_config */ | 262 | } /* qlogic_config */ |
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 0be232b58ffb..b330c11a1752 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c | |||
@@ -700,15 +700,27 @@ static struct scsi_host_template sym53c500_driver_template = { | |||
700 | #define CS_CHECK(fn, ret) \ | 700 | #define CS_CHECK(fn, ret) \ |
701 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 701 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
702 | 702 | ||
703 | static int SYM53C500_config_check(struct pcmcia_device *p_dev, | ||
704 | cistpl_cftable_entry_t *cfg, | ||
705 | cistpl_cftable_entry_t *dflt, | ||
706 | unsigned int vcc, | ||
707 | void *priv_data) | ||
708 | { | ||
709 | p_dev->io.BasePort1 = cfg->io.win[0].base; | ||
710 | p_dev->io.NumPorts1 = cfg->io.win[0].len; | ||
711 | |||
712 | if (p_dev->io.BasePort1 == 0) | ||
713 | return -ENODEV; | ||
714 | |||
715 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
716 | } | ||
717 | |||
703 | static int | 718 | static int |
704 | SYM53C500_config(struct pcmcia_device *link) | 719 | SYM53C500_config(struct pcmcia_device *link) |
705 | { | 720 | { |
706 | struct scsi_info_t *info = link->priv; | 721 | struct scsi_info_t *info = link->priv; |
707 | tuple_t tuple; | 722 | int last_ret, last_fn; |
708 | cisparse_t parse; | ||
709 | int i, last_ret, last_fn; | ||
710 | int irq_level, port_base; | 723 | int irq_level, port_base; |
711 | unsigned short tuple_data[32]; | ||
712 | struct Scsi_Host *host; | 724 | struct Scsi_Host *host; |
713 | struct scsi_host_template *tpnt = &sym53c500_driver_template; | 725 | struct scsi_host_template *tpnt = &sym53c500_driver_template; |
714 | struct sym53c500_data *data; | 726 | struct sym53c500_data *data; |
@@ -717,27 +729,10 @@ SYM53C500_config(struct pcmcia_device *link) | |||
717 | 729 | ||
718 | info->manf_id = link->manf_id; | 730 | info->manf_id = link->manf_id; |
719 | 731 | ||
720 | tuple.TupleData = (cisdata_t *)tuple_data; | 732 | last_ret = pcmcia_loop_config(link, SYM53C500_config_check, NULL); |
721 | tuple.TupleDataMax = 64; | 733 | if (last_ret) { |
722 | tuple.TupleOffset = 0; | 734 | cs_error(link, RequestIO, last_ret); |
723 | 735 | goto failed; | |
724 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
725 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
726 | while (1) { | ||
727 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
728 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
729 | goto next_entry; | ||
730 | link->conf.ConfigIndex = parse.cftable_entry.index; | ||
731 | link->io.BasePort1 = parse.cftable_entry.io.win[0].base; | ||
732 | link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; | ||
733 | |||
734 | if (link->io.BasePort1 != 0) { | ||
735 | i = pcmcia_request_io(link, &link->io); | ||
736 | if (i == CS_SUCCESS) | ||
737 | break; | ||
738 | } | ||
739 | next_entry: | ||
740 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
741 | } | 736 | } |
742 | 737 | ||
743 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 738 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
@@ -831,6 +826,7 @@ err_release: | |||
831 | 826 | ||
832 | cs_failed: | 827 | cs_failed: |
833 | cs_error(link, last_fn, last_ret); | 828 | cs_error(link, last_fn, last_ret); |
829 | failed: | ||
834 | SYM53C500_release(link); | 830 | SYM53C500_release(link); |
835 | return -ENODEV; | 831 | return -ENODEV; |
836 | } /* SYM53C500_config */ | 832 | } /* SYM53C500_config */ |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 164d2a42eb59..7546aa887fa7 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -431,131 +431,103 @@ first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) | |||
431 | { | 431 | { |
432 | int i; | 432 | int i; |
433 | i = pcmcia_get_first_tuple(handle, tuple); | 433 | i = pcmcia_get_first_tuple(handle, tuple); |
434 | if (i != CS_SUCCESS) | 434 | if (i != 0) |
435 | return CS_NO_MORE_ITEMS; | ||
436 | i = pcmcia_get_tuple_data(handle, tuple); | ||
437 | if (i != CS_SUCCESS) | ||
438 | return i; | 435 | return i; |
439 | return pcmcia_parse_tuple(handle, tuple, parse); | ||
440 | } | ||
441 | |||
442 | static int | ||
443 | next_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) | ||
444 | { | ||
445 | int i; | ||
446 | i = pcmcia_get_next_tuple(handle, tuple); | ||
447 | if (i != CS_SUCCESS) | ||
448 | return CS_NO_MORE_ITEMS; | ||
449 | i = pcmcia_get_tuple_data(handle, tuple); | 436 | i = pcmcia_get_tuple_data(handle, tuple); |
450 | if (i != CS_SUCCESS) | 437 | if (i != 0) |
451 | return i; | 438 | return i; |
452 | return pcmcia_parse_tuple(handle, tuple, parse); | 439 | return pcmcia_parse_tuple(tuple, parse); |
453 | } | 440 | } |
454 | 441 | ||
455 | /*====================================================================*/ | 442 | /*====================================================================*/ |
456 | 443 | ||
457 | static int simple_config(struct pcmcia_device *link) | 444 | static int simple_config_check(struct pcmcia_device *p_dev, |
445 | cistpl_cftable_entry_t *cf, | ||
446 | cistpl_cftable_entry_t *dflt, | ||
447 | unsigned int vcc, | ||
448 | void *priv_data) | ||
458 | { | 449 | { |
459 | static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; | ||
460 | static const int size_table[2] = { 8, 16 }; | 450 | static const int size_table[2] = { 8, 16 }; |
461 | struct serial_info *info = link->priv; | 451 | int *try = priv_data; |
462 | struct serial_cfg_mem *cfg_mem; | 452 | |
463 | tuple_t *tuple; | 453 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
464 | u_char *buf; | 454 | p_dev->conf.Vpp = |
465 | cisparse_t *parse; | 455 | cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
466 | cistpl_cftable_entry_t *cf; | 456 | |
467 | config_info_t config; | 457 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[(*try >> 1)]) |
468 | int i, j, try; | 458 | && (cf->io.win[0].base != 0)) { |
469 | int s; | 459 | p_dev->io.BasePort1 = cf->io.win[0].base; |
460 | p_dev->io.IOAddrLines = ((*try & 0x1) == 0) ? | ||
461 | 16 : cf->io.flags & CISTPL_IO_LINES_MASK; | ||
462 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
463 | return 0; | ||
464 | } | ||
465 | return -EINVAL; | ||
466 | } | ||
470 | 467 | ||
471 | cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL); | 468 | static int simple_config_check_notpicky(struct pcmcia_device *p_dev, |
472 | if (!cfg_mem) | 469 | cistpl_cftable_entry_t *cf, |
473 | return -1; | 470 | cistpl_cftable_entry_t *dflt, |
471 | unsigned int vcc, | ||
472 | void *priv_data) | ||
473 | { | ||
474 | static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; | ||
475 | int j; | ||
476 | |||
477 | if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | ||
478 | for (j = 0; j < 5; j++) { | ||
479 | p_dev->io.BasePort1 = base[j]; | ||
480 | p_dev->io.IOAddrLines = base[j] ? 16 : 3; | ||
481 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
482 | return 0; | ||
483 | } | ||
484 | } | ||
485 | return -ENODEV; | ||
486 | } | ||
474 | 487 | ||
475 | tuple = &cfg_mem->tuple; | 488 | static int simple_config(struct pcmcia_device *link) |
476 | parse = &cfg_mem->parse; | 489 | { |
477 | cf = &parse->cftable_entry; | 490 | struct serial_info *info = link->priv; |
478 | buf = cfg_mem->buf; | 491 | int i = -ENODEV, try; |
479 | 492 | ||
480 | /* If the card is already configured, look up the port and irq */ | 493 | /* If the card is already configured, look up the port and irq */ |
481 | i = pcmcia_get_configuration_info(link, &config); | 494 | if (link->function_config) { |
482 | if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) { | ||
483 | unsigned int port = 0; | 495 | unsigned int port = 0; |
484 | if ((config.BasePort2 != 0) && (config.NumPorts2 == 8)) { | 496 | if ((link->io.BasePort2 != 0) && |
485 | port = config.BasePort2; | 497 | (link->io.NumPorts2 == 8)) { |
498 | port = link->io.BasePort2; | ||
486 | info->slave = 1; | 499 | info->slave = 1; |
487 | } else if ((info->manfid == MANFID_OSITECH) && | 500 | } else if ((info->manfid == MANFID_OSITECH) && |
488 | (config.NumPorts1 == 0x40)) { | 501 | (link->io.NumPorts1 == 0x40)) { |
489 | port = config.BasePort1 + 0x28; | 502 | port = link->io.BasePort1 + 0x28; |
490 | info->slave = 1; | 503 | info->slave = 1; |
491 | } | 504 | } |
492 | if (info->slave) { | 505 | if (info->slave) { |
493 | kfree(cfg_mem); | 506 | return setup_serial(link, info, port, |
494 | return setup_serial(link, info, port, config.AssignedIRQ); | 507 | link->irq.AssignedIRQ); |
495 | } | 508 | } |
496 | } | 509 | } |
497 | 510 | ||
498 | /* First pass: look for a config entry that looks normal. */ | 511 | /* First pass: look for a config entry that looks normal. |
499 | tuple->TupleData = (cisdata_t *) buf; | 512 | * Two tries: without IO aliases, then with aliases */ |
500 | tuple->TupleOffset = 0; | 513 | for (try = 0; try < 4; try++) |
501 | tuple->TupleDataMax = 255; | 514 | if (!pcmcia_loop_config(link, simple_config_check, &try)) |
502 | tuple->Attributes = 0; | 515 | goto found_port; |
503 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | 516 | |
504 | /* Two tries: without IO aliases, then with aliases */ | ||
505 | for (s = 0; s < 2; s++) { | ||
506 | for (try = 0; try < 2; try++) { | ||
507 | i = first_tuple(link, tuple, parse); | ||
508 | while (i != CS_NO_MORE_ITEMS) { | ||
509 | if (i != CS_SUCCESS) | ||
510 | goto next_entry; | ||
511 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
512 | link->conf.Vpp = | ||
513 | cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
514 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[s]) && | ||
515 | (cf->io.win[0].base != 0)) { | ||
516 | link->conf.ConfigIndex = cf->index; | ||
517 | link->io.BasePort1 = cf->io.win[0].base; | ||
518 | link->io.IOAddrLines = (try == 0) ? | ||
519 | 16 : cf->io.flags & CISTPL_IO_LINES_MASK; | ||
520 | i = pcmcia_request_io(link, &link->io); | ||
521 | if (i == CS_SUCCESS) | ||
522 | goto found_port; | ||
523 | } | ||
524 | next_entry: | ||
525 | i = next_tuple(link, tuple, parse); | ||
526 | } | ||
527 | } | ||
528 | } | ||
529 | /* Second pass: try to find an entry that isn't picky about | 517 | /* Second pass: try to find an entry that isn't picky about |
530 | its base address, then try to grab any standard serial port | 518 | its base address, then try to grab any standard serial port |
531 | address, and finally try to get any free port. */ | 519 | address, and finally try to get any free port. */ |
532 | i = first_tuple(link, tuple, parse); | 520 | if (!pcmcia_loop_config(link, simple_config_check_notpicky, NULL)) |
533 | while (i != CS_NO_MORE_ITEMS) { | 521 | goto found_port; |
534 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && | ||
535 | ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | ||
536 | link->conf.ConfigIndex = cf->index; | ||
537 | for (j = 0; j < 5; j++) { | ||
538 | link->io.BasePort1 = base[j]; | ||
539 | link->io.IOAddrLines = base[j] ? 16 : 3; | ||
540 | i = pcmcia_request_io(link, &link->io); | ||
541 | if (i == CS_SUCCESS) | ||
542 | goto found_port; | ||
543 | } | ||
544 | } | ||
545 | i = next_tuple(link, tuple, parse); | ||
546 | } | ||
547 | 522 | ||
548 | found_port: | 523 | printk(KERN_NOTICE |
549 | if (i != CS_SUCCESS) { | 524 | "serial_cs: no usable port range found, giving up\n"); |
550 | printk(KERN_NOTICE | 525 | cs_error(link, RequestIO, i); |
551 | "serial_cs: no usable port range found, giving up\n"); | 526 | return -1; |
552 | cs_error(link, RequestIO, i); | ||
553 | kfree(cfg_mem); | ||
554 | return -1; | ||
555 | } | ||
556 | 527 | ||
528 | found_port: | ||
557 | i = pcmcia_request_irq(link, &link->irq); | 529 | i = pcmcia_request_irq(link, &link->irq); |
558 | if (i != CS_SUCCESS) { | 530 | if (i != 0) { |
559 | cs_error(link, RequestIRQ, i); | 531 | cs_error(link, RequestIRQ, i); |
560 | link->irq.AssignedIRQ = 0; | 532 | link->irq.AssignedIRQ = 0; |
561 | } | 533 | } |
@@ -569,88 +541,76 @@ next_entry: | |||
569 | info->quirk->config(link); | 541 | info->quirk->config(link); |
570 | 542 | ||
571 | i = pcmcia_request_configuration(link, &link->conf); | 543 | i = pcmcia_request_configuration(link, &link->conf); |
572 | if (i != CS_SUCCESS) { | 544 | if (i != 0) { |
573 | cs_error(link, RequestConfiguration, i); | 545 | cs_error(link, RequestConfiguration, i); |
574 | kfree(cfg_mem); | ||
575 | return -1; | 546 | return -1; |
576 | } | 547 | } |
577 | kfree(cfg_mem); | ||
578 | return setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); | 548 | return setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); |
579 | } | 549 | } |
580 | 550 | ||
581 | static int multi_config(struct pcmcia_device * link) | 551 | static int multi_config_check(struct pcmcia_device *p_dev, |
552 | cistpl_cftable_entry_t *cf, | ||
553 | cistpl_cftable_entry_t *dflt, | ||
554 | unsigned int vcc, | ||
555 | void *priv_data) | ||
582 | { | 556 | { |
583 | struct serial_info *info = link->priv; | 557 | int *base2 = priv_data; |
584 | struct serial_cfg_mem *cfg_mem; | 558 | |
585 | tuple_t *tuple; | 559 | /* The quad port cards have bad CIS's, so just look for a |
586 | u_char *buf; | 560 | window larger than 8 ports and assume it will be right */ |
587 | cisparse_t *parse; | 561 | if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { |
588 | cistpl_cftable_entry_t *cf; | 562 | p_dev->io.BasePort1 = cf->io.win[0].base; |
589 | int i, rc, base2 = 0; | 563 | p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; |
564 | if (!pcmcia_request_io(p_dev, &p_dev->io)) { | ||
565 | *base2 = p_dev->io.BasePort1 + 8; | ||
566 | return 0; | ||
567 | } | ||
568 | } | ||
569 | return -ENODEV; | ||
570 | } | ||
590 | 571 | ||
591 | cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL); | 572 | static int multi_config_check_notpicky(struct pcmcia_device *p_dev, |
592 | if (!cfg_mem) | 573 | cistpl_cftable_entry_t *cf, |
593 | return -1; | 574 | cistpl_cftable_entry_t *dflt, |
594 | tuple = &cfg_mem->tuple; | 575 | unsigned int vcc, |
595 | parse = &cfg_mem->parse; | 576 | void *priv_data) |
596 | cf = &parse->cftable_entry; | 577 | { |
597 | buf = cfg_mem->buf; | 578 | int *base2 = priv_data; |
579 | |||
580 | if (cf->io.nwin == 2) { | ||
581 | p_dev->io.BasePort1 = cf->io.win[0].base; | ||
582 | p_dev->io.BasePort2 = cf->io.win[1].base; | ||
583 | p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | ||
584 | if (!pcmcia_request_io(p_dev, &p_dev->io)) { | ||
585 | *base2 = p_dev->io.BasePort2; | ||
586 | return 0; | ||
587 | } | ||
588 | } | ||
589 | return -ENODEV; | ||
590 | } | ||
598 | 591 | ||
599 | tuple->TupleData = (cisdata_t *) buf; | 592 | static int multi_config(struct pcmcia_device *link) |
600 | tuple->TupleOffset = 0; | 593 | { |
601 | tuple->TupleDataMax = 255; | 594 | struct serial_info *info = link->priv; |
602 | tuple->Attributes = 0; | 595 | int i, base2 = 0; |
603 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
604 | 596 | ||
605 | /* First, look for a generic full-sized window */ | 597 | /* First, look for a generic full-sized window */ |
606 | link->io.NumPorts1 = info->multi * 8; | 598 | link->io.NumPorts1 = info->multi * 8; |
607 | i = first_tuple(link, tuple, parse); | 599 | if (pcmcia_loop_config(link, multi_config_check, &base2)) { |
608 | while (i != CS_NO_MORE_ITEMS) { | 600 | /* If that didn't work, look for two windows */ |
609 | /* The quad port cards have bad CIS's, so just look for a | ||
610 | window larger than 8 ports and assume it will be right */ | ||
611 | if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && | ||
612 | (cf->io.win[0].len > 8)) { | ||
613 | link->conf.ConfigIndex = cf->index; | ||
614 | link->io.BasePort1 = cf->io.win[0].base; | ||
615 | link->io.IOAddrLines = | ||
616 | cf->io.flags & CISTPL_IO_LINES_MASK; | ||
617 | i = pcmcia_request_io(link, &link->io); | ||
618 | base2 = link->io.BasePort1 + 8; | ||
619 | if (i == CS_SUCCESS) | ||
620 | break; | ||
621 | } | ||
622 | i = next_tuple(link, tuple, parse); | ||
623 | } | ||
624 | |||
625 | /* If that didn't work, look for two windows */ | ||
626 | if (i != CS_SUCCESS) { | ||
627 | link->io.NumPorts1 = link->io.NumPorts2 = 8; | 601 | link->io.NumPorts1 = link->io.NumPorts2 = 8; |
628 | info->multi = 2; | 602 | info->multi = 2; |
629 | i = first_tuple(link, tuple, parse); | 603 | if (pcmcia_loop_config(link, multi_config_check_notpicky, |
630 | while (i != CS_NO_MORE_ITEMS) { | 604 | &base2)) { |
631 | if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) { | 605 | printk(KERN_NOTICE "serial_cs: no usable port range" |
632 | link->conf.ConfigIndex = cf->index; | 606 | "found, giving up\n"); |
633 | link->io.BasePort1 = cf->io.win[0].base; | 607 | return -ENODEV; |
634 | link->io.BasePort2 = cf->io.win[1].base; | ||
635 | link->io.IOAddrLines = | ||
636 | cf->io.flags & CISTPL_IO_LINES_MASK; | ||
637 | i = pcmcia_request_io(link, &link->io); | ||
638 | base2 = link->io.BasePort2; | ||
639 | if (i == CS_SUCCESS) | ||
640 | break; | ||
641 | } | ||
642 | i = next_tuple(link, tuple, parse); | ||
643 | } | 608 | } |
644 | } | 609 | } |
645 | 610 | ||
646 | if (i != CS_SUCCESS) { | ||
647 | cs_error(link, RequestIO, i); | ||
648 | rc = -1; | ||
649 | goto free_cfg_mem; | ||
650 | } | ||
651 | |||
652 | i = pcmcia_request_irq(link, &link->irq); | 611 | i = pcmcia_request_irq(link, &link->irq); |
653 | if (i != CS_SUCCESS) { | 612 | if (i != 0) { |
613 | /* FIXME: comment does not fit, error handling does not fit */ | ||
654 | printk(KERN_NOTICE | 614 | printk(KERN_NOTICE |
655 | "serial_cs: no usable port range found, giving up\n"); | 615 | "serial_cs: no usable port range found, giving up\n"); |
656 | cs_error(link, RequestIRQ, i); | 616 | cs_error(link, RequestIRQ, i); |
@@ -664,10 +624,9 @@ static int multi_config(struct pcmcia_device * link) | |||
664 | info->quirk->config(link); | 624 | info->quirk->config(link); |
665 | 625 | ||
666 | i = pcmcia_request_configuration(link, &link->conf); | 626 | i = pcmcia_request_configuration(link, &link->conf); |
667 | if (i != CS_SUCCESS) { | 627 | if (i != 0) { |
668 | cs_error(link, RequestConfiguration, i); | 628 | cs_error(link, RequestConfiguration, i); |
669 | rc = -1; | 629 | return -ENODEV; |
670 | goto free_cfg_mem; | ||
671 | } | 630 | } |
672 | 631 | ||
673 | /* The Oxford Semiconductor OXCF950 cards are in fact single-port: | 632 | /* The Oxford Semiconductor OXCF950 cards are in fact single-port: |
@@ -678,7 +637,8 @@ static int multi_config(struct pcmcia_device * link) | |||
678 | info->prodid == PRODID_POSSIO_GCC)) { | 637 | info->prodid == PRODID_POSSIO_GCC)) { |
679 | int err; | 638 | int err; |
680 | 639 | ||
681 | if (cf->index == 1 || cf->index == 3) { | 640 | if (link->conf.ConfigIndex == 1 || |
641 | link->conf.ConfigIndex == 3) { | ||
682 | err = setup_serial(link, info, base2, | 642 | err = setup_serial(link, info, base2, |
683 | link->irq.AssignedIRQ); | 643 | link->irq.AssignedIRQ); |
684 | base2 = link->io.BasePort1; | 644 | base2 = link->io.BasePort1; |
@@ -695,18 +655,14 @@ static int multi_config(struct pcmcia_device * link) | |||
695 | if (info->quirk && info->quirk->wakeup) | 655 | if (info->quirk && info->quirk->wakeup) |
696 | info->quirk->wakeup(link); | 656 | info->quirk->wakeup(link); |
697 | 657 | ||
698 | rc = 0; | 658 | return 0; |
699 | goto free_cfg_mem; | ||
700 | } | 659 | } |
701 | 660 | ||
702 | setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); | 661 | setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); |
703 | for (i = 0; i < info->multi - 1; i++) | 662 | for (i = 0; i < info->multi - 1; i++) |
704 | setup_serial(link, info, base2 + (8 * i), | 663 | setup_serial(link, info, base2 + (8 * i), |
705 | link->irq.AssignedIRQ); | 664 | link->irq.AssignedIRQ); |
706 | rc = 0; | 665 | return 0; |
707 | free_cfg_mem: | ||
708 | kfree(cfg_mem); | ||
709 | return rc; | ||
710 | } | 666 | } |
711 | 667 | ||
712 | /*====================================================================== | 668 | /*====================================================================== |
@@ -746,7 +702,7 @@ static int serial_config(struct pcmcia_device * link) | |||
746 | /* Is this a compliant multifunction card? */ | 702 | /* Is this a compliant multifunction card? */ |
747 | tuple->DesiredTuple = CISTPL_LONGLINK_MFC; | 703 | tuple->DesiredTuple = CISTPL_LONGLINK_MFC; |
748 | tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; | 704 | tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; |
749 | info->multi = (first_tuple(link, tuple, parse) == CS_SUCCESS); | 705 | info->multi = (first_tuple(link, tuple, parse) == 0); |
750 | 706 | ||
751 | /* Is this a multiport card? */ | 707 | /* Is this a multiport card? */ |
752 | tuple->DesiredTuple = CISTPL_MANFID; | 708 | tuple->DesiredTuple = CISTPL_MANFID; |
@@ -770,7 +726,7 @@ static int serial_config(struct pcmcia_device * link) | |||
770 | ((link->func_id == CISTPL_FUNCID_MULTI) || | 726 | ((link->func_id == CISTPL_FUNCID_MULTI) || |
771 | (link->func_id == CISTPL_FUNCID_SERIAL))) { | 727 | (link->func_id == CISTPL_FUNCID_SERIAL))) { |
772 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | 728 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; |
773 | if (first_tuple(link, tuple, parse) == CS_SUCCESS) { | 729 | if (first_tuple(link, tuple, parse) == 0) { |
774 | if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) | 730 | if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) |
775 | info->multi = cf->io.win[0].len >> 3; | 731 | info->multi = cf->io.win[0].len >> 3; |
776 | if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && | 732 | if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && |
diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c index 24c2a46c1476..fbfadbac67e8 100644 --- a/drivers/ssb/pcmcia.c +++ b/drivers/ssb/pcmcia.c | |||
@@ -80,7 +80,7 @@ static int ssb_pcmcia_cfg_write(struct ssb_bus *bus, u8 offset, u8 value) | |||
80 | reg.Action = CS_WRITE; | 80 | reg.Action = CS_WRITE; |
81 | reg.Value = value; | 81 | reg.Value = value; |
82 | res = pcmcia_access_configuration_register(bus->host_pcmcia, ®); | 82 | res = pcmcia_access_configuration_register(bus->host_pcmcia, ®); |
83 | if (unlikely(res != CS_SUCCESS)) | 83 | if (unlikely(res != 0)) |
84 | return -EBUSY; | 84 | return -EBUSY; |
85 | 85 | ||
86 | return 0; | 86 | return 0; |
@@ -96,7 +96,7 @@ static int ssb_pcmcia_cfg_read(struct ssb_bus *bus, u8 offset, u8 *value) | |||
96 | reg.Offset = offset; | 96 | reg.Offset = offset; |
97 | reg.Action = CS_READ; | 97 | reg.Action = CS_READ; |
98 | res = pcmcia_access_configuration_register(bus->host_pcmcia, ®); | 98 | res = pcmcia_access_configuration_register(bus->host_pcmcia, ®); |
99 | if (unlikely(res != CS_SUCCESS)) | 99 | if (unlikely(res != 0)) |
100 | return -EBUSY; | 100 | return -EBUSY; |
101 | *value = reg.Value; | 101 | *value = reg.Value; |
102 | 102 | ||
@@ -638,17 +638,17 @@ int ssb_pcmcia_get_invariants(struct ssb_bus *bus, | |||
638 | tuple.TupleData = buf; | 638 | tuple.TupleData = buf; |
639 | tuple.TupleDataMax = sizeof(buf); | 639 | tuple.TupleDataMax = sizeof(buf); |
640 | res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple); | 640 | res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple); |
641 | GOTO_ERROR_ON(res != CS_SUCCESS, "MAC first tpl"); | 641 | GOTO_ERROR_ON(res != 0, "MAC first tpl"); |
642 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); | 642 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); |
643 | GOTO_ERROR_ON(res != CS_SUCCESS, "MAC first tpl data"); | 643 | GOTO_ERROR_ON(res != 0, "MAC first tpl data"); |
644 | while (1) { | 644 | while (1) { |
645 | GOTO_ERROR_ON(tuple.TupleDataLen < 1, "MAC tpl < 1"); | 645 | GOTO_ERROR_ON(tuple.TupleDataLen < 1, "MAC tpl < 1"); |
646 | if (tuple.TupleData[0] == CISTPL_FUNCE_LAN_NODE_ID) | 646 | if (tuple.TupleData[0] == CISTPL_FUNCE_LAN_NODE_ID) |
647 | break; | 647 | break; |
648 | res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); | 648 | res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); |
649 | GOTO_ERROR_ON(res != CS_SUCCESS, "MAC next tpl"); | 649 | GOTO_ERROR_ON(res != 0, "MAC next tpl"); |
650 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); | 650 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); |
651 | GOTO_ERROR_ON(res != CS_SUCCESS, "MAC next tpl data"); | 651 | GOTO_ERROR_ON(res != 0, "MAC next tpl data"); |
652 | } | 652 | } |
653 | GOTO_ERROR_ON(tuple.TupleDataLen != ETH_ALEN + 2, "MAC tpl size"); | 653 | GOTO_ERROR_ON(tuple.TupleDataLen != ETH_ALEN + 2, "MAC tpl size"); |
654 | memcpy(sprom->il0mac, &tuple.TupleData[2], ETH_ALEN); | 654 | memcpy(sprom->il0mac, &tuple.TupleData[2], ETH_ALEN); |
@@ -659,9 +659,9 @@ int ssb_pcmcia_get_invariants(struct ssb_bus *bus, | |||
659 | tuple.TupleData = buf; | 659 | tuple.TupleData = buf; |
660 | tuple.TupleDataMax = sizeof(buf); | 660 | tuple.TupleDataMax = sizeof(buf); |
661 | res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple); | 661 | res = pcmcia_get_first_tuple(bus->host_pcmcia, &tuple); |
662 | GOTO_ERROR_ON(res != CS_SUCCESS, "VEN first tpl"); | 662 | GOTO_ERROR_ON(res != 0, "VEN first tpl"); |
663 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); | 663 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); |
664 | GOTO_ERROR_ON(res != CS_SUCCESS, "VEN first tpl data"); | 664 | GOTO_ERROR_ON(res != 0, "VEN first tpl data"); |
665 | while (1) { | 665 | while (1) { |
666 | GOTO_ERROR_ON(tuple.TupleDataLen < 1, "VEN tpl < 1"); | 666 | GOTO_ERROR_ON(tuple.TupleDataLen < 1, "VEN tpl < 1"); |
667 | switch (tuple.TupleData[0]) { | 667 | switch (tuple.TupleData[0]) { |
@@ -733,11 +733,11 @@ int ssb_pcmcia_get_invariants(struct ssb_bus *bus, | |||
733 | break; | 733 | break; |
734 | } | 734 | } |
735 | res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); | 735 | res = pcmcia_get_next_tuple(bus->host_pcmcia, &tuple); |
736 | if (res == CS_NO_MORE_ITEMS) | 736 | if (res == -ENOSPC) |
737 | break; | 737 | break; |
738 | GOTO_ERROR_ON(res != CS_SUCCESS, "VEN next tpl"); | 738 | GOTO_ERROR_ON(res != 0, "VEN next tpl"); |
739 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); | 739 | res = pcmcia_get_tuple_data(bus->host_pcmcia, &tuple); |
740 | GOTO_ERROR_ON(res != CS_SUCCESS, "VEN next tpl data"); | 740 | GOTO_ERROR_ON(res != 0, "VEN next tpl data"); |
741 | } | 741 | } |
742 | 742 | ||
743 | return 0; | 743 | return 0; |
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index ff9a29b76336..347c3ed1d9f1 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c | |||
@@ -124,65 +124,53 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) | |||
124 | return; | 124 | return; |
125 | } | 125 | } |
126 | 126 | ||
127 | static int ixj_config_check(struct pcmcia_device *p_dev, | ||
128 | cistpl_cftable_entry_t *cfg, | ||
129 | cistpl_cftable_entry_t *dflt, | ||
130 | unsigned int vcc, | ||
131 | void *priv_data) | ||
132 | { | ||
133 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
134 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
135 | p_dev->io.BasePort1 = io->win[0].base; | ||
136 | p_dev->io.NumPorts1 = io->win[0].len; | ||
137 | if (io->nwin == 2) { | ||
138 | p_dev->io.BasePort2 = io->win[1].base; | ||
139 | p_dev->io.NumPorts2 = io->win[1].len; | ||
140 | } | ||
141 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
142 | return 0; | ||
143 | } | ||
144 | return -ENODEV; | ||
145 | } | ||
146 | |||
127 | static int ixj_config(struct pcmcia_device * link) | 147 | static int ixj_config(struct pcmcia_device * link) |
128 | { | 148 | { |
129 | IXJ *j; | 149 | IXJ *j; |
130 | ixj_info_t *info; | 150 | ixj_info_t *info; |
131 | tuple_t tuple; | 151 | cistpl_cftable_entry_t dflt = { 0 }; |
132 | u_short buf[128]; | 152 | |
133 | cisparse_t parse; | ||
134 | cistpl_cftable_entry_t *cfg = &parse.cftable_entry; | ||
135 | cistpl_cftable_entry_t dflt = | ||
136 | { | ||
137 | 0 | ||
138 | }; | ||
139 | int last_ret, last_fn; | ||
140 | info = link->priv; | 153 | info = link->priv; |
141 | DEBUG(0, "ixj_config(0x%p)\n", link); | 154 | DEBUG(0, "ixj_config(0x%p)\n", link); |
142 | tuple.TupleData = (cisdata_t *) buf; | ||
143 | tuple.TupleOffset = 0; | ||
144 | tuple.TupleDataMax = 255; | ||
145 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
146 | tuple.Attributes = 0; | ||
147 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
148 | while (1) { | ||
149 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
150 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
151 | goto next_entry; | ||
152 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
153 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
154 | link->conf.ConfigIndex = cfg->index; | ||
155 | link->io.BasePort1 = io->win[0].base; | ||
156 | link->io.NumPorts1 = io->win[0].len; | ||
157 | if (io->nwin == 2) { | ||
158 | link->io.BasePort2 = io->win[1].base; | ||
159 | link->io.NumPorts2 = io->win[1].len; | ||
160 | } | ||
161 | if (pcmcia_request_io(link, &link->io) != 0) | ||
162 | goto next_entry; | ||
163 | /* If we've got this far, we're done */ | ||
164 | break; | ||
165 | } | ||
166 | next_entry: | ||
167 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
168 | dflt = *cfg; | ||
169 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
170 | } | ||
171 | 155 | ||
172 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | 156 | if (pcmcia_loop_config(link, ixj_config_check, &dflt)) |
157 | goto cs_failed; | ||
158 | |||
159 | if (pcmcia_request_configuration(link, &link->conf)) | ||
160 | goto cs_failed; | ||
173 | 161 | ||
174 | /* | 162 | /* |
175 | * Register the card with the core. | 163 | * Register the card with the core. |
176 | */ | 164 | */ |
177 | j=ixj_pcmcia_probe(link->io.BasePort1,link->io.BasePort1 + 0x10); | 165 | j = ixj_pcmcia_probe(link->io.BasePort1, link->io.BasePort1 + 0x10); |
178 | 166 | ||
179 | info->ndev = 1; | 167 | info->ndev = 1; |
180 | info->node.major = PHONE_MAJOR; | 168 | info->node.major = PHONE_MAJOR; |
181 | link->dev_node = &info->node; | 169 | link->dev_node = &info->node; |
182 | ixj_get_serial(link, j); | 170 | ixj_get_serial(link, j); |
183 | return 0; | 171 | return 0; |
172 | |||
184 | cs_failed: | 173 | cs_failed: |
185 | cs_error(link, last_fn, last_ret); | ||
186 | ixj_cs_release(link); | 174 | ixj_cs_release(link); |
187 | return -ENODEV; | 175 | return -ENODEV; |
188 | } | 176 | } |
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 5da63f535005..516848dd9b48 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c | |||
@@ -112,7 +112,8 @@ static struct platform_device platform_dev = { | |||
112 | .num_resources = ARRAY_SIZE(resources), | 112 | .num_resources = ARRAY_SIZE(resources), |
113 | }; | 113 | }; |
114 | 114 | ||
115 | static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) | 115 | static int sl811_hc_init(struct device *parent, resource_size_t base_addr, |
116 | int irq) | ||
116 | { | 117 | { |
117 | if (platform_dev.dev.parent) | 118 | if (platform_dev.dev.parent) |
118 | return -EBUSY; | 119 | return -EBUSY; |
@@ -155,97 +156,72 @@ static void sl811_cs_release(struct pcmcia_device * link) | |||
155 | platform_device_unregister(&platform_dev); | 156 | platform_device_unregister(&platform_dev); |
156 | } | 157 | } |
157 | 158 | ||
159 | static int sl811_cs_config_check(struct pcmcia_device *p_dev, | ||
160 | cistpl_cftable_entry_t *cfg, | ||
161 | cistpl_cftable_entry_t *dflt, | ||
162 | unsigned int vcc, | ||
163 | void *priv_data) | ||
164 | { | ||
165 | if (cfg->index == 0) | ||
166 | return -ENODEV; | ||
167 | |||
168 | /* Use power settings for Vcc and Vpp if present */ | ||
169 | /* Note that the CIS values need to be rescaled */ | ||
170 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
171 | if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) | ||
172 | return -ENODEV; | ||
173 | } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
174 | if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc) | ||
175 | return -ENODEV; | ||
176 | } | ||
177 | |||
178 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
179 | p_dev->conf.Vpp = | ||
180 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
181 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
182 | p_dev->conf.Vpp = | ||
183 | dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
184 | |||
185 | /* we need an interrupt */ | ||
186 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
187 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
188 | |||
189 | /* IO window settings */ | ||
190 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
191 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
192 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
193 | |||
194 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
195 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
196 | p_dev->io.BasePort1 = io->win[0].base; | ||
197 | p_dev->io.NumPorts1 = io->win[0].len; | ||
198 | |||
199 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
200 | } | ||
201 | pcmcia_disable_device(p_dev); | ||
202 | return -ENODEV; | ||
203 | } | ||
204 | |||
205 | |||
158 | static int sl811_cs_config(struct pcmcia_device *link) | 206 | static int sl811_cs_config(struct pcmcia_device *link) |
159 | { | 207 | { |
160 | struct device *parent = &handle_to_dev(link); | 208 | struct device *parent = &handle_to_dev(link); |
161 | local_info_t *dev = link->priv; | 209 | local_info_t *dev = link->priv; |
162 | tuple_t tuple; | ||
163 | cisparse_t parse; | ||
164 | int last_fn, last_ret; | 210 | int last_fn, last_ret; |
165 | u_char buf[64]; | ||
166 | config_info_t conf; | ||
167 | cistpl_cftable_entry_t dflt = { 0 }; | ||
168 | 211 | ||
169 | DBG(0, "sl811_cs_config(0x%p)\n", link); | 212 | DBG(0, "sl811_cs_config(0x%p)\n", link); |
170 | 213 | ||
171 | /* Look up the current Vcc */ | 214 | if (pcmcia_loop_config(link, sl811_cs_config_check, NULL)) |
172 | CS_CHECK(GetConfigurationInfo, | 215 | goto failed; |
173 | pcmcia_get_configuration_info(link, &conf)); | ||
174 | |||
175 | tuple.Attributes = 0; | ||
176 | tuple.TupleData = buf; | ||
177 | tuple.TupleDataMax = sizeof(buf); | ||
178 | tuple.TupleOffset = 0; | ||
179 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
180 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
181 | while (1) { | ||
182 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
183 | |||
184 | if (pcmcia_get_tuple_data(link, &tuple) != 0 | ||
185 | || pcmcia_parse_tuple(link, &tuple, &parse) | ||
186 | != 0) | ||
187 | goto next_entry; | ||
188 | |||
189 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { | ||
190 | dflt = *cfg; | ||
191 | } | ||
192 | |||
193 | if (cfg->index == 0) | ||
194 | goto next_entry; | ||
195 | |||
196 | link->conf.ConfigIndex = cfg->index; | ||
197 | |||
198 | /* Use power settings for Vcc and Vpp if present */ | ||
199 | /* Note that the CIS values need to be rescaled */ | ||
200 | if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
201 | if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 | ||
202 | != conf.Vcc) | ||
203 | goto next_entry; | ||
204 | } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) { | ||
205 | if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000 | ||
206 | != conf.Vcc) | ||
207 | goto next_entry; | ||
208 | } | ||
209 | |||
210 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
211 | link->conf.Vpp = | ||
212 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
213 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
214 | link->conf.Vpp = | ||
215 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
216 | |||
217 | /* we need an interrupt */ | ||
218 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
219 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
220 | |||
221 | /* IO window settings */ | ||
222 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
223 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
224 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
225 | |||
226 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
227 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
228 | link->io.BasePort1 = io->win[0].base; | ||
229 | link->io.NumPorts1 = io->win[0].len; | ||
230 | |||
231 | if (pcmcia_request_io(link, &link->io) != 0) | ||
232 | goto next_entry; | ||
233 | } | ||
234 | break; | ||
235 | |||
236 | next_entry: | ||
237 | pcmcia_disable_device(link); | ||
238 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
239 | } | ||
240 | 216 | ||
241 | /* require an IRQ and two registers */ | 217 | /* require an IRQ and two registers */ |
242 | if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) | 218 | if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) |
243 | goto cs_failed; | 219 | goto failed; |
244 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 220 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
245 | CS_CHECK(RequestIRQ, | 221 | CS_CHECK(RequestIRQ, |
246 | pcmcia_request_irq(link, &link->irq)); | 222 | pcmcia_request_irq(link, &link->irq)); |
247 | else | 223 | else |
248 | goto cs_failed; | 224 | goto failed; |
249 | 225 | ||
250 | CS_CHECK(RequestConfiguration, | 226 | CS_CHECK(RequestConfiguration, |
251 | pcmcia_request_configuration(link, &link->conf)); | 227 | pcmcia_request_configuration(link, &link->conf)); |
@@ -266,8 +242,9 @@ next_entry: | |||
266 | if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) | 242 | if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) |
267 | < 0) { | 243 | < 0) { |
268 | cs_failed: | 244 | cs_failed: |
269 | printk("sl811_cs_config failed\n"); | ||
270 | cs_error(link, last_fn, last_ret); | 245 | cs_error(link, last_fn, last_ret); |
246 | failed: | ||
247 | printk(KERN_WARNING "sl811_cs_config failed\n"); | ||
271 | sl811_cs_release(link); | 248 | sl811_cs_release(link); |
272 | return -ENODEV; | 249 | return -ENODEV; |
273 | } | 250 | } |