aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-21 17:25:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-21 17:25:16 -0400
commitb65378898c2eefb20f419632c1199bc0592e2f79 (patch)
tree052bb72d329c44790f91fc8097b8500d4774d02c
parent157b6ceb13e4b4148ee03dd517dbe88748943125 (diff)
parent5b917a1420d3d1a9c8da49fb0090692dc9aaee86 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (22 commits) pcmcia: synclink_cs: fix information leak to userland pcmcia: don't call flush_scheduled_work() spuriously serial_cs: drop spurious flush_scheduled_work() call pcmcia/yenta: guide users in case of problems with O2-bridges pcmcia: fix unused function compile warning pcmcia: vrc4173_cardu: Fix error path for pci_release_regions and pci_disable_device pcmcia: add a few debug statements pcmcia: remove obsolete and wrong comments pcmcia: avoid messages on module (un)loading pcmcia: move driver name to struct pcmcia_driver pcmcia: remove the "Finally, report what we've done" message pcmcia: use autoconfiguration feature for ioports and iomem pcmcia: introduce autoconfiguration feature pcmcia: Documentation update pcmcia: convert pcmcia_request_configuration to pcmcia_enable_device pcmcia: move config_{base,index,regs} to struct pcmcia_device pcmcia: simplify IntType pcmcia: simplify Status, ExtStatus register access pcmcia: remove Pin, Copy configuration register access pcmcia: move Vpp setup to struct pcmcia_device ...
-rw-r--r--Documentation/pcmcia/driver-changes.txt25
-rw-r--r--drivers/ata/pata_pcmcia.c104
-rw-r--r--drivers/bluetooth/bluecard_cs.c12
-rw-r--r--drivers/bluetooth/bt3c_cs.c64
-rw-r--r--drivers/bluetooth/btuart_cs.c62
-rw-r--r--drivers/bluetooth/dtl1_cs.c27
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c31
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c40
-rw-r--r--drivers/char/pcmcia/ipwireless/main.c117
-rw-r--r--drivers/char/pcmcia/ipwireless/main.h5
-rw-r--r--drivers/char/pcmcia/ipwireless/tty.h1
-rw-r--r--drivers/char/pcmcia/synclink_cs.c46
-rw-r--r--drivers/ide/ide-cs.c156
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c83
-rw-r--r--drivers/isdn/hisax/avma1_cs.c97
-rw-r--r--drivers/isdn/hisax/elsa_cs.c100
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c168
-rw-r--r--drivers/isdn/hisax/teles_cs.c98
-rw-r--r--drivers/mmc/host/sdricoh_cs.c5
-rw-r--r--drivers/mtd/maps/pcmciamtd.c102
-rw-r--r--drivers/net/pcmcia/3c574_cs.c35
-rw-r--r--drivers/net/pcmcia/3c589_cs.c47
-rw-r--r--drivers/net/pcmcia/axnet_cs.c87
-rw-r--r--drivers/net/pcmcia/com20020_cs.c43
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c67
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c89
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c42
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c146
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c114
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c161
-rw-r--r--drivers/net/wireless/airo_cs.c154
-rw-r--r--drivers/net/wireless/atmel_cs.c135
-rw-r--r--drivers/net/wireless/b43/pcmcia.c24
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c102
-rw-r--r--drivers/net/wireless/libertas/if_cs.c58
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c137
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c134
-rw-r--r--drivers/net/wireless/ray_cs.c91
-rw-r--r--drivers/net/wireless/ray_cs.h2
-rw-r--r--drivers/net/wireless/wl3501_cs.c47
-rw-r--r--drivers/parport/parport_cs.c76
-rw-r--r--drivers/pcmcia/au1000_generic.c3
-rw-r--r--drivers/pcmcia/au1000_generic.h1
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c1
-rw-r--r--drivers/pcmcia/cistpl.c1
-rw-r--r--drivers/pcmcia/cs.c3
-rw-r--r--drivers/pcmcia/cs_internal.h9
-rw-r--r--drivers/pcmcia/ds.c37
-rw-r--r--drivers/pcmcia/i82092.c1
-rw-r--r--drivers/pcmcia/i82365.c1
-rw-r--r--drivers/pcmcia/m32r_cfc.c1
-rw-r--r--drivers/pcmcia/m32r_pcc.c1
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c1
-rw-r--r--drivers/pcmcia/o2micro.h4
-rw-r--r--drivers/pcmcia/pcmcia_cis.c117
-rw-r--r--drivers/pcmcia/pcmcia_resource.c409
-rw-r--r--drivers/pcmcia/pd6729.c1
-rw-r--r--drivers/pcmcia/rsrc_iodyn.c1
-rw-r--r--drivers/pcmcia/rsrc_mgr.c1
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c1
-rw-r--r--drivers/pcmcia/sa1100_generic.c1
-rw-r--r--drivers/pcmcia/soc_common.c4
-rw-r--r--drivers/pcmcia/soc_common.h1
-rw-r--r--drivers/pcmcia/socket_sysfs.c1
-rw-r--r--drivers/pcmcia/tcic.c1
-rw-r--r--drivers/pcmcia/vrc4173_cardu.c58
-rw-r--r--drivers/pcmcia/xxs1500_ss.c1
-rw-r--r--drivers/pcmcia/yenta_socket.c1
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c48
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c24
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c182
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c24
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c22
-rw-r--r--drivers/serial/serial_cs.c205
-rw-r--r--drivers/ssb/main.c1
-rw-r--r--drivers/ssb/pcmcia.c1
-rw-r--r--drivers/ssb/scan.c1
-rw-r--r--drivers/staging/comedi/drivers/cb_das16_cs.c58
-rw-r--r--drivers/staging/comedi/drivers/das08_cs.c129
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_700.c130
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_dio24.c130
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc_cs.c144
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_cs.c23
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c124
-rw-r--r--drivers/staging/wlags49_h2/wl_cs.c77
-rw-r--r--drivers/staging/wlags49_h2/wl_internal.h1
-rw-r--r--drivers/staging/wlags49_h2/wl_main.c19
-rw-r--r--drivers/telephony/ixj_pcmcia.c41
-rw-r--r--drivers/usb/host/sl811_cs.c68
-rw-r--r--include/pcmcia/cs.h95
-rw-r--r--include/pcmcia/ds.h85
-rw-r--r--include/pcmcia/ss.h1
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.c16
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.h1
-rw-r--r--sound/pcmcia/vx/vxpocket.c15
-rw-r--r--sound/pcmcia/vx/vxpocket.h1
96 files changed, 1327 insertions, 4135 deletions
diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt
index 26c0f9c00545..dd04361dd361 100644
--- a/Documentation/pcmcia/driver-changes.txt
+++ b/Documentation/pcmcia/driver-changes.txt
@@ -1,4 +1,29 @@
1This file details changes in 2.6 which affect PCMCIA card driver authors: 1This file details changes in 2.6 which affect PCMCIA card driver authors:
2* pcmcia_loop_config() and autoconfiguration (as of 2.6.36)
3 If struct pcmcia_device *p_dev->config_flags is set accordingly,
4 pcmcia_loop_config() now sets up certain configuration values
5 automatically, though the driver may still override the settings
6 in the callback function. The following autoconfiguration options
7 are provided at the moment:
8 CONF_AUTO_CHECK_VCC : check for matching Vcc
9 CONF_AUTO_SET_VPP : set Vpp
10 CONF_AUTO_AUDIO : auto-enable audio line, if required
11 CONF_AUTO_SET_IO : set ioport resources (->resource[0,1])
12 CONF_AUTO_SET_IOMEM : set first iomem resource (->resource[2])
13
14* pcmcia_request_configuration -> pcmcia_enable_device (as of 2.6.36)
15 pcmcia_request_configuration() got renamed to pcmcia_enable_device(),
16 as it mirrors pcmcia_disable_device(). Configuration settings are now
17 stored in struct pcmcia_device, e.g. in the fields config_flags,
18 config_index, config_base, vpp.
19
20* pcmcia_request_window changes (as of 2.6.36)
21 Instead of win_req_t, drivers are now requested to fill out
22 struct pcmcia_device *p_dev->resource[2,3,4,5] for up to four ioport
23 ranges. After a call to pcmcia_request_window(), the regions found there
24 are reserved and may be used immediately -- until pcmcia_release_window()
25 is called.
26
2* pcmcia_request_io changes (as of 2.6.36) 27* pcmcia_request_io changes (as of 2.6.36)
3 Instead of io_req_t, drivers are now requested to fill out 28 Instead of io_req_t, drivers are now requested to fill out
4 struct pcmcia_device *p_dev->resource[0,1] for up to two ioport 29 struct pcmcia_device *p_dev->resource[0,1] for up to two ioport
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index e944aa0c5517..806292160b3f 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -34,7 +34,6 @@
34#include <linux/ata.h> 34#include <linux/ata.h>
35#include <linux/libata.h> 35#include <linux/libata.h>
36 36
37#include <pcmcia/cs.h>
38#include <pcmcia/cistpl.h> 37#include <pcmcia/cistpl.h>
39#include <pcmcia/ds.h> 38#include <pcmcia/ds.h>
40#include <pcmcia/cisreg.h> 39#include <pcmcia/cisreg.h>
@@ -168,63 +167,26 @@ static struct ata_port_operations pcmcia_8bit_port_ops = {
168}; 167};
169 168
170 169
171struct pcmcia_config_check { 170static int pcmcia_check_one_config(struct pcmcia_device *pdev, void *priv_data)
172 unsigned long ctl_base;
173 int skip_vcc;
174 int is_kme;
175};
176
177static int pcmcia_check_one_config(struct pcmcia_device *pdev,
178 cistpl_cftable_entry_t *cfg,
179 cistpl_cftable_entry_t *dflt,
180 unsigned int vcc,
181 void *priv_data)
182{ 171{
183 struct pcmcia_config_check *stk = priv_data; 172 int *is_kme = priv_data;
184 173
185 /* Check for matching Vcc, unless we're desperate */ 174 if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) {
186 if (!stk->skip_vcc) { 175 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
187 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { 176 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
188 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
189 return -ENODEV;
190 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
191 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
192 return -ENODEV;
193 }
194 } 177 }
178 pdev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
179 pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
195 180
196 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 181 if (pdev->resource[1]->end) {
197 pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 182 pdev->resource[0]->end = 8;
198 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 183 pdev->resource[1]->end = (*is_kme) ? 2 : 1;
199 pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 184 } else {
200 185 if (pdev->resource[0]->end < 16)
201 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
202 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
203 pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
204 pdev->resource[0]->start = io->win[0].base;
205 if (!(io->flags & CISTPL_IO_16BIT)) {
206 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
207 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
208 }
209 if (io->nwin == 2) {
210 pdev->resource[0]->end = 8;
211 pdev->resource[1]->start = io->win[1].base;
212 pdev->resource[1]->end = (stk->is_kme) ? 2 : 1;
213 if (pcmcia_request_io(pdev) != 0)
214 return -ENODEV;
215 stk->ctl_base = pdev->resource[1]->start;
216 } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
217 pdev->resource[0]->end = io->win[0].len;
218 pdev->resource[1]->end = 0;
219 if (pcmcia_request_io(pdev) != 0)
220 return -ENODEV;
221 stk->ctl_base = pdev->resource[0]->start + 0x0e;
222 } else
223 return -ENODEV; 186 return -ENODEV;
224 /* If we've got this far, we're done */
225 return 0;
226 } 187 }
227 return -ENODEV; 188
189 return pcmcia_request_io(pdev);
228} 190}
229 191
230/** 192/**
@@ -239,7 +201,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
239{ 201{
240 struct ata_host *host; 202 struct ata_host *host;
241 struct ata_port *ap; 203 struct ata_port *ap;
242 struct pcmcia_config_check *stk = NULL;
243 int is_kme = 0, ret = -ENOMEM, p; 204 int is_kme = 0, ret = -ENOMEM, p;
244 unsigned long io_base, ctl_base; 205 unsigned long io_base, ctl_base;
245 void __iomem *io_addr, *ctl_addr; 206 void __iomem *io_addr, *ctl_addr;
@@ -247,10 +208,8 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
247 struct ata_port_operations *ops = &pcmcia_port_ops; 208 struct ata_port_operations *ops = &pcmcia_port_ops;
248 209
249 /* Set up attributes in order to probe card and get resources */ 210 /* Set up attributes in order to probe card and get resources */
250 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 211 pdev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO |
251 pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 212 CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
252 pdev->conf.Attributes = CONF_ENABLE_IRQ;
253 pdev->conf.IntType = INT_MEMORY_AND_IO;
254 213
255 /* See if we have a manufacturer identifier. Use it to set is_kme for 214 /* See if we have a manufacturer identifier. Use it to set is_kme for
256 vendor quirks */ 215 vendor quirks */
@@ -258,25 +217,21 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
258 ((pdev->card_id == PRODID_KME_KXLC005_A) || 217 ((pdev->card_id == PRODID_KME_KXLC005_A) ||
259 (pdev->card_id == PRODID_KME_KXLC005_B))); 218 (pdev->card_id == PRODID_KME_KXLC005_B)));
260 219
261 /* Allocate resoure probing structures */ 220 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, &is_kme)) {
262 221 pdev->config_flags &= ~CONF_AUTO_CHECK_VCC;
263 stk = kzalloc(sizeof(*stk), GFP_KERNEL); 222 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, &is_kme))
264 if (!stk)
265 goto out1;
266 stk->is_kme = is_kme;
267 stk->skip_vcc = io_base = ctl_base = 0;
268
269 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk)) {
270 stk->skip_vcc = 1;
271 if (pcmcia_loop_config(pdev, pcmcia_check_one_config, stk))
272 goto failed; /* No suitable config found */ 223 goto failed; /* No suitable config found */
273 } 224 }
274 io_base = pdev->resource[0]->start; 225 io_base = pdev->resource[0]->start;
275 ctl_base = stk->ctl_base; 226 if (pdev->resource[1]->end)
227 ctl_base = pdev->resource[1]->start;
228 else
229 ctl_base = pdev->resource[0]->start + 0x0e;
230
276 if (!pdev->irq) 231 if (!pdev->irq)
277 goto failed; 232 goto failed;
278 233
279 ret = pcmcia_request_configuration(pdev, &pdev->conf); 234 ret = pcmcia_enable_device(pdev);
280 if (ret) 235 if (ret)
281 goto failed; 236 goto failed;
282 237
@@ -329,13 +284,10 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
329 goto failed; 284 goto failed;
330 285
331 pdev->priv = host; 286 pdev->priv = host;
332 kfree(stk);
333 return 0; 287 return 0;
334 288
335failed: 289failed:
336 kfree(stk);
337 pcmcia_disable_device(pdev); 290 pcmcia_disable_device(pdev);
338out1:
339 return ret; 291 return ret;
340} 292}
341 293
@@ -430,9 +382,7 @@ MODULE_DEVICE_TABLE(pcmcia, pcmcia_devices);
430 382
431static struct pcmcia_driver pcmcia_driver = { 383static struct pcmcia_driver pcmcia_driver = {
432 .owner = THIS_MODULE, 384 .owner = THIS_MODULE,
433 .drv = { 385 .name = DRV_NAME,
434 .name = DRV_NAME,
435 },
436 .id_table = pcmcia_devices, 386 .id_table = pcmcia_devices,
437 .probe = pcmcia_init_one, 387 .probe = pcmcia_init_one,
438 .remove = pcmcia_remove_one, 388 .remove = pcmcia_remove_one,
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index d52e90a5a617..4104b7feae67 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -39,7 +39,6 @@
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/io.h> 40#include <linux/io.h>
41 41
42#include <pcmcia/cs.h>
43#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
44#include <pcmcia/ciscode.h> 43#include <pcmcia/ciscode.h>
45#include <pcmcia/ds.h> 44#include <pcmcia/ds.h>
@@ -865,8 +864,7 @@ static int bluecard_probe(struct pcmcia_device *link)
865 info->p_dev = link; 864 info->p_dev = link;
866 link->priv = info; 865 link->priv = info;
867 866
868 link->conf.Attributes = CONF_ENABLE_IRQ; 867 link->config_flags |= CONF_ENABLE_IRQ;
869 link->conf.IntType = INT_MEMORY_AND_IO;
870 868
871 return bluecard_config(link); 869 return bluecard_config(link);
872} 870}
@@ -886,7 +884,7 @@ static int bluecard_config(struct pcmcia_device *link)
886 bluecard_info_t *info = link->priv; 884 bluecard_info_t *info = link->priv;
887 int i, n; 885 int i, n;
888 886
889 link->conf.ConfigIndex = 0x20; 887 link->config_index = 0x20;
890 888
891 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 889 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
892 link->resource[0]->end = 64; 890 link->resource[0]->end = 64;
@@ -906,7 +904,7 @@ static int bluecard_config(struct pcmcia_device *link)
906 if (i != 0) 904 if (i != 0)
907 goto failed; 905 goto failed;
908 906
909 i = pcmcia_request_configuration(link, &link->conf); 907 i = pcmcia_enable_device(link);
910 if (i != 0) 908 if (i != 0)
911 goto failed; 909 goto failed;
912 910
@@ -942,9 +940,7 @@ MODULE_DEVICE_TABLE(pcmcia, bluecard_ids);
942 940
943static struct pcmcia_driver bluecard_driver = { 941static struct pcmcia_driver bluecard_driver = {
944 .owner = THIS_MODULE, 942 .owner = THIS_MODULE,
945 .drv = { 943 .name = "bluecard_cs",
946 .name = "bluecard_cs",
947 },
948 .probe = bluecard_probe, 944 .probe = bluecard_probe,
949 .remove = bluecard_detach, 945 .remove = bluecard_detach,
950 .id_table = bluecard_ids, 946 .id_table = bluecard_ids,
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 7ab8f29d5e0d..0c8a65587491 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -45,7 +45,6 @@
45#include <linux/device.h> 45#include <linux/device.h>
46#include <linux/firmware.h> 46#include <linux/firmware.h>
47 47
48#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
50#include <pcmcia/ciscode.h> 49#include <pcmcia/ciscode.h>
51#include <pcmcia/ds.h> 50#include <pcmcia/ds.h>
@@ -657,11 +656,8 @@ static int bt3c_probe(struct pcmcia_device *link)
657 info->p_dev = link; 656 info->p_dev = link;
658 link->priv = info; 657 link->priv = info;
659 658
660 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 659 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
661 link->resource[0]->end = 8; 660 CONF_AUTO_SET_IO;
662
663 link->conf.Attributes = CONF_ENABLE_IRQ;
664 link->conf.IntType = INT_MEMORY_AND_IO;
665 661
666 return bt3c_config(link); 662 return bt3c_config(link);
667} 663}
@@ -675,43 +671,41 @@ static void bt3c_detach(struct pcmcia_device *link)
675 kfree(info); 671 kfree(info);
676} 672}
677 673
678static int bt3c_check_config(struct pcmcia_device *p_dev, 674static int bt3c_check_config(struct pcmcia_device *p_dev, void *priv_data)
679 cistpl_cftable_entry_t *cf,
680 cistpl_cftable_entry_t *dflt,
681 unsigned int vcc,
682 void *priv_data)
683{ 675{
684 unsigned long try = (unsigned long) priv_data; 676 int *try = priv_data;
685 677
686 p_dev->io_lines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 678 if (try == 0)
679 p_dev->io_lines = 16;
687 680
688 if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 681 if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
689 p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 682 return -EINVAL;
690 if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 683
691 (cf->io.win[0].base != 0)) { 684 p_dev->resource[0]->end = 8;
692 p_dev->resource[0]->start = cf->io.win[0].base; 685 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
693 if (!pcmcia_request_io(p_dev)) 686 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
694 return 0; 687
695 } 688 return pcmcia_request_io(p_dev);
696 return -ENODEV;
697} 689}
698 690
699static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev, 691static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
700 cistpl_cftable_entry_t *cf,
701 cistpl_cftable_entry_t *dflt,
702 unsigned int vcc,
703 void *priv_data) 692 void *priv_data)
704{ 693{
705 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 694 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
706 int j; 695 int j;
707 696
708 if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 697 if (p_dev->io_lines > 3)
709 for (j = 0; j < 5; j++) { 698 return -ENODEV;
710 p_dev->resource[0]->start = base[j]; 699
711 p_dev->io_lines = base[j] ? 16 : 3; 700 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
712 if (!pcmcia_request_io(p_dev)) 701 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
713 return 0; 702 p_dev->resource[0]->end = 8;
714 } 703
704 for (j = 0; j < 5; j++) {
705 p_dev->resource[0]->start = base[j];
706 p_dev->io_lines = base[j] ? 16 : 3;
707 if (!pcmcia_request_io(p_dev))
708 return 0;
715 } 709 }
716 return -ENODEV; 710 return -ENODEV;
717} 711}
@@ -742,7 +736,7 @@ found_port:
742 if (i != 0) 736 if (i != 0)
743 goto failed; 737 goto failed;
744 738
745 i = pcmcia_request_configuration(link, &link->conf); 739 i = pcmcia_enable_device(link);
746 if (i != 0) 740 if (i != 0)
747 goto failed; 741 goto failed;
748 742
@@ -775,9 +769,7 @@ MODULE_DEVICE_TABLE(pcmcia, bt3c_ids);
775 769
776static struct pcmcia_driver bt3c_driver = { 770static struct pcmcia_driver bt3c_driver = {
777 .owner = THIS_MODULE, 771 .owner = THIS_MODULE,
778 .drv = { 772 .name = "bt3c_cs",
779 .name = "bt3c_cs",
780 },
781 .probe = bt3c_probe, 773 .probe = bt3c_probe,
782 .remove = bt3c_detach, 774 .remove = bt3c_detach,
783 .id_table = bt3c_ids, 775 .id_table = bt3c_ids,
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 1c4f5e863b03..f8a0708e2311 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -41,7 +41,6 @@
41#include <asm/system.h> 41#include <asm/system.h>
42#include <asm/io.h> 42#include <asm/io.h>
43 43
44#include <pcmcia/cs.h>
45#include <pcmcia/cistpl.h> 44#include <pcmcia/cistpl.h>
46#include <pcmcia/ciscode.h> 45#include <pcmcia/ciscode.h>
47#include <pcmcia/ds.h> 46#include <pcmcia/ds.h>
@@ -586,11 +585,8 @@ static int btuart_probe(struct pcmcia_device *link)
586 info->p_dev = link; 585 info->p_dev = link;
587 link->priv = info; 586 link->priv = info;
588 587
589 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 588 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
590 link->resource[0]->end = 8; 589 CONF_AUTO_SET_IO;
591
592 link->conf.Attributes = CONF_ENABLE_IRQ;
593 link->conf.IntType = INT_MEMORY_AND_IO;
594 590
595 return btuart_config(link); 591 return btuart_config(link);
596} 592}
@@ -604,43 +600,41 @@ static void btuart_detach(struct pcmcia_device *link)
604 kfree(info); 600 kfree(info);
605} 601}
606 602
607static int btuart_check_config(struct pcmcia_device *p_dev, 603static int btuart_check_config(struct pcmcia_device *p_dev, void *priv_data)
608 cistpl_cftable_entry_t *cf,
609 cistpl_cftable_entry_t *dflt,
610 unsigned int vcc,
611 void *priv_data)
612{ 604{
613 int *try = priv_data; 605 int *try = priv_data;
614 606
615 p_dev->io_lines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 607 if (try == 0)
608 p_dev->io_lines = 16;
616 609
617 if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 610 if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
618 p_dev->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 611 return -EINVAL;
619 if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 612
620 (cf->io.win[0].base != 0)) { 613 p_dev->resource[0]->end = 8;
621 p_dev->resource[0]->start = cf->io.win[0].base; 614 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
622 if (!pcmcia_request_io(p_dev)) 615 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
623 return 0; 616
624 } 617 return pcmcia_request_io(p_dev);
625 return -ENODEV;
626} 618}
627 619
628static int btuart_check_config_notpicky(struct pcmcia_device *p_dev, 620static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
629 cistpl_cftable_entry_t *cf,
630 cistpl_cftable_entry_t *dflt,
631 unsigned int vcc,
632 void *priv_data) 621 void *priv_data)
633{ 622{
634 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 623 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
635 int j; 624 int j;
636 625
637 if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 626 if (p_dev->io_lines > 3)
638 for (j = 0; j < 5; j++) { 627 return -ENODEV;
639 p_dev->resource[0]->start = base[j]; 628
640 p_dev->io_lines = base[j] ? 16 : 3; 629 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
641 if (!pcmcia_request_io(p_dev)) 630 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
642 return 0; 631 p_dev->resource[0]->end = 8;
643 } 632
633 for (j = 0; j < 5; j++) {
634 p_dev->resource[0]->start = base[j];
635 p_dev->io_lines = base[j] ? 16 : 3;
636 if (!pcmcia_request_io(p_dev))
637 return 0;
644 } 638 }
645 return -ENODEV; 639 return -ENODEV;
646} 640}
@@ -671,7 +665,7 @@ found_port:
671 if (i != 0) 665 if (i != 0)
672 goto failed; 666 goto failed;
673 667
674 i = pcmcia_request_configuration(link, &link->conf); 668 i = pcmcia_enable_device(link);
675 if (i != 0) 669 if (i != 0)
676 goto failed; 670 goto failed;
677 671
@@ -703,9 +697,7 @@ MODULE_DEVICE_TABLE(pcmcia, btuart_ids);
703 697
704static struct pcmcia_driver btuart_driver = { 698static struct pcmcia_driver btuart_driver = {
705 .owner = THIS_MODULE, 699 .owner = THIS_MODULE,
706 .drv = { 700 .name = "btuart_cs",
707 .name = "btuart_cs",
708 },
709 .probe = btuart_probe, 701 .probe = btuart_probe,
710 .remove = btuart_detach, 702 .remove = btuart_detach,
711 .id_table = btuart_ids, 703 .id_table = btuart_ids,
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index db7c8db695fc..26ee0cf88d20 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -41,7 +41,6 @@
41#include <asm/system.h> 41#include <asm/system.h>
42#include <asm/io.h> 42#include <asm/io.h>
43 43
44#include <pcmcia/cs.h>
45#include <pcmcia/cistpl.h> 44#include <pcmcia/cistpl.h>
46#include <pcmcia/ciscode.h> 45#include <pcmcia/ciscode.h>
47#include <pcmcia/ds.h> 46#include <pcmcia/ds.h>
@@ -572,11 +571,7 @@ static int dtl1_probe(struct pcmcia_device *link)
572 info->p_dev = link; 571 info->p_dev = link;
573 link->priv = info; 572 link->priv = info;
574 573
575 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 574 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
576 link->resource[0]->end = 8;
577
578 link->conf.Attributes = CONF_ENABLE_IRQ;
579 link->conf.IntType = INT_MEMORY_AND_IO;
580 575
581 return dtl1_config(link); 576 return dtl1_config(link);
582} 577}
@@ -591,18 +586,14 @@ static void dtl1_detach(struct pcmcia_device *link)
591 kfree(info); 586 kfree(info);
592} 587}
593 588
594static int dtl1_confcheck(struct pcmcia_device *p_dev, 589static int dtl1_confcheck(struct pcmcia_device *p_dev, void *priv_data)
595 cistpl_cftable_entry_t *cf,
596 cistpl_cftable_entry_t *dflt,
597 unsigned int vcc,
598 void *priv_data)
599{ 590{
600 if ((cf->io.nwin != 1) || (cf->io.win[0].len <= 8)) 591 if ((p_dev->resource[1]->end) || (p_dev->resource[1]->end < 8))
601 return -ENODEV; 592 return -ENODEV;
602 593
603 p_dev->resource[0]->start = cf->io.win[0].base; 594 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
604 p_dev->resource[0]->end = cf->io.win[0].len; /*yo */ 595 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
605 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 596
606 return pcmcia_request_io(p_dev); 597 return pcmcia_request_io(p_dev);
607} 598}
608 599
@@ -620,7 +611,7 @@ static int dtl1_config(struct pcmcia_device *link)
620 if (i != 0) 611 if (i != 0)
621 goto failed; 612 goto failed;
622 613
623 i = pcmcia_request_configuration(link, &link->conf); 614 i = pcmcia_enable_device(link);
624 if (i != 0) 615 if (i != 0)
625 goto failed; 616 goto failed;
626 617
@@ -656,9 +647,7 @@ MODULE_DEVICE_TABLE(pcmcia, dtl1_ids);
656 647
657static struct pcmcia_driver dtl1_driver = { 648static struct pcmcia_driver dtl1_driver = {
658 .owner = THIS_MODULE, 649 .owner = THIS_MODULE,
659 .drv = { 650 .name = "dtl1_cs",
660 .name = "dtl1_cs",
661 },
662 .probe = dtl1_probe, 651 .probe = dtl1_probe,
663 .remove = dtl1_detach, 652 .remove = dtl1_detach,
664 .id_table = dtl1_ids, 653 .id_table = dtl1_ids,
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index ec73d9f6d9ed..c7b482d15e2a 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -34,7 +34,6 @@
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35#include <linux/io.h> 35#include <linux/io.h>
36 36
37#include <pcmcia/cs.h>
38#include <pcmcia/cistpl.h> 37#include <pcmcia/cistpl.h>
39#include <pcmcia/cisreg.h> 38#include <pcmcia/cisreg.h>
40#include <pcmcia/ciscode.h> 39#include <pcmcia/ciscode.h>
@@ -55,8 +54,6 @@
55 __func__ , ## args); \ 54 __func__ , ## args); \
56 } while (0) 55 } while (0)
57 56
58static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte";
59
60#define T_1SEC (HZ) 57#define T_1SEC (HZ)
61#define T_10MSEC msecs_to_jiffies(10) 58#define T_10MSEC msecs_to_jiffies(10)
62#define T_20MSEC msecs_to_jiffies(20) 59#define T_20MSEC msecs_to_jiffies(20)
@@ -1742,20 +1739,8 @@ static void cmm_cm4000_release(struct pcmcia_device * link)
1742 1739
1743/*==== Interface to PCMCIA Layer =======================================*/ 1740/*==== Interface to PCMCIA Layer =======================================*/
1744 1741
1745static int cm4000_config_check(struct pcmcia_device *p_dev, 1742static int cm4000_config_check(struct pcmcia_device *p_dev, void *priv_data)
1746 cistpl_cftable_entry_t *cfg,
1747 cistpl_cftable_entry_t *dflt,
1748 unsigned int vcc,
1749 void *priv_data)
1750{ 1743{
1751 if (!cfg->io.nwin)
1752 return -ENODEV;
1753
1754 p_dev->resource[0]->start = cfg->io.win[0].base;
1755 p_dev->resource[0]->end = cfg->io.win[0].len;
1756 p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags);
1757 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK;
1758
1759 return pcmcia_request_io(p_dev); 1744 return pcmcia_request_io(p_dev);
1760} 1745}
1761 1746
@@ -1763,13 +1748,13 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
1763{ 1748{
1764 struct cm4000_dev *dev; 1749 struct cm4000_dev *dev;
1765 1750
1751 link->config_flags |= CONF_AUTO_SET_IO;
1752
1766 /* read the config-tuples */ 1753 /* read the config-tuples */
1767 if (pcmcia_loop_config(link, cm4000_config_check, NULL)) 1754 if (pcmcia_loop_config(link, cm4000_config_check, NULL))
1768 goto cs_release; 1755 goto cs_release;
1769 1756
1770 link->conf.IntType = 00000002; 1757 if (pcmcia_enable_device(link))
1771
1772 if (pcmcia_request_configuration(link, &link->conf))
1773 goto cs_release; 1758 goto cs_release;
1774 1759
1775 dev = link->priv; 1760 dev = link->priv;
@@ -1829,7 +1814,6 @@ static int cm4000_probe(struct pcmcia_device *link)
1829 1814
1830 dev->p_dev = link; 1815 dev->p_dev = link;
1831 link->priv = dev; 1816 link->priv = dev;
1832 link->conf.IntType = INT_MEMORY_AND_IO;
1833 dev_table[i] = link; 1817 dev_table[i] = link;
1834 1818
1835 init_waitqueue_head(&dev->devq); 1819 init_waitqueue_head(&dev->devq);
@@ -1891,9 +1875,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4000_ids);
1891 1875
1892static struct pcmcia_driver cm4000_driver = { 1876static struct pcmcia_driver cm4000_driver = {
1893 .owner = THIS_MODULE, 1877 .owner = THIS_MODULE,
1894 .drv = { 1878 .name = "cm4000_cs",
1895 .name = "cm4000_cs",
1896 },
1897 .probe = cm4000_probe, 1879 .probe = cm4000_probe,
1898 .remove = cm4000_detach, 1880 .remove = cm4000_detach,
1899 .suspend = cm4000_suspend, 1881 .suspend = cm4000_suspend,
@@ -1905,8 +1887,6 @@ static int __init cmm_init(void)
1905{ 1887{
1906 int rc; 1888 int rc;
1907 1889
1908 printk(KERN_INFO "%s\n", version);
1909
1910 cmm_class = class_create(THIS_MODULE, "cardman_4000"); 1890 cmm_class = class_create(THIS_MODULE, "cardman_4000");
1911 if (IS_ERR(cmm_class)) 1891 if (IS_ERR(cmm_class))
1912 return PTR_ERR(cmm_class); 1892 return PTR_ERR(cmm_class);
@@ -1931,7 +1911,6 @@ static int __init cmm_init(void)
1931 1911
1932static void __exit cmm_exit(void) 1912static void __exit cmm_exit(void)
1933{ 1913{
1934 printk(KERN_INFO MODULE_NAME ": unloading\n");
1935 pcmcia_unregister_driver(&cm4000_driver); 1914 pcmcia_unregister_driver(&cm4000_driver);
1936 unregister_chrdev(major, DEVICE_NAME); 1915 unregister_chrdev(major, DEVICE_NAME);
1937 class_destroy(cmm_class); 1916 class_destroy(cmm_class);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 815cde1d0570..bf2f046fc2c1 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -29,7 +29,6 @@
29#include <asm/uaccess.h> 29#include <asm/uaccess.h>
30#include <asm/io.h> 30#include <asm/io.h>
31 31
32#include <pcmcia/cs.h>
33#include <pcmcia/cistpl.h> 32#include <pcmcia/cistpl.h>
34#include <pcmcia/cisreg.h> 33#include <pcmcia/cisreg.h>
35#include <pcmcia/ciscode.h> 34#include <pcmcia/ciscode.h>
@@ -49,9 +48,6 @@
49 __func__ , ## args); \ 48 __func__ , ## args); \
50 } while (0) 49 } while (0)
51 50
52static char *version =
53"OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte";
54
55#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) 51#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
56#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) 52#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
57#define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ) 53#define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ)
@@ -516,26 +512,9 @@ static void cm4040_reader_release(struct pcmcia_device *link)
516 return; 512 return;
517} 513}
518 514
519static int cm4040_config_check(struct pcmcia_device *p_dev, 515static int cm4040_config_check(struct pcmcia_device *p_dev, void *priv_data)
520 cistpl_cftable_entry_t *cfg,
521 cistpl_cftable_entry_t *dflt,
522 unsigned int vcc,
523 void *priv_data)
524{ 516{
525 int rc; 517 return pcmcia_request_io(p_dev);
526 if (!cfg->io.nwin)
527 return -ENODEV;
528
529 /* Get the IOaddr */
530 p_dev->resource[0]->start = cfg->io.win[0].base;
531 p_dev->resource[0]->end = cfg->io.win[0].len;
532 p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags);
533 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK;
534 rc = pcmcia_request_io(p_dev);
535
536 dev_printk(KERN_INFO, &p_dev->dev,
537 "pcmcia_request_io returned 0x%x\n", rc);
538 return rc;
539} 518}
540 519
541 520
@@ -544,15 +523,15 @@ static int reader_config(struct pcmcia_device *link, int devno)
544 struct reader_dev *dev; 523 struct reader_dev *dev;
545 int fail_rc; 524 int fail_rc;
546 525
526 link->config_flags |= CONF_AUTO_SET_IO;
527
547 if (pcmcia_loop_config(link, cm4040_config_check, NULL)) 528 if (pcmcia_loop_config(link, cm4040_config_check, NULL))
548 goto cs_release; 529 goto cs_release;
549 530
550 link->conf.IntType = 00000002; 531 fail_rc = pcmcia_enable_device(link);
551
552 fail_rc = pcmcia_request_configuration(link, &link->conf);
553 if (fail_rc != 0) { 532 if (fail_rc != 0) {
554 dev_printk(KERN_INFO, &link->dev, 533 dev_printk(KERN_INFO, &link->dev,
555 "pcmcia_request_configuration failed 0x%x\n", 534 "pcmcia_enable_device failed 0x%x\n",
556 fail_rc); 535 fail_rc);
557 goto cs_release; 536 goto cs_release;
558 } 537 }
@@ -599,7 +578,6 @@ static int reader_probe(struct pcmcia_device *link)
599 link->priv = dev; 578 link->priv = dev;
600 dev->p_dev = link; 579 dev->p_dev = link;
601 580
602 link->conf.IntType = INT_MEMORY_AND_IO;
603 dev_table[i] = link; 581 dev_table[i] = link;
604 582
605 init_waitqueue_head(&dev->devq); 583 init_waitqueue_head(&dev->devq);
@@ -662,9 +640,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4040_ids);
662 640
663static struct pcmcia_driver reader_driver = { 641static struct pcmcia_driver reader_driver = {
664 .owner = THIS_MODULE, 642 .owner = THIS_MODULE,
665 .drv = { 643 .name = "cm4040_cs",
666 .name = "cm4040_cs",
667 },
668 .probe = reader_probe, 644 .probe = reader_probe,
669 .remove = reader_detach, 645 .remove = reader_detach,
670 .id_table = cm4040_ids, 646 .id_table = cm4040_ids,
@@ -674,7 +650,6 @@ static int __init cm4040_init(void)
674{ 650{
675 int rc; 651 int rc;
676 652
677 printk(KERN_INFO "%s\n", version);
678 cmx_class = class_create(THIS_MODULE, "cardman_4040"); 653 cmx_class = class_create(THIS_MODULE, "cardman_4040");
679 if (IS_ERR(cmx_class)) 654 if (IS_ERR(cmx_class))
680 return PTR_ERR(cmx_class); 655 return PTR_ERR(cmx_class);
@@ -699,7 +674,6 @@ static int __init cm4040_init(void)
699 674
700static void __exit cm4040_exit(void) 675static void __exit cm4040_exit(void)
701{ 676{
702 printk(KERN_INFO MODULE_NAME ": unloading\n");
703 pcmcia_unregister_driver(&reader_driver); 677 pcmcia_unregister_driver(&reader_driver);
704 unregister_chrdev(major, DEVICE_NAME); 678 unregister_chrdev(major, DEVICE_NAME);
705 class_destroy(cmx_class); 679 class_destroy(cmx_class);
diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c
index 67bdb05798b1..94b8eb4d691d 100644
--- a/drivers/char/pcmcia/ipwireless/main.c
+++ b/drivers/char/pcmcia/ipwireless/main.c
@@ -32,7 +32,6 @@
32#include <pcmcia/device_id.h> 32#include <pcmcia/device_id.h>
33#include <pcmcia/ss.h> 33#include <pcmcia/ss.h>
34#include <pcmcia/ds.h> 34#include <pcmcia/ds.h>
35#include <pcmcia/cs.h>
36 35
37static struct pcmcia_device_id ipw_ids[] = { 36static struct pcmcia_device_id ipw_ids[] = {
38 PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100), 37 PCMCIA_DEVICE_MANF_CARD(0x02f2, 0x0100),
@@ -76,23 +75,18 @@ static void signalled_reboot_callback(void *callback_data)
76 schedule_work(&ipw->work_reboot); 75 schedule_work(&ipw->work_reboot);
77} 76}
78 77
79static int ipwireless_probe(struct pcmcia_device *p_dev, 78static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data)
80 cistpl_cftable_entry_t *cfg,
81 cistpl_cftable_entry_t *dflt,
82 unsigned int vcc,
83 void *priv_data)
84{ 79{
85 struct ipw_dev *ipw = priv_data; 80 struct ipw_dev *ipw = priv_data;
86 struct resource *io_resource; 81 struct resource *io_resource;
87 int ret; 82 int ret;
88 83
84 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
89 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 85 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
90 p_dev->resource[0]->start = cfg->io.win[0].base;
91 p_dev->resource[0]->end = cfg->io.win[0].len;
92 86
93 /* 0x40 causes it to generate level mode interrupts. */ 87 /* 0x40 causes it to generate level mode interrupts. */
94 /* 0x04 enables IREQ pin. */ 88 /* 0x04 enables IREQ pin. */
95 p_dev->conf.ConfigIndex = cfg->index | 0x44; 89 p_dev->config_index |= 0x44;
96 p_dev->io_lines = 16; 90 p_dev->io_lines = 16;
97 ret = pcmcia_request_io(p_dev); 91 ret = pcmcia_request_io(p_dev);
98 if (ret) 92 if (ret)
@@ -102,65 +96,49 @@ static int ipwireless_probe(struct pcmcia_device *p_dev,
102 resource_size(p_dev->resource[0]), 96 resource_size(p_dev->resource[0]),
103 IPWIRELESS_PCCARD_NAME); 97 IPWIRELESS_PCCARD_NAME);
104 98
105 if (cfg->mem.nwin == 0) 99 p_dev->resource[2]->flags |=
106 return 0;
107
108 ipw->request_common_memory.Attributes =
109 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE; 100 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_CM | WIN_ENABLE;
110 ipw->request_common_memory.Base = cfg->mem.win[0].host_addr;
111 ipw->request_common_memory.Size = cfg->mem.win[0].len;
112 if (ipw->request_common_memory.Size < 0x1000)
113 ipw->request_common_memory.Size = 0x1000;
114 ipw->request_common_memory.AccessSpeed = 0;
115
116 ret = pcmcia_request_window(p_dev, &ipw->request_common_memory,
117 &ipw->handle_common_memory);
118 101
102 ret = pcmcia_request_window(p_dev, p_dev->resource[2], 0);
119 if (ret != 0) 103 if (ret != 0)
120 goto exit1; 104 goto exit1;
121 105
122 ret = pcmcia_map_mem_page(p_dev, ipw->handle_common_memory, 106 ret = pcmcia_map_mem_page(p_dev, p_dev->resource[2], p_dev->card_addr);
123 cfg->mem.win[0].card_addr);
124
125 if (ret != 0) 107 if (ret != 0)
126 goto exit2; 108 goto exit2;
127 109
128 ipw->is_v2_card = cfg->mem.win[0].len == 0x100; 110 ipw->is_v2_card = resource_size(p_dev->resource[2]) == 0x100;
129 111
130 ipw->common_memory = ioremap(ipw->request_common_memory.Base, 112 ipw->attr_memory = ioremap(p_dev->resource[2]->start,
131 ipw->request_common_memory.Size); 113 resource_size(p_dev->resource[2]));
132 request_mem_region(ipw->request_common_memory.Base, 114 request_mem_region(p_dev->resource[2]->start,
133 ipw->request_common_memory.Size, 115 resource_size(p_dev->resource[2]),
134 IPWIRELESS_PCCARD_NAME); 116 IPWIRELESS_PCCARD_NAME);
135 117
136 ipw->request_attr_memory.Attributes = 118 p_dev->resource[3]->flags |= WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM |
137 WIN_DATA_WIDTH_16 | WIN_MEMORY_TYPE_AM | WIN_ENABLE; 119 WIN_ENABLE;
138 ipw->request_attr_memory.Base = 0; 120 p_dev->resource[3]->end = 0; /* this used to be 0x1000 */
139 ipw->request_attr_memory.Size = 0; /* this used to be 0x1000 */ 121 ret = pcmcia_request_window(p_dev, p_dev->resource[3], 0);
140 ipw->request_attr_memory.AccessSpeed = 0;
141
142 ret = pcmcia_request_window(p_dev, &ipw->request_attr_memory,
143 &ipw->handle_attr_memory);
144
145 if (ret != 0) 122 if (ret != 0)
146 goto exit2; 123 goto exit2;
147 124
148 ret = pcmcia_map_mem_page(p_dev, ipw->handle_attr_memory, 0); 125 ret = pcmcia_map_mem_page(p_dev, p_dev->resource[3], 0);
149 if (ret != 0) 126 if (ret != 0)
150 goto exit3; 127 goto exit3;
151 128
152 ipw->attr_memory = ioremap(ipw->request_attr_memory.Base, 129 ipw->attr_memory = ioremap(p_dev->resource[3]->start,
153 ipw->request_attr_memory.Size); 130 resource_size(p_dev->resource[3]));
154 request_mem_region(ipw->request_attr_memory.Base, 131 request_mem_region(p_dev->resource[3]->start,
155 ipw->request_attr_memory.Size, IPWIRELESS_PCCARD_NAME); 132 resource_size(p_dev->resource[3]),
133 IPWIRELESS_PCCARD_NAME);
156 134
157 return 0; 135 return 0;
158 136
159exit3: 137exit3:
160exit2: 138exit2:
161 if (ipw->common_memory) { 139 if (ipw->common_memory) {
162 release_mem_region(ipw->request_common_memory.Base, 140 release_mem_region(p_dev->resource[2]->start,
163 ipw->request_common_memory.Size); 141 resource_size(p_dev->resource[2]));
164 iounmap(ipw->common_memory); 142 iounmap(ipw->common_memory);
165 } 143 }
166exit1: 144exit1:
@@ -175,14 +153,13 @@ static int config_ipwireless(struct ipw_dev *ipw)
175 int ret = 0; 153 int ret = 0;
176 154
177 ipw->is_v2_card = 0; 155 ipw->is_v2_card = 0;
156 link->config_flags |= CONF_AUTO_SET_IO | CONF_AUTO_SET_IOMEM |
157 CONF_ENABLE_IRQ;
178 158
179 ret = pcmcia_loop_config(link, ipwireless_probe, ipw); 159 ret = pcmcia_loop_config(link, ipwireless_probe, ipw);
180 if (ret != 0) 160 if (ret != 0)
181 return ret; 161 return ret;
182 162
183 link->conf.Attributes = CONF_ENABLE_IRQ;
184 link->conf.IntType = INT_MEMORY_AND_IO;
185
186 INIT_WORK(&ipw->work_reboot, signalled_reboot_work); 163 INIT_WORK(&ipw->work_reboot, signalled_reboot_work);
187 164
188 ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start, 165 ipwireless_init_hardware_v1(ipw->hardware, link->resource[0]->start,
@@ -201,13 +178,9 @@ static int config_ipwireless(struct ipw_dev *ipw)
201 (unsigned int) link->irq); 178 (unsigned int) link->irq);
202 if (ipw->attr_memory && ipw->common_memory) 179 if (ipw->attr_memory && ipw->common_memory)
203 printk(KERN_INFO IPWIRELESS_PCCARD_NAME 180 printk(KERN_INFO IPWIRELESS_PCCARD_NAME
204 ": attr memory 0x%08lx-0x%08lx, common memory 0x%08lx-0x%08lx\n", 181 ": attr memory %pR, common memory %pR\n",
205 ipw->request_attr_memory.Base, 182 link->resource[3],
206 ipw->request_attr_memory.Base 183 link->resource[2]);
207 + ipw->request_attr_memory.Size - 1,
208 ipw->request_common_memory.Base,
209 ipw->request_common_memory.Base
210 + ipw->request_common_memory.Size - 1);
211 184
212 ipw->network = ipwireless_network_create(ipw->hardware); 185 ipw->network = ipwireless_network_create(ipw->hardware);
213 if (!ipw->network) 186 if (!ipw->network)
@@ -223,25 +196,23 @@ static int config_ipwireless(struct ipw_dev *ipw)
223 * Do the RequestConfiguration last, because it enables interrupts. 196 * Do the RequestConfiguration last, because it enables interrupts.
224 * Then we don't get any interrupts before we're ready for them. 197 * Then we don't get any interrupts before we're ready for them.
225 */ 198 */
226 ret = pcmcia_request_configuration(link, &link->conf); 199 ret = pcmcia_enable_device(link);
227
228 if (ret != 0) 200 if (ret != 0)
229 goto exit; 201 goto exit;
230 202
231 return 0; 203 return 0;
232 204
233exit: 205exit:
234 if (ipw->attr_memory) {
235 release_mem_region(ipw->request_attr_memory.Base,
236 ipw->request_attr_memory.Size);
237 iounmap(ipw->attr_memory);
238
239 }
240 if (ipw->common_memory) { 206 if (ipw->common_memory) {
241 release_mem_region(ipw->request_common_memory.Base, 207 release_mem_region(link->resource[2]->start,
242 ipw->request_common_memory.Size); 208 resource_size(link->resource[2]));
243 iounmap(ipw->common_memory); 209 iounmap(ipw->common_memory);
244 } 210 }
211 if (ipw->attr_memory) {
212 release_mem_region(link->resource[3]->start,
213 resource_size(link->resource[3]));
214 iounmap(ipw->attr_memory);
215 }
245 pcmcia_disable_device(link); 216 pcmcia_disable_device(link);
246 return -1; 217 return -1;
247} 218}
@@ -249,13 +220,13 @@ exit:
249static void release_ipwireless(struct ipw_dev *ipw) 220static void release_ipwireless(struct ipw_dev *ipw)
250{ 221{
251 if (ipw->common_memory) { 222 if (ipw->common_memory) {
252 release_mem_region(ipw->request_common_memory.Base, 223 release_mem_region(ipw->link->resource[2]->start,
253 ipw->request_common_memory.Size); 224 resource_size(ipw->link->resource[2]));
254 iounmap(ipw->common_memory); 225 iounmap(ipw->common_memory);
255 } 226 }
256 if (ipw->attr_memory) { 227 if (ipw->attr_memory) {
257 release_mem_region(ipw->request_attr_memory.Base, 228 release_mem_region(ipw->link->resource[3]->start,
258 ipw->request_attr_memory.Size); 229 resource_size(ipw->link->resource[3]));
259 iounmap(ipw->attr_memory); 230 iounmap(ipw->attr_memory);
260 } 231 }
261 pcmcia_disable_device(ipw->link); 232 pcmcia_disable_device(ipw->link);
@@ -324,7 +295,7 @@ static struct pcmcia_driver me = {
324 .owner = THIS_MODULE, 295 .owner = THIS_MODULE,
325 .probe = ipwireless_attach, 296 .probe = ipwireless_attach,
326 .remove = ipwireless_detach, 297 .remove = ipwireless_detach,
327 .drv = { .name = IPWIRELESS_PCCARD_NAME }, 298 .name = IPWIRELESS_PCCARD_NAME,
328 .id_table = ipw_ids 299 .id_table = ipw_ids
329}; 300};
330 301
@@ -336,9 +307,6 @@ static int __init init_ipwireless(void)
336{ 307{
337 int ret; 308 int ret;
338 309
339 printk(KERN_INFO IPWIRELESS_PCCARD_NAME " "
340 IPWIRELESS_PCMCIA_VERSION " by " IPWIRELESS_PCMCIA_AUTHOR "\n");
341
342 ret = ipwireless_tty_init(); 310 ret = ipwireless_tty_init();
343 if (ret != 0) 311 if (ret != 0)
344 return ret; 312 return ret;
@@ -355,9 +323,6 @@ static int __init init_ipwireless(void)
355 */ 323 */
356static void __exit exit_ipwireless(void) 324static void __exit exit_ipwireless(void)
357{ 325{
358 printk(KERN_INFO IPWIRELESS_PCCARD_NAME " "
359 IPWIRELESS_PCMCIA_VERSION " removed\n");
360
361 pcmcia_unregister_driver(&me); 326 pcmcia_unregister_driver(&me);
362 ipwireless_tty_release(); 327 ipwireless_tty_release();
363} 328}
diff --git a/drivers/char/pcmcia/ipwireless/main.h b/drivers/char/pcmcia/ipwireless/main.h
index c207be87b597..f2cbb116bccb 100644
--- a/drivers/char/pcmcia/ipwireless/main.h
+++ b/drivers/char/pcmcia/ipwireless/main.h
@@ -21,7 +21,6 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/types.h> 22#include <linux/types.h>
23 23
24#include <pcmcia/cs.h>
25#include <pcmcia/cistpl.h> 24#include <pcmcia/cistpl.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
27 26
@@ -45,13 +44,9 @@ struct ipw_dev {
45 struct pcmcia_device *link; 44 struct pcmcia_device *link;
46 int is_v2_card; 45 int is_v2_card;
47 46
48 window_handle_t handle_attr_memory;
49 void __iomem *attr_memory; 47 void __iomem *attr_memory;
50 win_req_t request_attr_memory;
51 48
52 window_handle_t handle_common_memory;
53 void __iomem *common_memory; 49 void __iomem *common_memory;
54 win_req_t request_common_memory;
55 50
56 /* Reference to attribute memory, containing CIS data */ 51 /* Reference to attribute memory, containing CIS data */
57 void *attribute_memory; 52 void *attribute_memory;
diff --git a/drivers/char/pcmcia/ipwireless/tty.h b/drivers/char/pcmcia/ipwireless/tty.h
index 3e163d4cab15..747b2d637860 100644
--- a/drivers/char/pcmcia/ipwireless/tty.h
+++ b/drivers/char/pcmcia/ipwireless/tty.h
@@ -21,7 +21,6 @@
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/sched.h> 22#include <linux/sched.h>
23 23
24#include <pcmcia/cs.h>
25#include <pcmcia/cistpl.h> 24#include <pcmcia/cistpl.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
27 26
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 9ecd6bef5d3b..be1810057607 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -70,7 +70,6 @@
70#include <linux/workqueue.h> 70#include <linux/workqueue.h>
71#include <linux/hdlc.h> 71#include <linux/hdlc.h>
72 72
73#include <pcmcia/cs.h>
74#include <pcmcia/cistpl.h> 73#include <pcmcia/cistpl.h>
75#include <pcmcia/cisreg.h> 74#include <pcmcia/cisreg.h>
76#include <pcmcia/ds.h> 75#include <pcmcia/ds.h>
@@ -550,9 +549,6 @@ static int mgslpc_probe(struct pcmcia_device *link)
550 549
551 /* Initialize the struct pcmcia_device structure */ 550 /* Initialize the struct pcmcia_device structure */
552 551
553 link->conf.Attributes = 0;
554 link->conf.IntType = INT_MEMORY_AND_IO;
555
556 ret = mgslpc_config(link); 552 ret = mgslpc_config(link);
557 if (ret) 553 if (ret)
558 return ret; 554 return ret;
@@ -565,20 +561,8 @@ static int mgslpc_probe(struct pcmcia_device *link)
565/* Card has been inserted. 561/* Card has been inserted.
566 */ 562 */
567 563
568static int mgslpc_ioprobe(struct pcmcia_device *p_dev, 564static int mgslpc_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
569 cistpl_cftable_entry_t *cfg,
570 cistpl_cftable_entry_t *dflt,
571 unsigned int vcc,
572 void *priv_data)
573{ 565{
574 if (!cfg->io.nwin)
575 return -ENODEV;
576
577 p_dev->resource[0]->start = cfg->io.win[0].base;
578 p_dev->resource[0]->end = cfg->io.win[0].len;
579 p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags);
580 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK;
581
582 return pcmcia_request_io(p_dev); 566 return pcmcia_request_io(p_dev);
583} 567}
584 568
@@ -590,32 +574,24 @@ static int mgslpc_config(struct pcmcia_device *link)
590 if (debug_level >= DEBUG_LEVEL_INFO) 574 if (debug_level >= DEBUG_LEVEL_INFO)
591 printk("mgslpc_config(0x%p)\n", link); 575 printk("mgslpc_config(0x%p)\n", link);
592 576
577 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
578
593 ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL); 579 ret = pcmcia_loop_config(link, mgslpc_ioprobe, NULL);
594 if (ret != 0) 580 if (ret != 0)
595 goto failed; 581 goto failed;
596 582
597 link->conf.Attributes = CONF_ENABLE_IRQ; 583 link->config_index = 8;
598 link->conf.IntType = INT_MEMORY_AND_IO; 584 link->config_regs = PRESENT_OPTION;
599 link->conf.ConfigIndex = 8;
600 link->conf.Present = PRESENT_OPTION;
601 585
602 ret = pcmcia_request_irq(link, mgslpc_isr); 586 ret = pcmcia_request_irq(link, mgslpc_isr);
603 if (ret) 587 if (ret)
604 goto failed; 588 goto failed;
605 ret = pcmcia_request_configuration(link, &link->conf); 589 ret = pcmcia_enable_device(link);
606 if (ret) 590 if (ret)
607 goto failed; 591 goto failed;
608 592
609 info->io_base = link->resource[0]->start; 593 info->io_base = link->resource[0]->start;
610 info->irq_level = link->irq; 594 info->irq_level = link->irq;
611
612 dev_info(&link->dev, "index 0x%02x:",
613 link->conf.ConfigIndex);
614 if (link->conf.Attributes & CONF_ENABLE_IRQ)
615 printk(", irq %d", link->irq);
616 if (link->resource[0])
617 printk(", io %pR", link->resource[0]);
618 printk("\n");
619 return 0; 595 return 0;
620 596
621failed: 597failed:
@@ -2797,9 +2773,7 @@ MODULE_DEVICE_TABLE(pcmcia, mgslpc_ids);
2797 2773
2798static struct pcmcia_driver mgslpc_driver = { 2774static struct pcmcia_driver mgslpc_driver = {
2799 .owner = THIS_MODULE, 2775 .owner = THIS_MODULE,
2800 .drv = { 2776 .name = "synclink_cs",
2801 .name = "synclink_cs",
2802 },
2803 .probe = mgslpc_probe, 2777 .probe = mgslpc_probe,
2804 .remove = mgslpc_detach, 2778 .remove = mgslpc_detach,
2805 .id_table = mgslpc_ids, 2779 .id_table = mgslpc_ids,
@@ -2835,8 +2809,6 @@ static void synclink_cs_cleanup(void)
2835{ 2809{
2836 int rc; 2810 int rc;
2837 2811
2838 printk("Unloading %s: version %s\n", driver_name, driver_version);
2839
2840 while(mgslpc_device_list) 2812 while(mgslpc_device_list)
2841 mgslpc_remove_device(mgslpc_device_list); 2813 mgslpc_remove_device(mgslpc_device_list);
2842 2814
@@ -2859,8 +2831,6 @@ static int __init synclink_cs_init(void)
2859 BREAKPOINT(); 2831 BREAKPOINT();
2860 } 2832 }
2861 2833
2862 printk("%s %s\n", driver_name, driver_version);
2863
2864 if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0) 2834 if ((rc = pcmcia_register_driver(&mgslpc_driver)) < 0)
2865 return rc; 2835 return rc;
2866 2836
@@ -4127,6 +4097,8 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4127 if (cmd != SIOCWANDEV) 4097 if (cmd != SIOCWANDEV)
4128 return hdlc_ioctl(dev, ifr, cmd); 4098 return hdlc_ioctl(dev, ifr, cmd);
4129 4099
4100 memset(&new_line, 0, size);
4101
4130 switch(ifr->ifr_settings.type) { 4102 switch(ifr->ifr_settings.type) {
4131 case IF_GET_IFACE: /* return current sync_serial_settings */ 4103 case IF_GET_IFACE: /* return current sync_serial_settings */
4132 4104
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index 2a4cb9c18f01..404843e8611b 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -43,7 +43,6 @@
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/system.h> 44#include <asm/system.h>
45 45
46#include <pcmcia/cs.h>
47#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
48#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
49#include <pcmcia/cisreg.h> 48#include <pcmcia/cisreg.h>
@@ -72,17 +71,6 @@ static int ide_config(struct pcmcia_device *);
72 71
73static void ide_detach(struct pcmcia_device *p_dev); 72static void ide_detach(struct pcmcia_device *p_dev);
74 73
75
76
77
78/*======================================================================
79
80 ide_attach() creates an "instance" of the driver, allocating
81 local data structures for one device. The device is registered
82 with Card Services.
83
84======================================================================*/
85
86static int ide_probe(struct pcmcia_device *link) 74static int ide_probe(struct pcmcia_device *link)
87{ 75{
88 ide_info_t *info; 76 ide_info_t *info;
@@ -97,23 +85,12 @@ static int ide_probe(struct pcmcia_device *link)
97 info->p_dev = link; 85 info->p_dev = link;
98 link->priv = info; 86 link->priv = info;
99 87
100 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 88 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO |
101 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 89 CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
102 link->conf.Attributes = CONF_ENABLE_IRQ;
103 link->conf.IntType = INT_MEMORY_AND_IO;
104 90
105 return ide_config(link); 91 return ide_config(link);
106} /* ide_attach */ 92} /* ide_attach */
107 93
108/*======================================================================
109
110 This deletes a driver "instance". The device is de-registered
111 with Card Services. If it has been released, all local data
112 structures are freed. Otherwise, the structures will be freed
113 when the device is released.
114
115======================================================================*/
116
117static void ide_detach(struct pcmcia_device *link) 94static void ide_detach(struct pcmcia_device *link)
118{ 95{
119 ide_info_t *info = link->priv; 96 ide_info_t *info = link->priv;
@@ -187,79 +164,31 @@ out_release:
187 return NULL; 164 return NULL;
188} 165}
189 166
190/*====================================================================== 167static int pcmcia_check_one_config(struct pcmcia_device *pdev, void *priv_data)
191
192 ide_config() is scheduled to run after a CARD_INSERTION event
193 is received, to configure the PCMCIA socket, and to make the
194 ide device available to the system.
195
196======================================================================*/
197
198struct pcmcia_config_check {
199 unsigned long ctl_base;
200 int skip_vcc;
201 int is_kme;
202};
203
204static int pcmcia_check_one_config(struct pcmcia_device *pdev,
205 cistpl_cftable_entry_t *cfg,
206 cistpl_cftable_entry_t *dflt,
207 unsigned int vcc,
208 void *priv_data)
209{ 168{
210 struct pcmcia_config_check *stk = priv_data; 169 int *is_kme = priv_data;
211
212 /* Check for matching Vcc, unless we're desperate */
213 if (!stk->skip_vcc) {
214 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
215 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
216 return -ENODEV;
217 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
218 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
219 return -ENODEV;
220 }
221 }
222 170
223 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 171 if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) {
224 pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 172 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
225 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 173 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
226 pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 174 }
227 175 pdev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
228 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 176 pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
229 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 177
230 pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 178 if (pdev->resource[1]->end) {
231 179 pdev->resource[0]->end = 8;
232 pdev->conf.ConfigIndex = cfg->index; 180 pdev->resource[1]->end = (*is_kme) ? 2 : 1;
233 pdev->resource[0]->start = io->win[0].base; 181 } else {
234 if (!(io->flags & CISTPL_IO_16BIT)) { 182 if (pdev->resource[0]->end < 16)
235 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
236 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
237 }
238 if (io->nwin == 2) {
239 pdev->resource[0]->end = 8;
240 pdev->resource[1]->start = io->win[1].base;
241 pdev->resource[1]->end = (stk->is_kme) ? 2 : 1;
242 if (pcmcia_request_io(pdev) != 0)
243 return -ENODEV;
244 stk->ctl_base = pdev->resource[1]->start;
245 } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
246 pdev->resource[0]->end = io->win[0].len;
247 pdev->resource[1]->end = 0;
248 if (pcmcia_request_io(pdev) != 0)
249 return -ENODEV;
250 stk->ctl_base = pdev->resource[0]->start + 0x0e;
251 } else
252 return -ENODEV; 183 return -ENODEV;
253 /* If we've got this far, we're done */
254 return 0;
255 } 184 }
256 return -ENODEV; 185
186 return pcmcia_request_io(pdev);
257} 187}
258 188
259static int ide_config(struct pcmcia_device *link) 189static int ide_config(struct pcmcia_device *link)
260{ 190{
261 ide_info_t *info = link->priv; 191 ide_info_t *info = link->priv;
262 struct pcmcia_config_check *stk = NULL;
263 int ret = 0, is_kme = 0; 192 int ret = 0, is_kme = 0;
264 unsigned long io_base, ctl_base; 193 unsigned long io_base, ctl_base;
265 struct ide_host *host; 194 struct ide_host *host;
@@ -270,23 +199,21 @@ static int ide_config(struct pcmcia_device *link)
270 ((link->card_id == PRODID_KME_KXLC005_A) || 199 ((link->card_id == PRODID_KME_KXLC005_A) ||
271 (link->card_id == PRODID_KME_KXLC005_B))); 200 (link->card_id == PRODID_KME_KXLC005_B)));
272 201
273 stk = kzalloc(sizeof(*stk), GFP_KERNEL); 202 if (pcmcia_loop_config(link, pcmcia_check_one_config, &is_kme)) {
274 if (!stk) 203 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
275 goto err_mem; 204 if (pcmcia_loop_config(link, pcmcia_check_one_config, &is_kme))
276 stk->is_kme = is_kme;
277 stk->skip_vcc = io_base = ctl_base = 0;
278
279 if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) {
280 stk->skip_vcc = 1;
281 if (pcmcia_loop_config(link, pcmcia_check_one_config, stk))
282 goto failed; /* No suitable config found */ 205 goto failed; /* No suitable config found */
283 } 206 }
284 io_base = link->resource[0]->start; 207 io_base = link->resource[0]->start;
285 ctl_base = stk->ctl_base; 208 if (link->resource[1]->end)
209 ctl_base = link->resource[1]->start;
210 else
211 ctl_base = link->resource[0]->start + 0x0e;
286 212
287 if (!link->irq) 213 if (!link->irq)
288 goto failed; 214 goto failed;
289 ret = pcmcia_request_configuration(link, &link->conf); 215
216 ret = pcmcia_enable_device(link);
290 if (ret) 217 if (ret)
291 goto failed; 218 goto failed;
292 219
@@ -311,29 +238,15 @@ static int ide_config(struct pcmcia_device *link)
311 info->host = host; 238 info->host = host;
312 dev_info(&link->dev, "ide-cs: hd%c: Vpp = %d.%d\n", 239 dev_info(&link->dev, "ide-cs: hd%c: Vpp = %d.%d\n",
313 'a' + host->ports[0]->index * 2, 240 'a' + host->ports[0]->index * 2,
314 link->conf.Vpp / 10, link->conf.Vpp % 10); 241 link->vpp / 10, link->vpp % 10);
315 242
316 kfree(stk);
317 return 0; 243 return 0;
318 244
319err_mem:
320 printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n");
321 goto failed;
322
323failed: 245failed:
324 kfree(stk);
325 ide_release(link); 246 ide_release(link);
326 return -ENODEV; 247 return -ENODEV;
327} /* ide_config */ 248} /* ide_config */
328 249
329/*======================================================================
330
331 After a card is removed, ide_release() will unregister the net
332 device, and release the PCMCIA configuration. If the device is
333 still open, this will be postponed until it is closed.
334
335======================================================================*/
336
337static void ide_release(struct pcmcia_device *link) 250static void ide_release(struct pcmcia_device *link)
338{ 251{
339 ide_info_t *info = link->priv; 252 ide_info_t *info = link->priv;
@@ -359,15 +272,6 @@ static void ide_release(struct pcmcia_device *link)
359} /* ide_release */ 272} /* ide_release */
360 273
361 274
362/*======================================================================
363
364 The card status event handler. Mostly, this schedules other
365 stuff to run after an event is received. A CARD_REMOVAL event
366 also sets some flags to discourage the ide drivers from
367 talking to the ports.
368
369======================================================================*/
370
371static struct pcmcia_device_id ide_ids[] = { 275static struct pcmcia_device_id ide_ids[] = {
372 PCMCIA_DEVICE_FUNC_ID(4), 276 PCMCIA_DEVICE_FUNC_ID(4),
373 PCMCIA_DEVICE_MANF_CARD(0x0000, 0x0000), /* Corsair */ 277 PCMCIA_DEVICE_MANF_CARD(0x0000, 0x0000), /* Corsair */
@@ -440,9 +344,7 @@ MODULE_DEVICE_TABLE(pcmcia, ide_ids);
440 344
441static struct pcmcia_driver ide_cs_driver = { 345static struct pcmcia_driver ide_cs_driver = {
442 .owner = THIS_MODULE, 346 .owner = THIS_MODULE,
443 .drv = { 347 .name = "ide-cs",
444 .name = "ide-cs",
445 },
446 .probe = ide_probe, 348 .probe = ide_probe,
447 .remove = ide_detach, 349 .remove = ide_detach,
448 .id_table = ide_ids, 350 .id_table = ide_ids,
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 09b1795516f4..91f06a3ef002 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -20,7 +20,6 @@
20#include <asm/io.h> 20#include <asm/io.h>
21#include <asm/system.h> 21#include <asm/system.h>
22 22
23#include <pcmcia/cs.h>
24#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
25#include <pcmcia/ciscode.h> 24#include <pcmcia/ciscode.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
@@ -39,87 +38,32 @@ MODULE_LICENSE("GPL");
39 38
40/*====================================================================*/ 39/*====================================================================*/
41 40
42/*
43 The event() function is this driver's Card Services event handler.
44 It will be called by Card Services when an appropriate card status
45 event is received. The config() and release() entry points are
46 used to configure or release a socket, in response to card insertion
47 and ejection events. They are invoked from the skeleton event
48 handler.
49*/
50
51static int avmcs_config(struct pcmcia_device *link); 41static int avmcs_config(struct pcmcia_device *link);
52static void avmcs_release(struct pcmcia_device *link); 42static void avmcs_release(struct pcmcia_device *link);
53
54/*
55 The attach() and detach() entry points are used to create and destroy
56 "instances" of the driver, where each instance represents everything
57 needed to manage one actual PCMCIA card.
58*/
59
60static void avmcs_detach(struct pcmcia_device *p_dev); 43static void avmcs_detach(struct pcmcia_device *p_dev);
61 44
62/*======================================================================
63
64 avmcs_attach() creates an "instance" of the driver, allocating
65 local data structures for one device. The device is registered
66 with Card Services.
67
68 The dev_link structure is initialized, but we don't actually
69 configure the card at this point -- we wait until we receive a
70 card insertion event.
71
72======================================================================*/
73
74static int avmcs_probe(struct pcmcia_device *p_dev) 45static int avmcs_probe(struct pcmcia_device *p_dev)
75{ 46{
76
77 /* The io structure describes IO port mapping */
78 p_dev->resource[0]->end = 16;
79 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
80
81 /* General socket configuration */ 47 /* General socket configuration */
82 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 48 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
83 p_dev->conf.IntType = INT_MEMORY_AND_IO; 49 p_dev->config_index = 1;
84 p_dev->conf.ConfigIndex = 1; 50 p_dev->config_regs = PRESENT_OPTION;
85 p_dev->conf.Present = PRESENT_OPTION;
86 51
87 return avmcs_config(p_dev); 52 return avmcs_config(p_dev);
88} /* avmcs_attach */ 53} /* avmcs_attach */
89 54
90/*======================================================================
91
92 This deletes a driver "instance". The device is de-registered
93 with Card Services. If it has been released, all local data
94 structures are freed. Otherwise, the structures will be freed
95 when the device is released.
96
97======================================================================*/
98 55
99static void avmcs_detach(struct pcmcia_device *link) 56static void avmcs_detach(struct pcmcia_device *link)
100{ 57{
101 avmcs_release(link); 58 avmcs_release(link);
102} /* avmcs_detach */ 59} /* avmcs_detach */
103 60
104/*====================================================================== 61static int avmcs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
105
106 avmcs_config() is scheduled to run after a CARD_INSERTION event
107 is received, to configure the PCMCIA socket, and to make the
108 ethernet device available to the system.
109
110======================================================================*/
111
112static int avmcs_configcheck(struct pcmcia_device *p_dev,
113 cistpl_cftable_entry_t *cf,
114 cistpl_cftable_entry_t *dflt,
115 unsigned int vcc,
116 void *priv_data)
117{ 62{
118 if (cf->io.nwin <= 0) 63 p_dev->resource[0]->end = 16;
119 return -ENODEV; 64 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
65 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
120 66
121 p_dev->resource[0]->start = cf->io.win[0].base;
122 p_dev->resource[0]->end = cf->io.win[0].len;
123 return pcmcia_request_io(p_dev); 67 return pcmcia_request_io(p_dev);
124} 68}
125 69
@@ -150,7 +94,7 @@ static int avmcs_config(struct pcmcia_device *link)
150 /* 94 /*
151 * configure the PCMCIA socket 95 * configure the PCMCIA socket
152 */ 96 */
153 i = pcmcia_request_configuration(link, &link->conf); 97 i = pcmcia_enable_device(link);
154 if (i != 0) { 98 if (i != 0) {
155 pcmcia_disable_device(link); 99 pcmcia_disable_device(link);
156 break; 100 break;
@@ -197,13 +141,6 @@ static int avmcs_config(struct pcmcia_device *link)
197 141
198} /* avmcs_config */ 142} /* avmcs_config */
199 143
200/*======================================================================
201
202 After a card is removed, avmcs_release() will unregister the net
203 device, and release the PCMCIA configuration. If the device is
204 still open, this will be postponed until it is closed.
205
206======================================================================*/
207 144
208static void avmcs_release(struct pcmcia_device *link) 145static void avmcs_release(struct pcmcia_device *link)
209{ 146{
@@ -222,9 +159,7 @@ MODULE_DEVICE_TABLE(pcmcia, avmcs_ids);
222 159
223static struct pcmcia_driver avmcs_driver = { 160static struct pcmcia_driver avmcs_driver = {
224 .owner = THIS_MODULE, 161 .owner = THIS_MODULE,
225 .drv = { 162 .name = "avm_cs",
226 .name = "avm_cs",
227 },
228 .probe = avmcs_probe, 163 .probe = avmcs_probe,
229 .remove = avmcs_detach, 164 .remove = avmcs_detach,
230 .id_table = avmcs_ids, 165 .id_table = avmcs_ids,
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 94263c22b874..ac4dd7857cbd 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -20,7 +20,6 @@
20#include <asm/io.h> 20#include <asm/io.h>
21#include <asm/system.h> 21#include <asm/system.h>
22 22
23#include <pcmcia/cs.h>
24#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
25#include <pcmcia/ds.h> 24#include <pcmcia/ds.h>
26#include "hisax_cfg.h" 25#include "hisax_cfg.h"
@@ -40,67 +39,22 @@ module_param(isdnprot, int, 0);
40 39
41/*====================================================================*/ 40/*====================================================================*/
42 41
43/*
44 The event() function is this driver's Card Services event handler.
45 It will be called by Card Services when an appropriate card status
46 event is received. The config() and release() entry points are
47 used to configure or release a socket, in response to card insertion
48 and ejection events. They are invoked from the skeleton event
49 handler.
50*/
51
52static int avma1cs_config(struct pcmcia_device *link) __devinit ; 42static int avma1cs_config(struct pcmcia_device *link) __devinit ;
53static void avma1cs_release(struct pcmcia_device *link); 43static void avma1cs_release(struct pcmcia_device *link);
54
55/*
56 The attach() and detach() entry points are used to create and destroy
57 "instances" of the driver, where each instance represents everything
58 needed to manage one actual PCMCIA card.
59*/
60
61static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit ; 44static void avma1cs_detach(struct pcmcia_device *p_dev) __devexit ;
62 45
63
64/*======================================================================
65
66 avma1cs_attach() creates an "instance" of the driver, allocating
67 local data structures for one device. The device is registered
68 with Card Services.
69
70 The dev_link structure is initialized, but we don't actually
71 configure the card at this point -- we wait until we receive a
72 card insertion event.
73
74======================================================================*/
75
76static int __devinit avma1cs_probe(struct pcmcia_device *p_dev) 46static int __devinit avma1cs_probe(struct pcmcia_device *p_dev)
77{ 47{
78 dev_dbg(&p_dev->dev, "avma1cs_attach()\n"); 48 dev_dbg(&p_dev->dev, "avma1cs_attach()\n");
79 49
80 /* The io structure describes IO port mapping */
81 p_dev->resource[0]->end = 16;
82 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
83 p_dev->resource[1]->end = 16;
84 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_16;
85
86 /* General socket configuration */ 50 /* General socket configuration */
87 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 51 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
88 p_dev->conf.IntType = INT_MEMORY_AND_IO; 52 p_dev->config_index = 1;
89 p_dev->conf.ConfigIndex = 1; 53 p_dev->config_regs = PRESENT_OPTION;
90 p_dev->conf.Present = PRESENT_OPTION;
91 54
92 return avma1cs_config(p_dev); 55 return avma1cs_config(p_dev);
93} /* avma1cs_attach */ 56} /* avma1cs_attach */
94 57
95/*======================================================================
96
97 This deletes a driver "instance". The device is de-registered
98 with Card Services. If it has been released, all local data
99 structures are freed. Otherwise, the structures will be freed
100 when the device is released.
101
102======================================================================*/
103
104static void __devexit avma1cs_detach(struct pcmcia_device *link) 58static void __devexit avma1cs_detach(struct pcmcia_device *link)
105{ 59{
106 dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link); 60 dev_dbg(&link->dev, "avma1cs_detach(0x%p)\n", link);
@@ -108,26 +62,13 @@ static void __devexit avma1cs_detach(struct pcmcia_device *link)
108 kfree(link->priv); 62 kfree(link->priv);
109} /* avma1cs_detach */ 63} /* avma1cs_detach */
110 64
111/*====================================================================== 65static int avma1cs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
112
113 avma1cs_config() is scheduled to run after a CARD_INSERTION event
114 is received, to configure the PCMCIA socket, and to make the
115 ethernet device available to the system.
116
117======================================================================*/
118
119static int avma1cs_configcheck(struct pcmcia_device *p_dev,
120 cistpl_cftable_entry_t *cf,
121 cistpl_cftable_entry_t *dflt,
122 unsigned int vcc,
123 void *priv_data)
124{ 66{
125 if (cf->io.nwin <= 0) 67 p_dev->resource[0]->end = 16;
126 return -ENODEV; 68 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
127 69 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
128 p_dev->resource[0]->start = cf->io.win[0].base;
129 p_dev->resource[0]->end = cf->io.win[0].len;
130 p_dev->io_lines = 5; 70 p_dev->io_lines = 5;
71
131 return pcmcia_request_io(p_dev); 72 return pcmcia_request_io(p_dev);
132} 73}
133 74
@@ -161,7 +102,7 @@ static int __devinit avma1cs_config(struct pcmcia_device *link)
161 /* 102 /*
162 * configure the PCMCIA socket 103 * configure the PCMCIA socket
163 */ 104 */
164 i = pcmcia_request_configuration(link, &link->conf); 105 i = pcmcia_enable_device(link);
165 if (i != 0) { 106 if (i != 0) {
166 pcmcia_disable_device(link); 107 pcmcia_disable_device(link);
167 break; 108 break;
@@ -175,9 +116,6 @@ static int __devinit avma1cs_config(struct pcmcia_device *link)
175 return -ENODEV; 116 return -ENODEV;
176 } 117 }
177 118
178 printk(KERN_NOTICE "avma1_cs: checking at i/o %#x, irq %d\n",
179 (unsigned int) link->resource[0]->start, link->irq);
180
181 icard.para[0] = link->irq; 119 icard.para[0] = link->irq;
182 icard.para[1] = link->resource[0]->start; 120 icard.para[1] = link->resource[0]->start;
183 icard.protocol = isdnprot; 121 icard.protocol = isdnprot;
@@ -196,14 +134,6 @@ static int __devinit avma1cs_config(struct pcmcia_device *link)
196 return 0; 134 return 0;
197} /* avma1cs_config */ 135} /* avma1cs_config */
198 136
199/*======================================================================
200
201 After a card is removed, avma1cs_release() will unregister the net
202 device, and release the PCMCIA configuration. If the device is
203 still open, this will be postponed until it is closed.
204
205======================================================================*/
206
207static void avma1cs_release(struct pcmcia_device *link) 137static void avma1cs_release(struct pcmcia_device *link)
208{ 138{
209 unsigned long minor = (unsigned long) link->priv; 139 unsigned long minor = (unsigned long) link->priv;
@@ -216,7 +146,6 @@ static void avma1cs_release(struct pcmcia_device *link)
216 pcmcia_disable_device(link); 146 pcmcia_disable_device(link);
217} /* avma1cs_release */ 147} /* avma1cs_release */
218 148
219
220static struct pcmcia_device_id avma1cs_ids[] = { 149static struct pcmcia_device_id avma1cs_ids[] = {
221 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb), 150 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb),
222 PCMCIA_DEVICE_PROD_ID12("ISDN", "CARD", 0x8d9761c8, 0x01c5aa7b), 151 PCMCIA_DEVICE_PROD_ID12("ISDN", "CARD", 0x8d9761c8, 0x01c5aa7b),
@@ -226,19 +155,15 @@ MODULE_DEVICE_TABLE(pcmcia, avma1cs_ids);
226 155
227static struct pcmcia_driver avma1cs_driver = { 156static struct pcmcia_driver avma1cs_driver = {
228 .owner = THIS_MODULE, 157 .owner = THIS_MODULE,
229 .drv = { 158 .name = "avma1_cs",
230 .name = "avma1_cs",
231 },
232 .probe = avma1cs_probe, 159 .probe = avma1cs_probe,
233 .remove = __devexit_p(avma1cs_detach), 160 .remove = __devexit_p(avma1cs_detach),
234 .id_table = avma1cs_ids, 161 .id_table = avma1cs_ids,
235}; 162};
236 163
237/*====================================================================*/
238
239static int __init init_avma1_cs(void) 164static int __init init_avma1_cs(void)
240{ 165{
241 return(pcmcia_register_driver(&avma1cs_driver)); 166 return pcmcia_register_driver(&avma1cs_driver);
242} 167}
243 168
244static void __exit exit_avma1_cs(void) 169static void __exit exit_avma1_cs(void)
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index b3c08aaf41c4..496d477af0f8 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -46,7 +46,6 @@
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/system.h> 47#include <asm/system.h>
48 48
49#include <pcmcia/cs.h>
50#include <pcmcia/cistpl.h> 49#include <pcmcia/cistpl.h>
51#include <pcmcia/cisreg.h> 50#include <pcmcia/cisreg.h>
52#include <pcmcia/ds.h> 51#include <pcmcia/ds.h>
@@ -64,26 +63,8 @@ MODULE_LICENSE("Dual MPL/GPL");
64static int protocol = 2; /* EURO-ISDN Default */ 63static int protocol = 2; /* EURO-ISDN Default */
65module_param(protocol, int, 0); 64module_param(protocol, int, 0);
66 65
67/*====================================================================*/
68
69/*
70 The event() function is this driver's Card Services event handler.
71 It will be called by Card Services when an appropriate card status
72 event is received. The config() and release() entry points are
73 used to configure or release a socket, in response to card insertion
74 and ejection events. They are invoked from the elsa_cs event
75 handler.
76*/
77
78static int elsa_cs_config(struct pcmcia_device *link) __devinit ; 66static int elsa_cs_config(struct pcmcia_device *link) __devinit ;
79static void elsa_cs_release(struct pcmcia_device *link); 67static void elsa_cs_release(struct pcmcia_device *link);
80
81/*
82 The attach() and detach() entry points are used to create and destroy
83 "instances" of the driver, where each instance represents everything
84 needed to manage one actual PCMCIA card.
85*/
86
87static void elsa_cs_detach(struct pcmcia_device *p_dev) __devexit; 68static void elsa_cs_detach(struct pcmcia_device *p_dev) __devexit;
88 69
89typedef struct local_info_t { 70typedef struct local_info_t {
@@ -92,18 +73,6 @@ typedef struct local_info_t {
92 int cardnr; 73 int cardnr;
93} local_info_t; 74} local_info_t;
94 75
95/*======================================================================
96
97 elsa_cs_attach() creates an "instance" of the driver, allocatingx
98 local data structures for one device. The device is registered
99 with Card Services.
100
101 The dev_link structure is initialized, but we don't actually
102 configure the card at this point -- we wait until we receive a
103 card insertion event.
104
105======================================================================*/
106
107static int __devinit elsa_cs_probe(struct pcmcia_device *link) 76static int __devinit elsa_cs_probe(struct pcmcia_device *link)
108{ 77{
109 local_info_t *local; 78 local_info_t *local;
@@ -119,31 +88,9 @@ static int __devinit elsa_cs_probe(struct pcmcia_device *link)
119 88
120 local->cardnr = -1; 89 local->cardnr = -1;
121 90
122 /*
123 General socket configuration defaults can go here. In this
124 client, we assume very little, and rely on the CIS for almost
125 everything. In most clients, many details (i.e., number, sizes,
126 and attributes of IO windows) are fixed by the nature of the
127 device, and can be hard-wired here.
128 */
129 link->resource[0]->end = 8;
130 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
131
132 link->conf.Attributes = CONF_ENABLE_IRQ;
133 link->conf.IntType = INT_MEMORY_AND_IO;
134
135 return elsa_cs_config(link); 91 return elsa_cs_config(link);
136} /* elsa_cs_attach */ 92} /* elsa_cs_attach */
137 93
138/*======================================================================
139
140 This deletes a driver "instance". The device is de-registered
141 with Card Services. If it has been released, all local data
142 structures are freed. Otherwise, the structures will be freed
143 when the device is released.
144
145======================================================================*/
146
147static void __devexit elsa_cs_detach(struct pcmcia_device *link) 94static void __devexit elsa_cs_detach(struct pcmcia_device *link)
148{ 95{
149 local_info_t *info = link->priv; 96 local_info_t *info = link->priv;
@@ -156,27 +103,17 @@ static void __devexit elsa_cs_detach(struct pcmcia_device *link)
156 kfree(info); 103 kfree(info);
157} /* elsa_cs_detach */ 104} /* elsa_cs_detach */
158 105
159/*====================================================================== 106static int elsa_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
160
161 elsa_cs_config() is scheduled to run after a CARD_INSERTION event
162 is received, to configure the PCMCIA socket, and to make the
163 device available to the system.
164
165======================================================================*/
166
167static int elsa_cs_configcheck(struct pcmcia_device *p_dev,
168 cistpl_cftable_entry_t *cf,
169 cistpl_cftable_entry_t *dflt,
170 unsigned int vcc,
171 void *priv_data)
172{ 107{
173 int j; 108 int j;
174 109
175 p_dev->io_lines = 3; 110 p_dev->io_lines = 3;
111 p_dev->resource[0]->end = 8;
112 p_dev->resource[0]->flags &= IO_DATA_PATH_WIDTH;
113 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
176 114
177 if ((cf->io.nwin > 0) && cf->io.win[0].base) { 115 if ((p_dev->resource[0]->end) && p_dev->resource[0]->start) {
178 printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); 116 printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n");
179 p_dev->resource[0]->start = cf->io.win[0].base;
180 if (!pcmcia_request_io(p_dev)) 117 if (!pcmcia_request_io(p_dev))
181 return 0; 118 return 0;
182 } else { 119 } else {
@@ -199,6 +136,8 @@ static int __devinit elsa_cs_config(struct pcmcia_device *link)
199 dev_dbg(&link->dev, "elsa_config(0x%p)\n", link); 136 dev_dbg(&link->dev, "elsa_config(0x%p)\n", link);
200 dev = link->priv; 137 dev = link->priv;
201 138
139 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
140
202 i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL); 141 i = pcmcia_loop_config(link, elsa_cs_configcheck, NULL);
203 if (i != 0) 142 if (i != 0)
204 goto failed; 143 goto failed;
@@ -206,21 +145,10 @@ static int __devinit elsa_cs_config(struct pcmcia_device *link)
206 if (!link->irq) 145 if (!link->irq)
207 goto failed; 146 goto failed;
208 147
209 i = pcmcia_request_configuration(link, &link->conf); 148 i = pcmcia_enable_device(link);
210 if (i != 0) 149 if (i != 0)
211 goto failed; 150 goto failed;
212 151
213 /* Finally, report what we've done */
214 dev_info(&link->dev, "index 0x%02x: ",
215 link->conf.ConfigIndex);
216 if (link->conf.Attributes & CONF_ENABLE_IRQ)
217 printk(", irq %d", link->irq);
218 if (link->resource[0])
219 printk(" & %pR", link->resource[0]);
220 if (link->resource[1])
221 printk(" & %pR", link->resource[1]);
222 printk("\n");
223
224 icard.para[0] = link->irq; 152 icard.para[0] = link->irq;
225 icard.para[1] = link->resource[0]->start; 153 icard.para[1] = link->resource[0]->start;
226 icard.protocol = protocol; 154 icard.protocol = protocol;
@@ -240,14 +168,6 @@ failed:
240 return -ENODEV; 168 return -ENODEV;
241} /* elsa_cs_config */ 169} /* elsa_cs_config */
242 170
243/*======================================================================
244
245 After a card is removed, elsa_cs_release() will unregister the net
246 device, and release the PCMCIA configuration. If the device is
247 still open, this will be postponed until it is closed.
248
249======================================================================*/
250
251static void elsa_cs_release(struct pcmcia_device *link) 171static void elsa_cs_release(struct pcmcia_device *link)
252{ 172{
253 local_info_t *local = link->priv; 173 local_info_t *local = link->priv;
@@ -291,9 +211,7 @@ MODULE_DEVICE_TABLE(pcmcia, elsa_ids);
291 211
292static struct pcmcia_driver elsa_cs_driver = { 212static struct pcmcia_driver elsa_cs_driver = {
293 .owner = THIS_MODULE, 213 .owner = THIS_MODULE,
294 .drv = { 214 .name = "elsa_cs",
295 .name = "elsa_cs",
296 },
297 .probe = elsa_cs_probe, 215 .probe = elsa_cs_probe,
298 .remove = __devexit_p(elsa_cs_detach), 216 .remove = __devexit_p(elsa_cs_detach),
299 .id_table = elsa_ids, 217 .id_table = elsa_ids,
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index a024192b672a..360204bc2777 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -46,7 +46,6 @@
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/system.h> 47#include <asm/system.h>
48 48
49#include <pcmcia/cs.h>
50#include <pcmcia/cistpl.h> 49#include <pcmcia/cistpl.h>
51#include <pcmcia/cisreg.h> 50#include <pcmcia/cisreg.h>
52#include <pcmcia/ds.h> 51#include <pcmcia/ds.h>
@@ -64,26 +63,9 @@ MODULE_LICENSE("Dual MPL/GPL");
64static int protocol = 2; /* EURO-ISDN Default */ 63static int protocol = 2; /* EURO-ISDN Default */
65module_param(protocol, int, 0); 64module_param(protocol, int, 0);
66 65
67/*====================================================================*/
68
69/*
70 The event() function is this driver's Card Services event handler.
71 It will be called by Card Services when an appropriate card status
72 event is received. The config() and release() entry points are
73 used to configure or release a socket, in response to card
74 insertion and ejection events. They are invoked from the sedlbauer
75 event handler.
76*/
77
78static int sedlbauer_config(struct pcmcia_device *link) __devinit ; 66static int sedlbauer_config(struct pcmcia_device *link) __devinit ;
79static void sedlbauer_release(struct pcmcia_device *link); 67static void sedlbauer_release(struct pcmcia_device *link);
80 68
81/*
82 The attach() and detach() entry points are used to create and destroy
83 "instances" of the driver, where each instance represents everything
84 needed to manage one actual PCMCIA card.
85*/
86
87static void sedlbauer_detach(struct pcmcia_device *p_dev) __devexit; 69static void sedlbauer_detach(struct pcmcia_device *p_dev) __devexit;
88 70
89typedef struct local_info_t { 71typedef struct local_info_t {
@@ -92,18 +74,6 @@ typedef struct local_info_t {
92 int cardnr; 74 int cardnr;
93} local_info_t; 75} local_info_t;
94 76
95/*======================================================================
96
97 sedlbauer_attach() creates an "instance" of the driver, allocating
98 local data structures for one device. The device is registered
99 with Card Services.
100
101 The dev_link structure is initialized, but we don't actually
102 configure the card at this point -- we wait until we receive a
103 card insertion event.
104
105======================================================================*/
106
107static int __devinit sedlbauer_probe(struct pcmcia_device *link) 77static int __devinit sedlbauer_probe(struct pcmcia_device *link)
108{ 78{
109 local_info_t *local; 79 local_info_t *local;
@@ -118,35 +88,9 @@ static int __devinit sedlbauer_probe(struct pcmcia_device *link)
118 local->p_dev = link; 88 local->p_dev = link;
119 link->priv = local; 89 link->priv = local;
120 90
121 /*
122 General socket configuration defaults can go here. In this
123 client, we assume very little, and rely on the CIS for almost
124 everything. In most clients, many details (i.e., number, sizes,
125 and attributes of IO windows) are fixed by the nature of the
126 device, and can be hard-wired here.
127 */
128
129 /* from old sedl_cs
130 */
131 /* The io structure describes IO port mapping */
132 link->resource[0]->end = 8;
133 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
134
135 link->conf.Attributes = 0;
136 link->conf.IntType = INT_MEMORY_AND_IO;
137
138 return sedlbauer_config(link); 91 return sedlbauer_config(link);
139} /* sedlbauer_attach */ 92} /* sedlbauer_attach */
140 93
141/*======================================================================
142
143 This deletes a driver "instance". The device is de-registered
144 with Card Services. If it has been released, all local data
145 structures are freed. Otherwise, the structures will be freed
146 when the device is released.
147
148======================================================================*/
149
150static void __devexit sedlbauer_detach(struct pcmcia_device *link) 94static void __devexit sedlbauer_detach(struct pcmcia_device *link)
151{ 95{
152 dev_dbg(&link->dev, "sedlbauer_detach(0x%p)\n", link); 96 dev_dbg(&link->dev, "sedlbauer_detach(0x%p)\n", link);
@@ -158,70 +102,15 @@ static void __devexit sedlbauer_detach(struct pcmcia_device *link)
158 kfree(link->priv); 102 kfree(link->priv);
159} /* sedlbauer_detach */ 103} /* sedlbauer_detach */
160 104
161/*====================================================================== 105static int sedlbauer_config_check(struct pcmcia_device *p_dev, void *priv_data)
162
163 sedlbauer_config() is scheduled to run after a CARD_INSERTION event
164 is received, to configure the PCMCIA socket, and to make the
165 device available to the system.
166
167======================================================================*/
168static int sedlbauer_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{ 106{
174 if (cfg->index == 0) 107 if (p_dev->config_index == 0)
175 return -ENODEV; 108 return -EINVAL;
176
177 /* Does this card need audio output? */
178 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
179 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
180 p_dev->conf.Status = CCSR_AUDIO_ENA;
181 }
182 109
183 /* Use power settings for Vcc and Vpp if present */ 110 p_dev->io_lines = 3;
184 /* Note that the CIS values need to be rescaled */ 111 return pcmcia_request_io(p_dev);
185 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
186 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000)
187 return -ENODEV;
188 } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
189 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000)
190 return -ENODEV;
191 }
192
193 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
194 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
195 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
196 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
197
198 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
199
200 /* IO window settings */
201 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
202 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
203 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
204 p_dev->resource[0]->start = io->win[0].base;
205 p_dev->resource[0]->end = io->win[0].len;
206 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
207 p_dev->resource[0]->flags |=
208 pcmcia_io_cfg_data_width(io->flags);
209 if (io->nwin > 1) {
210 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
211 p_dev->resource[1]->start = io->win[1].base;
212 p_dev->resource[1]->end = io->win[1].len;
213 }
214 /* This reserves IO space but doesn't actually enable it */
215 p_dev->io_lines = 3;
216 if (pcmcia_request_io(p_dev) != 0)
217 return -ENODEV;
218 }
219
220 return 0;
221} 112}
222 113
223
224
225static int __devinit sedlbauer_config(struct pcmcia_device *link) 114static int __devinit sedlbauer_config(struct pcmcia_device *link)
226{ 115{
227 int ret; 116 int ret;
@@ -229,44 +118,17 @@ static int __devinit sedlbauer_config(struct pcmcia_device *link)
229 118
230 dev_dbg(&link->dev, "sedlbauer_config(0x%p)\n", link); 119 dev_dbg(&link->dev, "sedlbauer_config(0x%p)\n", link);
231 120
232 /* 121 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC |
233 In this loop, we scan the CIS for configuration table entries, 122 CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
234 each of which describes a valid card configuration, including 123
235 voltage, IO window, memory window, and interrupt settings.
236
237 We make no assumptions about the card to be configured: we use
238 just the information available in the CIS. In an ideal world,
239 this would work for any PCMCIA card, but it requires a complete
240 and accurate CIS. In practice, a driver usually "knows" most of
241 these things without consulting the CIS, and most client drivers
242 will only use the CIS to fill in implementation-defined details.
243 */
244 ret = pcmcia_loop_config(link, sedlbauer_config_check, NULL); 124 ret = pcmcia_loop_config(link, sedlbauer_config_check, NULL);
245 if (ret) 125 if (ret)
246 goto failed; 126 goto failed;
247 127
248 /* 128 ret = pcmcia_enable_device(link);
249 This actually configures the PCMCIA socket -- setting up
250 the I/O windows and the interrupt mapping, and putting the
251 card and host interface into "Memory and IO" mode.
252 */
253 ret = pcmcia_request_configuration(link, &link->conf);
254 if (ret) 129 if (ret)
255 goto failed; 130 goto failed;
256 131
257 /* Finally, report what we've done */
258 dev_info(&link->dev, "index 0x%02x:",
259 link->conf.ConfigIndex);
260 if (link->conf.Vpp)
261 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
262 if (link->conf.Attributes & CONF_ENABLE_IRQ)
263 printk(", irq %d", link->irq);
264 if (link->resource[0])
265 printk(" & %pR", link->resource[0]);
266 if (link->resource[1])
267 printk(" & %pR", link->resource[1]);
268 printk("\n");
269
270 icard.para[0] = link->irq; 132 icard.para[0] = link->irq;
271 icard.para[1] = link->resource[0]->start; 133 icard.para[1] = link->resource[0]->start;
272 icard.protocol = protocol; 134 icard.protocol = protocol;
@@ -290,14 +152,6 @@ failed:
290 152
291} /* sedlbauer_config */ 153} /* sedlbauer_config */
292 154
293/*======================================================================
294
295 After a card is removed, sedlbauer_release() will unregister the
296 device, and release the PCMCIA configuration. If the device is
297 still open, this will be postponed until it is closed.
298
299======================================================================*/
300
301static void sedlbauer_release(struct pcmcia_device *link) 155static void sedlbauer_release(struct pcmcia_device *link)
302{ 156{
303 local_info_t *local = link->priv; 157 local_info_t *local = link->priv;
@@ -346,9 +200,7 @@ MODULE_DEVICE_TABLE(pcmcia, sedlbauer_ids);
346 200
347static struct pcmcia_driver sedlbauer_driver = { 201static struct pcmcia_driver sedlbauer_driver = {
348 .owner = THIS_MODULE, 202 .owner = THIS_MODULE,
349 .drv = { 203 .name = "sedlbauer_cs",
350 .name = "sedlbauer_cs",
351 },
352 .probe = sedlbauer_probe, 204 .probe = sedlbauer_probe,
353 .remove = __devexit_p(sedlbauer_detach), 205 .remove = __devexit_p(sedlbauer_detach),
354 .id_table = sedlbauer_ids, 206 .id_table = sedlbauer_ids,
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index 7296102ca255..282a4467ef19 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -27,7 +27,6 @@
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/system.h> 28#include <asm/system.h>
29 29
30#include <pcmcia/cs.h>
31#include <pcmcia/cistpl.h> 30#include <pcmcia/cistpl.h>
32#include <pcmcia/cisreg.h> 31#include <pcmcia/cisreg.h>
33#include <pcmcia/ds.h> 32#include <pcmcia/ds.h>
@@ -45,26 +44,8 @@ MODULE_LICENSE("GPL");
45static int protocol = 2; /* EURO-ISDN Default */ 44static int protocol = 2; /* EURO-ISDN Default */
46module_param(protocol, int, 0); 45module_param(protocol, int, 0);
47 46
48/*====================================================================*/
49
50/*
51 The event() function is this driver's Card Services event handler.
52 It will be called by Card Services when an appropriate card status
53 event is received. The config() and release() entry points are
54 used to configure or release a socket, in response to card insertion
55 and ejection events. They are invoked from the teles_cs event
56 handler.
57*/
58
59static int teles_cs_config(struct pcmcia_device *link) __devinit ; 47static int teles_cs_config(struct pcmcia_device *link) __devinit ;
60static void teles_cs_release(struct pcmcia_device *link); 48static void teles_cs_release(struct pcmcia_device *link);
61
62/*
63 The attach() and detach() entry points are used to create and destroy
64 "instances" of the driver, where each instance represents everything
65 needed to manage one actual PCMCIA card.
66*/
67
68static void teles_detach(struct pcmcia_device *p_dev) __devexit ; 49static void teles_detach(struct pcmcia_device *p_dev) __devexit ;
69 50
70typedef struct local_info_t { 51typedef struct local_info_t {
@@ -73,18 +54,6 @@ typedef struct local_info_t {
73 int cardnr; 54 int cardnr;
74} local_info_t; 55} local_info_t;
75 56
76/*======================================================================
77
78 teles_attach() creates an "instance" of the driver, allocatingx
79 local data structures for one device. The device is registered
80 with Card Services.
81
82 The dev_link structure is initialized, but we don't actually
83 configure the card at this point -- we wait until we receive a
84 card insertion event.
85
86======================================================================*/
87
88static int __devinit teles_probe(struct pcmcia_device *link) 57static int __devinit teles_probe(struct pcmcia_device *link)
89{ 58{
90 local_info_t *local; 59 local_info_t *local;
@@ -99,31 +68,11 @@ static int __devinit teles_probe(struct pcmcia_device *link)
99 local->p_dev = link; 68 local->p_dev = link;
100 link->priv = local; 69 link->priv = local;
101 70
102 /* 71 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
103 General socket configuration defaults can go here. In this
104 client, we assume very little, and rely on the CIS for almost
105 everything. In most clients, many details (i.e., number, sizes,
106 and attributes of IO windows) are fixed by the nature of the
107 device, and can be hard-wired here.
108 */
109 link->resource[0]->end = 96;
110 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
111
112 link->conf.Attributes = CONF_ENABLE_IRQ;
113 link->conf.IntType = INT_MEMORY_AND_IO;
114 72
115 return teles_cs_config(link); 73 return teles_cs_config(link);
116} /* teles_attach */ 74} /* teles_attach */
117 75
118/*======================================================================
119
120 This deletes a driver "instance". The device is de-registered
121 with Card Services. If it has been released, all local data
122 structures are freed. Otherwise, the structures will be freed
123 when the device is released.
124
125======================================================================*/
126
127static void __devexit teles_detach(struct pcmcia_device *link) 76static void __devexit teles_detach(struct pcmcia_device *link)
128{ 77{
129 local_info_t *info = link->priv; 78 local_info_t *info = link->priv;
@@ -136,27 +85,17 @@ static void __devexit teles_detach(struct pcmcia_device *link)
136 kfree(info); 85 kfree(info);
137} /* teles_detach */ 86} /* teles_detach */
138 87
139/*====================================================================== 88static int teles_cs_configcheck(struct pcmcia_device *p_dev, void *priv_data)
140
141 teles_cs_config() is scheduled to run after a CARD_INSERTION event
142 is received, to configure the PCMCIA socket, and to make the
143 device available to the system.
144
145======================================================================*/
146
147static int teles_cs_configcheck(struct pcmcia_device *p_dev,
148 cistpl_cftable_entry_t *cf,
149 cistpl_cftable_entry_t *dflt,
150 unsigned int vcc,
151 void *priv_data)
152{ 89{
153 int j; 90 int j;
154 91
155 p_dev->io_lines = 5; 92 p_dev->io_lines = 5;
93 p_dev->resource[0]->end = 96;
94 p_dev->resource[0]->flags &= IO_DATA_PATH_WIDTH;
95 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
156 96
157 if ((cf->io.nwin > 0) && cf->io.win[0].base) { 97 if ((p_dev->resource[0]->end) && p_dev->resource[0]->start) {
158 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); 98 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n");
159 p_dev->resource[0]->start = cf->io.win[0].base;
160 if (!pcmcia_request_io(p_dev)) 99 if (!pcmcia_request_io(p_dev))
161 return 0; 100 return 0;
162 } else { 101 } else {
@@ -186,21 +125,10 @@ static int __devinit teles_cs_config(struct pcmcia_device *link)
186 if (!link->irq) 125 if (!link->irq)
187 goto cs_failed; 126 goto cs_failed;
188 127
189 i = pcmcia_request_configuration(link, &link->conf); 128 i = pcmcia_enable_device(link);
190 if (i != 0) 129 if (i != 0)
191 goto cs_failed; 130 goto cs_failed;
192 131
193 /* Finally, report what we've done */
194 dev_info(&link->dev, "index 0x%02x:",
195 link->conf.ConfigIndex);
196 if (link->conf.Attributes & CONF_ENABLE_IRQ)
197 printk(", irq %d", link->irq);
198 if (link->resource[0])
199 printk(" & %pR", link->resource[0]);
200 if (link->resource[1])
201 printk(" & %pR", link->resource[1]);
202 printk("\n");
203
204 icard.para[0] = link->irq; 132 icard.para[0] = link->irq;
205 icard.para[1] = link->resource[0]->start; 133 icard.para[1] = link->resource[0]->start;
206 icard.protocol = protocol; 134 icard.protocol = protocol;
@@ -222,14 +150,6 @@ cs_failed:
222 return -ENODEV; 150 return -ENODEV;
223} /* teles_cs_config */ 151} /* teles_cs_config */
224 152
225/*======================================================================
226
227 After a card is removed, teles_cs_release() will unregister the net
228 device, and release the PCMCIA configuration. If the device is
229 still open, this will be postponed until it is closed.
230
231======================================================================*/
232
233static void teles_cs_release(struct pcmcia_device *link) 153static void teles_cs_release(struct pcmcia_device *link)
234{ 154{
235 local_info_t *local = link->priv; 155 local_info_t *local = link->priv;
@@ -273,9 +193,7 @@ MODULE_DEVICE_TABLE(pcmcia, teles_ids);
273 193
274static struct pcmcia_driver teles_cs_driver = { 194static struct pcmcia_driver teles_cs_driver = {
275 .owner = THIS_MODULE, 195 .owner = THIS_MODULE,
276 .drv = { 196 .name = "teles_cs",
277 .name = "teles_cs",
278 },
279 .probe = teles_probe, 197 .probe = teles_probe,
280 .remove = __devexit_p(teles_detach), 198 .remove = __devexit_p(teles_detach),
281 .id_table = teles_ids, 199 .id_table = teles_ids,
diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c
index 7aa65bb2af4a..f472c2714eb8 100644
--- a/drivers/mmc/host/sdricoh_cs.c
+++ b/drivers/mmc/host/sdricoh_cs.c
@@ -30,7 +30,6 @@
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/scatterlist.h> 31#include <linux/scatterlist.h>
32 32
33#include <pcmcia/cs.h>
34#include <pcmcia/cistpl.h> 33#include <pcmcia/cistpl.h>
35#include <pcmcia/ds.h> 34#include <pcmcia/ds.h>
36#include <linux/io.h> 35#include <linux/io.h>
@@ -536,9 +535,7 @@ static int sdricoh_pcmcia_resume(struct pcmcia_device *link)
536#endif 535#endif
537 536
538static struct pcmcia_driver sdricoh_driver = { 537static struct pcmcia_driver sdricoh_driver = {
539 .drv = { 538 .name = DRIVER_NAME,
540 .name = DRIVER_NAME,
541 },
542 .probe = sdricoh_pcmcia_probe, 539 .probe = sdricoh_pcmcia_probe,
543 .remove = sdricoh_pcmcia_detach, 540 .remove = sdricoh_pcmcia_detach,
544 .id_table = pcmcia_ids, 541 .id_table = pcmcia_ids,
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index e9ca5ba7d9d2..57a1acfe22c4 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -16,7 +16,6 @@
16#include <asm/io.h> 16#include <asm/io.h>
17#include <asm/system.h> 17#include <asm/system.h>
18 18
19#include <pcmcia/cs.h>
20#include <pcmcia/cistpl.h> 19#include <pcmcia/cistpl.h>
21#include <pcmcia/ds.h> 20#include <pcmcia/ds.h>
22 21
@@ -101,7 +100,7 @@ MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)")
101static caddr_t remap_window(struct map_info *map, unsigned long to) 100static caddr_t remap_window(struct map_info *map, unsigned long to)
102{ 101{
103 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 102 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
104 window_handle_t win = (window_handle_t)map->map_priv_2; 103 struct resource *win = (struct resource *) map->map_priv_2;
105 unsigned int offset; 104 unsigned int offset;
106 int ret; 105 int ret;
107 106
@@ -316,30 +315,19 @@ static void pcmciamtd_set_vpp(struct map_info *map, int on)
316{ 315{
317 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 316 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
318 struct pcmcia_device *link = dev->p_dev; 317 struct pcmcia_device *link = dev->p_dev;
319 modconf_t mod;
320 int ret;
321
322 mod.Attributes = CONF_VPP1_CHANGE_VALID | CONF_VPP2_CHANGE_VALID;
323 mod.Vcc = 0;
324 mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0;
325 318
326 DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); 319 DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp);
327 ret = pcmcia_modify_configuration(link, &mod); 320 pcmcia_fixup_vpp(link, on ? dev->vpp : 0);
328} 321}
329 322
330 323
331/* After a card is removed, pcmciamtd_release() will unregister the
332 * device, and release the PCMCIA configuration. If the device is
333 * still open, this will be postponed until it is closed.
334 */
335
336static void pcmciamtd_release(struct pcmcia_device *link) 324static void pcmciamtd_release(struct pcmcia_device *link)
337{ 325{
338 struct pcmciamtd_dev *dev = link->priv; 326 struct pcmciamtd_dev *dev = link->priv;
339 327
340 DEBUG(3, "link = 0x%p", link); 328 DEBUG(3, "link = 0x%p", link);
341 329
342 if (link->win) { 330 if (link->resource[2]->end) {
343 if(dev->win_base) { 331 if(dev->win_base) {
344 iounmap(dev->win_base); 332 iounmap(dev->win_base);
345 dev->win_base = NULL; 333 dev->win_base = NULL;
@@ -482,18 +470,12 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *p_dev
482} 470}
483 471
484 472
485/* pcmciamtd_config() is scheduled to run after a CARD_INSERTION event
486 * is received, to configure the PCMCIA socket, and to make the
487 * MTD device available to the system.
488 */
489
490static int pcmciamtd_config(struct pcmcia_device *link) 473static int pcmciamtd_config(struct pcmcia_device *link)
491{ 474{
492 struct pcmciamtd_dev *dev = link->priv; 475 struct pcmciamtd_dev *dev = link->priv;
493 struct mtd_info *mtd = NULL; 476 struct mtd_info *mtd = NULL;
494 win_req_t req;
495 int ret; 477 int ret;
496 int i; 478 int i, j = 0;
497 static char *probes[] = { "jedec_probe", "cfi_probe" }; 479 static char *probes[] = { "jedec_probe", "cfi_probe" };
498 int new_name = 0; 480 int new_name = 0;
499 481
@@ -520,28 +502,34 @@ static int pcmciamtd_config(struct pcmcia_device *link)
520 * smaller windows until we succeed 502 * smaller windows until we succeed
521 */ 503 */
522 504
523 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; 505 link->resource[2]->flags |= WIN_MEMORY_TYPE_CM | WIN_ENABLE;
524 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; 506 link->resource[2]->flags |= (dev->pcmcia_map.bankwidth == 1) ?
525 req.Base = 0; 507 WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16;
526 req.AccessSpeed = mem_speed; 508 link->resource[2]->start = 0;
527 link->win = (window_handle_t)link; 509 link->resource[2]->end = (force_size) ? force_size << 20 :
528 req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; 510 MAX_PCMCIA_ADDR;
529 dev->win_size = 0; 511 dev->win_size = 0;
530 512
531 do { 513 do {
532 int ret; 514 int ret;
533 DEBUG(2, "requesting window with size = %dKiB memspeed = %d", 515 DEBUG(2, "requesting window with size = %luKiB memspeed = %d",
534 req.Size >> 10, req.AccessSpeed); 516 (unsigned long) resource_size(link->resource[2]) >> 10,
535 ret = pcmcia_request_window(link, &req, &link->win); 517 mem_speed);
518 ret = pcmcia_request_window(link, link->resource[2], mem_speed);
536 DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); 519 DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size);
537 if(ret) { 520 if(ret) {
538 req.Size >>= 1; 521 j++;
522 link->resource[2]->start = 0;
523 link->resource[2]->end = (force_size) ?
524 force_size << 20 : MAX_PCMCIA_ADDR;
525 link->resource[2]->end >>= j;
539 } else { 526 } else {
540 DEBUG(2, "Got window of size %dKiB", req.Size >> 10); 527 DEBUG(2, "Got window of size %luKiB", (unsigned long)
541 dev->win_size = req.Size; 528 resource_size(link->resource[2]) >> 10);
529 dev->win_size = resource_size(link->resource[2]);
542 break; 530 break;
543 } 531 }
544 } while(req.Size >= 0x1000); 532 } while (link->resource[2]->end >= 0x1000);
545 533
546 DEBUG(2, "dev->win_size = %d", dev->win_size); 534 DEBUG(2, "dev->win_size = %d", dev->win_size);
547 535
@@ -553,33 +541,31 @@ static int pcmciamtd_config(struct pcmcia_device *link)
553 DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); 541 DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
554 542
555 /* Get write protect status */ 543 /* Get write protect status */
556 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); 544 dev->win_base = ioremap(link->resource[2]->start,
557 dev->win_base = ioremap(req.Base, req.Size); 545 resource_size(link->resource[2]));
558 if(!dev->win_base) { 546 if(!dev->win_base) {
559 dev_err(&dev->p_dev->dev, "ioremap(%lu, %u) failed\n", 547 dev_err(&dev->p_dev->dev, "ioremap(%pR) failed\n",
560 req.Base, req.Size); 548 link->resource[2]);
561 pcmciamtd_release(link); 549 pcmciamtd_release(link);
562 return -ENODEV; 550 return -ENODEV;
563 } 551 }
564 DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", 552 DEBUG(1, "mapped window dev = %p @ %pR, base = %p",
565 dev, req.Base, dev->win_base, req.Size); 553 dev, link->resource[2], dev->win_base);
566 554
567 dev->offset = 0; 555 dev->offset = 0;
568 dev->pcmcia_map.map_priv_1 = (unsigned long)dev; 556 dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
569 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 557 dev->pcmcia_map.map_priv_2 = (unsigned long)link->resource[2];
570 558
571 dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp; 559 dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp;
572 link->conf.Attributes = 0;
573 if(setvpp == 2) { 560 if(setvpp == 2) {
574 link->conf.Vpp = dev->vpp; 561 link->vpp = dev->vpp;
575 } else { 562 } else {
576 link->conf.Vpp = 0; 563 link->vpp = 0;
577 } 564 }
578 565
579 link->conf.IntType = INT_MEMORY; 566 link->config_index = 0;
580 link->conf.ConfigIndex = 0;
581 DEBUG(2, "Setting Configuration"); 567 DEBUG(2, "Setting Configuration");
582 ret = pcmcia_request_configuration(link, &link->conf); 568 ret = pcmcia_enable_device(link);
583 if (ret != 0) { 569 if (ret != 0) {
584 if (dev->win_base) { 570 if (dev->win_base) {
585 iounmap(dev->win_base); 571 iounmap(dev->win_base);
@@ -680,12 +666,6 @@ static int pcmciamtd_resume(struct pcmcia_device *dev)
680} 666}
681 667
682 668
683/* This deletes a driver "instance". The device is de-registered
684 * with Card Services. If it has been released, all local data
685 * structures are freed. Otherwise, the structures will be freed
686 * when the device is released.
687 */
688
689static void pcmciamtd_detach(struct pcmcia_device *link) 669static void pcmciamtd_detach(struct pcmcia_device *link)
690{ 670{
691 struct pcmciamtd_dev *dev = link->priv; 671 struct pcmciamtd_dev *dev = link->priv;
@@ -703,11 +683,6 @@ static void pcmciamtd_detach(struct pcmcia_device *link)
703} 683}
704 684
705 685
706/* pcmciamtd_attach() creates an "instance" of the driver, allocating
707 * local data structures for one device. The device is registered
708 * with Card Services.
709 */
710
711static int pcmciamtd_probe(struct pcmcia_device *link) 686static int pcmciamtd_probe(struct pcmcia_device *link)
712{ 687{
713 struct pcmciamtd_dev *dev; 688 struct pcmciamtd_dev *dev;
@@ -720,9 +695,6 @@ static int pcmciamtd_probe(struct pcmcia_device *link)
720 dev->p_dev = link; 695 dev->p_dev = link;
721 link->priv = dev; 696 link->priv = dev;
722 697
723 link->conf.Attributes = 0;
724 link->conf.IntType = INT_MEMORY;
725
726 return pcmciamtd_config(link); 698 return pcmciamtd_config(link);
727} 699}
728 700
@@ -757,9 +729,7 @@ static struct pcmcia_device_id pcmciamtd_ids[] = {
757MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids); 729MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids);
758 730
759static struct pcmcia_driver pcmciamtd_driver = { 731static struct pcmcia_driver pcmciamtd_driver = {
760 .drv = { 732 .name = "pcmciamtd",
761 .name = "pcmciamtd"
762 },
763 .probe = pcmciamtd_probe, 733 .probe = pcmciamtd_probe,
764 .remove = pcmciamtd_detach, 734 .remove = pcmciamtd_detach,
765 .owner = THIS_MODULE, 735 .owner = THIS_MODULE,
@@ -771,8 +741,6 @@ static struct pcmcia_driver pcmciamtd_driver = {
771 741
772static int __init init_pcmciamtd(void) 742static int __init init_pcmciamtd(void)
773{ 743{
774 info(DRIVER_DESC);
775
776 if(bankwidth && bankwidth != 1 && bankwidth != 2) { 744 if(bankwidth && bankwidth != 1 && bankwidth != 2) {
777 info("bad bankwidth (%d), using default", bankwidth); 745 info("bad bankwidth (%d), using default", bankwidth);
778 bankwidth = 2; 746 bankwidth = 2;
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index c683f77c6f42..ff824e11f0b6 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -87,7 +87,6 @@ earlier 3Com products.
87#include <linux/bitops.h> 87#include <linux/bitops.h>
88#include <linux/mii.h> 88#include <linux/mii.h>
89 89
90#include <pcmcia/cs.h>
91#include <pcmcia/cistpl.h> 90#include <pcmcia/cistpl.h>
92#include <pcmcia/cisreg.h> 91#include <pcmcia/cisreg.h>
93#include <pcmcia/ciscode.h> 92#include <pcmcia/ciscode.h>
@@ -280,25 +279,15 @@ static int tc574_probe(struct pcmcia_device *link)
280 spin_lock_init(&lp->window_lock); 279 spin_lock_init(&lp->window_lock);
281 link->resource[0]->end = 32; 280 link->resource[0]->end = 32;
282 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 281 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
283 link->conf.Attributes = CONF_ENABLE_IRQ; 282 link->config_flags |= CONF_ENABLE_IRQ;
284 link->conf.IntType = INT_MEMORY_AND_IO; 283 link->config_index = 1;
285 link->conf.ConfigIndex = 1;
286 284
287 dev->netdev_ops = &el3_netdev_ops; 285 dev->netdev_ops = &el3_netdev_ops;
288 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 286 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
289 dev->watchdog_timeo = TX_TIMEOUT; 287 dev->watchdog_timeo = TX_TIMEOUT;
290 288
291 return tc574_config(link); 289 return tc574_config(link);
292} /* tc574_attach */ 290}
293
294/*
295
296 This deletes a driver "instance". The device is de-registered
297 with Card Services. If it has been released, all local data
298 structures are freed. Otherwise, the structures will be freed
299 when the device is released.
300
301*/
302 291
303static void tc574_detach(struct pcmcia_device *link) 292static void tc574_detach(struct pcmcia_device *link)
304{ 293{
@@ -313,12 +302,6 @@ static void tc574_detach(struct pcmcia_device *link)
313 free_netdev(dev); 302 free_netdev(dev);
314} /* tc574_detach */ 303} /* tc574_detach */
315 304
316/*
317 tc574_config() is scheduled to run after a CARD_INSERTION event
318 is received, to configure the PCMCIA socket, and to make the
319 ethernet device available to the system.
320*/
321
322static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 305static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
323 306
324static int tc574_config(struct pcmcia_device *link) 307static int tc574_config(struct pcmcia_device *link)
@@ -352,7 +335,7 @@ static int tc574_config(struct pcmcia_device *link)
352 if (ret) 335 if (ret)
353 goto failed; 336 goto failed;
354 337
355 ret = pcmcia_request_configuration(link, &link->conf); 338 ret = pcmcia_enable_device(link);
356 if (ret) 339 if (ret)
357 goto failed; 340 goto failed;
358 341
@@ -465,12 +448,6 @@ failed:
465 448
466} /* tc574_config */ 449} /* tc574_config */
467 450
468/*
469 After a card is removed, tc574_release() will unregister the net
470 device, and release the PCMCIA configuration. If the device is
471 still open, this will be postponed until it is closed.
472*/
473
474static void tc574_release(struct pcmcia_device *link) 451static void tc574_release(struct pcmcia_device *link)
475{ 452{
476 pcmcia_disable_device(link); 453 pcmcia_disable_device(link);
@@ -1198,9 +1175,7 @@ MODULE_DEVICE_TABLE(pcmcia, tc574_ids);
1198 1175
1199static struct pcmcia_driver tc574_driver = { 1176static struct pcmcia_driver tc574_driver = {
1200 .owner = THIS_MODULE, 1177 .owner = THIS_MODULE,
1201 .drv = { 1178 .name = "3c574_cs",
1202 .name = "3c574_cs",
1203 },
1204 .probe = tc574_probe, 1179 .probe = tc574_probe,
1205 .remove = tc574_detach, 1180 .remove = tc574_detach,
1206 .id_table = tc574_ids, 1181 .id_table = tc574_ids,
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 61f9cf2100ff..a07e22295330 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -41,7 +41,6 @@
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42#include <linux/jiffies.h> 42#include <linux/jiffies.h>
43 43
44#include <pcmcia/cs.h>
45#include <pcmcia/cistpl.h> 44#include <pcmcia/cistpl.h>
46#include <pcmcia/cisreg.h> 45#include <pcmcia/cisreg.h>
47#include <pcmcia/ciscode.h> 46#include <pcmcia/ciscode.h>
@@ -176,14 +175,6 @@ static const struct ethtool_ops netdev_ethtool_ops;
176 175
177static void tc589_detach(struct pcmcia_device *p_dev); 176static void tc589_detach(struct pcmcia_device *p_dev);
178 177
179/*======================================================================
180
181 tc589_attach() creates an "instance" of the driver, allocating
182 local data structures for one device. The device is registered
183 with Card Services.
184
185======================================================================*/
186
187static const struct net_device_ops el3_netdev_ops = { 178static const struct net_device_ops el3_netdev_ops = {
188 .ndo_open = el3_open, 179 .ndo_open = el3_open,
189 .ndo_stop = el3_close, 180 .ndo_stop = el3_close,
@@ -216,9 +207,8 @@ static int tc589_probe(struct pcmcia_device *link)
216 link->resource[0]->end = 16; 207 link->resource[0]->end = 16;
217 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16; 208 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
218 209
219 link->conf.Attributes = CONF_ENABLE_IRQ; 210 link->config_flags |= CONF_ENABLE_IRQ;
220 link->conf.IntType = INT_MEMORY_AND_IO; 211 link->config_index = 1;
221 link->conf.ConfigIndex = 1;
222 212
223 dev->netdev_ops = &el3_netdev_ops; 213 dev->netdev_ops = &el3_netdev_ops;
224 dev->watchdog_timeo = TX_TIMEOUT; 214 dev->watchdog_timeo = TX_TIMEOUT;
@@ -226,16 +216,7 @@ static int tc589_probe(struct pcmcia_device *link)
226 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 216 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
227 217
228 return tc589_config(link); 218 return tc589_config(link);
229} /* tc589_attach */ 219}
230
231/*======================================================================
232
233 This deletes a driver "instance". The device is de-registered
234 with Card Services. If it has been released, all local data
235 structures are freed. Otherwise, the structures will be freed
236 when the device is released.
237
238======================================================================*/
239 220
240static void tc589_detach(struct pcmcia_device *link) 221static void tc589_detach(struct pcmcia_device *link)
241{ 222{
@@ -250,14 +231,6 @@ static void tc589_detach(struct pcmcia_device *link)
250 free_netdev(dev); 231 free_netdev(dev);
251} /* tc589_detach */ 232} /* tc589_detach */
252 233
253/*======================================================================
254
255 tc589_config() is scheduled to run after a CARD_INSERTION event
256 is received, to configure the PCMCIA socket, and to make the
257 ethernet device available to the system.
258
259======================================================================*/
260
261static int tc589_config(struct pcmcia_device *link) 234static int tc589_config(struct pcmcia_device *link)
262{ 235{
263 struct net_device *dev = link->priv; 236 struct net_device *dev = link->priv;
@@ -294,7 +267,7 @@ static int tc589_config(struct pcmcia_device *link)
294 if (ret) 267 if (ret)
295 goto failed; 268 goto failed;
296 269
297 ret = pcmcia_request_configuration(link, &link->conf); 270 ret = pcmcia_enable_device(link);
298 if (ret) 271 if (ret)
299 goto failed; 272 goto failed;
300 273
@@ -352,14 +325,6 @@ failed:
352 return -ENODEV; 325 return -ENODEV;
353} /* tc589_config */ 326} /* tc589_config */
354 327
355/*======================================================================
356
357 After a card is removed, tc589_release() will unregister the net
358 device, and release the PCMCIA configuration. If the device is
359 still open, this will be postponed until it is closed.
360
361======================================================================*/
362
363static void tc589_release(struct pcmcia_device *link) 328static void tc589_release(struct pcmcia_device *link)
364{ 329{
365 pcmcia_disable_device(link); 330 pcmcia_disable_device(link);
@@ -955,9 +920,7 @@ MODULE_DEVICE_TABLE(pcmcia, tc589_ids);
955 920
956static struct pcmcia_driver tc589_driver = { 921static struct pcmcia_driver tc589_driver = {
957 .owner = THIS_MODULE, 922 .owner = THIS_MODULE,
958 .drv = { 923 .name = "3c589_cs",
959 .name = "3c589_cs",
960 },
961 .probe = tc589_probe, 924 .probe = tc589_probe,
962 .remove = tc589_detach, 925 .remove = tc589_detach,
963 .id_table = tc589_ids, 926 .id_table = tc589_ids,
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 5f05ffb240cc..9e8b28b271ae 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -39,7 +39,6 @@
39#include <linux/mii.h> 39#include <linux/mii.h>
40#include "../8390.h" 40#include "../8390.h"
41 41
42#include <pcmcia/cs.h>
43#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
44#include <pcmcia/ciscode.h> 43#include <pcmcia/ciscode.h>
45#include <pcmcia/ds.h> 44#include <pcmcia/ds.h>
@@ -140,14 +139,6 @@ static const struct net_device_ops axnet_netdev_ops = {
140 .ndo_validate_addr = eth_validate_addr, 139 .ndo_validate_addr = eth_validate_addr,
141}; 140};
142 141
143/*======================================================================
144
145 axnet_attach() creates an "instance" of the driver, allocating
146 local data structures for one device. The device is registered
147 with Card Services.
148
149======================================================================*/
150
151static int axnet_probe(struct pcmcia_device *link) 142static int axnet_probe(struct pcmcia_device *link)
152{ 143{
153 axnet_dev_t *info; 144 axnet_dev_t *info;
@@ -166,8 +157,7 @@ static int axnet_probe(struct pcmcia_device *link)
166 info = PRIV(dev); 157 info = PRIV(dev);
167 info->p_dev = link; 158 info->p_dev = link;
168 link->priv = dev; 159 link->priv = dev;
169 link->conf.Attributes = CONF_ENABLE_IRQ; 160 link->config_flags |= CONF_ENABLE_IRQ;
170 link->conf.IntType = INT_MEMORY_AND_IO;
171 161
172 dev->netdev_ops = &axnet_netdev_ops; 162 dev->netdev_ops = &axnet_netdev_ops;
173 163
@@ -177,15 +167,6 @@ static int axnet_probe(struct pcmcia_device *link)
177 return axnet_config(link); 167 return axnet_config(link);
178} /* axnet_attach */ 168} /* axnet_attach */
179 169
180/*======================================================================
181
182 This deletes a driver "instance". The device is de-registered
183 with Card Services. If it has been released, all local data
184 structures are freed. Otherwise, the structures will be freed
185 when the device is released.
186
187======================================================================*/
188
189static void axnet_detach(struct pcmcia_device *link) 170static void axnet_detach(struct pcmcia_device *link)
190{ 171{
191 struct net_device *dev = link->priv; 172 struct net_device *dev = link->priv;
@@ -231,7 +212,7 @@ static int get_prom(struct pcmcia_device *link)
231 }; 212 };
232 213
233 /* Not much of a test, but the alternatives are messy */ 214 /* Not much of a test, but the alternatives are messy */
234 if (link->conf.ConfigBase != 0x03c0) 215 if (link->config_base != 0x03c0)
235 return 0; 216 return 0;
236 217
237 axnet_reset_8390(dev); 218 axnet_reset_8390(dev);
@@ -248,14 +229,6 @@ static int get_prom(struct pcmcia_device *link)
248 return 1; 229 return 1;
249} /* get_prom */ 230} /* get_prom */
250 231
251/*======================================================================
252
253 axnet_config() is scheduled to run after a CARD_INSERTION event
254 is received, to configure the PCMCIA socket, and to make the
255 ethernet device available to the system.
256
257======================================================================*/
258
259static int try_io_port(struct pcmcia_device *link) 232static int try_io_port(struct pcmcia_device *link)
260{ 233{
261 int j, ret; 234 int j, ret;
@@ -286,35 +259,16 @@ static int try_io_port(struct pcmcia_device *link)
286 } 259 }
287} 260}
288 261
289static int axnet_configcheck(struct pcmcia_device *p_dev, 262static int axnet_configcheck(struct pcmcia_device *p_dev, void *priv_data)
290 cistpl_cftable_entry_t *cfg,
291 cistpl_cftable_entry_t *dflt,
292 unsigned int vcc,
293 void *priv_data)
294{ 263{
295 int i; 264 if (p_dev->config_index == 0)
296 cistpl_io_t *io = &cfg->io; 265 return -EINVAL;
297 266
298 if (cfg->index == 0 || cfg->io.nwin == 0) 267 p_dev->config_index = 0x05;
268 if (p_dev->resource[0]->end + p_dev->resource[1]->end < 32)
299 return -ENODEV; 269 return -ENODEV;
300 270
301 p_dev->conf.ConfigIndex = 0x05; 271 return try_io_port(p_dev);
302 /* For multifunction cards, by convention, we configure the
303 network function with window 0, and serial with window 1 */
304 if (io->nwin > 1) {
305 i = (io->win[1].len > io->win[0].len);
306 p_dev->resource[1]->start = io->win[1-i].base;
307 p_dev->resource[1]->end = io->win[1-i].len;
308 } else {
309 i = p_dev->resource[1]->end = 0;
310 }
311 p_dev->resource[0]->start = io->win[i].base;
312 p_dev->resource[0]->end = io->win[i].len;
313 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
314 if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32)
315 return try_io_port(p_dev);
316
317 return -ENODEV;
318} 272}
319 273
320static int axnet_config(struct pcmcia_device *link) 274static int axnet_config(struct pcmcia_device *link)
@@ -326,20 +280,19 @@ static int axnet_config(struct pcmcia_device *link)
326 dev_dbg(&link->dev, "axnet_config(0x%p)\n", link); 280 dev_dbg(&link->dev, "axnet_config(0x%p)\n", link);
327 281
328 /* don't trust the CIS on this; Linksys got it wrong */ 282 /* don't trust the CIS on this; Linksys got it wrong */
329 link->conf.Present = 0x63; 283 link->config_regs = 0x63;
284 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
330 ret = pcmcia_loop_config(link, axnet_configcheck, NULL); 285 ret = pcmcia_loop_config(link, axnet_configcheck, NULL);
331 if (ret != 0) 286 if (ret != 0)
332 goto failed; 287 goto failed;
333 288
334 if (!link->irq) 289 if (!link->irq)
335 goto failed; 290 goto failed;
291
292 if (resource_size(link->resource[1]) == 8)
293 link->config_flags |= CONF_ENABLE_SPKR;
336 294
337 if (resource_size(link->resource[1]) == 8) { 295 ret = pcmcia_enable_device(link);
338 link->conf.Attributes |= CONF_ENABLE_SPKR;
339 link->conf.Status = CCSR_AUDIO_ENA;
340 }
341
342 ret = pcmcia_request_configuration(link, &link->conf);
343 if (ret) 296 if (ret)
344 goto failed; 297 goto failed;
345 298
@@ -414,14 +367,6 @@ failed:
414 return -ENODEV; 367 return -ENODEV;
415} /* axnet_config */ 368} /* axnet_config */
416 369
417/*======================================================================
418
419 After a card is removed, axnet_release() will unregister the net
420 device, and release the PCMCIA configuration. If the device is
421 still open, this will be postponed until it is closed.
422
423======================================================================*/
424
425static void axnet_release(struct pcmcia_device *link) 370static void axnet_release(struct pcmcia_device *link)
426{ 371{
427 pcmcia_disable_device(link); 372 pcmcia_disable_device(link);
@@ -783,9 +728,7 @@ MODULE_DEVICE_TABLE(pcmcia, axnet_ids);
783 728
784static struct pcmcia_driver axnet_cs_driver = { 729static struct pcmcia_driver axnet_cs_driver = {
785 .owner = THIS_MODULE, 730 .owner = THIS_MODULE,
786 .drv = { 731 .name = "axnet_cs",
787 .name = "axnet_cs",
788 },
789 .probe = axnet_probe, 732 .probe = axnet_probe,
790 .remove = axnet_detach, 733 .remove = axnet_detach,
791 .id_table = axnet_ids, 734 .id_table = axnet_ids,
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 3c400cfa82ae..b706a7249477 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -43,7 +43,6 @@
43#include <linux/arcdevice.h> 43#include <linux/arcdevice.h>
44#include <linux/com20020.h> 44#include <linux/com20020.h>
45 45
46#include <pcmcia/cs.h>
47#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
48#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
49 48
@@ -123,14 +122,6 @@ typedef struct com20020_dev_t {
123 struct net_device *dev; 122 struct net_device *dev;
124} com20020_dev_t; 123} com20020_dev_t;
125 124
126/*======================================================================
127
128 com20020_attach() creates an "instance" of the driver, allocating
129 local data structures for one device. The device is registered
130 with Card Services.
131
132======================================================================*/
133
134static int com20020_probe(struct pcmcia_device *p_dev) 125static int com20020_probe(struct pcmcia_device *p_dev)
135{ 126{
136 com20020_dev_t *info; 127 com20020_dev_t *info;
@@ -160,8 +151,7 @@ static int com20020_probe(struct pcmcia_device *p_dev)
160 151
161 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 152 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
162 p_dev->resource[0]->end = 16; 153 p_dev->resource[0]->end = 16;
163 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 154 p_dev->config_flags |= CONF_ENABLE_IRQ;
164 p_dev->conf.IntType = INT_MEMORY_AND_IO;
165 155
166 info->dev = dev; 156 info->dev = dev;
167 p_dev->priv = info; 157 p_dev->priv = info;
@@ -174,15 +164,6 @@ fail_alloc_info:
174 return -ENOMEM; 164 return -ENOMEM;
175} /* com20020_attach */ 165} /* com20020_attach */
176 166
177/*======================================================================
178
179 This deletes a driver "instance". The device is de-registered
180 with Card Services. If it has been released, all local data
181 structures are freed. Otherwise, the structures will be freed
182 when the device is released.
183
184======================================================================*/
185
186static void com20020_detach(struct pcmcia_device *link) 167static void com20020_detach(struct pcmcia_device *link)
187{ 168{
188 struct com20020_dev_t *info = link->priv; 169 struct com20020_dev_t *info = link->priv;
@@ -221,14 +202,6 @@ static void com20020_detach(struct pcmcia_device *link)
221 202
222} /* com20020_detach */ 203} /* com20020_detach */
223 204
224/*======================================================================
225
226 com20020_config() is scheduled to run after a CARD_INSERTION event
227 is received, to configure the PCMCIA socket, and to make the
228 device available to the system.
229
230======================================================================*/
231
232static int com20020_config(struct pcmcia_device *link) 205static int com20020_config(struct pcmcia_device *link)
233{ 206{
234 struct arcnet_local *lp; 207 struct arcnet_local *lp;
@@ -282,7 +255,7 @@ static int com20020_config(struct pcmcia_device *link)
282 255
283 dev->irq = link->irq; 256 dev->irq = link->irq;
284 257
285 ret = pcmcia_request_configuration(link, &link->conf); 258 ret = pcmcia_enable_device(link);
286 if (ret) 259 if (ret)
287 goto failed; 260 goto failed;
288 261
@@ -316,14 +289,6 @@ failed:
316 return -ENODEV; 289 return -ENODEV;
317} /* com20020_config */ 290} /* com20020_config */
318 291
319/*======================================================================
320
321 After a card is removed, com20020_release() will unregister the net
322 device, and release the PCMCIA configuration. If the device is
323 still open, this will be postponed until it is closed.
324
325======================================================================*/
326
327static void com20020_release(struct pcmcia_device *link) 292static void com20020_release(struct pcmcia_device *link)
328{ 293{
329 dev_dbg(&link->dev, "com20020_release\n"); 294 dev_dbg(&link->dev, "com20020_release\n");
@@ -366,9 +331,7 @@ MODULE_DEVICE_TABLE(pcmcia, com20020_ids);
366 331
367static struct pcmcia_driver com20020_cs_driver = { 332static struct pcmcia_driver com20020_cs_driver = {
368 .owner = THIS_MODULE, 333 .owner = THIS_MODULE,
369 .drv = { 334 .name = "com20020_cs",
370 .name = "com20020_cs",
371 },
372 .probe = com20020_probe, 335 .probe = com20020_probe,
373 .remove = com20020_detach, 336 .remove = com20020_detach,
374 .id_table = com20020_ids, 337 .id_table = com20020_ids,
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 98fffb03ecd7..1c327598bbe8 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -49,7 +49,6 @@
49#include <linux/ioport.h> 49#include <linux/ioport.h>
50#include <linux/crc32.h> 50#include <linux/crc32.h>
51 51
52#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
54#include <pcmcia/ciscode.h> 53#include <pcmcia/ciscode.h>
55#include <pcmcia/ds.h> 54#include <pcmcia/ds.h>
@@ -252,8 +251,7 @@ static int fmvj18x_probe(struct pcmcia_device *link)
252 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 251 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
253 252
254 /* General socket configuration */ 253 /* General socket configuration */
255 link->conf.Attributes = CONF_ENABLE_IRQ; 254 link->config_flags |= CONF_ENABLE_IRQ;
256 link->conf.IntType = INT_MEMORY_AND_IO;
257 255
258 dev->netdev_ops = &fjn_netdev_ops; 256 dev->netdev_ops = &fjn_netdev_ops;
259 dev->watchdog_timeo = TX_TIMEOUT; 257 dev->watchdog_timeo = TX_TIMEOUT;
@@ -313,7 +311,7 @@ static int ungermann_try_io_port(struct pcmcia_device *link)
313 ret = pcmcia_request_io(link); 311 ret = pcmcia_request_io(link);
314 if (ret == 0) { 312 if (ret == 0) {
315 /* calculate ConfigIndex value */ 313 /* calculate ConfigIndex value */
316 link->conf.ConfigIndex = 314 link->config_index =
317 ((link->resource[0]->start & 0x0f0) >> 3) | 0x22; 315 ((link->resource[0]->start & 0x0f0) >> 3) | 0x22;
318 return ret; 316 return ret;
319 } 317 }
@@ -321,11 +319,7 @@ static int ungermann_try_io_port(struct pcmcia_device *link)
321 return ret; /* RequestIO failed */ 319 return ret; /* RequestIO failed */
322} 320}
323 321
324static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, 322static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
325 cistpl_cftable_entry_t *cfg,
326 cistpl_cftable_entry_t *dflt,
327 unsigned int vcc,
328 void *priv_data)
329{ 323{
330 return 0; /* strange, but that's what the code did already before... */ 324 return 0; /* strange, but that's what the code did already before... */
331} 325}
@@ -362,28 +356,28 @@ static int fmvj18x_config(struct pcmcia_device *link)
362 link->card_id == PRODID_TDK_NP9610 || 356 link->card_id == PRODID_TDK_NP9610 ||
363 link->card_id == PRODID_TDK_MN3200) { 357 link->card_id == PRODID_TDK_MN3200) {
364 /* MultiFunction Card */ 358 /* MultiFunction Card */
365 link->conf.ConfigBase = 0x800; 359 link->config_base = 0x800;
366 link->conf.ConfigIndex = 0x47; 360 link->config_index = 0x47;
367 link->resource[1]->end = 8; 361 link->resource[1]->end = 8;
368 } 362 }
369 break; 363 break;
370 case MANFID_NEC: 364 case MANFID_NEC:
371 cardtype = NEC; /* MultiFunction Card */ 365 cardtype = NEC; /* MultiFunction Card */
372 link->conf.ConfigBase = 0x800; 366 link->config_base = 0x800;
373 link->conf.ConfigIndex = 0x47; 367 link->config_index = 0x47;
374 link->resource[1]->end = 8; 368 link->resource[1]->end = 8;
375 break; 369 break;
376 case MANFID_KME: 370 case MANFID_KME:
377 cardtype = KME; /* MultiFunction Card */ 371 cardtype = KME; /* MultiFunction Card */
378 link->conf.ConfigBase = 0x800; 372 link->config_base = 0x800;
379 link->conf.ConfigIndex = 0x47; 373 link->config_index = 0x47;
380 link->resource[1]->end = 8; 374 link->resource[1]->end = 8;
381 break; 375 break;
382 case MANFID_CONTEC: 376 case MANFID_CONTEC:
383 cardtype = CONTEC; 377 cardtype = CONTEC;
384 break; 378 break;
385 case MANFID_FUJITSU: 379 case MANFID_FUJITSU:
386 if (link->conf.ConfigBase == 0x0fe0) 380 if (link->config_base == 0x0fe0)
387 cardtype = MBH10302; 381 cardtype = MBH10302;
388 else if (link->card_id == PRODID_FUJITSU_MBH10302) 382 else if (link->card_id == PRODID_FUJITSU_MBH10302)
389 /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302), 383 /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302),
@@ -403,10 +397,10 @@ static int fmvj18x_config(struct pcmcia_device *link)
403 case MANFID_FUJITSU: 397 case MANFID_FUJITSU:
404 if (link->card_id == PRODID_FUJITSU_MBH10304) { 398 if (link->card_id == PRODID_FUJITSU_MBH10304) {
405 cardtype = XXX10304; /* MBH10304 with buggy CIS */ 399 cardtype = XXX10304; /* MBH10304 with buggy CIS */
406 link->conf.ConfigIndex = 0x20; 400 link->config_index = 0x20;
407 } else { 401 } else {
408 cardtype = MBH10302; /* NextCom NC5310, etc. */ 402 cardtype = MBH10302; /* NextCom NC5310, etc. */
409 link->conf.ConfigIndex = 1; 403 link->config_index = 1;
410 } 404 }
411 break; 405 break;
412 case MANFID_UNGERMANN: 406 case MANFID_UNGERMANN:
@@ -414,7 +408,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
414 break; 408 break;
415 default: 409 default:
416 cardtype = MBH10302; 410 cardtype = MBH10302;
417 link->conf.ConfigIndex = 1; 411 link->config_index = 1;
418 } 412 }
419 } 413 }
420 414
@@ -432,7 +426,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
432 ret = pcmcia_request_irq(link, fjn_interrupt); 426 ret = pcmcia_request_irq(link, fjn_interrupt);
433 if (ret) 427 if (ret)
434 goto failed; 428 goto failed;
435 ret = pcmcia_request_configuration(link, &link->conf); 429 ret = pcmcia_enable_device(link);
436 if (ret) 430 if (ret)
437 goto failed; 431 goto failed;
438 432
@@ -544,20 +538,18 @@ failed:
544 538
545static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) 539static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
546{ 540{
547 win_req_t req;
548 u_char __iomem *base; 541 u_char __iomem *base;
549 int i, j; 542 int i, j;
550 543
551 /* Allocate a small memory window */ 544 /* Allocate a small memory window */
552 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 545 link->resource[2]->flags |= WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
553 req.Base = 0; req.Size = 0; 546 link->resource[2]->start = 0; link->resource[2]->end = 0;
554 req.AccessSpeed = 0; 547 i = pcmcia_request_window(link, link->resource[2], 0);
555 i = pcmcia_request_window(link, &req, &link->win);
556 if (i != 0) 548 if (i != 0)
557 return -1; 549 return -1;
558 550
559 base = ioremap(req.Base, req.Size); 551 base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
560 pcmcia_map_mem_page(link, link->win, 0); 552 pcmcia_map_mem_page(link, link->resource[2], 0);
561 553
562 /* 554 /*
563 * MBH10304 CISTPL_FUNCE_LAN_NODE_ID format 555 * MBH10304 CISTPL_FUNCE_LAN_NODE_ID format
@@ -582,7 +574,7 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
582 } 574 }
583 575
584 iounmap(base); 576 iounmap(base);
585 j = pcmcia_release_window(link, link->win); 577 j = pcmcia_release_window(link, link->resource[2]);
586 return (i != 0x200) ? 0 : -1; 578 return (i != 0x200) ? 0 : -1;
587 579
588} /* fmvj18x_get_hwinfo */ 580} /* fmvj18x_get_hwinfo */
@@ -590,27 +582,26 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
590 582
591static int fmvj18x_setup_mfc(struct pcmcia_device *link) 583static int fmvj18x_setup_mfc(struct pcmcia_device *link)
592{ 584{
593 win_req_t req;
594 int i; 585 int i;
595 struct net_device *dev = link->priv; 586 struct net_device *dev = link->priv;
596 unsigned int ioaddr; 587 unsigned int ioaddr;
597 local_info_t *lp = netdev_priv(dev); 588 local_info_t *lp = netdev_priv(dev);
598 589
599 /* Allocate a small memory window */ 590 /* Allocate a small memory window */
600 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 591 link->resource[3]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
601 req.Base = 0; req.Size = 0; 592 link->resource[3]->start = link->resource[3]->end = 0;
602 req.AccessSpeed = 0; 593 i = pcmcia_request_window(link, link->resource[3], 0);
603 i = pcmcia_request_window(link, &req, &link->win);
604 if (i != 0) 594 if (i != 0)
605 return -1; 595 return -1;
606 596
607 lp->base = ioremap(req.Base, req.Size); 597 lp->base = ioremap(link->resource[3]->start,
598 resource_size(link->resource[3]));
608 if (lp->base == NULL) { 599 if (lp->base == NULL) {
609 printk(KERN_NOTICE "fmvj18x_cs: ioremap failed\n"); 600 printk(KERN_NOTICE "fmvj18x_cs: ioremap failed\n");
610 return -1; 601 return -1;
611 } 602 }
612 603
613 i = pcmcia_map_mem_page(link, link->win, 0); 604 i = pcmcia_map_mem_page(link, link->resource[3], 0);
614 if (i != 0) { 605 if (i != 0) {
615 iounmap(lp->base); 606 iounmap(lp->base);
616 lp->base = NULL; 607 lp->base = NULL;
@@ -638,7 +629,6 @@ static void fmvj18x_release(struct pcmcia_device *link)
638 struct net_device *dev = link->priv; 629 struct net_device *dev = link->priv;
639 local_info_t *lp = netdev_priv(dev); 630 local_info_t *lp = netdev_priv(dev);
640 u_char __iomem *tmp; 631 u_char __iomem *tmp;
641 int j;
642 632
643 dev_dbg(&link->dev, "fmvj18x_release\n"); 633 dev_dbg(&link->dev, "fmvj18x_release\n");
644 634
@@ -646,7 +636,6 @@ static void fmvj18x_release(struct pcmcia_device *link)
646 tmp = lp->base; 636 tmp = lp->base;
647 lp->base = NULL; /* set NULL before iounmap */ 637 lp->base = NULL; /* set NULL before iounmap */
648 iounmap(tmp); 638 iounmap(tmp);
649 j = pcmcia_release_window(link, link->win);
650 } 639 }
651 640
652 pcmcia_disable_device(link); 641 pcmcia_disable_device(link);
@@ -708,9 +697,7 @@ MODULE_DEVICE_TABLE(pcmcia, fmvj18x_ids);
708 697
709static struct pcmcia_driver fmvj18x_cs_driver = { 698static struct pcmcia_driver fmvj18x_cs_driver = {
710 .owner = THIS_MODULE, 699 .owner = THIS_MODULE,
711 .drv = { 700 .name = "fmvj18x_cs",
712 .name = "fmvj18x_cs",
713 },
714 .probe = fmvj18x_probe, 701 .probe = fmvj18x_probe,
715 .remove = fmvj18x_detach, 702 .remove = fmvj18x_detach,
716 .id_table = fmvj18x_ids, 703 .id_table = fmvj18x_ids,
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index b0d06a3d962f..bf7dff96d881 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -57,7 +57,6 @@
57#include <linux/trdevice.h> 57#include <linux/trdevice.h>
58#include <linux/ibmtr.h> 58#include <linux/ibmtr.h>
59 59
60#include <pcmcia/cs.h>
61#include <pcmcia/cistpl.h> 60#include <pcmcia/cistpl.h>
62#include <pcmcia/ds.h> 61#include <pcmcia/ds.h>
63 62
@@ -102,9 +101,8 @@ static void ibmtr_detach(struct pcmcia_device *p_dev);
102 101
103typedef struct ibmtr_dev_t { 102typedef struct ibmtr_dev_t {
104 struct pcmcia_device *p_dev; 103 struct pcmcia_device *p_dev;
105 struct net_device *dev; 104 struct net_device *dev;
106 window_handle_t sram_win_handle; 105 struct tok_info *ti;
107 struct tok_info *ti;
108} ibmtr_dev_t; 106} ibmtr_dev_t;
109 107
110static void netdev_get_drvinfo(struct net_device *dev, 108static void netdev_get_drvinfo(struct net_device *dev,
@@ -123,14 +121,6 @@ static irqreturn_t ibmtr_interrupt(int irq, void *dev_id) {
123 return tok_interrupt(irq, dev); 121 return tok_interrupt(irq, dev);
124}; 122};
125 123
126/*======================================================================
127
128 ibmtr_attach() creates an "instance" of the driver, allocating
129 local data structures for one device. The device is registered
130 with Card Services.
131
132======================================================================*/
133
134static int __devinit ibmtr_attach(struct pcmcia_device *link) 124static int __devinit ibmtr_attach(struct pcmcia_device *link)
135{ 125{
136 ibmtr_dev_t *info; 126 ibmtr_dev_t *info;
@@ -153,9 +143,8 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link)
153 143
154 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 144 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
155 link->resource[0]->end = 4; 145 link->resource[0]->end = 4;
156 link->conf.Attributes = CONF_ENABLE_IRQ; 146 link->config_flags |= CONF_ENABLE_IRQ;
157 link->conf.IntType = INT_MEMORY_AND_IO; 147 link->config_regs = PRESENT_OPTION;
158 link->conf.Present = PRESENT_OPTION;
159 148
160 info->dev = dev; 149 info->dev = dev;
161 150
@@ -164,15 +153,6 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link)
164 return ibmtr_config(link); 153 return ibmtr_config(link);
165} /* ibmtr_attach */ 154} /* ibmtr_attach */
166 155
167/*======================================================================
168
169 This deletes a driver "instance". The device is de-registered
170 with Card Services. If it has been released, all local data
171 structures are freed. Otherwise, the structures will be freed
172 when the device is released.
173
174======================================================================*/
175
176static void ibmtr_detach(struct pcmcia_device *link) 156static void ibmtr_detach(struct pcmcia_device *link)
177{ 157{
178 struct ibmtr_dev_t *info = link->priv; 158 struct ibmtr_dev_t *info = link->priv;
@@ -197,26 +177,17 @@ static void ibmtr_detach(struct pcmcia_device *link)
197 kfree(info); 177 kfree(info);
198} /* ibmtr_detach */ 178} /* ibmtr_detach */
199 179
200/*======================================================================
201
202 ibmtr_config() is scheduled to run after a CARD_INSERTION event
203 is received, to configure the PCMCIA socket, and to make the
204 token-ring device available to the system.
205
206======================================================================*/
207
208static int __devinit ibmtr_config(struct pcmcia_device *link) 180static int __devinit ibmtr_config(struct pcmcia_device *link)
209{ 181{
210 ibmtr_dev_t *info = link->priv; 182 ibmtr_dev_t *info = link->priv;
211 struct net_device *dev = info->dev; 183 struct net_device *dev = info->dev;
212 struct tok_info *ti = netdev_priv(dev); 184 struct tok_info *ti = netdev_priv(dev);
213 win_req_t req;
214 int i, ret; 185 int i, ret;
215 186
216 dev_dbg(&link->dev, "ibmtr_config\n"); 187 dev_dbg(&link->dev, "ibmtr_config\n");
217 188
218 link->conf.ConfigIndex = 0x61;
219 link->io_lines = 16; 189 link->io_lines = 16;
190 link->config_index = 0x61;
220 191
221 /* Determine if this is PRIMARY or ALTERNATE. */ 192 /* Determine if this is PRIMARY or ALTERNATE. */
222 193
@@ -240,39 +211,39 @@ static int __devinit ibmtr_config(struct pcmcia_device *link)
240 ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); 211 ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq);
241 212
242 /* Allocate the MMIO memory window */ 213 /* Allocate the MMIO memory window */
243 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; 214 link->resource[2]->flags |= WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
244 req.Attributes |= WIN_USE_WAIT; 215 link->resource[2]->flags |= WIN_USE_WAIT;
245 req.Base = 0; 216 link->resource[2]->start = 0;
246 req.Size = 0x2000; 217 link->resource[2]->end = 0x2000;
247 req.AccessSpeed = 250; 218 ret = pcmcia_request_window(link, link->resource[2], 250);
248 ret = pcmcia_request_window(link, &req, &link->win);
249 if (ret) 219 if (ret)
250 goto failed; 220 goto failed;
251 221
252 ret = pcmcia_map_mem_page(link, link->win, mmiobase); 222 ret = pcmcia_map_mem_page(link, link->resource[2], mmiobase);
253 if (ret) 223 if (ret)
254 goto failed; 224 goto failed;
255 ti->mmio = ioremap(req.Base, req.Size); 225 ti->mmio = ioremap(link->resource[2]->start,
226 resource_size(link->resource[2]));
256 227
257 /* Allocate the SRAM memory window */ 228 /* Allocate the SRAM memory window */
258 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; 229 link->resource[3]->flags = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
259 req.Attributes |= WIN_USE_WAIT; 230 link->resource[3]->flags |= WIN_USE_WAIT;
260 req.Base = 0; 231 link->resource[3]->start = 0;
261 req.Size = sramsize * 1024; 232 link->resource[3]->end = sramsize * 1024;
262 req.AccessSpeed = 250; 233 ret = pcmcia_request_window(link, link->resource[3], 250);
263 ret = pcmcia_request_window(link, &req, &info->sram_win_handle);
264 if (ret) 234 if (ret)
265 goto failed; 235 goto failed;
266 236
267 ret = pcmcia_map_mem_page(link, info->sram_win_handle, srambase); 237 ret = pcmcia_map_mem_page(link, link->resource[3], srambase);
268 if (ret) 238 if (ret)
269 goto failed; 239 goto failed;
270 240
271 ti->sram_base = srambase >> 12; 241 ti->sram_base = srambase >> 12;
272 ti->sram_virt = ioremap(req.Base, req.Size); 242 ti->sram_virt = ioremap(link->resource[3]->start,
273 ti->sram_phys = req.Base; 243 resource_size(link->resource[3]));
244 ti->sram_phys = link->resource[3]->start;
274 245
275 ret = pcmcia_request_configuration(link, &link->conf); 246 ret = pcmcia_enable_device(link);
276 if (ret) 247 if (ret)
277 goto failed; 248 goto failed;
278 249
@@ -301,14 +272,6 @@ failed:
301 return -ENODEV; 272 return -ENODEV;
302} /* ibmtr_config */ 273} /* ibmtr_config */
303 274
304/*======================================================================
305
306 After a card is removed, ibmtr_release() will unregister the net
307 device, and release the PCMCIA configuration. If the device is
308 still open, this will be postponed until it is closed.
309
310======================================================================*/
311
312static void ibmtr_release(struct pcmcia_device *link) 275static void ibmtr_release(struct pcmcia_device *link)
313{ 276{
314 ibmtr_dev_t *info = link->priv; 277 ibmtr_dev_t *info = link->priv;
@@ -316,7 +279,7 @@ static void ibmtr_release(struct pcmcia_device *link)
316 279
317 dev_dbg(&link->dev, "ibmtr_release\n"); 280 dev_dbg(&link->dev, "ibmtr_release\n");
318 281
319 if (link->win) { 282 if (link->resource[2]->end) {
320 struct tok_info *ti = netdev_priv(dev); 283 struct tok_info *ti = netdev_priv(dev);
321 iounmap(ti->mmio); 284 iounmap(ti->mmio);
322 } 285 }
@@ -398,9 +361,7 @@ MODULE_DEVICE_TABLE(pcmcia, ibmtr_ids);
398 361
399static struct pcmcia_driver ibmtr_cs_driver = { 362static struct pcmcia_driver ibmtr_cs_driver = {
400 .owner = THIS_MODULE, 363 .owner = THIS_MODULE,
401 .drv = { 364 .name = "ibmtr_cs",
402 .name = "ibmtr_cs",
403 },
404 .probe = ibmtr_attach, 365 .probe = ibmtr_attach,
405 .remove = ibmtr_detach, 366 .remove = ibmtr_detach,
406 .id_table = ibmtr_ids, 367 .id_table = ibmtr_ids,
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 68f2deeb3ade..1eca4f5a6e78 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -146,7 +146,6 @@ Include Files
146#include <linux/ioport.h> 146#include <linux/ioport.h>
147#include <linux/bitops.h> 147#include <linux/bitops.h>
148 148
149#include <pcmcia/cs.h>
150#include <pcmcia/cisreg.h> 149#include <pcmcia/cisreg.h>
151#include <pcmcia/cistpl.h> 150#include <pcmcia/cistpl.h>
152#include <pcmcia/ds.h> 151#include <pcmcia/ds.h>
@@ -435,13 +434,6 @@ static const struct net_device_ops mace_netdev_ops = {
435 .ndo_validate_addr = eth_validate_addr, 434 .ndo_validate_addr = eth_validate_addr,
436}; 435};
437 436
438/* ----------------------------------------------------------------------------
439nmclan_attach
440 Creates an "instance" of the driver, allocating local data
441 structures for one device. The device is registered with Card
442 Services.
443---------------------------------------------------------------------------- */
444
445static int nmclan_probe(struct pcmcia_device *link) 437static int nmclan_probe(struct pcmcia_device *link)
446{ 438{
447 mace_private *lp; 439 mace_private *lp;
@@ -460,10 +452,9 @@ static int nmclan_probe(struct pcmcia_device *link)
460 spin_lock_init(&lp->bank_lock); 452 spin_lock_init(&lp->bank_lock);
461 link->resource[0]->end = 32; 453 link->resource[0]->end = 32;
462 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 454 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
463 link->conf.Attributes = CONF_ENABLE_IRQ; 455 link->config_flags |= CONF_ENABLE_IRQ;
464 link->conf.IntType = INT_MEMORY_AND_IO; 456 link->config_index = 1;
465 link->conf.ConfigIndex = 1; 457 link->config_regs = PRESENT_OPTION;
466 link->conf.Present = PRESENT_OPTION;
467 458
468 lp->tx_free_frames=AM2150_MAX_TX_FRAMES; 459 lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
469 460
@@ -474,14 +465,6 @@ static int nmclan_probe(struct pcmcia_device *link)
474 return nmclan_config(link); 465 return nmclan_config(link);
475} /* nmclan_attach */ 466} /* nmclan_attach */
476 467
477/* ----------------------------------------------------------------------------
478nmclan_detach
479 This deletes a driver "instance". The device is de-registered
480 with Card Services. If it has been released, all local data
481 structures are freed. Otherwise, the structures will be freed
482 when the device is released.
483---------------------------------------------------------------------------- */
484
485static void nmclan_detach(struct pcmcia_device *link) 468static void nmclan_detach(struct pcmcia_device *link)
486{ 469{
487 struct net_device *dev = link->priv; 470 struct net_device *dev = link->priv;
@@ -625,13 +608,6 @@ static int mace_init(mace_private *lp, unsigned int ioaddr, char *enet_addr)
625 return 0; 608 return 0;
626} /* mace_init */ 609} /* mace_init */
627 610
628/* ----------------------------------------------------------------------------
629nmclan_config
630 This routine is scheduled to run after a CARD_INSERTION event
631 is received, to configure the PCMCIA socket, and to make the
632 ethernet device available to the system.
633---------------------------------------------------------------------------- */
634
635static int nmclan_config(struct pcmcia_device *link) 611static int nmclan_config(struct pcmcia_device *link)
636{ 612{
637 struct net_device *dev = link->priv; 613 struct net_device *dev = link->priv;
@@ -650,7 +626,7 @@ static int nmclan_config(struct pcmcia_device *link)
650 ret = pcmcia_request_exclusive_irq(link, mace_interrupt); 626 ret = pcmcia_request_exclusive_irq(link, mace_interrupt);
651 if (ret) 627 if (ret)
652 goto failed; 628 goto failed;
653 ret = pcmcia_request_configuration(link, &link->conf); 629 ret = pcmcia_enable_device(link);
654 if (ret) 630 if (ret)
655 goto failed; 631 goto failed;
656 632
@@ -712,12 +688,6 @@ failed:
712 return -ENODEV; 688 return -ENODEV;
713} /* nmclan_config */ 689} /* nmclan_config */
714 690
715/* ----------------------------------------------------------------------------
716nmclan_release
717 After a card is removed, nmclan_release() will unregister the
718 net device, and release the PCMCIA configuration. If the device
719 is still open, this will be postponed until it is closed.
720---------------------------------------------------------------------------- */
721static void nmclan_release(struct pcmcia_device *link) 691static void nmclan_release(struct pcmcia_device *link)
722{ 692{
723 dev_dbg(&link->dev, "nmclan_release\n"); 693 dev_dbg(&link->dev, "nmclan_release\n");
@@ -1535,9 +1505,7 @@ MODULE_DEVICE_TABLE(pcmcia, nmclan_ids);
1535 1505
1536static struct pcmcia_driver nmclan_cs_driver = { 1506static struct pcmcia_driver nmclan_cs_driver = {
1537 .owner = THIS_MODULE, 1507 .owner = THIS_MODULE,
1538 .drv = { 1508 .name = "nmclan_cs",
1539 .name = "nmclan_cs",
1540 },
1541 .probe = nmclan_probe, 1509 .probe = nmclan_probe,
1542 .remove = nmclan_detach, 1510 .remove = nmclan_detach,
1543 .id_table = nmclan_ids, 1511 .id_table = nmclan_ids,
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index f9b509a6b09a..5d7d1d3088ae 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -42,7 +42,6 @@
42#include <linux/mii.h> 42#include <linux/mii.h>
43#include "../8390.h" 43#include "../8390.h"
44 44
45#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
47#include <pcmcia/ciscode.h> 46#include <pcmcia/ciscode.h>
48#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
@@ -238,14 +237,6 @@ static const struct net_device_ops pcnet_netdev_ops = {
238#endif 237#endif
239}; 238};
240 239
241/*======================================================================
242
243 pcnet_attach() creates an "instance" of the driver, allocating
244 local data structures for one device. The device is registered
245 with Card Services.
246
247======================================================================*/
248
249static int pcnet_probe(struct pcmcia_device *link) 240static int pcnet_probe(struct pcmcia_device *link)
250{ 241{
251 pcnet_dev_t *info; 242 pcnet_dev_t *info;
@@ -260,23 +251,13 @@ static int pcnet_probe(struct pcmcia_device *link)
260 info->p_dev = link; 251 info->p_dev = link;
261 link->priv = dev; 252 link->priv = dev;
262 253
263 link->conf.Attributes = CONF_ENABLE_IRQ; 254 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
264 link->conf.IntType = INT_MEMORY_AND_IO;
265 255
266 dev->netdev_ops = &pcnet_netdev_ops; 256 dev->netdev_ops = &pcnet_netdev_ops;
267 257
268 return pcnet_config(link); 258 return pcnet_config(link);
269} /* pcnet_attach */ 259} /* pcnet_attach */
270 260
271/*======================================================================
272
273 This deletes a driver "instance". The device is de-registered
274 with Card Services. If it has been released, all local data
275 structures are freed. Otherwise, the structures will be freed
276 when the device is released.
277
278======================================================================*/
279
280static void pcnet_detach(struct pcmcia_device *link) 261static void pcnet_detach(struct pcmcia_device *link)
281{ 262{
282 struct net_device *dev = link->priv; 263 struct net_device *dev = link->priv;
@@ -300,22 +281,22 @@ static void pcnet_detach(struct pcmcia_device *link)
300static hw_info_t *get_hwinfo(struct pcmcia_device *link) 281static hw_info_t *get_hwinfo(struct pcmcia_device *link)
301{ 282{
302 struct net_device *dev = link->priv; 283 struct net_device *dev = link->priv;
303 win_req_t req;
304 u_char __iomem *base, *virt; 284 u_char __iomem *base, *virt;
305 int i, j; 285 int i, j;
306 286
307 /* Allocate a small memory window */ 287 /* Allocate a small memory window */
308 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 288 link->resource[2]->flags |= WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
309 req.Base = 0; req.Size = 0; 289 link->resource[2]->start = 0; link->resource[2]->end = 0;
310 req.AccessSpeed = 0; 290 i = pcmcia_request_window(link, link->resource[2], 0);
311 i = pcmcia_request_window(link, &req, &link->win);
312 if (i != 0) 291 if (i != 0)
313 return NULL; 292 return NULL;
314 293
315 virt = ioremap(req.Base, req.Size); 294 virt = ioremap(link->resource[2]->start,
295 resource_size(link->resource[2]));
316 for (i = 0; i < NR_INFO; i++) { 296 for (i = 0; i < NR_INFO; i++) {
317 pcmcia_map_mem_page(link, link->win, hw_info[i].offset & ~(req.Size-1)); 297 pcmcia_map_mem_page(link, link->resource[2],
318 base = &virt[hw_info[i].offset & (req.Size-1)]; 298 hw_info[i].offset & ~(resource_size(link->resource[2])-1));
299 base = &virt[hw_info[i].offset & (resource_size(link->resource[2])-1)];
319 if ((readb(base+0) == hw_info[i].a0) && 300 if ((readb(base+0) == hw_info[i].a0) &&
320 (readb(base+2) == hw_info[i].a1) && 301 (readb(base+2) == hw_info[i].a1) &&
321 (readb(base+4) == hw_info[i].a2)) { 302 (readb(base+4) == hw_info[i].a2)) {
@@ -326,7 +307,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
326 } 307 }
327 308
328 iounmap(virt); 309 iounmap(virt);
329 j = pcmcia_release_window(link, link->win); 310 j = pcmcia_release_window(link, link->resource[2]);
330 return (i < NR_INFO) ? hw_info+i : NULL; 311 return (i < NR_INFO) ? hw_info+i : NULL;
331} /* get_hwinfo */ 312} /* get_hwinfo */
332 313
@@ -421,7 +402,7 @@ static hw_info_t *get_ax88190(struct pcmcia_device *link)
421 int i, j; 402 int i, j;
422 403
423 /* Not much of a test, but the alternatives are messy */ 404 /* Not much of a test, but the alternatives are messy */
424 if (link->conf.ConfigBase != 0x03c0) 405 if (link->config_base != 0x03c0)
425 return NULL; 406 return NULL;
426 407
427 outb_p(0x01, ioaddr + EN0_DCFG); /* Set word-wide access. */ 408 outb_p(0x01, ioaddr + EN0_DCFG); /* Set word-wide access. */
@@ -463,14 +444,6 @@ static hw_info_t *get_hwired(struct pcmcia_device *link)
463 return &default_info; 444 return &default_info;
464} /* get_hwired */ 445} /* get_hwired */
465 446
466/*======================================================================
467
468 pcnet_config() is scheduled to run after a CARD_INSERTION event
469 is received, to configure the PCMCIA socket, and to make the
470 ethernet device available to the system.
471
472======================================================================*/
473
474static int try_io_port(struct pcmcia_device *link) 447static int try_io_port(struct pcmcia_device *link)
475{ 448{
476 int j, ret; 449 int j, ret;
@@ -502,43 +475,22 @@ static int try_io_port(struct pcmcia_device *link)
502 } 475 }
503} 476}
504 477
505static int pcnet_confcheck(struct pcmcia_device *p_dev, 478static int pcnet_confcheck(struct pcmcia_device *p_dev, void *priv_data)
506 cistpl_cftable_entry_t *cfg,
507 cistpl_cftable_entry_t *dflt,
508 unsigned int vcc,
509 void *priv_data)
510{ 479{
511 int *priv = priv_data; 480 int *priv = priv_data;
512 int try = (*priv & 0x1); 481 int try = (*priv & 0x1);
513 int i;
514 cistpl_io_t *io = &cfg->io;
515 482
516 if (cfg->index == 0 || cfg->io.nwin == 0) 483 *priv &= (p_dev->resource[2]->end >= 0x4000) ? 0x10 : ~0x10;
517 return -EINVAL;
518 484
519 /* For multifunction cards, by convention, we configure the 485 if (p_dev->config_index == 0)
520 network function with window 0, and serial with window 1 */ 486 return -EINVAL;
521 if (io->nwin > 1) {
522 i = (io->win[1].len > io->win[0].len);
523 p_dev->resource[1]->start = io->win[1-i].base;
524 p_dev->resource[1]->end = io->win[1-i].len;
525 } else {
526 i = p_dev->resource[1]->end = 0;
527 }
528 487
529 *priv &= ((cfg->mem.nwin == 1) && 488 if (p_dev->resource[0]->end + p_dev->resource[1]->end < 32)
530 (cfg->mem.win[0].len >= 0x4000)) ? 0x10 : ~0x10; 489 return -EINVAL;
531 490
532 p_dev->resource[0]->start = io->win[i].base; 491 if (try)
533 p_dev->resource[0]->end = io->win[i].len;
534 if (!try)
535 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
536 else
537 p_dev->io_lines = 16; 492 p_dev->io_lines = 16;
538 if (p_dev->resource[0]->end + p_dev->resource[1]->end >= 32) 493 return try_io_port(p_dev);
539 return try_io_port(p_dev);
540
541 return -EINVAL;
542} 494}
543 495
544static hw_info_t *pcnet_try_config(struct pcmcia_device *link, 496static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
@@ -560,15 +512,14 @@ static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
560 if (!link->irq) 512 if (!link->irq)
561 return NULL; 513 return NULL;
562 514
563 if (resource_size(link->resource[1]) == 8) { 515 if (resource_size(link->resource[1]) == 8)
564 link->conf.Attributes |= CONF_ENABLE_SPKR; 516 link->config_flags |= CONF_ENABLE_SPKR;
565 link->conf.Status = CCSR_AUDIO_ENA; 517
566 }
567 if ((link->manf_id == MANFID_IBM) && 518 if ((link->manf_id == MANFID_IBM) &&
568 (link->card_id == PRODID_IBM_HOME_AND_AWAY)) 519 (link->card_id == PRODID_IBM_HOME_AND_AWAY))
569 link->conf.ConfigIndex |= 0x10; 520 link->config_index |= 0x10;
570 521
571 ret = pcmcia_request_configuration(link, &link->conf); 522 ret = pcmcia_enable_device(link);
572 if (ret) 523 if (ret)
573 return NULL; 524 return NULL;
574 525
@@ -583,7 +534,7 @@ static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
583 } else 534 } else
584 dev->if_port = 0; 535 dev->if_port = 0;
585 536
586 if ((link->conf.ConfigBase == 0x03c0) && 537 if ((link->config_base == 0x03c0) &&
587 (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) { 538 (link->manf_id == 0x149) && (link->card_id == 0xc1ab)) {
588 dev_info(&link->dev, 539 dev_info(&link->dev,
589 "this is an AX88190 card - use axnet_cs instead.\n"); 540 "this is an AX88190 card - use axnet_cs instead.\n");
@@ -689,14 +640,6 @@ failed:
689 return -ENODEV; 640 return -ENODEV;
690} /* pcnet_config */ 641} /* pcnet_config */
691 642
692/*======================================================================
693
694 After a card is removed, pcnet_release() will unregister the net
695 device, and release the PCMCIA configuration. If the device is
696 still open, this will be postponed until it is closed.
697
698======================================================================*/
699
700static void pcnet_release(struct pcmcia_device *link) 643static void pcnet_release(struct pcmcia_device *link)
701{ 644{
702 pcnet_dev_t *info = PRIV(link->priv); 645 pcnet_dev_t *info = PRIV(link->priv);
@@ -709,15 +652,6 @@ static void pcnet_release(struct pcmcia_device *link)
709 pcmcia_disable_device(link); 652 pcmcia_disable_device(link);
710} 653}
711 654
712/*======================================================================
713
714 The card status event handler. Mostly, this schedules other
715 stuff to run after an event is received. A CARD_REMOVAL event
716 also sets some flags to discourage the net drivers from trying
717 to talk to the card any more.
718
719======================================================================*/
720
721static int pcnet_suspend(struct pcmcia_device *link) 655static int pcnet_suspend(struct pcmcia_device *link)
722{ 656{
723 struct net_device *dev = link->priv; 657 struct net_device *dev = link->priv;
@@ -1486,7 +1420,6 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1486{ 1420{
1487 struct net_device *dev = link->priv; 1421 struct net_device *dev = link->priv;
1488 pcnet_dev_t *info = PRIV(dev); 1422 pcnet_dev_t *info = PRIV(dev);
1489 win_req_t req;
1490 int i, window_size, offset, ret; 1423 int i, window_size, offset, ret;
1491 1424
1492 window_size = (stop_pg - start_pg) << 8; 1425 window_size = (stop_pg - start_pg) << 8;
@@ -1497,22 +1430,22 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1497 window_size = roundup_pow_of_two(window_size); 1430 window_size = roundup_pow_of_two(window_size);
1498 1431
1499 /* Allocate a memory window */ 1432 /* Allocate a memory window */
1500 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE; 1433 link->resource[3]->flags |= WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
1501 req.Attributes |= WIN_USE_WAIT; 1434 link->resource[3]->flags |= WIN_USE_WAIT;
1502 req.Base = 0; req.Size = window_size; 1435 link->resource[3]->start = 0; link->resource[3]->end = window_size;
1503 req.AccessSpeed = mem_speed; 1436 ret = pcmcia_request_window(link, link->resource[3], mem_speed);
1504 ret = pcmcia_request_window(link, &req, &link->win);
1505 if (ret) 1437 if (ret)
1506 goto failed; 1438 goto failed;
1507 1439
1508 offset = (start_pg << 8) + cm_offset; 1440 offset = (start_pg << 8) + cm_offset;
1509 offset -= offset % window_size; 1441 offset -= offset % window_size;
1510 ret = pcmcia_map_mem_page(link, link->win, offset); 1442 ret = pcmcia_map_mem_page(link, link->resource[3], offset);
1511 if (ret) 1443 if (ret)
1512 goto failed; 1444 goto failed;
1513 1445
1514 /* Try scribbling on the buffer */ 1446 /* Try scribbling on the buffer */
1515 info->base = ioremap(req.Base, window_size); 1447 info->base = ioremap(link->resource[3]->start,
1448 resource_size(link->resource[3]));
1516 for (i = 0; i < (TX_PAGES<<8); i += 2) 1449 for (i = 0; i < (TX_PAGES<<8); i += 2)
1517 __raw_writew((i>>1), info->base+offset+i); 1450 __raw_writew((i>>1), info->base+offset+i);
1518 udelay(100); 1451 udelay(100);
@@ -1521,19 +1454,20 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1521 pcnet_reset_8390(dev); 1454 pcnet_reset_8390(dev);
1522 if (i != (TX_PAGES<<8)) { 1455 if (i != (TX_PAGES<<8)) {
1523 iounmap(info->base); 1456 iounmap(info->base);
1524 pcmcia_release_window(link, link->win); 1457 pcmcia_release_window(link, link->resource[3]);
1525 info->base = NULL; link->win = 0; 1458 info->base = NULL;
1526 goto failed; 1459 goto failed;
1527 } 1460 }
1528 1461
1529 ei_status.mem = info->base + offset; 1462 ei_status.mem = info->base + offset;
1530 ei_status.priv = req.Size; 1463 ei_status.priv = resource_size(link->resource[3]);
1531 dev->mem_start = (u_long)ei_status.mem; 1464 dev->mem_start = (u_long)ei_status.mem;
1532 dev->mem_end = dev->mem_start + req.Size; 1465 dev->mem_end = dev->mem_start + resource_size(link->resource[3]);
1533 1466
1534 ei_status.tx_start_page = start_pg; 1467 ei_status.tx_start_page = start_pg;
1535 ei_status.rx_start_page = start_pg + TX_PAGES; 1468 ei_status.rx_start_page = start_pg + TX_PAGES;
1536 ei_status.stop_page = start_pg + ((req.Size - offset) >> 8); 1469 ei_status.stop_page = start_pg + (
1470 (resource_size(link->resource[3]) - offset) >> 8);
1537 1471
1538 /* set up block i/o functions */ 1472 /* set up block i/o functions */
1539 ei_status.get_8390_hdr = &shmem_get_8390_hdr; 1473 ei_status.get_8390_hdr = &shmem_get_8390_hdr;
@@ -1772,9 +1706,7 @@ MODULE_FIRMWARE("cis/PE-200.cis");
1772MODULE_FIRMWARE("cis/tamarack.cis"); 1706MODULE_FIRMWARE("cis/tamarack.cis");
1773 1707
1774static struct pcmcia_driver pcnet_driver = { 1708static struct pcmcia_driver pcnet_driver = {
1775 .drv = { 1709 .name = "pcnet_cs",
1776 .name = "pcnet_cs",
1777 },
1778 .probe = pcnet_probe, 1710 .probe = pcnet_probe,
1779 .remove = pcnet_detach, 1711 .remove = pcnet_detach,
1780 .owner = THIS_MODULE, 1712 .owner = THIS_MODULE,
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 377367d03b41..0af2fc8ec164 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -44,7 +44,6 @@
44#include <linux/jiffies.h> 44#include <linux/jiffies.h>
45#include <linux/firmware.h> 45#include <linux/firmware.h>
46 46
47#include <pcmcia/cs.h>
48#include <pcmcia/cistpl.h> 47#include <pcmcia/cistpl.h>
49#include <pcmcia/cisreg.h> 48#include <pcmcia/cisreg.h>
50#include <pcmcia/ciscode.h> 49#include <pcmcia/ciscode.h>
@@ -300,14 +299,6 @@ static const struct net_device_ops smc_netdev_ops = {
300 .ndo_validate_addr = eth_validate_addr, 299 .ndo_validate_addr = eth_validate_addr,
301}; 300};
302 301
303/*======================================================================
304
305 smc91c92_attach() creates an "instance" of the driver, allocating
306 local data structures for one device. The device is registered
307 with Card Services.
308
309======================================================================*/
310
311static int smc91c92_probe(struct pcmcia_device *link) 302static int smc91c92_probe(struct pcmcia_device *link)
312{ 303{
313 struct smc_private *smc; 304 struct smc_private *smc;
@@ -324,10 +315,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
324 link->priv = dev; 315 link->priv = dev;
325 316
326 spin_lock_init(&smc->lock); 317 spin_lock_init(&smc->lock);
327 link->resource[0]->end = 16;
328 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
329 link->conf.Attributes = CONF_ENABLE_IRQ;
330 link->conf.IntType = INT_MEMORY_AND_IO;
331 318
332 /* The SMC91c92-specific entries in the device structure. */ 319 /* The SMC91c92-specific entries in the device structure. */
333 dev->netdev_ops = &smc_netdev_ops; 320 dev->netdev_ops = &smc_netdev_ops;
@@ -343,15 +330,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
343 return smc91c92_config(link); 330 return smc91c92_config(link);
344} /* smc91c92_attach */ 331} /* smc91c92_attach */
345 332
346/*======================================================================
347
348 This deletes a driver "instance". The device is de-registered
349 with Card Services. If it has been released, all local data
350 structures are freed. Otherwise, the structures will be freed
351 when the device is released.
352
353======================================================================*/
354
355static void smc91c92_detach(struct pcmcia_device *link) 333static void smc91c92_detach(struct pcmcia_device *link)
356{ 334{
357 struct net_device *dev = link->priv; 335 struct net_device *dev = link->priv;
@@ -412,26 +390,28 @@ static int mhz_3288_power(struct pcmcia_device *link)
412 mdelay(200); 390 mdelay(200);
413 391
414 /* Now read and write the COR... */ 392 /* Now read and write the COR... */
415 tmp = readb(smc->base + link->conf.ConfigBase + CISREG_COR); 393 tmp = readb(smc->base + link->config_base + CISREG_COR);
416 udelay(5); 394 udelay(5);
417 writeb(tmp, smc->base + link->conf.ConfigBase + CISREG_COR); 395 writeb(tmp, smc->base + link->config_base + CISREG_COR);
418 396
419 return 0; 397 return 0;
420} 398}
421 399
422static int mhz_mfc_config_check(struct pcmcia_device *p_dev, 400static int mhz_mfc_config_check(struct pcmcia_device *p_dev, void *priv_data)
423 cistpl_cftable_entry_t *cf,
424 cistpl_cftable_entry_t *dflt,
425 unsigned int vcc,
426 void *priv_data)
427{ 401{
428 int k; 402 int k;
429 p_dev->resource[1]->start = cf->io.win[0].base; 403 p_dev->io_lines = 16;
404 p_dev->resource[1]->start = p_dev->resource[0]->start;
405 p_dev->resource[1]->end = 8;
406 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
407 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
408 p_dev->resource[0]->end = 16;
409 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
410 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
430 for (k = 0; k < 0x400; k += 0x10) { 411 for (k = 0; k < 0x400; k += 0x10) {
431 if (k & 0x80) 412 if (k & 0x80)
432 continue; 413 continue;
433 p_dev->resource[0]->start = k ^ 0x300; 414 p_dev->resource[0]->start = k ^ 0x300;
434 p_dev->io_lines = 16;
435 if (!pcmcia_request_io(p_dev)) 415 if (!pcmcia_request_io(p_dev))
436 return 0; 416 return 0;
437 } 417 }
@@ -442,14 +422,11 @@ static int mhz_mfc_config(struct pcmcia_device *link)
442{ 422{
443 struct net_device *dev = link->priv; 423 struct net_device *dev = link->priv;
444 struct smc_private *smc = netdev_priv(dev); 424 struct smc_private *smc = netdev_priv(dev);
445 win_req_t req;
446 unsigned int offset; 425 unsigned int offset;
447 int i; 426 int i;
448 427
449 link->conf.Attributes |= CONF_ENABLE_SPKR; 428 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ |
450 link->conf.Status = CCSR_AUDIO_ENA; 429 CONF_AUTO_SET_IO;
451 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
452 link->resource[1]->end = 8;
453 430
454 /* The Megahertz combo cards have modem-like CIS entries, so 431 /* The Megahertz combo cards have modem-like CIS entries, so
455 we have to explicitly try a bunch of port combinations. */ 432 we have to explicitly try a bunch of port combinations. */
@@ -459,16 +436,16 @@ static int mhz_mfc_config(struct pcmcia_device *link)
459 dev->base_addr = link->resource[0]->start; 436 dev->base_addr = link->resource[0]->start;
460 437
461 /* Allocate a memory window, for accessing the ISR */ 438 /* Allocate a memory window, for accessing the ISR */
462 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 439 link->resource[2]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
463 req.Base = req.Size = 0; 440 link->resource[2]->start = link->resource[2]->end = 0;
464 req.AccessSpeed = 0; 441 i = pcmcia_request_window(link, link->resource[2], 0);
465 i = pcmcia_request_window(link, &req, &link->win);
466 if (i != 0) 442 if (i != 0)
467 return -ENODEV; 443 return -ENODEV;
468 444
469 smc->base = ioremap(req.Base, req.Size); 445 smc->base = ioremap(link->resource[2]->start,
470 offset = (smc->manfid == MANFID_MOTOROLA) ? link->conf.ConfigBase : 0; 446 resource_size(link->resource[2]));
471 i = pcmcia_map_mem_page(link, link->win, offset); 447 offset = (smc->manfid == MANFID_MOTOROLA) ? link->config_base : 0;
448 i = pcmcia_map_mem_page(link, link->resource[2], offset);
472 if ((i == 0) && 449 if ((i == 0) &&
473 (smc->manfid == MANFID_MEGAHERTZ) && 450 (smc->manfid == MANFID_MEGAHERTZ) &&
474 (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 451 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
@@ -591,14 +568,12 @@ static int mot_setup(struct pcmcia_device *link)
591 568
592/*====================================================================*/ 569/*====================================================================*/
593 570
594static int smc_configcheck(struct pcmcia_device *p_dev, 571static int smc_configcheck(struct pcmcia_device *p_dev, void *priv_data)
595 cistpl_cftable_entry_t *cf,
596 cistpl_cftable_entry_t *dflt,
597 unsigned int vcc,
598 void *priv_data)
599{ 572{
600 p_dev->resource[0]->start = cf->io.win[0].base; 573 p_dev->resource[0]->end = 16;
601 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 574 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
575 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
576
602 return pcmcia_request_io(p_dev); 577 return pcmcia_request_io(p_dev);
603} 578}
604 579
@@ -607,7 +582,8 @@ static int smc_config(struct pcmcia_device *link)
607 struct net_device *dev = link->priv; 582 struct net_device *dev = link->priv;
608 int i; 583 int i;
609 584
610 link->resource[0]->end = 16; 585 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
586
611 i = pcmcia_loop_config(link, smc_configcheck, NULL); 587 i = pcmcia_loop_config(link, smc_configcheck, NULL);
612 if (!i) 588 if (!i)
613 dev->base_addr = link->resource[0]->start; 589 dev->base_addr = link->resource[0]->start;
@@ -640,15 +616,14 @@ static int osi_config(struct pcmcia_device *link)
640 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; 616 static const unsigned int com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
641 int i, j; 617 int i, j;
642 618
643 link->conf.Attributes |= CONF_ENABLE_SPKR; 619 link->config_flags |= CONF_ENABLE_SPKR | CONF_ENABLE_IRQ;
644 link->conf.Status = CCSR_AUDIO_ENA;
645 link->resource[0]->end = 64; 620 link->resource[0]->end = 64;
646 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 621 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
647 link->resource[1]->end = 8; 622 link->resource[1]->end = 8;
648 623
649 /* Enable Hard Decode, LAN, Modem */ 624 /* Enable Hard Decode, LAN, Modem */
650 link->conf.ConfigIndex = 0x23;
651 link->io_lines = 16; 625 link->io_lines = 16;
626 link->config_index = 0x23;
652 627
653 for (i = j = 0; j < 4; j++) { 628 for (i = j = 0; j < 4; j++) {
654 link->resource[1]->start = com[j]; 629 link->resource[1]->start = com[j];
@@ -658,7 +633,7 @@ static int osi_config(struct pcmcia_device *link)
658 } 633 }
659 if (i != 0) { 634 if (i != 0) {
660 /* Fallback: turn off hard decode */ 635 /* Fallback: turn off hard decode */
661 link->conf.ConfigIndex = 0x03; 636 link->config_index = 0x03;
662 link->resource[1]->end = 0; 637 link->resource[1]->end = 0;
663 i = pcmcia_request_io(link); 638 i = pcmcia_request_io(link);
664 } 639 }
@@ -817,27 +792,16 @@ static int check_sig(struct pcmcia_device *link)
817 } 792 }
818 793
819 if (width) { 794 if (width) {
820 modconf_t mod = {
821 .Attributes = CONF_IO_CHANGE_WIDTH,
822 };
823 printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); 795 printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n");
824 796
825 smc91c92_suspend(link); 797 smc91c92_suspend(link);
826 pcmcia_modify_configuration(link, &mod); 798 pcmcia_fixup_iowidth(link);
827 smc91c92_resume(link); 799 smc91c92_resume(link);
828 return check_sig(link); 800 return check_sig(link);
829 } 801 }
830 return -ENODEV; 802 return -ENODEV;
831} 803}
832 804
833/*======================================================================
834
835 smc91c92_config() is scheduled to run after a CARD_INSERTION event
836 is received, to configure the PCMCIA socket, and to make the
837 ethernet device available to the system.
838
839======================================================================*/
840
841static int smc91c92_config(struct pcmcia_device *link) 805static int smc91c92_config(struct pcmcia_device *link)
842{ 806{
843 struct net_device *dev = link->priv; 807 struct net_device *dev = link->priv;
@@ -869,7 +833,7 @@ static int smc91c92_config(struct pcmcia_device *link)
869 i = pcmcia_request_irq(link, smc_interrupt); 833 i = pcmcia_request_irq(link, smc_interrupt);
870 if (i) 834 if (i)
871 goto config_failed; 835 goto config_failed;
872 i = pcmcia_request_configuration(link, &link->conf); 836 i = pcmcia_enable_device(link);
873 if (i) 837 if (i)
874 goto config_failed; 838 goto config_failed;
875 839
@@ -988,18 +952,10 @@ config_failed:
988 return -ENODEV; 952 return -ENODEV;
989} /* smc91c92_config */ 953} /* smc91c92_config */
990 954
991/*======================================================================
992
993 After a card is removed, smc91c92_release() will unregister the net
994 device, and release the PCMCIA configuration. If the device is
995 still open, this will be postponed until it is closed.
996
997======================================================================*/
998
999static void smc91c92_release(struct pcmcia_device *link) 955static void smc91c92_release(struct pcmcia_device *link)
1000{ 956{
1001 dev_dbg(&link->dev, "smc91c92_release\n"); 957 dev_dbg(&link->dev, "smc91c92_release\n");
1002 if (link->win) { 958 if (link->resource[2]->end) {
1003 struct net_device *dev = link->priv; 959 struct net_device *dev = link->priv;
1004 struct smc_private *smc = netdev_priv(dev); 960 struct smc_private *smc = netdev_priv(dev);
1005 iounmap(smc->base); 961 iounmap(smc->base);
@@ -2101,9 +2057,7 @@ MODULE_DEVICE_TABLE(pcmcia, smc91c92_ids);
2101 2057
2102static struct pcmcia_driver smc91c92_cs_driver = { 2058static struct pcmcia_driver smc91c92_cs_driver = {
2103 .owner = THIS_MODULE, 2059 .owner = THIS_MODULE,
2104 .drv = { 2060 .name = "smc91c92_cs",
2105 .name = "smc91c92_cs",
2106 },
2107 .probe = smc91c92_probe, 2061 .probe = smc91c92_probe,
2108 .remove = smc91c92_detach, 2062 .remove = smc91c92_detach,
2109 .id_table = smc91c92_ids, 2063 .id_table = smc91c92_ids,
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index f5819526b5ee..1fece617c069 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -82,7 +82,6 @@
82#include <linux/bitops.h> 82#include <linux/bitops.h>
83#include <linux/mii.h> 83#include <linux/mii.h>
84 84
85#include <pcmcia/cs.h>
86#include <pcmcia/cistpl.h> 85#include <pcmcia/cistpl.h>
87#include <pcmcia/cisreg.h> 86#include <pcmcia/cisreg.h>
88#include <pcmcia/ciscode.h> 87#include <pcmcia/ciscode.h>
@@ -267,33 +266,11 @@ static unsigned mii_rd(unsigned int ioaddr, u_char phyaddr, u_char phyreg);
267static void mii_wr(unsigned int ioaddr, u_char phyaddr, u_char phyreg, 266static void mii_wr(unsigned int ioaddr, u_char phyaddr, u_char phyreg,
268 unsigned data, int len); 267 unsigned data, int len);
269 268
270/*
271 * The event() function is this driver's Card Services event handler.
272 * It will be called by Card Services when an appropriate card status
273 * event is received. The config() and release() entry points are
274 * used to configure or release a socket, in response to card insertion
275 * and ejection events. They are invoked from the event handler.
276 */
277
278static int has_ce2_string(struct pcmcia_device * link); 269static int has_ce2_string(struct pcmcia_device * link);
279static int xirc2ps_config(struct pcmcia_device * link); 270static int xirc2ps_config(struct pcmcia_device * link);
280static void xirc2ps_release(struct pcmcia_device * link); 271static void xirc2ps_release(struct pcmcia_device * link);
281
282/****************
283 * The attach() and detach() entry points are used to create and destroy
284 * "instances" of the driver, where each instance represents everything
285 * needed to manage one actual PCMCIA card.
286 */
287
288static void xirc2ps_detach(struct pcmcia_device *p_dev); 272static void xirc2ps_detach(struct pcmcia_device *p_dev);
289 273
290/****************
291 * You'll also need to prototype all the functions that will actually
292 * be used to talk to your device. See 'pcmem_cs' for a good example
293 * of a fully self-sufficient driver; the other drivers rely more or
294 * less on other parts of the kernel.
295 */
296
297static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id); 274static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
298 275
299typedef struct local_info_t { 276typedef struct local_info_t {
@@ -501,16 +478,6 @@ static const struct net_device_ops netdev_ops = {
501 .ndo_validate_addr = eth_validate_addr, 478 .ndo_validate_addr = eth_validate_addr,
502}; 479};
503 480
504/****************
505 * xirc2ps_attach() creates an "instance" of the driver, allocating
506 * local data structures for one device. The device is registered
507 * with Card Services.
508 *
509 * The dev_link structure is initialized, but we don't actually
510 * configure the card at this point -- we wait until we receive a
511 * card insertion event.
512 */
513
514static int 481static int
515xirc2ps_probe(struct pcmcia_device *link) 482xirc2ps_probe(struct pcmcia_device *link)
516{ 483{
@@ -529,9 +496,7 @@ xirc2ps_probe(struct pcmcia_device *link)
529 link->priv = dev; 496 link->priv = dev;
530 497
531 /* General socket configuration */ 498 /* General socket configuration */
532 link->conf.Attributes = CONF_ENABLE_IRQ; 499 link->config_index = 1;
533 link->conf.IntType = INT_MEMORY_AND_IO;
534 link->conf.ConfigIndex = 1;
535 500
536 /* Fill in card specific entries */ 501 /* Fill in card specific entries */
537 dev->netdev_ops = &netdev_ops; 502 dev->netdev_ops = &netdev_ops;
@@ -542,13 +507,6 @@ xirc2ps_probe(struct pcmcia_device *link)
542 return xirc2ps_config(link); 507 return xirc2ps_config(link);
543} /* xirc2ps_attach */ 508} /* xirc2ps_attach */
544 509
545/****************
546 * This deletes a driver "instance". The device is de-registered
547 * with Card Services. If it has been released, all local data
548 * structures are freed. Otherwise, the structures will be freed
549 * when the device is released.
550 */
551
552static void 510static void
553xirc2ps_detach(struct pcmcia_device *link) 511xirc2ps_detach(struct pcmcia_device *link)
554{ 512{
@@ -667,44 +625,53 @@ has_ce2_string(struct pcmcia_device * p_dev)
667} 625}
668 626
669static int 627static int
670xirc2ps_config_modem(struct pcmcia_device *p_dev, 628xirc2ps_config_modem(struct pcmcia_device *p_dev, void *priv_data)
671 cistpl_cftable_entry_t *cf,
672 cistpl_cftable_entry_t *dflt,
673 unsigned int vcc,
674 void *priv_data)
675{ 629{
676 unsigned int ioaddr; 630 unsigned int ioaddr;
677 631
678 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 632 if ((p_dev->resource[0]->start & 0xf) == 8)
679 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 633 return -ENODEV;
680 p_dev->resource[1]->start = cf->io.win[0].base; 634
681 p_dev->resource[0]->start = ioaddr; 635 p_dev->resource[0]->end = 16;
682 if (!pcmcia_request_io(p_dev)) 636 p_dev->resource[1]->end = 8;
683 return 0; 637 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
684 } 638 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
639 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
640 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
641 p_dev->io_lines = 10;
642
643 p_dev->resource[1]->start = p_dev->resource[0]->start;
644 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
645 p_dev->resource[0]->start = ioaddr;
646 if (!pcmcia_request_io(p_dev))
647 return 0;
685 } 648 }
686 return -ENODEV; 649 return -ENODEV;
687} 650}
688 651
689static int 652static int
690xirc2ps_config_check(struct pcmcia_device *p_dev, 653xirc2ps_config_check(struct pcmcia_device *p_dev, void *priv_data)
691 cistpl_cftable_entry_t *cf,
692 cistpl_cftable_entry_t *dflt,
693 unsigned int vcc,
694 void *priv_data)
695{ 654{
696 int *pass = priv_data; 655 int *pass = priv_data;
656 resource_size_t tmp = p_dev->resource[1]->start;
697 657
698 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 658 tmp += (*pass ? (p_dev->config_index & 0x20 ? -24 : 8)
699 p_dev->resource[1]->start = cf->io.win[0].base; 659 : (p_dev->config_index & 0x20 ? 8 : -24));
700 p_dev->resource[0]->start = p_dev->resource[1]->start 660
701 + (*pass ? (cf->index & 0x20 ? -24:8) 661 if ((p_dev->resource[0]->start & 0xf) == 8)
702 : (cf->index & 0x20 ? 8:-24)); 662 return -ENODEV;
703 if (!pcmcia_request_io(p_dev)) 663
704 return 0; 664 p_dev->resource[0]->end = 18;
705 } 665 p_dev->resource[1]->end = 8;
706 return -ENODEV; 666 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
667 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
668 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
669 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
670 p_dev->io_lines = 10;
707 671
672 p_dev->resource[1]->start = p_dev->resource[0]->start;
673 p_dev->resource[0]->start = tmp;
674 return pcmcia_request_io(p_dev);
708} 675}
709 676
710 677
@@ -727,11 +694,6 @@ static int pcmcia_get_mac_ce(struct pcmcia_device *p_dev,
727}; 694};
728 695
729 696
730/****************
731 * xirc2ps_config() is scheduled to run after a CARD_INSERTION event
732 * is received, to configure the PCMCIA socket, and to make the
733 * ethernet device available to the system.
734 */
735static int 697static int
736xirc2ps_config(struct pcmcia_device * link) 698xirc2ps_config(struct pcmcia_device * link)
737{ 699{
@@ -807,32 +769,24 @@ xirc2ps_config(struct pcmcia_device * link)
807 goto failure; 769 goto failure;
808 } 770 }
809 771
810 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
811 link->io_lines = 10;
812 if (local->modem) { 772 if (local->modem) {
813 int pass; 773 int pass;
774 link->config_flags |= CONF_AUTO_SET_IO;
814 775
815 if (do_sound) {
816 link->conf.Attributes |= CONF_ENABLE_SPKR;
817 link->conf.Status |= CCSR_AUDIO_ENA;
818 }
819 link->resource[1]->end = 8;
820 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
821 if (local->dingo) { 776 if (local->dingo) {
822 /* Take the Modem IO port from the CIS and scan for a free 777 /* Take the Modem IO port from the CIS and scan for a free
823 * Ethernet port */ 778 * Ethernet port */
824 link->resource[0]->end = 16; /* no Mako stuff anymore */
825 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) 779 if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL))
826 goto port_found; 780 goto port_found;
827 } else { 781 } else {
828 link->resource[0]->end = 18;
829 /* We do 2 passes here: The first one uses the regular mapping and 782 /* We do 2 passes here: The first one uses the regular mapping and
830 * the second tries again, thereby considering that the 32 ports are 783 * the second tries again, thereby considering that the 32 ports are
831 * mirrored every 32 bytes. Actually we use a mirrored port for 784 * mirrored every 32 bytes. Actually we use a mirrored port for
832 * the Mako if (on the first pass) the COR bit 5 is set. 785 * the Mako if (on the first pass) the COR bit 5 is set.
833 */ 786 */
834 for (pass=0; pass < 2; pass++) 787 for (pass=0; pass < 2; pass++)
835 if (!pcmcia_loop_config(link, xirc2ps_config_check, &pass)) 788 if (!pcmcia_loop_config(link, xirc2ps_config_check,
789 &pass))
836 goto port_found; 790 goto port_found;
837 /* if special option: 791 /* if special option:
838 * try to configure as Ethernet only. 792 * try to configure as Ethernet only.
@@ -840,7 +794,9 @@ xirc2ps_config(struct pcmcia_device * link)
840 } 794 }
841 printk(KNOT_XIRC "no ports available\n"); 795 printk(KNOT_XIRC "no ports available\n");
842 } else { 796 } else {
797 link->io_lines = 10;
843 link->resource[0]->end = 16; 798 link->resource[0]->end = 16;
799 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
844 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 800 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
845 link->resource[0]->start = ioaddr; 801 link->resource[0]->start = ioaddr;
846 if (!(err = pcmcia_request_io(link))) 802 if (!(err = pcmcia_request_io(link)))
@@ -861,16 +817,14 @@ xirc2ps_config(struct pcmcia_device * link)
861 if ((err=pcmcia_request_irq(link, xirc2ps_interrupt))) 817 if ((err=pcmcia_request_irq(link, xirc2ps_interrupt)))
862 goto config_error; 818 goto config_error;
863 819
864 /**************** 820 link->config_flags |= CONF_ENABLE_IRQ;
865 * This actually configures the PCMCIA socket -- setting up 821 if (do_sound)
866 * the I/O windows and the interrupt mapping. 822 link->config_flags |= CONF_ENABLE_SPKR;
867 */ 823
868 if ((err=pcmcia_request_configuration(link, &link->conf))) 824 if ((err = pcmcia_enable_device(link)))
869 goto config_error; 825 goto config_error;
870 826
871 if (local->dingo) { 827 if (local->dingo) {
872 win_req_t req;
873
874 /* Reset the modem's BAR to the correct value 828 /* Reset the modem's BAR to the correct value
875 * This is necessary because in the RequestConfiguration call, 829 * This is necessary because in the RequestConfiguration call,
876 * the base address of the ethernet port (BasePort1) is written 830 * the base address of the ethernet port (BasePort1) is written
@@ -890,14 +844,14 @@ xirc2ps_config(struct pcmcia_device * link)
890 * is at 0x0800. So we allocate a window into the attribute 844 * is at 0x0800. So we allocate a window into the attribute
891 * memory and write direct to the CIS registers 845 * memory and write direct to the CIS registers
892 */ 846 */
893 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 847 link->resource[2]->flags = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM |
894 req.Base = req.Size = 0; 848 WIN_ENABLE;
895 req.AccessSpeed = 0; 849 link->resource[2]->start = link->resource[2]->end = 0;
896 if ((err = pcmcia_request_window(link, &req, &link->win))) 850 if ((err = pcmcia_request_window(link, link->resource[2], 0)))
897 goto config_error; 851 goto config_error;
898 852
899 local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800; 853 local->dingo_ccr = ioremap(link->resource[2]->start, 0x1000) + 0x0800;
900 if ((err = pcmcia_map_mem_page(link, link->win, 0))) 854 if ((err = pcmcia_map_mem_page(link, link->resource[2], 0)))
901 goto config_error; 855 goto config_error;
902 856
903 /* Setup the CCRs; there are no infos in the CIS about the Ethernet 857 /* Setup the CCRs; there are no infos in the CIS about the Ethernet
@@ -978,17 +932,12 @@ xirc2ps_config(struct pcmcia_device * link)
978 return -ENODEV; 932 return -ENODEV;
979} /* xirc2ps_config */ 933} /* xirc2ps_config */
980 934
981/****************
982 * After a card is removed, xirc2ps_release() will unregister the net
983 * device, and release the PCMCIA configuration. If the device is
984 * still open, this will be postponed until it is closed.
985 */
986static void 935static void
987xirc2ps_release(struct pcmcia_device *link) 936xirc2ps_release(struct pcmcia_device *link)
988{ 937{
989 dev_dbg(&link->dev, "release\n"); 938 dev_dbg(&link->dev, "release\n");
990 939
991 if (link->win) { 940 if (link->resource[2]->end) {
992 struct net_device *dev = link->priv; 941 struct net_device *dev = link->priv;
993 local_info_t *local = netdev_priv(dev); 942 local_info_t *local = netdev_priv(dev);
994 if (local->dingo) 943 if (local->dingo)
@@ -1830,9 +1779,7 @@ MODULE_DEVICE_TABLE(pcmcia, xirc2ps_ids);
1830 1779
1831static struct pcmcia_driver xirc2ps_cs_driver = { 1780static struct pcmcia_driver xirc2ps_cs_driver = {
1832 .owner = THIS_MODULE, 1781 .owner = THIS_MODULE,
1833 .drv = { 1782 .name = "xirc2ps_cs",
1834 .name = "xirc2ps_cs",
1835 },
1836 .probe = xirc2ps_probe, 1783 .probe = xirc2ps_probe,
1837 .remove = xirc2ps_detach, 1784 .remove = xirc2ps_detach,
1838 .id_table = xirc2ps_ids, 1785 .id_table = xirc2ps_ids,
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 9a121a5b787c..df2484d45474 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -32,7 +32,6 @@
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/netdevice.h> 33#include <linux/netdevice.h>
34 34
35#include <pcmcia/cs.h>
36#include <pcmcia/cistpl.h> 35#include <pcmcia/cistpl.h>
37#include <pcmcia/cisreg.h> 36#include <pcmcia/cisreg.h>
38#include <pcmcia/ds.h> 37#include <pcmcia/ds.h>
@@ -54,58 +53,21 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
54 53
55/*====================================================================*/ 54/*====================================================================*/
56 55
57/*
58 The event() function is this driver's Card Services event handler.
59 It will be called by Card Services when an appropriate card status
60 event is received. The config() and release() entry points are
61 used to configure or release a socket, in response to card
62 insertion and ejection events. They are invoked from the airo_cs
63 event handler.
64*/
65
66static int airo_config(struct pcmcia_device *link); 56static int airo_config(struct pcmcia_device *link);
67static void airo_release(struct pcmcia_device *link); 57static void airo_release(struct pcmcia_device *link);
68 58
69/*
70 The attach() and detach() entry points are used to create and destroy
71 "instances" of the driver, where each instance represents everything
72 needed to manage one actual PCMCIA card.
73*/
74
75static void airo_detach(struct pcmcia_device *p_dev); 59static void airo_detach(struct pcmcia_device *p_dev);
76 60
77typedef struct local_info_t { 61typedef struct local_info_t {
78 struct net_device *eth_dev; 62 struct net_device *eth_dev;
79} local_info_t; 63} local_info_t;
80 64
81/*======================================================================
82
83 airo_attach() creates an "instance" of the driver, allocating
84 local data structures for one device. The device is registered
85 with Card Services.
86
87 The dev_link structure is initialized, but we don't actually
88 configure the card at this point -- we wait until we receive a
89 card insertion event.
90
91 ======================================================================*/
92
93static int airo_probe(struct pcmcia_device *p_dev) 65static int airo_probe(struct pcmcia_device *p_dev)
94{ 66{
95 local_info_t *local; 67 local_info_t *local;
96 68
97 dev_dbg(&p_dev->dev, "airo_attach()\n"); 69 dev_dbg(&p_dev->dev, "airo_attach()\n");
98 70
99 /*
100 General socket configuration defaults can go here. In this
101 client, we assume very little, and rely on the CIS for almost
102 everything. In most clients, many details (i.e., number, sizes,
103 and attributes of IO windows) are fixed by the nature of the
104 device, and can be hard-wired here.
105 */
106 p_dev->conf.Attributes = 0;
107 p_dev->conf.IntType = INT_MEMORY_AND_IO;
108
109 /* Allocate space for private device-specific data */ 71 /* Allocate space for private device-specific data */
110 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 72 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
111 if (!local) { 73 if (!local) {
@@ -117,15 +79,6 @@ static int airo_probe(struct pcmcia_device *p_dev)
117 return airo_config(p_dev); 79 return airo_config(p_dev);
118} /* airo_attach */ 80} /* airo_attach */
119 81
120/*======================================================================
121
122 This deletes a driver "instance". The device is de-registered
123 with Card Services. If it has been released, all local data
124 structures are freed. Otherwise, the structures will be freed
125 when the device is released.
126
127 ======================================================================*/
128
129static void airo_detach(struct pcmcia_device *link) 82static void airo_detach(struct pcmcia_device *link)
130{ 83{
131 dev_dbg(&link->dev, "airo_detach\n"); 84 dev_dbg(&link->dev, "airo_detach\n");
@@ -140,60 +93,12 @@ static void airo_detach(struct pcmcia_device *link)
140 kfree(link->priv); 93 kfree(link->priv);
141} /* airo_detach */ 94} /* airo_detach */
142 95
143/*====================================================================== 96static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
144
145 airo_config() is scheduled to run after a CARD_INSERTION event
146 is received, to configure the PCMCIA socket, and to make the
147 device available to the system.
148
149 ======================================================================*/
150
151static int airo_cs_config_check(struct pcmcia_device *p_dev,
152 cistpl_cftable_entry_t *cfg,
153 cistpl_cftable_entry_t *dflt,
154 unsigned int vcc,
155 void *priv_data)
156{ 97{
157 if (cfg->index == 0) 98 if (p_dev->config_index == 0)
158 return -ENODEV; 99 return -EINVAL;
159
160 /* Does this card need audio output? */
161 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
162 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
163 p_dev->conf.Status = CCSR_AUDIO_ENA;
164 }
165
166 /* Use power settings for Vcc and Vpp if present */
167 /* Note that the CIS values need to be rescaled */
168 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
169 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
170 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
171 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
172
173 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
174
175 /* IO window settings */
176 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
177 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
178 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
179 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
180 p_dev->resource[0]->flags |=
181 pcmcia_io_cfg_data_width(io->flags);
182 p_dev->resource[0]->start = io->win[0].base;
183 p_dev->resource[0]->end = io->win[0].len;
184 if (io->nwin > 1) {
185 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
186 p_dev->resource[1]->start = io->win[1].base;
187 p_dev->resource[1]->end = io->win[1].len;
188 }
189 }
190 100
191 /* This reserves IO space but doesn't actually enable it */ 101 return pcmcia_request_io(p_dev);
192 if (pcmcia_request_io(p_dev) != 0)
193 return -ENODEV;
194
195 /* If we got this far, we're cool! */
196 return 0;
197} 102}
198 103
199 104
@@ -206,20 +111,9 @@ static int airo_config(struct pcmcia_device *link)
206 111
207 dev_dbg(&link->dev, "airo_config\n"); 112 dev_dbg(&link->dev, "airo_config\n");
208 113
209 /* 114 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
210 * In this loop, we scan the CIS for configuration table 115 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
211 * entries, each of which describes a valid card 116
212 * configuration, including voltage, IO window, memory window,
213 * and interrupt settings.
214 *
215 * We make no assumptions about the card to be configured: we
216 * use just the information available in the CIS. In an ideal
217 * world, this would work for any PCMCIA card, but it requires
218 * a complete and accurate CIS. In practice, a driver usually
219 * "knows" most of these things without consulting the CIS,
220 * and most client drivers will only use the CIS to fill in
221 * implementation-defined details.
222 */
223 ret = pcmcia_loop_config(link, airo_cs_config_check, NULL); 117 ret = pcmcia_loop_config(link, airo_cs_config_check, NULL);
224 if (ret) 118 if (ret)
225 goto failed; 119 goto failed;
@@ -227,12 +121,7 @@ static int airo_config(struct pcmcia_device *link)
227 if (!link->irq) 121 if (!link->irq)
228 goto failed; 122 goto failed;
229 123
230 /* 124 ret = pcmcia_enable_device(link);
231 This actually configures the PCMCIA socket -- setting up
232 the I/O windows and the interrupt mapping, and putting the
233 card and host interface into "Memory and IO" mode.
234 */
235 ret = pcmcia_request_configuration(link, &link->conf);
236 if (ret) 125 if (ret)
237 goto failed; 126 goto failed;
238 ((local_info_t *)link->priv)->eth_dev = 127 ((local_info_t *)link->priv)->eth_dev =
@@ -241,17 +130,6 @@ static int airo_config(struct pcmcia_device *link)
241 if (!((local_info_t *)link->priv)->eth_dev) 130 if (!((local_info_t *)link->priv)->eth_dev)
242 goto failed; 131 goto failed;
243 132
244 /* Finally, report what we've done */
245 dev_info(&link->dev, "index 0x%02x: ",
246 link->conf.ConfigIndex);
247 if (link->conf.Vpp)
248 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
249 printk(", irq %d", link->irq);
250 if (link->resource[0])
251 printk(" & %pR", link->resource[0]);
252 if (link->resource[1])
253 printk(" & %pR", link->resource[1]);
254 printk("\n");
255 return 0; 133 return 0;
256 134
257 failed: 135 failed:
@@ -259,14 +137,6 @@ static int airo_config(struct pcmcia_device *link)
259 return -ENODEV; 137 return -ENODEV;
260} /* airo_config */ 138} /* airo_config */
261 139
262/*======================================================================
263
264 After a card is removed, airo_release() will unregister the
265 device, and release the PCMCIA configuration. If the device is
266 still open, this will be postponed until it is closed.
267
268 ======================================================================*/
269
270static void airo_release(struct pcmcia_device *link) 140static void airo_release(struct pcmcia_device *link)
271{ 141{
272 dev_dbg(&link->dev, "airo_release\n"); 142 dev_dbg(&link->dev, "airo_release\n");
@@ -305,9 +175,7 @@ MODULE_DEVICE_TABLE(pcmcia, airo_ids);
305 175
306static struct pcmcia_driver airo_driver = { 176static struct pcmcia_driver airo_driver = {
307 .owner = THIS_MODULE, 177 .owner = THIS_MODULE,
308 .drv = { 178 .name = "airo_cs",
309 .name = "airo_cs",
310 },
311 .probe = airo_probe, 179 .probe = airo_probe,
312 .remove = airo_detach, 180 .remove = airo_detach,
313 .id_table = airo_ids, 181 .id_table = airo_ids,
@@ -315,12 +183,12 @@ static struct pcmcia_driver airo_driver = {
315 .resume = airo_resume, 183 .resume = airo_resume,
316}; 184};
317 185
318static int airo_cs_init(void) 186static int __init airo_cs_init(void)
319{ 187{
320 return pcmcia_register_driver(&airo_driver); 188 return pcmcia_register_driver(&airo_driver);
321} 189}
322 190
323static void airo_cs_cleanup(void) 191static void __exit airo_cs_cleanup(void)
324{ 192{
325 pcmcia_unregister_driver(&airo_driver); 193 pcmcia_unregister_driver(&airo_driver);
326} 194}
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 3b632161c106..c96e19da2949 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -42,7 +42,6 @@
42#include <linux/moduleparam.h> 42#include <linux/moduleparam.h>
43#include <linux/device.h> 43#include <linux/device.h>
44 44
45#include <pcmcia/cs.h>
46#include <pcmcia/cistpl.h> 45#include <pcmcia/cistpl.h>
47#include <pcmcia/cisreg.h> 46#include <pcmcia/cisreg.h>
48#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
@@ -64,58 +63,21 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
64 63
65/*====================================================================*/ 64/*====================================================================*/
66 65
67/*
68 The event() function is this driver's Card Services event handler.
69 It will be called by Card Services when an appropriate card status
70 event is received. The config() and release() entry points are
71 used to configure or release a socket, in response to card
72 insertion and ejection events. They are invoked from the atmel_cs
73 event handler.
74*/
75
76static int atmel_config(struct pcmcia_device *link); 66static int atmel_config(struct pcmcia_device *link);
77static void atmel_release(struct pcmcia_device *link); 67static void atmel_release(struct pcmcia_device *link);
78 68
79/*
80 The attach() and detach() entry points are used to create and destroy
81 "instances" of the driver, where each instance represents everything
82 needed to manage one actual PCMCIA card.
83*/
84
85static void atmel_detach(struct pcmcia_device *p_dev); 69static void atmel_detach(struct pcmcia_device *p_dev);
86 70
87typedef struct local_info_t { 71typedef struct local_info_t {
88 struct net_device *eth_dev; 72 struct net_device *eth_dev;
89} local_info_t; 73} local_info_t;
90 74
91/*======================================================================
92
93 atmel_attach() creates an "instance" of the driver, allocating
94 local data structures for one device. The device is registered
95 with Card Services.
96
97 The dev_link structure is initialized, but we don't actually
98 configure the card at this point -- we wait until we receive a
99 card insertion event.
100
101 ======================================================================*/
102
103static int atmel_probe(struct pcmcia_device *p_dev) 75static int atmel_probe(struct pcmcia_device *p_dev)
104{ 76{
105 local_info_t *local; 77 local_info_t *local;
106 78
107 dev_dbg(&p_dev->dev, "atmel_attach()\n"); 79 dev_dbg(&p_dev->dev, "atmel_attach()\n");
108 80
109 /*
110 General socket configuration defaults can go here. In this
111 client, we assume very little, and rely on the CIS for almost
112 everything. In most clients, many details (i.e., number, sizes,
113 and attributes of IO windows) are fixed by the nature of the
114 device, and can be hard-wired here.
115 */
116 p_dev->conf.Attributes = 0;
117 p_dev->conf.IntType = INT_MEMORY_AND_IO;
118
119 /* Allocate space for private device-specific data */ 81 /* Allocate space for private device-specific data */
120 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 82 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
121 if (!local) { 83 if (!local) {
@@ -127,15 +89,6 @@ static int atmel_probe(struct pcmcia_device *p_dev)
127 return atmel_config(p_dev); 89 return atmel_config(p_dev);
128} /* atmel_attach */ 90} /* atmel_attach */
129 91
130/*======================================================================
131
132 This deletes a driver "instance". The device is de-registered
133 with Card Services. If it has been released, all local data
134 structures are freed. Otherwise, the structures will be freed
135 when the device is released.
136
137 ======================================================================*/
138
139static void atmel_detach(struct pcmcia_device *link) 92static void atmel_detach(struct pcmcia_device *link)
140{ 93{
141 dev_dbg(&link->dev, "atmel_detach\n"); 94 dev_dbg(&link->dev, "atmel_detach\n");
@@ -145,14 +98,6 @@ static void atmel_detach(struct pcmcia_device *link)
145 kfree(link->priv); 98 kfree(link->priv);
146} 99}
147 100
148/*======================================================================
149
150 atmel_config() is scheduled to run after a CARD_INSERTION event
151 is received, to configure the PCMCIA socket, and to make the
152 device available to the system.
153
154 ======================================================================*/
155
156/* Call-back function to interrogate PCMCIA-specific information 101/* Call-back function to interrogate PCMCIA-specific information
157 about the current existance of the card */ 102 about the current existance of the card */
158static int card_present(void *arg) 103static int card_present(void *arg)
@@ -165,47 +110,11 @@ static int card_present(void *arg)
165 return 0; 110 return 0;
166} 111}
167 112
168static int atmel_config_check(struct pcmcia_device *p_dev, 113static int atmel_config_check(struct pcmcia_device *p_dev, void *priv_data)
169 cistpl_cftable_entry_t *cfg,
170 cistpl_cftable_entry_t *dflt,
171 unsigned int vcc,
172 void *priv_data)
173{ 114{
174 if (cfg->index == 0) 115 if (p_dev->config_index == 0)
175 return -ENODEV; 116 return -EINVAL;
176
177 /* Does this card need audio output? */
178 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
179 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
180 p_dev->conf.Status = CCSR_AUDIO_ENA;
181 }
182 117
183 /* Use power settings for Vcc and Vpp if present */
184 /* Note that the CIS values need to be rescaled */
185 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
186 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
187 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
188 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
189
190 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
191
192 /* IO window settings */
193 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
194 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
195 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
196 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
197 p_dev->resource[0]->flags |=
198 pcmcia_io_cfg_data_width(io->flags);
199 p_dev->resource[0]->start = io->win[0].base;
200 p_dev->resource[0]->end = io->win[0].len;
201 if (io->nwin > 1) {
202 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
203 p_dev->resource[1]->start = io->win[1].base;
204 p_dev->resource[1]->end = io->win[1].len;
205 }
206 }
207
208 /* This reserves IO space but doesn't actually enable it */
209 return pcmcia_request_io(p_dev); 118 return pcmcia_request_io(p_dev);
210} 119}
211 120
@@ -220,18 +129,9 @@ static int atmel_config(struct pcmcia_device *link)
220 129
221 dev_dbg(&link->dev, "atmel_config\n"); 130 dev_dbg(&link->dev, "atmel_config\n");
222 131
223 /* 132 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
224 In this loop, we scan the CIS for configuration table entries, 133 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
225 each of which describes a valid card configuration, including 134
226 voltage, IO window, memory window, and interrupt settings.
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 */
235 if (pcmcia_loop_config(link, atmel_config_check, NULL)) 135 if (pcmcia_loop_config(link, atmel_config_check, NULL))
236 goto failed; 136 goto failed;
237 137
@@ -240,12 +140,7 @@ static int atmel_config(struct pcmcia_device *link)
240 goto failed; 140 goto failed;
241 } 141 }
242 142
243 /* 143 ret = pcmcia_enable_device(link);
244 This actually configures the PCMCIA socket -- setting up
245 the I/O windows and the interrupt mapping, and putting the
246 card and host interface into "Memory and IO" mode.
247 */
248 ret = pcmcia_request_configuration(link, &link->conf);
249 if (ret) 144 if (ret)
250 goto failed; 145 goto failed;
251 146
@@ -267,14 +162,6 @@ static int atmel_config(struct pcmcia_device *link)
267 return -ENODEV; 162 return -ENODEV;
268} 163}
269 164
270/*======================================================================
271
272 After a card is removed, atmel_release() will unregister the
273 device, and release the PCMCIA configuration. If the device is
274 still open, this will be postponed until it is closed.
275
276 ======================================================================*/
277
278static void atmel_release(struct pcmcia_device *link) 165static void atmel_release(struct pcmcia_device *link)
279{ 166{
280 struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; 167 struct net_device *dev = ((local_info_t*)link->priv)->eth_dev;
@@ -353,9 +240,7 @@ MODULE_DEVICE_TABLE(pcmcia, atmel_ids);
353 240
354static struct pcmcia_driver atmel_driver = { 241static struct pcmcia_driver atmel_driver = {
355 .owner = THIS_MODULE, 242 .owner = THIS_MODULE,
356 .drv = { 243 .name = "atmel_cs",
357 .name = "atmel_cs",
358 },
359 .probe = atmel_probe, 244 .probe = atmel_probe,
360 .remove = atmel_detach, 245 .remove = atmel_detach,
361 .id_table = atmel_ids, 246 .id_table = atmel_ids,
@@ -363,12 +248,12 @@ static struct pcmcia_driver atmel_driver = {
363 .resume = atmel_resume, 248 .resume = atmel_resume,
364}; 249};
365 250
366static int atmel_cs_init(void) 251static int __init atmel_cs_init(void)
367{ 252{
368 return pcmcia_register_driver(&atmel_driver); 253 return pcmcia_register_driver(&atmel_driver);
369} 254}
370 255
371static void atmel_cs_cleanup(void) 256static void __exit atmel_cs_cleanup(void)
372{ 257{
373 pcmcia_unregister_driver(&atmel_driver); 258 pcmcia_unregister_driver(&atmel_driver);
374} 259}
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index dfbc41d431ff..7dcba5fafdc7 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -26,7 +26,6 @@
26#include <linux/ssb/ssb.h> 26#include <linux/ssb/ssb.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28 28
29#include <pcmcia/cs.h>
30#include <pcmcia/cistpl.h> 29#include <pcmcia/cistpl.h>
31#include <pcmcia/ciscode.h> 30#include <pcmcia/ciscode.h>
32#include <pcmcia/ds.h> 31#include <pcmcia/ds.h>
@@ -63,7 +62,6 @@ static int b43_pcmcia_resume(struct pcmcia_device *dev)
63static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) 62static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
64{ 63{
65 struct ssb_bus *ssb; 64 struct ssb_bus *ssb;
66 win_req_t win;
67 int err = -ENOMEM; 65 int err = -ENOMEM;
68 int res = 0; 66 int res = 0;
69 67
@@ -73,30 +71,28 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
73 71
74 err = -ENODEV; 72 err = -ENODEV;
75 73
76 dev->conf.Attributes = CONF_ENABLE_IRQ; 74 dev->config_flags |= CONF_ENABLE_IRQ;
77 dev->conf.IntType = INT_MEMORY_AND_IO;
78 75
79 win.Attributes = WIN_ENABLE | WIN_DATA_WIDTH_16 | 76 dev->resource[2]->flags |= WIN_ENABLE | WIN_DATA_WIDTH_16 |
80 WIN_USE_WAIT; 77 WIN_USE_WAIT;
81 win.Base = 0; 78 dev->resource[2]->start = 0;
82 win.Size = SSB_CORE_SIZE; 79 dev->resource[2]->end = SSB_CORE_SIZE;
83 win.AccessSpeed = 250; 80 res = pcmcia_request_window(dev, dev->resource[2], 250);
84 res = pcmcia_request_window(dev, &win, &dev->win);
85 if (res != 0) 81 if (res != 0)
86 goto err_kfree_ssb; 82 goto err_kfree_ssb;
87 83
88 res = pcmcia_map_mem_page(dev, dev->win, 0); 84 res = pcmcia_map_mem_page(dev, dev->resource[2], 0);
89 if (res != 0) 85 if (res != 0)
90 goto err_disable; 86 goto err_disable;
91 87
92 if (!dev->irq) 88 if (!dev->irq)
93 goto err_disable; 89 goto err_disable;
94 90
95 res = pcmcia_request_configuration(dev, &dev->conf); 91 res = pcmcia_enable_device(dev);
96 if (res != 0) 92 if (res != 0)
97 goto err_disable; 93 goto err_disable;
98 94
99 err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); 95 err = ssb_bus_pcmciabus_register(ssb, dev, dev->resource[2]->start);
100 if (err) 96 if (err)
101 goto err_disable; 97 goto err_disable;
102 dev->priv = ssb; 98 dev->priv = ssb;
@@ -125,9 +121,7 @@ static void __devexit b43_pcmcia_remove(struct pcmcia_device *dev)
125 121
126static struct pcmcia_driver b43_pcmcia_driver = { 122static struct pcmcia_driver b43_pcmcia_driver = {
127 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
128 .drv = { 124 .name = "b43-pcmcia",
129 .name = "b43-pcmcia",
130 },
131 .id_table = b43_pcmcia_tbl, 125 .id_table = b43_pcmcia_tbl,
132 .probe = b43_pcmcia_probe, 126 .probe = b43_pcmcia_probe,
133 .remove = __devexit_p(b43_pcmcia_remove), 127 .remove = __devexit_p(b43_pcmcia_remove),
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index ba54d1b04d22..bd8a4134edeb 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -12,7 +12,6 @@
12#include <linux/wireless.h> 12#include <linux/wireless.h>
13#include <net/iw_handler.h> 13#include <net/iw_handler.h>
14 14
15#include <pcmcia/cs.h>
16#include <pcmcia/cistpl.h> 15#include <pcmcia/cistpl.h>
17#include <pcmcia/cisreg.h> 16#include <pcmcia/cisreg.h>
18#include <pcmcia/ds.h> 17#include <pcmcia/ds.h>
@@ -437,7 +436,6 @@ static int hostap_cs_probe(struct pcmcia_device *p_dev)
437 int ret; 436 int ret;
438 437
439 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 438 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
440 p_dev->conf.IntType = INT_MEMORY_AND_IO;
441 439
442 ret = prism2_config(p_dev); 440 ret = prism2_config(p_dev);
443 if (ret) { 441 if (ret) {
@@ -468,74 +466,11 @@ static void prism2_detach(struct pcmcia_device *link)
468} 466}
469 467
470 468
471/* run after a CARD_INSERTION event is received to configure the PCMCIA 469static int prism2_config_check(struct pcmcia_device *p_dev, void *priv_data)
472 * socket and make the device available to the system */
473
474static int prism2_config_check(struct pcmcia_device *p_dev,
475 cistpl_cftable_entry_t *cfg,
476 cistpl_cftable_entry_t *dflt,
477 unsigned int vcc,
478 void *priv_data)
479{ 470{
480 if (cfg->index == 0) 471 if (p_dev->config_index == 0)
481 return -ENODEV; 472 return -EINVAL;
482
483 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
484 "(default 0x%02X)\n", cfg->index, dflt->index);
485
486 /* Does this card need audio output? */
487 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
488 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
489 p_dev->conf.Status = CCSR_AUDIO_ENA;
490 }
491
492 /* Use power settings for Vcc and Vpp if present */
493 /* Note that the CIS values need to be rescaled */
494 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
495 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
496 10000 && !ignore_cis_vcc) {
497 PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
498 " this entry\n");
499 return -ENODEV;
500 }
501 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
502 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] /
503 10000 && !ignore_cis_vcc) {
504 PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
505 "- skipping this entry\n");
506 return -ENODEV;
507 }
508 }
509 473
510 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
511 p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
512 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
513 p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
514
515 /* Do we need to allocate an interrupt? */
516 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
517
518 /* IO window settings */
519 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
520 "dflt->io.nwin=%d\n",
521 cfg->io.nwin, dflt->io.nwin);
522 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
523 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
524 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
525 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
526 p_dev->resource[0]->flags |=
527 pcmcia_io_cfg_data_width(io->flags);
528 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
529 p_dev->resource[0]->start = io->win[0].base;
530 p_dev->resource[0]->end = io->win[0].len;
531 if (io->nwin > 1) {
532 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
533 p_dev->resource[1]->start = io->win[1].base;
534 p_dev->resource[1]->end = io->win[1].len;
535 }
536 }
537
538 /* This reserves IO space but doesn't actually enable it */
539 return pcmcia_request_io(p_dev); 474 return pcmcia_request_io(p_dev);
540} 475}
541 476
@@ -557,6 +492,10 @@ static int prism2_config(struct pcmcia_device *link)
557 } 492 }
558 493
559 /* Look for an appropriate configuration table entry in the CIS */ 494 /* Look for an appropriate configuration table entry in the CIS */
495 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO |
496 CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
497 if (ignore_cis_vcc)
498 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
560 ret = pcmcia_loop_config(link, prism2_config_check, NULL); 499 ret = pcmcia_loop_config(link, prism2_config_check, NULL);
561 if (ret) { 500 if (ret) {
562 if (!ignore_cis_vcc) 501 if (!ignore_cis_vcc)
@@ -588,12 +527,7 @@ static int prism2_config(struct pcmcia_device *link)
588 if (ret) 527 if (ret)
589 goto failed_unlock; 528 goto failed_unlock;
590 529
591 /* 530 ret = pcmcia_enable_device(link);
592 * This actually configures the PCMCIA socket -- setting up
593 * the I/O windows and the interrupt mapping, and putting the
594 * card and host interface into "Memory and IO" mode.
595 */
596 ret = pcmcia_request_configuration(link, &link->conf);
597 if (ret) 531 if (ret)
598 goto failed_unlock; 532 goto failed_unlock;
599 533
@@ -602,20 +536,6 @@ static int prism2_config(struct pcmcia_device *link)
602 536
603 spin_unlock_irqrestore(&local->irq_init_lock, flags); 537 spin_unlock_irqrestore(&local->irq_init_lock, flags);
604 538
605 /* Finally, report what we've done */
606 printk(KERN_INFO "%s: index 0x%02x: ",
607 dev_info, link->conf.ConfigIndex);
608 if (link->conf.Vpp)
609 printk(", Vpp %d.%d", link->conf.Vpp / 10,
610 link->conf.Vpp % 10);
611 if (link->conf.Attributes & CONF_ENABLE_IRQ)
612 printk(", irq %d", link->irq);
613 if (link->resource[0])
614 printk(" & %pR", link->resource[0]);
615 if (link->resource[1])
616 printk(" & %pR", link->resource[1]);
617 printk("\n");
618
619 local->shutdown = 0; 539 local->shutdown = 0;
620 540
621 sandisk_enable_wireless(dev); 541 sandisk_enable_wireless(dev);
@@ -627,7 +547,7 @@ static int prism2_config(struct pcmcia_device *link)
627 return ret; 547 return ret;
628 548
629 failed_unlock: 549 failed_unlock:
630 spin_unlock_irqrestore(&local->irq_init_lock, flags); 550 spin_unlock_irqrestore(&local->irq_init_lock, flags);
631 failed: 551 failed:
632 kfree(hw_priv); 552 kfree(hw_priv);
633 prism2_release((u_long)link); 553 prism2_release((u_long)link);
@@ -779,9 +699,7 @@ MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
779 699
780 700
781static struct pcmcia_driver hostap_driver = { 701static struct pcmcia_driver hostap_driver = {
782 .drv = { 702 .name = "hostap_cs",
783 .name = "hostap_cs",
784 },
785 .probe = hostap_cs_probe, 703 .probe = hostap_cs_probe,
786 .remove = prism2_detach, 704 .remove = prism2_detach,
787 .owner = THIS_MODULE, 705 .owner = THIS_MODULE,
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 9c298396be50..ff1280f41336 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -28,7 +28,6 @@
28#include <linux/firmware.h> 28#include <linux/firmware.h>
29#include <linux/netdevice.h> 29#include <linux/netdevice.h>
30 30
31#include <pcmcia/cs.h>
32#include <pcmcia/cistpl.h> 31#include <pcmcia/cistpl.h>
33#include <pcmcia/ds.h> 32#include <pcmcia/ds.h>
34 33
@@ -761,15 +760,6 @@ static int if_cs_host_to_card(struct lbs_private *priv,
761} 760}
762 761
763 762
764/********************************************************************/
765/* Card Services */
766/********************************************************************/
767
768/*
769 * After a card is removed, if_cs_release() will unregister the
770 * device, and release the PCMCIA configuration. If the device is
771 * still open, this will be postponed until it is closed.
772 */
773static void if_cs_release(struct pcmcia_device *p_dev) 763static void if_cs_release(struct pcmcia_device *p_dev)
774{ 764{
775 struct if_cs_card *card = p_dev->priv; 765 struct if_cs_card *card = p_dev->priv;
@@ -785,31 +775,12 @@ static void if_cs_release(struct pcmcia_device *p_dev)
785} 775}
786 776
787 777
788/* 778static int if_cs_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
789 * This creates an "instance" of the driver, allocating local data
790 * structures for one device. The device is registered with Card
791 * Services.
792 *
793 * The dev_link structure is initialized, but we don't actually
794 * configure the card at this point -- we wait until we receive a card
795 * insertion event.
796 */
797
798static int if_cs_ioprobe(struct pcmcia_device *p_dev,
799 cistpl_cftable_entry_t *cfg,
800 cistpl_cftable_entry_t *dflt,
801 unsigned int vcc,
802 void *priv_data)
803{ 779{
780 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
804 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 781 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
805 p_dev->resource[0]->start = cfg->io.win[0].base;
806 p_dev->resource[0]->end = cfg->io.win[0].len;
807
808 /* Do we need to allocate an interrupt? */
809 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
810 782
811 /* IO window settings */ 783 if (p_dev->resource[1]->end) {
812 if (cfg->io.nwin != 1) {
813 lbs_pr_err("wrong CIS (check number of IO windows)\n"); 784 lbs_pr_err("wrong CIS (check number of IO windows)\n");
814 return -ENODEV; 785 return -ENODEV;
815 } 786 }
@@ -835,15 +806,13 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
835 card->p_dev = p_dev; 806 card->p_dev = p_dev;
836 p_dev->priv = card; 807 p_dev->priv = card;
837 808
838 p_dev->conf.Attributes = 0; 809 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
839 p_dev->conf.IntType = INT_MEMORY_AND_IO;
840 810
841 if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) { 811 if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) {
842 lbs_pr_err("error in pcmcia_loop_config\n"); 812 lbs_pr_err("error in pcmcia_loop_config\n");
843 goto out1; 813 goto out1;
844 } 814 }
845 815
846
847 /* 816 /*
848 * Allocate an interrupt line. Note that this does not assign 817 * Allocate an interrupt line. Note that this does not assign
849 * a handler to the interrupt, unless the 'Handler' member of 818 * a handler to the interrupt, unless the 'Handler' member of
@@ -861,14 +830,9 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
861 goto out1; 830 goto out1;
862 } 831 }
863 832
864 /* 833 ret = pcmcia_enable_device(p_dev);
865 * This actually configures the PCMCIA socket -- setting up
866 * the I/O windows and the interrupt mapping, and putting the
867 * card and host interface into "Memory and IO" mode.
868 */
869 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
870 if (ret) { 834 if (ret) {
871 lbs_pr_err("error in pcmcia_request_configuration\n"); 835 lbs_pr_err("error in pcmcia_enable_device\n");
872 goto out2; 836 goto out2;
873 } 837 }
874 838
@@ -962,12 +926,6 @@ out:
962} 926}
963 927
964 928
965/*
966 * This deletes a driver "instance". The device is de-registered with
967 * Card Services. If it has been released, all local data structures
968 * are freed. Otherwise, the structures will be freed when the device
969 * is released.
970 */
971static void if_cs_detach(struct pcmcia_device *p_dev) 929static void if_cs_detach(struct pcmcia_device *p_dev)
972{ 930{
973 struct if_cs_card *card = p_dev->priv; 931 struct if_cs_card *card = p_dev->priv;
@@ -1000,9 +958,7 @@ MODULE_DEVICE_TABLE(pcmcia, if_cs_ids);
1000 958
1001static struct pcmcia_driver lbs_driver = { 959static struct pcmcia_driver lbs_driver = {
1002 .owner = THIS_MODULE, 960 .owner = THIS_MODULE,
1003 .drv = { 961 .name = DRV_NAME,
1004 .name = DRV_NAME,
1005 },
1006 .probe = if_cs_probe, 962 .probe = if_cs_probe,
1007 .remove = if_cs_detach, 963 .remove = if_cs_detach,
1008 .id_table = if_cs_ids, 964 .id_table = if_cs_ids,
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index ef46a2d88539..71b3d68b9403 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -17,7 +17,6 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <pcmcia/cs.h>
21#include <pcmcia/cistpl.h> 20#include <pcmcia/cistpl.h>
22#include <pcmcia/cisreg.h> 21#include <pcmcia/cisreg.h>
23#include <pcmcia/ds.h> 22#include <pcmcia/ds.h>
@@ -93,14 +92,6 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
93/* PCMCIA stuff */ 92/* PCMCIA stuff */
94/********************************************************************/ 93/********************************************************************/
95 94
96/*
97 * This creates an "instance" of the driver, allocating local data
98 * structures for one device. The device is registered with Card
99 * Services.
100 *
101 * The dev_link structure is initialized, but we don't actually
102 * configure the card at this point -- we wait until we receive a card
103 * insertion event. */
104static int 95static int
105orinoco_cs_probe(struct pcmcia_device *link) 96orinoco_cs_probe(struct pcmcia_device *link)
106{ 97{
@@ -117,23 +108,9 @@ orinoco_cs_probe(struct pcmcia_device *link)
117 card->p_dev = link; 108 card->p_dev = link;
118 link->priv = priv; 109 link->priv = priv;
119 110
120 /* General socket configuration defaults can go here. In this
121 * client, we assume very little, and rely on the CIS for
122 * almost everything. In most clients, many details (i.e.,
123 * number, sizes, and attributes of IO windows) are fixed by
124 * the nature of the device, and can be hard-wired here. */
125 link->conf.Attributes = 0;
126 link->conf.IntType = INT_MEMORY_AND_IO;
127
128 return orinoco_cs_config(link); 111 return orinoco_cs_config(link);
129} /* orinoco_cs_attach */ 112} /* orinoco_cs_attach */
130 113
131/*
132 * This deletes a driver "instance". The device is de-registered with
133 * Card Services. If it has been released, all local data structures
134 * are freed. Otherwise, the structures will be freed when the device
135 * is released.
136 */
137static void orinoco_cs_detach(struct pcmcia_device *link) 114static void orinoco_cs_detach(struct pcmcia_device *link)
138{ 115{
139 struct orinoco_private *priv = link->priv; 116 struct orinoco_private *priv = link->priv;
@@ -145,76 +122,12 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
145 free_orinocodev(priv); 122 free_orinocodev(priv);
146} /* orinoco_cs_detach */ 123} /* orinoco_cs_detach */
147 124
148/* 125static int orinoco_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
149 * orinoco_cs_config() is scheduled to run after a CARD_INSERTION
150 * event is received, to configure the PCMCIA socket, and to make the
151 * device available to the system.
152 */
153
154static int orinoco_cs_config_check(struct pcmcia_device *p_dev,
155 cistpl_cftable_entry_t *cfg,
156 cistpl_cftable_entry_t *dflt,
157 unsigned int vcc,
158 void *priv_data)
159{ 126{
160 if (cfg->index == 0) 127 if (p_dev->config_index == 0)
161 goto next_entry; 128 return -EINVAL;
162
163 /* Use power settings for Vcc and Vpp if present */
164 /* Note that the CIS values need to be rescaled */
165 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
166 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) {
167 DEBUG(2, "%s: Vcc mismatch (vcc = %d, CIS = %d)\n",
168 __func__, vcc,
169 cfg->vcc.param[CISTPL_POWER_VNOM] / 10000);
170 if (!ignore_cis_vcc)
171 goto next_entry;
172 }
173 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
174 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) {
175 DEBUG(2, "%s: Vcc mismatch (vcc = %d, CIS = %d)\n",
176 __func__, vcc,
177 dflt->vcc.param[CISTPL_POWER_VNOM] / 10000);
178 if (!ignore_cis_vcc)
179 goto next_entry;
180 }
181 }
182 129
183 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 130 return pcmcia_request_io(p_dev);
184 p_dev->conf.Vpp =
185 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
186 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
187 p_dev->conf.Vpp =
188 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
189
190 /* Do we need to allocate an interrupt? */
191 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
192
193 /* IO window settings */
194 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
195 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
196 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
197 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
198 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
199 p_dev->resource[0]->flags |=
200 pcmcia_io_cfg_data_width(io->flags);
201 p_dev->resource[0]->start = io->win[0].base;
202 p_dev->resource[0]->end = io->win[0].len;
203 if (io->nwin > 1) {
204 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
205 p_dev->resource[1]->start = io->win[1].base;
206 p_dev->resource[1]->end = io->win[1].len;
207 }
208
209 /* This reserves IO space but doesn't actually enable it */
210 if (pcmcia_request_io(p_dev) != 0)
211 goto next_entry;
212 }
213 return 0;
214
215next_entry:
216 pcmcia_disable_device(p_dev);
217 return -ENODEV;
218}; 131};
219 132
220static int 133static int
@@ -225,20 +138,10 @@ orinoco_cs_config(struct pcmcia_device *link)
225 int ret; 138 int ret;
226 void __iomem *mem; 139 void __iomem *mem;
227 140
228 /* 141 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC |
229 * In this loop, we scan the CIS for configuration table 142 CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
230 * entries, each of which describes a valid card 143 if (ignore_cis_vcc)
231 * configuration, including voltage, IO window, memory window, 144 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
232 * and interrupt settings.
233 *
234 * We make no assumptions about the card to be configured: we
235 * use just the information available in the CIS. In an ideal
236 * world, this would work for any PCMCIA card, but it requires
237 * a complete and accurate CIS. In practice, a driver usually
238 * "knows" most of these things without consulting the CIS,
239 * and most client drivers will only use the CIS to fill in
240 * implementation-defined details.
241 */
242 ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); 145 ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL);
243 if (ret) { 146 if (ret) {
244 if (!ignore_cis_vcc) 147 if (!ignore_cis_vcc)
@@ -262,12 +165,7 @@ orinoco_cs_config(struct pcmcia_device *link)
262 165
263 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 166 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
264 167
265 /* 168 ret = pcmcia_enable_device(link);
266 * This actually configures the PCMCIA socket -- setting up
267 * the I/O windows and the interrupt mapping, and putting the
268 * card and host interface into "Memory and IO" mode.
269 */
270 ret = pcmcia_request_configuration(link, &link->conf);
271 if (ret) 169 if (ret)
272 goto failed; 170 goto failed;
273 171
@@ -291,11 +189,6 @@ orinoco_cs_config(struct pcmcia_device *link)
291 return -ENODEV; 189 return -ENODEV;
292} /* orinoco_cs_config */ 190} /* orinoco_cs_config */
293 191
294/*
295 * After a card is removed, orinoco_cs_release() will unregister the
296 * device, and release the PCMCIA configuration. If the device is
297 * still open, this will be postponed until it is closed.
298 */
299static void 192static void
300orinoco_cs_release(struct pcmcia_device *link) 193orinoco_cs_release(struct pcmcia_device *link)
301{ 194{
@@ -344,12 +237,6 @@ static int orinoco_cs_resume(struct pcmcia_device *link)
344/* Module initialization */ 237/* Module initialization */
345/********************************************************************/ 238/********************************************************************/
346 239
347/* Can't be declared "const" or the whole __initdata section will
348 * become const */
349static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
350 " (David Gibson <hermes@gibson.dropbear.id.au>, "
351 "Pavel Roskin <proski@gnu.org>, et al)";
352
353static struct pcmcia_device_id orinoco_cs_ids[] = { 240static struct pcmcia_device_id orinoco_cs_ids[] = {
354 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */ 241 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777), /* 3Com AirConnect PCI 777A */
355 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), /* Lucent Orinoco and old Intersil */ 242 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), /* Lucent Orinoco and old Intersil */
@@ -441,9 +328,7 @@ MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids);
441 328
442static struct pcmcia_driver orinoco_driver = { 329static struct pcmcia_driver orinoco_driver = {
443 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
444 .drv = { 331 .name = DRIVER_NAME,
445 .name = DRIVER_NAME,
446 },
447 .probe = orinoco_cs_probe, 332 .probe = orinoco_cs_probe,
448 .remove = orinoco_cs_detach, 333 .remove = orinoco_cs_detach,
449 .id_table = orinoco_cs_ids, 334 .id_table = orinoco_cs_ids,
@@ -454,8 +339,6 @@ static struct pcmcia_driver orinoco_driver = {
454static int __init 339static int __init
455init_orinoco_cs(void) 340init_orinoco_cs(void)
456{ 341{
457 printk(KERN_DEBUG "%s\n", version);
458
459 return pcmcia_register_driver(&orinoco_driver); 342 return pcmcia_register_driver(&orinoco_driver);
460} 343}
461 344
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 873877e17e1b..fb859a5ad2eb 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -25,7 +25,6 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <pcmcia/cs.h>
29#include <pcmcia/cistpl.h> 28#include <pcmcia/cistpl.h>
30#include <pcmcia/cisreg.h> 29#include <pcmcia/cisreg.h>
31#include <pcmcia/ds.h> 30#include <pcmcia/ds.h>
@@ -154,14 +153,6 @@ spectrum_cs_stop_firmware(struct orinoco_private *priv, int idle)
154/* PCMCIA stuff */ 153/* PCMCIA stuff */
155/********************************************************************/ 154/********************************************************************/
156 155
157/*
158 * This creates an "instance" of the driver, allocating local data
159 * structures for one device. The device is registered with Card
160 * Services.
161 *
162 * The dev_link structure is initialized, but we don't actually
163 * configure the card at this point -- we wait until we receive a card
164 * insertion event. */
165static int 156static int
166spectrum_cs_probe(struct pcmcia_device *link) 157spectrum_cs_probe(struct pcmcia_device *link)
167{ 158{
@@ -179,23 +170,9 @@ spectrum_cs_probe(struct pcmcia_device *link)
179 card->p_dev = link; 170 card->p_dev = link;
180 link->priv = priv; 171 link->priv = priv;
181 172
182 /* General socket configuration defaults can go here. In this
183 * client, we assume very little, and rely on the CIS for
184 * almost everything. In most clients, many details (i.e.,
185 * number, sizes, and attributes of IO windows) are fixed by
186 * the nature of the device, and can be hard-wired here. */
187 link->conf.Attributes = 0;
188 link->conf.IntType = INT_MEMORY_AND_IO;
189
190 return spectrum_cs_config(link); 173 return spectrum_cs_config(link);
191} /* spectrum_cs_attach */ 174} /* spectrum_cs_attach */
192 175
193/*
194 * This deletes a driver "instance". The device is de-registered with
195 * Card Services. If it has been released, all local data structures
196 * are freed. Otherwise, the structures will be freed when the device
197 * is released.
198 */
199static void spectrum_cs_detach(struct pcmcia_device *link) 176static void spectrum_cs_detach(struct pcmcia_device *link)
200{ 177{
201 struct orinoco_private *priv = link->priv; 178 struct orinoco_private *priv = link->priv;
@@ -207,76 +184,13 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
207 free_orinocodev(priv); 184 free_orinocodev(priv);
208} /* spectrum_cs_detach */ 185} /* spectrum_cs_detach */
209 186
210/*
211 * spectrum_cs_config() is scheduled to run after a CARD_INSERTION
212 * event is received, to configure the PCMCIA socket, and to make the
213 * device available to the system.
214 */
215
216static int spectrum_cs_config_check(struct pcmcia_device *p_dev, 187static int spectrum_cs_config_check(struct pcmcia_device *p_dev,
217 cistpl_cftable_entry_t *cfg,
218 cistpl_cftable_entry_t *dflt,
219 unsigned int vcc,
220 void *priv_data) 188 void *priv_data)
221{ 189{
222 if (cfg->index == 0) 190 if (p_dev->config_index == 0)
223 goto next_entry; 191 return -EINVAL;
224
225 /* Use power settings for Vcc and Vpp if present */
226 /* Note that the CIS values need to be rescaled */
227 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
228 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) {
229 DEBUG(2, "%s: Vcc mismatch (vcc = %d, CIS = %d)\n",
230 __func__, vcc,
231 cfg->vcc.param[CISTPL_POWER_VNOM] / 10000);
232 if (!ignore_cis_vcc)
233 goto next_entry;
234 }
235 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
236 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) {
237 DEBUG(2, "%s: Vcc mismatch (vcc = %d, CIS = %d)\n",
238 __func__, vcc,
239 dflt->vcc.param[CISTPL_POWER_VNOM] / 10000);
240 if (!ignore_cis_vcc)
241 goto next_entry;
242 }
243 }
244 192
245 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 193 return pcmcia_request_io(p_dev);
246 p_dev->conf.Vpp =
247 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
248 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
249 p_dev->conf.Vpp =
250 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
251
252 /* Do we need to allocate an interrupt? */
253 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
254
255 /* IO window settings */
256 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
257 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
258 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
259 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
260 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
261 p_dev->resource[0]->flags |=
262 pcmcia_io_cfg_data_width(io->flags);
263 p_dev->resource[0]->start = io->win[0].base;
264 p_dev->resource[0]->end = io->win[0].len;
265 if (io->nwin > 1) {
266 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
267 p_dev->resource[1]->start = io->win[1].base;
268 p_dev->resource[1]->end = io->win[1].len;
269 }
270
271 /* This reserves IO space but doesn't actually enable it */
272 if (pcmcia_request_io(p_dev) != 0)
273 goto next_entry;
274 }
275 return 0;
276
277next_entry:
278 pcmcia_disable_device(p_dev);
279 return -ENODEV;
280}; 194};
281 195
282static int 196static int
@@ -287,20 +201,10 @@ spectrum_cs_config(struct pcmcia_device *link)
287 int ret; 201 int ret;
288 void __iomem *mem; 202 void __iomem *mem;
289 203
290 /* 204 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC |
291 * In this loop, we scan the CIS for configuration table 205 CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
292 * entries, each of which describes a valid card 206 if (ignore_cis_vcc)
293 * configuration, including voltage, IO window, memory window, 207 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
294 * and interrupt settings.
295 *
296 * We make no assumptions about the card to be configured: we
297 * use just the information available in the CIS. In an ideal
298 * world, this would work for any PCMCIA card, but it requires
299 * a complete and accurate CIS. In practice, a driver usually
300 * "knows" most of these things without consulting the CIS,
301 * and most client drivers will only use the CIS to fill in
302 * implementation-defined details.
303 */
304 ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); 208 ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL);
305 if (ret) { 209 if (ret) {
306 if (!ignore_cis_vcc) 210 if (!ignore_cis_vcc)
@@ -325,12 +229,7 @@ spectrum_cs_config(struct pcmcia_device *link)
325 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING); 229 hermes_struct_init(hw, mem, HERMES_16BIT_REGSPACING);
326 hw->eeprom_pda = true; 230 hw->eeprom_pda = true;
327 231
328 /* 232 ret = pcmcia_enable_device(link);
329 * This actually configures the PCMCIA socket -- setting up
330 * the I/O windows and the interrupt mapping, and putting the
331 * card and host interface into "Memory and IO" mode.
332 */
333 ret = pcmcia_request_configuration(link, &link->conf);
334 if (ret) 233 if (ret)
335 goto failed; 234 goto failed;
336 235
@@ -358,11 +257,6 @@ spectrum_cs_config(struct pcmcia_device *link)
358 return -ENODEV; 257 return -ENODEV;
359} /* spectrum_cs_config */ 258} /* spectrum_cs_config */
360 259
361/*
362 * After a card is removed, spectrum_cs_release() will unregister the
363 * device, and release the PCMCIA configuration. If the device is
364 * still open, this will be postponed until it is closed.
365 */
366static void 260static void
367spectrum_cs_release(struct pcmcia_device *link) 261spectrum_cs_release(struct pcmcia_device *link)
368{ 262{
@@ -407,12 +301,6 @@ spectrum_cs_resume(struct pcmcia_device *link)
407/* Module initialization */ 301/* Module initialization */
408/********************************************************************/ 302/********************************************************************/
409 303
410/* Can't be declared "const" or the whole __initdata section will
411 * become const */
412static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
413 " (Pavel Roskin <proski@gnu.org>,"
414 " David Gibson <hermes@gibson.dropbear.id.au>, et al)";
415
416static struct pcmcia_device_id spectrum_cs_ids[] = { 304static struct pcmcia_device_id spectrum_cs_ids[] = {
417 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */ 305 PCMCIA_DEVICE_MANF_CARD(0x026c, 0x0001), /* Symbol Spectrum24 LA4137 */
418 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */ 306 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0001), /* Socket Communications CF */
@@ -423,9 +311,7 @@ MODULE_DEVICE_TABLE(pcmcia, spectrum_cs_ids);
423 311
424static struct pcmcia_driver orinoco_driver = { 312static struct pcmcia_driver orinoco_driver = {
425 .owner = THIS_MODULE, 313 .owner = THIS_MODULE,
426 .drv = { 314 .name = DRIVER_NAME,
427 .name = DRIVER_NAME,
428 },
429 .probe = spectrum_cs_probe, 315 .probe = spectrum_cs_probe,
430 .remove = spectrum_cs_detach, 316 .remove = spectrum_cs_detach,
431 .suspend = spectrum_cs_suspend, 317 .suspend = spectrum_cs_suspend,
@@ -436,8 +322,6 @@ static struct pcmcia_driver orinoco_driver = {
436static int __init 322static int __init
437init_spectrum_cs(void) 323init_spectrum_cs(void)
438{ 324{
439 printk(KERN_DEBUG "%s\n", version);
440
441 return pcmcia_register_driver(&orinoco_driver); 325 return pcmcia_register_driver(&orinoco_driver);
442} 326}
443 327
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 88560d0ae50a..af5b17ce5a15 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -46,7 +46,6 @@
46#include <linux/ethtool.h> 46#include <linux/ethtool.h>
47#include <linux/ieee80211.h> 47#include <linux/ieee80211.h>
48 48
49#include <pcmcia/cs.h>
50#include <pcmcia/cistpl.h> 49#include <pcmcia/cistpl.h>
51#include <pcmcia/cisreg.h> 50#include <pcmcia/cisreg.h>
52#include <pcmcia/ds.h> 51#include <pcmcia/ds.h>
@@ -169,13 +168,6 @@ static int bc;
169 */ 168 */
170static char *phy_addr = NULL; 169static char *phy_addr = NULL;
171 170
172
173/* A struct pcmcia_device structure has fields for most things that are needed
174 to keep track of a socket, but there will usually be some device
175 specific information that also needs to be kept track of. The
176 'priv' pointer in a struct pcmcia_device structure can be used to point to
177 a device-specific private data structure, like this.
178*/
179static unsigned int ray_mem_speed = 500; 171static unsigned int ray_mem_speed = 500;
180 172
181/* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */ 173/* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
@@ -290,14 +282,6 @@ static const struct net_device_ops ray_netdev_ops = {
290 .ndo_validate_addr = eth_validate_addr, 282 .ndo_validate_addr = eth_validate_addr,
291}; 283};
292 284
293/*=============================================================================
294 ray_attach() creates an "instance" of the driver, allocating
295 local data structures for one device. The device is registered
296 with Card Services.
297 The dev_link structure is initialized, but we don't actually
298 configure the card at this point -- we wait until we receive a
299 card insertion event.
300=============================================================================*/
301static int ray_probe(struct pcmcia_device *p_dev) 285static int ray_probe(struct pcmcia_device *p_dev)
302{ 286{
303 ray_dev_t *local; 287 ray_dev_t *local;
@@ -318,9 +302,8 @@ static int ray_probe(struct pcmcia_device *p_dev)
318 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 302 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
319 303
320 /* General socket configuration */ 304 /* General socket configuration */
321 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 305 p_dev->config_flags |= CONF_ENABLE_IRQ;
322 p_dev->conf.IntType = INT_MEMORY_AND_IO; 306 p_dev->config_index = 1;
323 p_dev->conf.ConfigIndex = 1;
324 307
325 p_dev->priv = dev; 308 p_dev->priv = dev;
326 309
@@ -353,12 +336,6 @@ fail_alloc_dev:
353 return -ENOMEM; 336 return -ENOMEM;
354} /* ray_attach */ 337} /* ray_attach */
355 338
356/*=============================================================================
357 This deletes a driver "instance". The device is de-registered
358 with Card Services. If it has been released, all local data
359 structures are freed. Otherwise, the structures will be freed
360 when the device is released.
361=============================================================================*/
362static void ray_detach(struct pcmcia_device *link) 339static void ray_detach(struct pcmcia_device *link)
363{ 340{
364 struct net_device *dev; 341 struct net_device *dev;
@@ -381,17 +358,11 @@ static void ray_detach(struct pcmcia_device *link)
381 dev_dbg(&link->dev, "ray_cs ray_detach ending\n"); 358 dev_dbg(&link->dev, "ray_cs ray_detach ending\n");
382} /* ray_detach */ 359} /* ray_detach */
383 360
384/*=============================================================================
385 ray_config() is run after a CARD_INSERTION event
386 is received, to configure the PCMCIA socket, and to make the
387 ethernet device available to the system.
388=============================================================================*/
389#define MAX_TUPLE_SIZE 128 361#define MAX_TUPLE_SIZE 128
390static int ray_config(struct pcmcia_device *link) 362static int ray_config(struct pcmcia_device *link)
391{ 363{
392 int ret = 0; 364 int ret = 0;
393 int i; 365 int i;
394 win_req_t req;
395 struct net_device *dev = (struct net_device *)link->priv; 366 struct net_device *dev = (struct net_device *)link->priv;
396 ray_dev_t *local = netdev_priv(dev); 367 ray_dev_t *local = netdev_priv(dev);
397 368
@@ -412,54 +383,50 @@ static int ray_config(struct pcmcia_device *link)
412 goto failed; 383 goto failed;
413 dev->irq = link->irq; 384 dev->irq = link->irq;
414 385
415 /* This actually configures the PCMCIA socket -- setting up 386 ret = pcmcia_enable_device(link);
416 the I/O windows and the interrupt mapping.
417 */
418 ret = pcmcia_request_configuration(link, &link->conf);
419 if (ret) 387 if (ret)
420 goto failed; 388 goto failed;
421 389
422/*** Set up 32k window for shared memory (transmit and control) ************/ 390/*** Set up 32k window for shared memory (transmit and control) ************/
423 req.Attributes = 391 link->resource[2]->flags |= WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
424 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 392 link->resource[2]->start = 0;
425 req.Base = 0; 393 link->resource[2]->end = 0x8000;
426 req.Size = 0x8000; 394 ret = pcmcia_request_window(link, link->resource[2], ray_mem_speed);
427 req.AccessSpeed = ray_mem_speed;
428 ret = pcmcia_request_window(link, &req, &link->win);
429 if (ret) 395 if (ret)
430 goto failed; 396 goto failed;
431 ret = pcmcia_map_mem_page(link, link->win, 0); 397 ret = pcmcia_map_mem_page(link, link->resource[2], 0);
432 if (ret) 398 if (ret)
433 goto failed; 399 goto failed;
434 local->sram = ioremap(req.Base, req.Size); 400 local->sram = ioremap(link->resource[2]->start,
401 resource_size(link->resource[2]));
435 402
436/*** Set up 16k window for shared memory (receive buffer) ***************/ 403/*** Set up 16k window for shared memory (receive buffer) ***************/
437 req.Attributes = 404 link->resource[3]->flags |=
438 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 405 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
439 req.Base = 0; 406 link->resource[3]->start = 0;
440 req.Size = 0x4000; 407 link->resource[3]->end = 0x4000;
441 req.AccessSpeed = ray_mem_speed; 408 ret = pcmcia_request_window(link, link->resource[3], ray_mem_speed);
442 ret = pcmcia_request_window(link, &req, &local->rmem_handle);
443 if (ret) 409 if (ret)
444 goto failed; 410 goto failed;
445 ret = pcmcia_map_mem_page(link, local->rmem_handle, 0x8000); 411 ret = pcmcia_map_mem_page(link, link->resource[3], 0x8000);
446 if (ret) 412 if (ret)
447 goto failed; 413 goto failed;
448 local->rmem = ioremap(req.Base, req.Size); 414 local->rmem = ioremap(link->resource[3]->start,
415 resource_size(link->resource[3]));
449 416
450/*** Set up window for attribute memory ***********************************/ 417/*** Set up window for attribute memory ***********************************/
451 req.Attributes = 418 link->resource[4]->flags |=
452 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT; 419 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
453 req.Base = 0; 420 link->resource[4]->start = 0;
454 req.Size = 0x1000; 421 link->resource[4]->end = 0x1000;
455 req.AccessSpeed = ray_mem_speed; 422 ret = pcmcia_request_window(link, link->resource[4], ray_mem_speed);
456 ret = pcmcia_request_window(link, &req, &local->amem_handle);
457 if (ret) 423 if (ret)
458 goto failed; 424 goto failed;
459 ret = pcmcia_map_mem_page(link, local->amem_handle, 0); 425 ret = pcmcia_map_mem_page(link, link->resource[4], 0);
460 if (ret) 426 if (ret)
461 goto failed; 427 goto failed;
462 local->amem = ioremap(req.Base, req.Size); 428 local->amem = ioremap(link->resource[4]->start,
429 resource_size(link->resource[4]));
463 430
464 dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram); 431 dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
465 dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem); 432 dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
@@ -775,11 +742,7 @@ static void join_net(u_long data)
775 local->card_status = CARD_DOING_ACQ; 742 local->card_status = CARD_DOING_ACQ;
776} 743}
777 744
778/*============================================================================ 745
779 After a card is removed, ray_release() will unregister the net
780 device, and release the PCMCIA configuration. If the device is
781 still open, this will be postponed until it is closed.
782=============================================================================*/
783static void ray_release(struct pcmcia_device *link) 746static void ray_release(struct pcmcia_device *link)
784{ 747{
785 struct net_device *dev = link->priv; 748 struct net_device *dev = link->priv;
@@ -2847,9 +2810,7 @@ MODULE_DEVICE_TABLE(pcmcia, ray_ids);
2847 2810
2848static struct pcmcia_driver ray_driver = { 2811static struct pcmcia_driver ray_driver = {
2849 .owner = THIS_MODULE, 2812 .owner = THIS_MODULE,
2850 .drv = { 2813 .name = "ray_cs",
2851 .name = "ray_cs",
2852 },
2853 .probe = ray_probe, 2814 .probe = ray_probe,
2854 .remove = ray_detach, 2815 .remove = ray_detach,
2855 .id_table = ray_ids, 2816 .id_table = ray_ids,
diff --git a/drivers/net/wireless/ray_cs.h b/drivers/net/wireless/ray_cs.h
index 9f01ddb19748..e79848fbcca1 100644
--- a/drivers/net/wireless/ray_cs.h
+++ b/drivers/net/wireless/ray_cs.h
@@ -25,8 +25,6 @@ struct beacon_rx {
25typedef struct ray_dev_t { 25typedef struct ray_dev_t {
26 int card_status; 26 int card_status;
27 int authentication_state; 27 int authentication_state;
28 window_handle_t amem_handle; /* handle to window for attribute memory */
29 window_handle_t rmem_handle; /* handle to window for rx buffer on card */
30 void __iomem *sram; /* pointer to beginning of shared RAM */ 28 void __iomem *sram; /* pointer to beginning of shared RAM */
31 void __iomem *amem; /* pointer to attribute mem window */ 29 void __iomem *amem; /* pointer to attribute mem window */
32 void __iomem *rmem; /* pointer to receive buffer window */ 30 void __iomem *rmem; /* pointer to receive buffer window */
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index a1cc2d498a1c..ca3f8961fa27 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -48,7 +48,6 @@
48 48
49#include <net/iw_handler.h> 49#include <net/iw_handler.h>
50 50
51#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
53#include <pcmcia/cisreg.h> 52#include <pcmcia/cisreg.h>
54#include <pcmcia/ds.h> 53#include <pcmcia/ds.h>
@@ -78,13 +77,6 @@
78#define WL3501_RESUME 0 77#define WL3501_RESUME 0
79#define WL3501_SUSPEND 1 78#define WL3501_SUSPEND 1
80 79
81/*
82 * The event() function is this driver's Card Services event handler. It will
83 * be called by Card Services when an appropriate card status event is
84 * received. The config() and release() entry points are used to configure or
85 * release a socket, in response to card insertion and ejection events. They
86 * are invoked from the wl24 event handler.
87 */
88static int wl3501_config(struct pcmcia_device *link); 80static int wl3501_config(struct pcmcia_device *link);
89static void wl3501_release(struct pcmcia_device *link); 81static void wl3501_release(struct pcmcia_device *link);
90 82
@@ -1869,15 +1861,6 @@ static const struct net_device_ops wl3501_netdev_ops = {
1869 .ndo_validate_addr = eth_validate_addr, 1861 .ndo_validate_addr = eth_validate_addr,
1870}; 1862};
1871 1863
1872/**
1873 * wl3501_attach - creates an "instance" of the driver
1874 *
1875 * Creates an "instance" of the driver, allocating local data structures for
1876 * one device. The device is registered with Card Services.
1877 *
1878 * The dev_link structure is initialized, but we don't actually configure the
1879 * card at this point -- we wait until we receive a card insertion event.
1880 */
1881static int wl3501_probe(struct pcmcia_device *p_dev) 1864static int wl3501_probe(struct pcmcia_device *p_dev)
1882{ 1865{
1883 struct net_device *dev; 1866 struct net_device *dev;
@@ -1888,9 +1871,8 @@ static int wl3501_probe(struct pcmcia_device *p_dev)
1888 p_dev->resource[0]->flags = IO_DATA_PATH_WIDTH_8; 1871 p_dev->resource[0]->flags = IO_DATA_PATH_WIDTH_8;
1889 1872
1890 /* General socket configuration */ 1873 /* General socket configuration */
1891 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 1874 p_dev->config_flags = CONF_ENABLE_IRQ;
1892 p_dev->conf.IntType = INT_MEMORY_AND_IO; 1875 p_dev->config_index = 1;
1893 p_dev->conf.ConfigIndex = 1;
1894 1876
1895 dev = alloc_etherdev(sizeof(struct wl3501_card)); 1877 dev = alloc_etherdev(sizeof(struct wl3501_card));
1896 if (!dev) 1878 if (!dev)
@@ -1914,14 +1896,6 @@ out_link:
1914 return -ENOMEM; 1896 return -ENOMEM;
1915} 1897}
1916 1898
1917/**
1918 * wl3501_config - configure the PCMCIA socket and make eth device available
1919 * @link - FILL_IN
1920 *
1921 * wl3501_config() is scheduled to run after a CARD_INSERTION event is
1922 * received, to configure the PCMCIA socket, and to make the ethernet device
1923 * available to the system.
1924 */
1925static int wl3501_config(struct pcmcia_device *link) 1899static int wl3501_config(struct pcmcia_device *link)
1926{ 1900{
1927 struct net_device *dev = link->priv; 1901 struct net_device *dev = link->priv;
@@ -1952,10 +1926,7 @@ static int wl3501_config(struct pcmcia_device *link)
1952 if (ret) 1926 if (ret)
1953 goto failed; 1927 goto failed;
1954 1928
1955 /* This actually configures the PCMCIA socket -- setting up the I/O 1929 ret = pcmcia_enable_device(link);
1956 * windows and the interrupt mapping. */
1957
1958 ret = pcmcia_request_configuration(link, &link->conf);
1959 if (ret) 1930 if (ret)
1960 goto failed; 1931 goto failed;
1961 1932
@@ -2010,14 +1981,6 @@ failed:
2010 return -ENODEV; 1981 return -ENODEV;
2011} 1982}
2012 1983
2013/**
2014 * wl3501_release - unregister the net, release PCMCIA configuration
2015 * @arg - link
2016 *
2017 * After a card is removed, wl3501_release() will unregister the net device,
2018 * and release the PCMCIA configuration. If the device is still open, this
2019 * will be postponed until it is closed.
2020 */
2021static void wl3501_release(struct pcmcia_device *link) 1984static void wl3501_release(struct pcmcia_device *link)
2022{ 1985{
2023 pcmcia_disable_device(link); 1986 pcmcia_disable_device(link);
@@ -2056,9 +2019,7 @@ MODULE_DEVICE_TABLE(pcmcia, wl3501_ids);
2056 2019
2057static struct pcmcia_driver wl3501_driver = { 2020static struct pcmcia_driver wl3501_driver = {
2058 .owner = THIS_MODULE, 2021 .owner = THIS_MODULE,
2059 .drv = { 2022 .name = "wl3501_cs",
2060 .name = "wl3501_cs",
2061 },
2062 .probe = wl3501_probe, 2023 .probe = wl3501_probe,
2063 .remove = wl3501_detach, 2024 .remove = wl3501_detach,
2064 .id_table = wl3501_ids, 2025 .id_table = wl3501_ids,
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 23e50f4a27c5..787ebdeae310 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -48,7 +48,6 @@
48#include <linux/parport.h> 48#include <linux/parport.h>
49#include <linux/parport_pc.h> 49#include <linux/parport_pc.h>
50 50
51#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
53#include <pcmcia/ds.h> 52#include <pcmcia/ds.h>
54#include <pcmcia/cisreg.h> 53#include <pcmcia/cisreg.h>
@@ -81,14 +80,6 @@ static void parport_detach(struct pcmcia_device *p_dev);
81static int parport_config(struct pcmcia_device *link); 80static int parport_config(struct pcmcia_device *link);
82static void parport_cs_release(struct pcmcia_device *); 81static void parport_cs_release(struct pcmcia_device *);
83 82
84/*======================================================================
85
86 parport_attach() creates an "instance" of the driver, allocating
87 local data structures for one device. The device is registered
88 with Card Services.
89
90======================================================================*/
91
92static int parport_probe(struct pcmcia_device *link) 83static int parport_probe(struct pcmcia_device *link)
93{ 84{
94 parport_info_t *info; 85 parport_info_t *info;
@@ -101,23 +92,11 @@ static int parport_probe(struct pcmcia_device *link)
101 link->priv = info; 92 link->priv = info;
102 info->p_dev = link; 93 info->p_dev = link;
103 94
104 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 95 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
105 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
106 link->conf.Attributes = CONF_ENABLE_IRQ;
107 link->conf.IntType = INT_MEMORY_AND_IO;
108 96
109 return parport_config(link); 97 return parport_config(link);
110} /* parport_attach */ 98} /* parport_attach */
111 99
112/*======================================================================
113
114 This deletes a driver "instance". The device is de-registered
115 with Card Services. If it has been released, all local data
116 structures are freed. Otherwise, the structures will be freed
117 when the device is released.
118
119======================================================================*/
120
121static void parport_detach(struct pcmcia_device *link) 100static void parport_detach(struct pcmcia_device *link)
122{ 101{
123 dev_dbg(&link->dev, "parport_detach\n"); 102 dev_dbg(&link->dev, "parport_detach\n");
@@ -127,36 +106,14 @@ static void parport_detach(struct pcmcia_device *link)
127 kfree(link->priv); 106 kfree(link->priv);
128} /* parport_detach */ 107} /* parport_detach */
129 108
130/*====================================================================== 109static int parport_config_check(struct pcmcia_device *p_dev, void *priv_data)
131
132 parport_config() is scheduled to run after a CARD_INSERTION event
133 is received, to configure the PCMCIA socket, and to make the
134 parport device available to the system.
135
136======================================================================*/
137
138static int parport_config_check(struct pcmcia_device *p_dev,
139 cistpl_cftable_entry_t *cfg,
140 cistpl_cftable_entry_t *dflt,
141 unsigned int vcc,
142 void *priv_data)
143{ 110{
144 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 111 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
145 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 112 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
146 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 113 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
147 if (epp_mode) 114 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
148 p_dev->conf.ConfigIndex |= FORCE_EPP_MODE; 115
149 p_dev->resource[0]->start = io->win[0].base; 116 return pcmcia_request_io(p_dev);
150 p_dev->resource[0]->end = io->win[0].len;
151 if (io->nwin == 2) {
152 p_dev->resource[1]->start = io->win[1].base;
153 p_dev->resource[1]->end = io->win[1].len;
154 }
155 if (pcmcia_request_io(p_dev) != 0)
156 return -ENODEV;
157 return 0;
158 }
159 return -ENODEV;
160} 117}
161 118
162static int parport_config(struct pcmcia_device *link) 119static int parport_config(struct pcmcia_device *link)
@@ -167,13 +124,16 @@ static int parport_config(struct pcmcia_device *link)
167 124
168 dev_dbg(&link->dev, "parport_config\n"); 125 dev_dbg(&link->dev, "parport_config\n");
169 126
127 if (epp_mode)
128 link->config_index |= FORCE_EPP_MODE;
129
170 ret = pcmcia_loop_config(link, parport_config_check, NULL); 130 ret = pcmcia_loop_config(link, parport_config_check, NULL);
171 if (ret) 131 if (ret)
172 goto failed; 132 goto failed;
173 133
174 if (!link->irq) 134 if (!link->irq)
175 goto failed; 135 goto failed;
176 ret = pcmcia_request_configuration(link, &link->conf); 136 ret = pcmcia_enable_device(link);
177 if (ret) 137 if (ret)
178 goto failed; 138 goto failed;
179 139
@@ -202,14 +162,6 @@ failed:
202 return -ENODEV; 162 return -ENODEV;
203} /* parport_config */ 163} /* parport_config */
204 164
205/*======================================================================
206
207 After a card is removed, parport_cs_release() will unregister the
208 device, and release the PCMCIA configuration. If the device is
209 still open, this will be postponed until it is closed.
210
211======================================================================*/
212
213static void parport_cs_release(struct pcmcia_device *link) 165static void parport_cs_release(struct pcmcia_device *link)
214{ 166{
215 parport_info_t *info = link->priv; 167 parport_info_t *info = link->priv;
@@ -236,9 +188,7 @@ MODULE_DEVICE_TABLE(pcmcia, parport_ids);
236 188
237static struct pcmcia_driver parport_cs_driver = { 189static struct pcmcia_driver parport_cs_driver = {
238 .owner = THIS_MODULE, 190 .owner = THIS_MODULE,
239 .drv = { 191 .name = "parport_cs",
240 .name = "parport_cs",
241 },
242 .probe = parport_probe, 192 .probe = parport_probe,
243 .remove = parport_detach, 193 .remove = parport_detach,
244 .id_table = parport_ids, 194 .id_table = parport_ids,
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 88c4c4098789..95dd7c62741f 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -441,14 +441,12 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
441 441
442 442
443out_err: 443out_err:
444 flush_scheduled_work();
445 ops->hw_shutdown(skt); 444 ops->hw_shutdown(skt);
446 while (i-- > 0) { 445 while (i-- > 0) {
447 skt = PCMCIA_SOCKET(i); 446 skt = PCMCIA_SOCKET(i);
448 447
449 del_timer_sync(&skt->poll_timer); 448 del_timer_sync(&skt->poll_timer);
450 pcmcia_unregister_socket(&skt->socket); 449 pcmcia_unregister_socket(&skt->socket);
451 flush_scheduled_work();
452 if (i == 0) { 450 if (i == 0) {
453 iounmap(skt->virt_io + (u32)mips_io_port_base); 451 iounmap(skt->virt_io + (u32)mips_io_port_base);
454 skt->virt_io = NULL; 452 skt->virt_io = NULL;
@@ -480,7 +478,6 @@ int au1x00_drv_pcmcia_remove(struct platform_device *dev)
480 478
481 del_timer_sync(&skt->poll_timer); 479 del_timer_sync(&skt->poll_timer);
482 pcmcia_unregister_socket(&skt->socket); 480 pcmcia_unregister_socket(&skt->socket);
483 flush_scheduled_work();
484 skt->ops->hw_shutdown(skt); 481 skt->ops->hw_shutdown(skt);
485 au1x00_pcmcia_config_skt(skt, &dead_socket); 482 au1x00_pcmcia_config_skt(skt, &dead_socket);
486 iounmap(skt->virt_io + (u32)mips_io_port_base); 483 iounmap(skt->virt_io + (u32)mips_io_port_base);
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h
index 67530cefcf3c..5c36bda2963b 100644
--- a/drivers/pcmcia/au1000_generic.h
+++ b/drivers/pcmcia/au1000_generic.h
@@ -23,7 +23,6 @@
23 23
24/* include the world */ 24/* include the world */
25 25
26#include <pcmcia/cs.h>
27#include <pcmcia/ss.h> 26#include <pcmcia/ss.h>
28#include <pcmcia/cistpl.h> 27#include <pcmcia/cistpl.h>
29#include "cs_internal.h" 28#include "cs_internal.h"
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index 807f2d75dad3..b2396647a165 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -31,7 +31,6 @@
31#include <linux/proc_fs.h> 31#include <linux/proc_fs.h>
32#include <linux/types.h> 32#include <linux/types.h>
33 33
34#include <pcmcia/cs.h>
35#include <pcmcia/ss.h> 34#include <pcmcia/ss.h>
36#include <pcmcia/cistpl.h> 35#include <pcmcia/cistpl.h>
37 36
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 91414a0ddc44..884a984216fe 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -28,7 +28,6 @@
28#include <asm/unaligned.h> 28#include <asm/unaligned.h>
29 29
30#include <pcmcia/ss.h> 30#include <pcmcia/ss.h>
31#include <pcmcia/cs.h>
32#include <pcmcia/cisreg.h> 31#include <pcmcia/cisreg.h>
33#include <pcmcia/cistpl.h> 32#include <pcmcia/cistpl.h>
34#include "cs_internal.h" 33#include "cs_internal.h"
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 2ec8ac97445c..d9ea192c4001 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -33,7 +33,6 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34 34
35#include <pcmcia/ss.h> 35#include <pcmcia/ss.h>
36#include <pcmcia/cs.h>
37#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
38#include <pcmcia/cisreg.h> 37#include <pcmcia/cisreg.h>
39#include <pcmcia/ds.h> 38#include <pcmcia/ds.h>
@@ -845,7 +844,7 @@ static int pcmcia_socket_dev_resume_noirq(struct device *dev)
845 return __pcmcia_pm_op(dev, socket_early_resume); 844 return __pcmcia_pm_op(dev, socket_early_resume);
846} 845}
847 846
848static int pcmcia_socket_dev_resume(struct device *dev) 847static int __used pcmcia_socket_dev_resume(struct device *dev)
849{ 848{
850 return __pcmcia_pm_op(dev, socket_late_resume); 849 return __pcmcia_pm_op(dev, socket_late_resume);
851} 850}
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index da055dc14d98..7f1953f78b12 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -33,18 +33,9 @@
33typedef struct config_t { 33typedef struct config_t {
34 struct kref ref; 34 struct kref ref;
35 unsigned int state; 35 unsigned int state;
36 unsigned int Attributes;
37 unsigned int IntType;
38 unsigned int ConfigBase;
39 unsigned char Status, Pin, Copy, Option, ExtStatus;
40 unsigned int CardValues;
41 36
42 struct resource io[MAX_IO_WIN]; /* io ports */ 37 struct resource io[MAX_IO_WIN]; /* io ports */
43 struct resource mem[MAX_WIN]; /* mem areas */ 38 struct resource mem[MAX_WIN]; /* mem areas */
44
45 struct {
46 u_int Attributes;
47 } irq;
48} config_t; 39} config_t;
49 40
50 41
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 55570d9e1e4c..100c4412457d 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -26,7 +26,6 @@
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28 28
29#include <pcmcia/cs.h>
30#include <pcmcia/cistpl.h> 29#include <pcmcia/cistpl.h>
31#include <pcmcia/ds.h> 30#include <pcmcia/ds.h>
32#include <pcmcia/ss.h> 31#include <pcmcia/ss.h>
@@ -52,7 +51,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
52 51
53 if (!p_drv->probe || !p_drv->remove) 52 if (!p_drv->probe || !p_drv->remove)
54 printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback " 53 printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback "
55 "function\n", p_drv->drv.name); 54 "function\n", p_drv->name);
56 55
57 while (did && did->match_flags) { 56 while (did && did->match_flags) {
58 for (i = 0; i < 4; i++) { 57 for (i = 0; i < 4; i++) {
@@ -65,7 +64,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
65 64
66 printk(KERN_DEBUG "pcmcia: %s: invalid hash for " 65 printk(KERN_DEBUG "pcmcia: %s: invalid hash for "
67 "product string \"%s\": is 0x%x, should " 66 "product string \"%s\": is 0x%x, should "
68 "be 0x%x\n", p_drv->drv.name, did->prod_id[i], 67 "be 0x%x\n", p_drv->name, did->prod_id[i],
69 did->prod_id_hash[i], hash); 68 did->prod_id_hash[i], hash);
70 printk(KERN_DEBUG "pcmcia: see " 69 printk(KERN_DEBUG "pcmcia: see "
71 "Documentation/pcmcia/devicetable.txt for " 70 "Documentation/pcmcia/devicetable.txt for "
@@ -180,10 +179,11 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
180 /* initialize common fields */ 179 /* initialize common fields */
181 driver->drv.bus = &pcmcia_bus_type; 180 driver->drv.bus = &pcmcia_bus_type;
182 driver->drv.owner = driver->owner; 181 driver->drv.owner = driver->owner;
182 driver->drv.name = driver->name;
183 mutex_init(&driver->dynids.lock); 183 mutex_init(&driver->dynids.lock);
184 INIT_LIST_HEAD(&driver->dynids.list); 184 INIT_LIST_HEAD(&driver->dynids.list);
185 185
186 pr_debug("registering driver %s\n", driver->drv.name); 186 pr_debug("registering driver %s\n", driver->name);
187 187
188 error = driver_register(&driver->drv); 188 error = driver_register(&driver->drv);
189 if (error < 0) 189 if (error < 0)
@@ -203,7 +203,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
203 */ 203 */
204void pcmcia_unregister_driver(struct pcmcia_driver *driver) 204void pcmcia_unregister_driver(struct pcmcia_driver *driver)
205{ 205{
206 pr_debug("unregistering driver %s\n", driver->drv.name); 206 pr_debug("unregistering driver %s\n", driver->name);
207 driver_unregister(&driver->drv); 207 driver_unregister(&driver->drv);
208 pcmcia_free_dynids(driver); 208 pcmcia_free_dynids(driver);
209} 209}
@@ -264,7 +264,7 @@ static int pcmcia_device_probe(struct device *dev)
264 p_drv = to_pcmcia_drv(dev->driver); 264 p_drv = to_pcmcia_drv(dev->driver);
265 s = p_dev->socket; 265 s = p_dev->socket;
266 266
267 dev_dbg(dev, "trying to bind to %s\n", p_drv->drv.name); 267 dev_dbg(dev, "trying to bind to %s\n", p_drv->name);
268 268
269 if ((!p_drv->probe) || (!p_dev->function_config) || 269 if ((!p_drv->probe) || (!p_dev->function_config) ||
270 (!try_module_get(p_drv->owner))) { 270 (!try_module_get(p_drv->owner))) {
@@ -276,21 +276,28 @@ static int pcmcia_device_probe(struct device *dev)
276 ret = pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_CONFIG, 276 ret = pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_CONFIG,
277 &cis_config); 277 &cis_config);
278 if (!ret) { 278 if (!ret) {
279 p_dev->conf.ConfigBase = cis_config.base; 279 p_dev->config_base = cis_config.base;
280 p_dev->conf.Present = cis_config.rmask[0]; 280 p_dev->config_regs = cis_config.rmask[0];
281 dev_dbg(dev, "base %x, regs %x", p_dev->config_base,
282 p_dev->config_regs);
281 } else { 283 } else {
282 dev_printk(KERN_INFO, dev, 284 dev_printk(KERN_INFO, dev,
283 "pcmcia: could not parse base and rmask0 of CIS\n"); 285 "pcmcia: could not parse base and rmask0 of CIS\n");
284 p_dev->conf.ConfigBase = 0; 286 p_dev->config_base = 0;
285 p_dev->conf.Present = 0; 287 p_dev->config_regs = 0;
286 } 288 }
287 289
288 ret = p_drv->probe(p_dev); 290 ret = p_drv->probe(p_dev);
289 if (ret) { 291 if (ret) {
290 dev_dbg(dev, "binding to %s failed with %d\n", 292 dev_dbg(dev, "binding to %s failed with %d\n",
291 p_drv->drv.name, ret); 293 p_drv->name, ret);
292 goto put_module; 294 goto put_module;
293 } 295 }
296 dev_dbg(dev, "%s bound: Vpp %d.%d, idx %x, IRQ %d", p_drv->name,
297 p_dev->vpp/10, p_dev->vpp%10, p_dev->config_index, p_dev->irq);
298 dev_dbg(dev, "resources: ioport %pR %pR iomem %pR %pR %pR",
299 p_dev->resource[0], p_dev->resource[1], p_dev->resource[2],
300 p_dev->resource[3], p_dev->resource[4]);
294 301
295 mutex_lock(&s->ops_mutex); 302 mutex_lock(&s->ops_mutex);
296 if ((s->pcmcia_pfc) && 303 if ((s->pcmcia_pfc) &&
@@ -374,13 +381,13 @@ static int pcmcia_device_remove(struct device *dev)
374 if (p_dev->_irq || p_dev->_io || p_dev->_locked) 381 if (p_dev->_irq || p_dev->_io || p_dev->_locked)
375 dev_printk(KERN_INFO, dev, 382 dev_printk(KERN_INFO, dev,
376 "pcmcia: driver %s did not release config properly\n", 383 "pcmcia: driver %s did not release config properly\n",
377 p_drv->drv.name); 384 p_drv->name);
378 385
379 for (i = 0; i < MAX_WIN; i++) 386 for (i = 0; i < MAX_WIN; i++)
380 if (p_dev->_win & CLIENT_WIN_REQ(i)) 387 if (p_dev->_win & CLIENT_WIN_REQ(i))
381 dev_printk(KERN_INFO, dev, 388 dev_printk(KERN_INFO, dev,
382 "pcmcia: driver %s did not release window properly\n", 389 "pcmcia: driver %s did not release window properly\n",
383 p_drv->drv.name); 390 p_drv->name);
384 391
385 /* references from pcmcia_probe_device */ 392 /* references from pcmcia_probe_device */
386 pcmcia_put_dev(p_dev); 393 pcmcia_put_dev(p_dev);
@@ -1136,7 +1143,7 @@ static int pcmcia_dev_suspend(struct device *dev, pm_message_t state)
1136 dev_printk(KERN_ERR, dev, 1143 dev_printk(KERN_ERR, dev,
1137 "pcmcia: device %s (driver %s) did " 1144 "pcmcia: device %s (driver %s) did "
1138 "not want to go to sleep (%d)\n", 1145 "not want to go to sleep (%d)\n",
1139 p_dev->devname, p_drv->drv.name, ret); 1146 p_dev->devname, p_drv->name, ret);
1140 mutex_lock(&p_dev->socket->ops_mutex); 1147 mutex_lock(&p_dev->socket->ops_mutex);
1141 p_dev->suspended = 0; 1148 p_dev->suspended = 0;
1142 mutex_unlock(&p_dev->socket->ops_mutex); 1149 mutex_unlock(&p_dev->socket->ops_mutex);
@@ -1178,7 +1185,7 @@ static int pcmcia_dev_resume(struct device *dev)
1178 1185
1179 if (p_dev->device_no == p_dev->func) { 1186 if (p_dev->device_no == p_dev->func) {
1180 dev_dbg(dev, "requesting configuration\n"); 1187 dev_dbg(dev, "requesting configuration\n");
1181 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1188 ret = pcmcia_enable_device(p_dev);
1182 if (ret) 1189 if (ret)
1183 goto out; 1190 goto out;
1184 } 1191 }
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index 05d0879ce935..fc7906eaf228 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -16,7 +16,6 @@
16#include <linux/device.h> 16#include <linux/device.h>
17 17
18#include <pcmcia/ss.h> 18#include <pcmcia/ss.h>
19#include <pcmcia/cs.h>
20 19
21#include <asm/system.h> 20#include <asm/system.h>
22#include <asm/io.h> 21#include <asm/io.h>
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index 61746bd598b3..72a033a2acdb 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -51,7 +51,6 @@
51#include <asm/system.h> 51#include <asm/system.h>
52 52
53#include <pcmcia/ss.h> 53#include <pcmcia/ss.h>
54#include <pcmcia/cs.h>
55 54
56#include <linux/isapnp.h> 55#include <linux/isapnp.h>
57 56
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 24de49925863..2adb0106a039 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -27,7 +27,6 @@
27#include <asm/system.h> 27#include <asm/system.h>
28 28
29#include <pcmcia/ss.h> 29#include <pcmcia/ss.h>
30#include <pcmcia/cs.h>
31 30
32#undef MAX_IO_WIN /* FIXME */ 31#undef MAX_IO_WIN /* FIXME */
33#define MAX_IO_WIN 1 32#define MAX_IO_WIN 1
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 8e4723844ad3..1511ff71c87b 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -28,7 +28,6 @@
28#include <asm/addrspace.h> 28#include <asm/addrspace.h>
29 29
30#include <pcmcia/ss.h> 30#include <pcmcia/ss.h>
31#include <pcmcia/cs.h>
32 31
33/* XXX: should be moved into asm/irq.h */ 32/* XXX: should be moved into asm/irq.h */
34#define PCC0_IRQ 24 33#define PCC0_IRQ 24
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index f0ecad99ce81..99d4f23cb435 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -59,7 +59,6 @@
59#include <asm/irq.h> 59#include <asm/irq.h>
60#include <asm/fs_pd.h> 60#include <asm/fs_pd.h>
61 61
62#include <pcmcia/cs.h>
63#include <pcmcia/ss.h> 62#include <pcmcia/ss.h>
64 63
65#define pcmcia_info(args...) printk(KERN_INFO "m8xx_pcmcia: "args) 64#define pcmcia_info(args...) printk(KERN_INFO "m8xx_pcmcia: "args)
diff --git a/drivers/pcmcia/o2micro.h b/drivers/pcmcia/o2micro.h
index e74bebac2695..5096e92c7a4c 100644
--- a/drivers/pcmcia/o2micro.h
+++ b/drivers/pcmcia/o2micro.h
@@ -153,14 +153,14 @@ static int o2micro_override(struct yenta_socket *socket)
153 153
154 if (use_speedup) { 154 if (use_speedup) {
155 dev_info(&socket->dev->dev, 155 dev_info(&socket->dev->dev,
156 "O2: enabling read prefetch/write burst\n"); 156 "O2: enabling read prefetch/write burst. If you experience problems or performance issues, use the yenta_socket parameter 'o2_speedup=off'\n");
157 config_writeb(socket, O2_RESERVED1, 157 config_writeb(socket, O2_RESERVED1,
158 a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); 158 a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST);
159 config_writeb(socket, O2_RESERVED2, 159 config_writeb(socket, O2_RESERVED2,
160 b | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); 160 b | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST);
161 } else { 161 } else {
162 dev_info(&socket->dev->dev, 162 dev_info(&socket->dev->dev,
163 "O2: disabling read prefetch/write burst\n"); 163 "O2: disabling read prefetch/write burst. If you experience problems or performance issues, use the yenta_socket parameter 'o2_speedup=on'\n");
164 config_writeb(socket, O2_RESERVED1, 164 config_writeb(socket, O2_RESERVED1,
165 a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); 165 a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST));
166 config_writeb(socket, O2_RESERVED2, 166 config_writeb(socket, O2_RESERVED2,
diff --git a/drivers/pcmcia/pcmcia_cis.c b/drivers/pcmcia/pcmcia_cis.c
index 0ac54da15885..e2c92415b892 100644
--- a/drivers/pcmcia/pcmcia_cis.c
+++ b/drivers/pcmcia/pcmcia_cis.c
@@ -6,7 +6,7 @@
6 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 6 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
7 * 7 *
8 * Copyright (C) 1999 David A. Hinds 8 * Copyright (C) 1999 David A. Hinds
9 * Copyright (C) 2004-2009 Dominik Brodowski 9 * Copyright (C) 2004-2010 Dominik Brodowski
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -22,7 +22,6 @@
22#include <pcmcia/cisreg.h> 22#include <pcmcia/cisreg.h>
23#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
24#include <pcmcia/ss.h> 24#include <pcmcia/ss.h>
25#include <pcmcia/cs.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
27#include "cs_internal.h" 26#include "cs_internal.h"
28 27
@@ -126,14 +125,24 @@ next_entry:
126 return ret; 125 return ret;
127} 126}
128 127
128
129/**
130 * pcmcia_io_cfg_data_width() - convert cfgtable to data path width parameter
131 */
132static int pcmcia_io_cfg_data_width(unsigned int flags)
133{
134 if (!(flags & CISTPL_IO_8BIT))
135 return IO_DATA_PATH_WIDTH_16;
136 if (!(flags & CISTPL_IO_16BIT))
137 return IO_DATA_PATH_WIDTH_8;
138 return IO_DATA_PATH_WIDTH_AUTO;
139}
140
141
129struct pcmcia_cfg_mem { 142struct pcmcia_cfg_mem {
130 struct pcmcia_device *p_dev; 143 struct pcmcia_device *p_dev;
144 int (*conf_check) (struct pcmcia_device *p_dev, void *priv_data);
131 void *priv_data; 145 void *priv_data;
132 int (*conf_check) (struct pcmcia_device *p_dev,
133 cistpl_cftable_entry_t *cfg,
134 cistpl_cftable_entry_t *dflt,
135 unsigned int vcc,
136 void *priv_data);
137 cisparse_t parse; 146 cisparse_t parse;
138 cistpl_cftable_entry_t dflt; 147 cistpl_cftable_entry_t dflt;
139}; 148};
@@ -147,25 +156,102 @@ struct pcmcia_cfg_mem {
147 */ 156 */
148static int pcmcia_do_loop_config(tuple_t *tuple, cisparse_t *parse, void *priv) 157static int pcmcia_do_loop_config(tuple_t *tuple, cisparse_t *parse, void *priv)
149{ 158{
150 cistpl_cftable_entry_t *cfg = &parse->cftable_entry;
151 struct pcmcia_cfg_mem *cfg_mem = priv; 159 struct pcmcia_cfg_mem *cfg_mem = priv;
160 struct pcmcia_device *p_dev = cfg_mem->p_dev;
161 cistpl_cftable_entry_t *cfg = &parse->cftable_entry;
162 cistpl_cftable_entry_t *dflt = &cfg_mem->dflt;
163 unsigned int flags = p_dev->config_flags;
164 unsigned int vcc = p_dev->socket->socket.Vcc;
165
166 dev_dbg(&p_dev->dev, "testing configuration %x, autoconf %x\n",
167 cfg->index, flags);
152 168
153 /* default values */ 169 /* default values */
154 cfg_mem->p_dev->conf.ConfigIndex = cfg->index; 170 cfg_mem->p_dev->config_index = cfg->index;
155 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 171 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
156 cfg_mem->dflt = *cfg; 172 cfg_mem->dflt = *cfg;
157 173
158 return cfg_mem->conf_check(cfg_mem->p_dev, cfg, &cfg_mem->dflt, 174 /* check for matching Vcc? */
159 cfg_mem->p_dev->socket->socket.Vcc, 175 if (flags & CONF_AUTO_CHECK_VCC) {
160 cfg_mem->priv_data); 176 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
177 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
178 return -ENODEV;
179 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
180 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
181 return -ENODEV;
182 }
183 }
184
185 /* set Vpp? */
186 if (flags & CONF_AUTO_SET_VPP) {
187 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
188 p_dev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
189 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
190 p_dev->vpp =
191 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
192 }
193
194 /* enable audio? */
195 if ((flags & CONF_AUTO_AUDIO) && (cfg->flags & CISTPL_CFTABLE_AUDIO))
196 p_dev->config_flags |= CONF_ENABLE_SPKR;
197
198
199 /* IO window settings? */
200 if (flags & CONF_AUTO_SET_IO) {
201 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
202 int i = 0;
203
204 p_dev->resource[0]->start = p_dev->resource[0]->end = 0;
205 p_dev->resource[1]->start = p_dev->resource[1]->end = 0;
206 if (io->nwin == 0)
207 return -ENODEV;
208
209 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
210 p_dev->resource[0]->flags |=
211 pcmcia_io_cfg_data_width(io->flags);
212 if (io->nwin > 1) {
213 /* For multifunction cards, by convention, we
214 * configure the network function with window 0,
215 * and serial with window 1 */
216 i = (io->win[1].len > io->win[0].len);
217 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
218 p_dev->resource[1]->start = io->win[1-i].base;
219 p_dev->resource[1]->end = io->win[1-i].len;
220 }
221 p_dev->resource[0]->start = io->win[i].base;
222 p_dev->resource[0]->end = io->win[i].len;
223 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
224 }
225
226 /* MEM window settings? */
227 if (flags & CONF_AUTO_SET_IOMEM) {
228 /* so far, we only set one memory window */
229 cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
230
231 p_dev->resource[2]->start = p_dev->resource[2]->end = 0;
232 if (mem->nwin == 0)
233 return -ENODEV;
234
235 p_dev->resource[2]->start = mem->win[0].host_addr;
236 p_dev->resource[2]->end = mem->win[0].len;
237 if (p_dev->resource[2]->end < 0x1000)
238 p_dev->resource[2]->end = 0x1000;
239 p_dev->card_addr = mem->win[0].card_addr;
240 }
241
242 dev_dbg(&p_dev->dev,
243 "checking configuration %x: %pr %pr %pr (%d lines)\n",
244 p_dev->config_index, p_dev->resource[0], p_dev->resource[1],
245 p_dev->resource[2], p_dev->io_lines);
246
247 return cfg_mem->conf_check(p_dev, cfg_mem->priv_data);
161} 248}
162 249
163/** 250/**
164 * pcmcia_loop_config() - loop over configuration options 251 * pcmcia_loop_config() - loop over configuration options
165 * @p_dev: the struct pcmcia_device which we need to loop for. 252 * @p_dev: the struct pcmcia_device which we need to loop for.
166 * @conf_check: function to call for each configuration option. 253 * @conf_check: function to call for each configuration option.
167 * It gets passed the struct pcmcia_device, the CIS data 254 * It gets passed the struct pcmcia_device and private data
168 * describing the configuration option, and private data
169 * being passed to pcmcia_loop_config() 255 * being passed to pcmcia_loop_config()
170 * @priv_data: private data to be passed to the conf_check function. 256 * @priv_data: private data to be passed to the conf_check function.
171 * 257 *
@@ -175,9 +261,6 @@ static int pcmcia_do_loop_config(tuple_t *tuple, cisparse_t *parse, void *priv)
175 */ 261 */
176int pcmcia_loop_config(struct pcmcia_device *p_dev, 262int pcmcia_loop_config(struct pcmcia_device *p_dev,
177 int (*conf_check) (struct pcmcia_device *p_dev, 263 int (*conf_check) (struct pcmcia_device *p_dev,
178 cistpl_cftable_entry_t *cfg,
179 cistpl_cftable_entry_t *dflt,
180 unsigned int vcc,
181 void *priv_data), 264 void *priv_data),
182 void *priv_data) 265 void *priv_data)
183{ 266{
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 9ba4dade69a4..a9af0d784426 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -6,7 +6,7 @@
6 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 6 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
7 * 7 *
8 * Copyright (C) 1999 David A. Hinds 8 * Copyright (C) 1999 David A. Hinds
9 * Copyright (C) 2004-2005 Dominik Brodowski 9 * Copyright (C) 2004-2010 Dominik Brodowski
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -26,7 +26,6 @@
26#include <asm/irq.h> 26#include <asm/irq.h>
27 27
28#include <pcmcia/ss.h> 28#include <pcmcia/ss.h>
29#include <pcmcia/cs.h>
30#include <pcmcia/cistpl.h> 29#include <pcmcia/cistpl.h>
31#include <pcmcia/cisreg.h> 30#include <pcmcia/cisreg.h>
32#include <pcmcia/ds.h> 31#include <pcmcia/ds.h>
@@ -56,6 +55,12 @@ struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align,
56} 55}
57 56
58 57
58/**
59 * release_io_space() - release IO ports allocated with alloc_io_space()
60 * @s: pcmcia socket
61 * @res: resource to release
62 *
63 */
59static void release_io_space(struct pcmcia_socket *s, struct resource *res) 64static void release_io_space(struct pcmcia_socket *s, struct resource *res)
60{ 65{
61 resource_size_t num = resource_size(res); 66 resource_size_t num = resource_size(res);
@@ -81,9 +86,14 @@ static void release_io_space(struct pcmcia_socket *s, struct resource *res)
81 } 86 }
82 } 87 }
83 } 88 }
84} /* release_io_space */ 89}
90
85 91
86/** alloc_io_space 92/**
93 * alloc_io_space() - allocate IO ports for use by a PCMCIA device
94 * @s: pcmcia socket
95 * @res: resource to allocate (begin: begin, end: size)
96 * @lines: number of IO lines decoded by the PCMCIA card
87 * 97 *
88 * Special stuff for managing IO windows, because they are scarce 98 * Special stuff for managing IO windows, because they are scarce
89 */ 99 */
@@ -135,7 +145,7 @@ static int alloc_io_space(struct pcmcia_socket *s, struct resource *res,
135 } 145 }
136 dev_dbg(&s->dev, "alloc_io_space request result %d: %pR\n", ret, res); 146 dev_dbg(&s->dev, "alloc_io_space request result %d: %pR\n", ret, res);
137 return ret; 147 return ret;
138} /* alloc_io_space */ 148}
139 149
140 150
141/** 151/**
@@ -168,14 +178,14 @@ static int pcmcia_access_config(struct pcmcia_device *p_dev,
168 return -EACCES; 178 return -EACCES;
169 } 179 }
170 180
171 addr = (c->ConfigBase + where) >> 1; 181 addr = (p_dev->config_base + where) >> 1;
172 182
173 ret = accessf(s, 1, addr, 1, val); 183 ret = accessf(s, 1, addr, 1, val);
174 184
175 mutex_unlock(&s->ops_mutex); 185 mutex_unlock(&s->ops_mutex);
176 186
177 return ret; 187 return ret;
178} /* pcmcia_access_config */ 188}
179 189
180 190
181/** 191/**
@@ -204,11 +214,20 @@ int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val)
204EXPORT_SYMBOL(pcmcia_write_config_byte); 214EXPORT_SYMBOL(pcmcia_write_config_byte);
205 215
206 216
207int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, 217/**
218 * pcmcia_map_mem_page() - modify iomem window to point to a different offset
219 * @p_dev: pcmcia device
220 * @res: iomem resource already enabled by pcmcia_request_window()
221 * @offset: card_offset to map
222 *
223 * pcmcia_map_mem_page() modifies what can be read and written by accessing
224 * an iomem range previously enabled by pcmcia_request_window(), by setting
225 * the card_offset value to @offset.
226 */
227int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
208 unsigned int offset) 228 unsigned int offset)
209{ 229{
210 struct pcmcia_socket *s = p_dev->socket; 230 struct pcmcia_socket *s = p_dev->socket;
211 struct resource *res = wh;
212 unsigned int w; 231 unsigned int w;
213 int ret; 232 int ret;
214 233
@@ -223,98 +242,111 @@ int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh,
223 dev_warn(&p_dev->dev, "failed to set_mem_map\n"); 242 dev_warn(&p_dev->dev, "failed to set_mem_map\n");
224 mutex_unlock(&s->ops_mutex); 243 mutex_unlock(&s->ops_mutex);
225 return ret; 244 return ret;
226} /* pcmcia_map_mem_page */ 245}
227EXPORT_SYMBOL(pcmcia_map_mem_page); 246EXPORT_SYMBOL(pcmcia_map_mem_page);
228 247
229 248
230/** pcmcia_modify_configuration 249/**
250 * pcmcia_fixup_iowidth() - reduce io width to 8bit
251 * @p_dev: pcmcia device
231 * 252 *
232 * Modify a locked socket configuration 253 * pcmcia_fixup_iowidth() allows a PCMCIA device driver to reduce the
254 * IO width to 8bit after having called pcmcia_enable_device()
255 * previously.
233 */ 256 */
234int pcmcia_modify_configuration(struct pcmcia_device *p_dev, 257int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev)
235 modconf_t *mod)
236{ 258{
237 struct pcmcia_socket *s; 259 struct pcmcia_socket *s = p_dev->socket;
238 config_t *c; 260 pccard_io_map io_off = { 0, 0, 0, 0, 1 };
239 int ret; 261 pccard_io_map io_on;
240 262 int i, ret = 0;
241 s = p_dev->socket;
242 263
243 mutex_lock(&s->ops_mutex); 264 mutex_lock(&s->ops_mutex);
244 c = p_dev->function_config;
245 265
246 if (!(s->state & SOCKET_PRESENT)) { 266 dev_dbg(&p_dev->dev, "fixup iowidth to 8bit\n");
247 dev_dbg(&p_dev->dev, "No card present\n"); 267
248 ret = -ENODEV; 268 if (!(s->state & SOCKET_PRESENT) ||
249 goto unlock; 269 !(p_dev->function_config->state & CONFIG_LOCKED)) {
250 } 270 dev_dbg(&p_dev->dev, "No card? Config not locked?\n");
251 if (!(c->state & CONFIG_LOCKED)) {
252 dev_dbg(&p_dev->dev, "Configuration isnt't locked\n");
253 ret = -EACCES; 271 ret = -EACCES;
254 goto unlock; 272 goto unlock;
255 } 273 }
256 274
257 if (mod->Attributes & (CONF_IRQ_CHANGE_VALID | CONF_VCC_CHANGE_VALID)) { 275 io_on.speed = io_speed;
258 dev_dbg(&p_dev->dev, 276 for (i = 0; i < MAX_IO_WIN; i++) {
259 "changing Vcc or IRQ is not allowed at this time\n"); 277 if (!s->io[i].res)
260 ret = -EINVAL; 278 continue;
261 goto unlock; 279 io_off.map = i;
262 } 280 io_on.map = i;
263 281
264 /* We only allow changing Vpp1 and Vpp2 to the same value */ 282 io_on.flags = MAP_ACTIVE | IO_DATA_PATH_WIDTH_8;
265 if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && 283 io_on.start = s->io[i].res->start;
266 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { 284 io_on.stop = s->io[i].res->end;
267 if (mod->Vpp1 != mod->Vpp2) { 285
268 dev_dbg(&p_dev->dev, 286 s->ops->set_io_map(s, &io_off);
269 "Vpp1 and Vpp2 must be the same\n"); 287 mdelay(40);
270 ret = -EINVAL; 288 s->ops->set_io_map(s, &io_on);
271 goto unlock;
272 }
273 s->socket.Vpp = mod->Vpp1;
274 if (s->ops->set_socket(s, &s->socket)) {
275 dev_printk(KERN_WARNING, &p_dev->dev,
276 "Unable to set VPP\n");
277 ret = -EIO;
278 goto unlock;
279 }
280 } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) ||
281 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) {
282 dev_dbg(&p_dev->dev,
283 "changing Vcc is not allowed at this time\n");
284 ret = -EINVAL;
285 goto unlock;
286 } 289 }
290unlock:
291 mutex_unlock(&s->ops_mutex);
292
293 return ret;
294}
295EXPORT_SYMBOL(pcmcia_fixup_iowidth);
296
297
298/**
299 * pcmcia_fixup_vpp() - set Vpp to a new voltage level
300 * @p_dev: pcmcia device
301 * @new_vpp: new Vpp voltage
302 *
303 * pcmcia_fixup_vpp() allows a PCMCIA device driver to set Vpp to
304 * a new voltage level between calls to pcmcia_enable_device()
305 * and pcmcia_disable_device().
306 */
307int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp)
308{
309 struct pcmcia_socket *s = p_dev->socket;
310 int ret = 0;
287 311
288 if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { 312 mutex_lock(&s->ops_mutex);
289 pccard_io_map io_off = { 0, 0, 0, 0, 1 };
290 pccard_io_map io_on;
291 int i;
292 313
293 io_on.speed = io_speed; 314 dev_dbg(&p_dev->dev, "fixup Vpp to %d\n", new_vpp);
294 for (i = 0; i < MAX_IO_WIN; i++) {
295 if (!s->io[i].res)
296 continue;
297 io_off.map = i;
298 io_on.map = i;
299 315
300 io_on.flags = MAP_ACTIVE | IO_DATA_PATH_WIDTH_8; 316 if (!(s->state & SOCKET_PRESENT) ||
301 io_on.start = s->io[i].res->start; 317 !(p_dev->function_config->state & CONFIG_LOCKED)) {
302 io_on.stop = s->io[i].res->end; 318 dev_dbg(&p_dev->dev, "No card? Config not locked?\n");
319 ret = -EACCES;
320 goto unlock;
321 }
303 322
304 s->ops->set_io_map(s, &io_off); 323 s->socket.Vpp = new_vpp;
305 mdelay(40); 324 if (s->ops->set_socket(s, &s->socket)) {
306 s->ops->set_io_map(s, &io_on); 325 dev_warn(&p_dev->dev, "Unable to set VPP\n");
307 } 326 ret = -EIO;
327 goto unlock;
308 } 328 }
309 ret = 0; 329 p_dev->vpp = new_vpp;
330
310unlock: 331unlock:
311 mutex_unlock(&s->ops_mutex); 332 mutex_unlock(&s->ops_mutex);
312 333
313 return ret; 334 return ret;
314} /* modify_configuration */ 335}
315EXPORT_SYMBOL(pcmcia_modify_configuration); 336EXPORT_SYMBOL(pcmcia_fixup_vpp);
316 337
317 338
339/**
340 * pcmcia_release_configuration() - physically disable a PCMCIA device
341 * @p_dev: pcmcia device
342 *
343 * pcmcia_release_configuration() is the 1:1 counterpart to
344 * pcmcia_enable_device(): If a PCMCIA device is no longer used by any
345 * driver, the Vpp voltage is set to 0, IRQs will no longer be generated,
346 * and I/O ranges will be disabled. As pcmcia_release_io() and
347 * pcmcia_release_window() still need to be called, device drivers are
348 * expected to call pcmcia_disable_device() instead.
349 */
318int pcmcia_release_configuration(struct pcmcia_device *p_dev) 350int pcmcia_release_configuration(struct pcmcia_device *p_dev)
319{ 351{
320 pccard_io_map io = { 0, 0, 0, 0, 1 }; 352 pccard_io_map io = { 0, 0, 0, 0, 1 };
@@ -327,7 +359,7 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
327 if (p_dev->_locked) { 359 if (p_dev->_locked) {
328 p_dev->_locked = 0; 360 p_dev->_locked = 0;
329 if (--(s->lock_count) == 0) { 361 if (--(s->lock_count) == 0) {
330 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ 362 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */
331 s->socket.Vpp = 0; 363 s->socket.Vpp = 0;
332 s->socket.io_irq = 0; 364 s->socket.io_irq = 0;
333 s->ops->set_socket(s, &s->socket); 365 s->ops->set_socket(s, &s->socket);
@@ -349,16 +381,18 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
349 mutex_unlock(&s->ops_mutex); 381 mutex_unlock(&s->ops_mutex);
350 382
351 return 0; 383 return 0;
352} /* pcmcia_release_configuration */ 384}
353 385
354 386
355/** pcmcia_release_io 387/**
388 * pcmcia_release_io() - release I/O allocated by a PCMCIA device
389 * @p_dev: pcmcia device
356 * 390 *
357 * Release_io() releases the I/O ranges allocated by a client. This 391 * pcmcia_release_io() releases the I/O ranges allocated by a PCMCIA
358 * may be invoked some time after a card ejection has already dumped 392 * device. This may be invoked some time after a card ejection has
359 * the actual socket configuration, so if the client is "stale", we 393 * already dumped the actual socket configuration, so if the client is
360 * don't bother checking the port ranges against the current socket 394 * "stale", we don't bother checking the port ranges against the
361 * values. 395 * current socket values.
362 */ 396 */
363static int pcmcia_release_io(struct pcmcia_device *p_dev) 397static int pcmcia_release_io(struct pcmcia_device *p_dev)
364{ 398{
@@ -387,6 +421,14 @@ out:
387} /* pcmcia_release_io */ 421} /* pcmcia_release_io */
388 422
389 423
424/**
425 * pcmcia_release_window() - release reserved iomem for PCMCIA devices
426 * @p_dev: pcmcia device
427 * @res: iomem resource to release
428 *
429 * pcmcia_release_window() releases &struct resource *res which was
430 * previously reserved by calling pcmcia_request_window().
431 */
390int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res) 432int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res)
391{ 433{
392 struct pcmcia_socket *s = p_dev->socket; 434 struct pcmcia_socket *s = p_dev->socket;
@@ -420,6 +462,8 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res)
420 kfree(win->res); 462 kfree(win->res);
421 win->res = NULL; 463 win->res = NULL;
422 } 464 }
465 res->start = res->end = 0;
466 res->flags = IORESOURCE_MEM;
423 p_dev->_win &= ~CLIENT_WIN_REQ(w); 467 p_dev->_win &= ~CLIENT_WIN_REQ(w);
424 mutex_unlock(&s->ops_mutex); 468 mutex_unlock(&s->ops_mutex);
425 469
@@ -428,23 +472,30 @@ int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res)
428EXPORT_SYMBOL(pcmcia_release_window); 472EXPORT_SYMBOL(pcmcia_release_window);
429 473
430 474
431int pcmcia_request_configuration(struct pcmcia_device *p_dev, 475/**
432 config_req_t *req) 476 * pcmcia_enable_device() - set up and activate a PCMCIA device
477 * @p_dev: the associated PCMCIA device
478 *
479 * pcmcia_enable_device() physically enables a PCMCIA device. It parses
480 * the flags passed to in @flags and stored in @p_dev->flags and sets up
481 * the Vpp voltage, enables the speaker line, I/O ports and store proper
482 * values to configuration registers.
483 */
484int pcmcia_enable_device(struct pcmcia_device *p_dev)
433{ 485{
434 int i; 486 int i;
435 u_int base; 487 unsigned int base;
436 struct pcmcia_socket *s = p_dev->socket; 488 struct pcmcia_socket *s = p_dev->socket;
437 config_t *c; 489 config_t *c;
438 pccard_io_map iomap; 490 pccard_io_map iomap;
491 unsigned char status = 0;
492 unsigned char ext_status = 0;
493 unsigned char option = 0;
494 unsigned int flags = p_dev->config_flags;
439 495
440 if (!(s->state & SOCKET_PRESENT)) 496 if (!(s->state & SOCKET_PRESENT))
441 return -ENODEV; 497 return -ENODEV;
442 498
443 if (req->IntType & INT_CARDBUS) {
444 dev_dbg(&p_dev->dev, "IntType may not be INT_CARDBUS\n");
445 return -EINVAL;
446 }
447
448 mutex_lock(&s->ops_mutex); 499 mutex_lock(&s->ops_mutex);
449 c = p_dev->function_config; 500 c = p_dev->function_config;
450 if (c->state & CONFIG_LOCKED) { 501 if (c->state & CONFIG_LOCKED) {
@@ -454,7 +505,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
454 } 505 }
455 506
456 /* Do power control. We don't allow changes in Vcc. */ 507 /* Do power control. We don't allow changes in Vcc. */
457 s->socket.Vpp = req->Vpp; 508 s->socket.Vpp = p_dev->vpp;
458 if (s->ops->set_socket(s, &s->socket)) { 509 if (s->ops->set_socket(s, &s->socket)) {
459 mutex_unlock(&s->ops_mutex); 510 mutex_unlock(&s->ops_mutex);
460 dev_printk(KERN_WARNING, &p_dev->dev, 511 dev_printk(KERN_WARNING, &p_dev->dev,
@@ -463,64 +514,72 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
463 } 514 }
464 515
465 /* Pick memory or I/O card, DMA mode, interrupt */ 516 /* Pick memory or I/O card, DMA mode, interrupt */
466 c->IntType = req->IntType; 517 if (p_dev->_io)
467 c->Attributes = req->Attributes;
468 if (req->IntType & INT_MEMORY_AND_IO)
469 s->socket.flags |= SS_IOCARD; 518 s->socket.flags |= SS_IOCARD;
470 if (req->IntType & INT_ZOOMED_VIDEO) 519 if (flags & CONF_ENABLE_SPKR) {
471 s->socket.flags |= SS_ZVCARD | SS_IOCARD;
472 if (req->Attributes & CONF_ENABLE_DMA)
473 s->socket.flags |= SS_DMA_MODE;
474 if (req->Attributes & CONF_ENABLE_SPKR)
475 s->socket.flags |= SS_SPKR_ENA; 520 s->socket.flags |= SS_SPKR_ENA;
476 if (req->Attributes & CONF_ENABLE_IRQ) 521 status = CCSR_AUDIO_ENA;
522 if (!(p_dev->config_regs & PRESENT_STATUS))
523 dev_warn(&p_dev->dev, "speaker requested, but "
524 "PRESENT_STATUS not set!\n");
525 }
526 if (flags & CONF_ENABLE_IRQ)
477 s->socket.io_irq = s->pcmcia_irq; 527 s->socket.io_irq = s->pcmcia_irq;
478 else 528 else
479 s->socket.io_irq = 0; 529 s->socket.io_irq = 0;
530 if (flags & CONF_ENABLE_ESR) {
531 p_dev->config_regs |= PRESENT_EXT_STATUS;
532 ext_status = ESR_REQ_ATTN_ENA;
533 }
480 s->ops->set_socket(s, &s->socket); 534 s->ops->set_socket(s, &s->socket);
481 s->lock_count++; 535 s->lock_count++;
482 536
537 dev_dbg(&p_dev->dev,
538 "enable_device: V %d, flags %x, base %x, regs %x, idx %x\n",
539 p_dev->vpp, flags, p_dev->config_base, p_dev->config_regs,
540 p_dev->config_index);
541
483 /* Set up CIS configuration registers */ 542 /* Set up CIS configuration registers */
484 base = c->ConfigBase = req->ConfigBase; 543 base = p_dev->config_base;
485 c->CardValues = req->Present; 544 if (p_dev->config_regs & PRESENT_COPY) {
486 if (req->Present & PRESENT_COPY) { 545 u16 tmp = 0;
487 c->Copy = req->Copy; 546 dev_dbg(&p_dev->dev, "clearing CISREG_SCR\n");
488 pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy); 547 pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &tmp);
489 } 548 }
490 if (req->Present & PRESENT_OPTION) { 549 if (p_dev->config_regs & PRESENT_PIN_REPLACE) {
550 u16 tmp = 0;
551 dev_dbg(&p_dev->dev, "clearing CISREG_PRR\n");
552 pcmcia_write_cis_mem(s, 1, (base + CISREG_PRR)>>1, 1, &tmp);
553 }
554 if (p_dev->config_regs & PRESENT_OPTION) {
491 if (s->functions == 1) { 555 if (s->functions == 1) {
492 c->Option = req->ConfigIndex & COR_CONFIG_MASK; 556 option = p_dev->config_index & COR_CONFIG_MASK;
493 } else { 557 } else {
494 c->Option = req->ConfigIndex & COR_MFC_CONFIG_MASK; 558 option = p_dev->config_index & COR_MFC_CONFIG_MASK;
495 c->Option |= COR_FUNC_ENA|COR_IREQ_ENA; 559 option |= COR_FUNC_ENA|COR_IREQ_ENA;
496 if (req->Present & PRESENT_IOBASE_0) 560 if (p_dev->config_regs & PRESENT_IOBASE_0)
497 c->Option |= COR_ADDR_DECODE; 561 option |= COR_ADDR_DECODE;
498 } 562 }
499 if ((req->Attributes & CONF_ENABLE_IRQ) && 563 if ((flags & CONF_ENABLE_IRQ) &&
500 !(req->Attributes & CONF_ENABLE_PULSE_IRQ)) 564 !(flags & CONF_ENABLE_PULSE_IRQ))
501 c->Option |= COR_LEVEL_REQ; 565 option |= COR_LEVEL_REQ;
502 pcmcia_write_cis_mem(s, 1, (base + CISREG_COR)>>1, 1, &c->Option); 566 pcmcia_write_cis_mem(s, 1, (base + CISREG_COR)>>1, 1, &option);
503 mdelay(40); 567 mdelay(40);
504 } 568 }
505 if (req->Present & PRESENT_STATUS) { 569 if (p_dev->config_regs & PRESENT_STATUS)
506 c->Status = req->Status; 570 pcmcia_write_cis_mem(s, 1, (base + CISREG_CCSR)>>1, 1, &status);
507 pcmcia_write_cis_mem(s, 1, (base + CISREG_CCSR)>>1, 1, &c->Status); 571
508 } 572 if (p_dev->config_regs & PRESENT_EXT_STATUS)
509 if (req->Present & PRESENT_PIN_REPLACE) { 573 pcmcia_write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1,
510 c->Pin = req->Pin; 574 &ext_status);
511 pcmcia_write_cis_mem(s, 1, (base + CISREG_PRR)>>1, 1, &c->Pin); 575
512 } 576 if (p_dev->config_regs & PRESENT_IOBASE_0) {
513 if (req->Present & PRESENT_EXT_STATUS) {
514 c->ExtStatus = req->ExtStatus;
515 pcmcia_write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1, &c->ExtStatus);
516 }
517 if (req->Present & PRESENT_IOBASE_0) {
518 u8 b = c->io[0].start & 0xff; 577 u8 b = c->io[0].start & 0xff;
519 pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b); 578 pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b);
520 b = (c->io[0].start >> 8) & 0xff; 579 b = (c->io[0].start >> 8) & 0xff;
521 pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b); 580 pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b);
522 } 581 }
523 if (req->Present & PRESENT_IOSIZE) { 582 if (p_dev->config_regs & PRESENT_IOSIZE) {
524 u8 b = resource_size(&c->io[0]) + resource_size(&c->io[1]) - 1; 583 u8 b = resource_size(&c->io[0]) + resource_size(&c->io[1]) - 1;
525 pcmcia_write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b); 584 pcmcia_write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b);
526 } 585 }
@@ -551,14 +610,15 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
551 p_dev->_locked = 1; 610 p_dev->_locked = 1;
552 mutex_unlock(&s->ops_mutex); 611 mutex_unlock(&s->ops_mutex);
553 return 0; 612 return 0;
554} /* pcmcia_request_configuration */ 613} /* pcmcia_enable_device */
555EXPORT_SYMBOL(pcmcia_request_configuration); 614EXPORT_SYMBOL(pcmcia_enable_device);
556 615
557 616
558/** 617/**
559 * pcmcia_request_io() - attempt to reserve port ranges for PCMCIA devices 618 * pcmcia_request_io() - attempt to reserve port ranges for PCMCIA devices
619 * @p_dev: the associated PCMCIA device
560 * 620 *
561 * pcmcia_request_io() attepts to reserve the IO port ranges specified in 621 * pcmcia_request_io() attempts to reserve the IO port ranges specified in
562 * &struct pcmcia_device @p_dev->resource[0] and @p_dev->resource[1]. The 622 * &struct pcmcia_device @p_dev->resource[0] and @p_dev->resource[1]. The
563 * "start" value is the requested start of the IO port resource; "end" 623 * "start" value is the requested start of the IO port resource; "end"
564 * reflects the number of ports requested. The number of IO lines requested 624 * reflects the number of ports requested. The number of IO lines requested
@@ -622,11 +682,13 @@ EXPORT_SYMBOL(pcmcia_request_io);
622 682
623/** 683/**
624 * pcmcia_request_irq() - attempt to request a IRQ for a PCMCIA device 684 * pcmcia_request_irq() - attempt to request a IRQ for a PCMCIA device
685 * @p_dev: the associated PCMCIA device
686 * @handler: IRQ handler to register
625 * 687 *
626 * pcmcia_request_irq() is a wrapper around request_irq which will allow 688 * pcmcia_request_irq() is a wrapper around request_irq() which allows
627 * the PCMCIA core to clean up the registration in pcmcia_disable_device(). 689 * the PCMCIA core to clean up the registration in pcmcia_disable_device().
628 * Drivers are free to use request_irq() directly, but then they need to 690 * Drivers are free to use request_irq() directly, but then they need to
629 * call free_irq themselfves, too. Also, only IRQF_SHARED capable IRQ 691 * call free_irq() themselfves, too. Also, only %IRQF_SHARED capable IRQ
630 * handlers are allowed. 692 * handlers are allowed.
631 */ 693 */
632int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev, 694int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
@@ -649,12 +711,14 @@ EXPORT_SYMBOL(pcmcia_request_irq);
649 711
650/** 712/**
651 * pcmcia_request_exclusive_irq() - attempt to request an exclusive IRQ first 713 * pcmcia_request_exclusive_irq() - attempt to request an exclusive IRQ first
714 * @p_dev: the associated PCMCIA device
715 * @handler: IRQ handler to register
652 * 716 *
653 * pcmcia_request_exclusive_irq() is a wrapper around request_irq which 717 * pcmcia_request_exclusive_irq() is a wrapper around request_irq() which
654 * attempts first to request an exclusive IRQ. If it fails, it also accepts 718 * attempts first to request an exclusive IRQ. If it fails, it also accepts
655 * a shared IRQ, but prints out a warning. PCMCIA drivers should allow for 719 * a shared IRQ, but prints out a warning. PCMCIA drivers should allow for
656 * IRQ sharing and either use request_irq directly (then they need to call 720 * IRQ sharing and either use request_irq directly (then they need to call
657 * free_irq themselves, too), or the pcmcia_request_irq() function. 721 * free_irq() themselves, too), or the pcmcia_request_irq() function.
658 */ 722 */
659int __must_check 723int __must_check
660__pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev, 724__pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
@@ -795,38 +859,47 @@ int pcmcia_setup_irq(struct pcmcia_device *p_dev)
795} 859}
796 860
797 861
798/** pcmcia_request_window 862/**
863 * pcmcia_request_window() - attempt to reserve iomem for PCMCIA devices
864 * @p_dev: the associated PCMCIA device
865 * @res: &struct resource pointing to p_dev->resource[2..5]
866 * @speed: access speed
799 * 867 *
800 * Request_window() establishes a mapping between card memory space 868 * pcmcia_request_window() attepts to reserve an iomem ranges specified in
801 * and system memory space. 869 * &struct resource @res pointing to one of the entries in
870 * &struct pcmcia_device @p_dev->resource[2..5]. The "start" value is the
871 * requested start of the IO mem resource; "end" reflects the size
872 * requested.
802 */ 873 */
803int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_handle_t *wh) 874int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
875 unsigned int speed)
804{ 876{
805 struct pcmcia_socket *s = p_dev->socket; 877 struct pcmcia_socket *s = p_dev->socket;
806 pccard_mem_map *win; 878 pccard_mem_map *win;
807 u_long align; 879 u_long align;
808 struct resource *res;
809 int w; 880 int w;
810 881
882 dev_dbg(&p_dev->dev, "request_window %pR %d\n", res, speed);
883
811 if (!(s->state & SOCKET_PRESENT)) { 884 if (!(s->state & SOCKET_PRESENT)) {
812 dev_dbg(&p_dev->dev, "No card present\n"); 885 dev_dbg(&p_dev->dev, "No card present\n");
813 return -ENODEV; 886 return -ENODEV;
814 } 887 }
815 888
816 /* Window size defaults to smallest available */ 889 /* Window size defaults to smallest available */
817 if (req->Size == 0) 890 if (res->end == 0)
818 req->Size = s->map_size; 891 res->end = s->map_size;
819 align = (s->features & SS_CAP_MEM_ALIGN) ? req->Size : s->map_size; 892 align = (s->features & SS_CAP_MEM_ALIGN) ? res->end : s->map_size;
820 if (req->Size & (s->map_size-1)) { 893 if (res->end & (s->map_size-1)) {
821 dev_dbg(&p_dev->dev, "invalid map size\n"); 894 dev_dbg(&p_dev->dev, "invalid map size\n");
822 return -EINVAL; 895 return -EINVAL;
823 } 896 }
824 if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || 897 if ((res->start && (s->features & SS_CAP_STATIC_MAP)) ||
825 (req->Base & (align-1))) { 898 (res->start & (align-1))) {
826 dev_dbg(&p_dev->dev, "invalid base address\n"); 899 dev_dbg(&p_dev->dev, "invalid base address\n");
827 return -EINVAL; 900 return -EINVAL;
828 } 901 }
829 if (req->Base) 902 if (res->start)
830 align = 0; 903 align = 0;
831 904
832 /* Allocate system memory window */ 905 /* Allocate system memory window */
@@ -843,7 +916,7 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
843 win = &s->win[w]; 916 win = &s->win[w];
844 917
845 if (!(s->features & SS_CAP_STATIC_MAP)) { 918 if (!(s->features & SS_CAP_STATIC_MAP)) {
846 win->res = pcmcia_find_mem_region(req->Base, req->Size, align, 919 win->res = pcmcia_find_mem_region(res->start, res->end, align,
847 0, s); 920 0, s);
848 if (!win->res) { 921 if (!win->res) {
849 dev_dbg(&p_dev->dev, "allocating mem region failed\n"); 922 dev_dbg(&p_dev->dev, "allocating mem region failed\n");
@@ -855,8 +928,8 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
855 928
856 /* Configure the socket controller */ 929 /* Configure the socket controller */
857 win->map = w+1; 930 win->map = w+1;
858 win->flags = req->Attributes; 931 win->flags = res->flags & WIN_FLAGS_MAP;
859 win->speed = req->AccessSpeed; 932 win->speed = speed;
860 win->card_start = 0; 933 win->card_start = 0;
861 934
862 if (s->ops->set_mem_map(s, win) != 0) { 935 if (s->ops->set_mem_map(s, win) != 0) {
@@ -868,17 +941,14 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
868 941
869 /* Return window handle */ 942 /* Return window handle */
870 if (s->features & SS_CAP_STATIC_MAP) 943 if (s->features & SS_CAP_STATIC_MAP)
871 req->Base = win->static_start; 944 res->start = win->static_start;
872 else 945 else
873 req->Base = win->res->start; 946 res->start = win->res->start;
874 947
875 /* convert to new-style resources */ 948 /* convert to new-style resources */
876 res = p_dev->resource[w + MAX_IO_WIN]; 949 res->end += res->start - 1;
877 res->start = req->Base; 950 res->flags &= ~WIN_FLAGS_REQ;
878 res->end = req->Base + req->Size - 1; 951 res->flags |= (win->map << 2) | IORESOURCE_MEM;
879 res->flags &= ~IORESOURCE_BITS;
880 res->flags |= (req->Attributes & WIN_FLAGS_MAP) | (win->map << 2);
881 res->flags |= IORESOURCE_MEM;
882 res->parent = win->res; 952 res->parent = win->res;
883 if (win->res) 953 if (win->res)
884 request_resource(&iomem_resource, res); 954 request_resource(&iomem_resource, res);
@@ -886,15 +956,30 @@ int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, window_ha
886 dev_dbg(&p_dev->dev, "request_window results in %pR\n", res); 956 dev_dbg(&p_dev->dev, "request_window results in %pR\n", res);
887 957
888 mutex_unlock(&s->ops_mutex); 958 mutex_unlock(&s->ops_mutex);
889 *wh = res;
890 959
891 return 0; 960 return 0;
892} /* pcmcia_request_window */ 961} /* pcmcia_request_window */
893EXPORT_SYMBOL(pcmcia_request_window); 962EXPORT_SYMBOL(pcmcia_request_window);
894 963
964
965/**
966 * pcmcia_disable_device() - disable and clean up a PCMCIA device
967 * @p_dev: the associated PCMCIA device
968 *
969 * pcmcia_disable_device() is the driver-callable counterpart to
970 * pcmcia_enable_device(): If a PCMCIA device is no longer used,
971 * drivers are expected to clean up and disable the device by calling
972 * this function. Any I/O ranges (iomem and ioports) will be released,
973 * the Vpp voltage will be set to 0, and IRQs will no longer be
974 * generated -- at least if there is no other card function (of
975 * multifunction devices) being used.
976 */
895void pcmcia_disable_device(struct pcmcia_device *p_dev) 977void pcmcia_disable_device(struct pcmcia_device *p_dev)
896{ 978{
897 int i; 979 int i;
980
981 dev_dbg(&p_dev->dev, "disabling device\n");
982
898 for (i = 0; i < MAX_WIN; i++) { 983 for (i = 0; i < MAX_WIN; i++) {
899 struct resource *res = p_dev->resource[MAX_IO_WIN + i]; 984 struct resource *res = p_dev->resource[MAX_IO_WIN + i];
900 if (res->flags & WIN_FLAGS_REQ) 985 if (res->flags & WIN_FLAGS_REQ)
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index deef6656ab7b..8cbfa067171f 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -18,7 +18,6 @@
18#include <linux/io.h> 18#include <linux/io.h>
19 19
20#include <pcmcia/ss.h> 20#include <pcmcia/ss.h>
21#include <pcmcia/cs.h>
22 21
23#include <asm/system.h> 22#include <asm/system.h>
24 23
diff --git a/drivers/pcmcia/rsrc_iodyn.c b/drivers/pcmcia/rsrc_iodyn.c
index 8510c35d2952..523eb691c30b 100644
--- a/drivers/pcmcia/rsrc_iodyn.c
+++ b/drivers/pcmcia/rsrc_iodyn.c
@@ -17,7 +17,6 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18 18
19#include <pcmcia/ss.h> 19#include <pcmcia/ss.h>
20#include <pcmcia/cs.h>
21#include <pcmcia/cistpl.h> 20#include <pcmcia/cistpl.h>
22#include "cs_internal.h" 21#include "cs_internal.h"
23 22
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index 4e80421fd908..aa628ed0e9f4 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -17,7 +17,6 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18 18
19#include <pcmcia/ss.h> 19#include <pcmcia/ss.h>
20#include <pcmcia/cs.h>
21#include <pcmcia/cistpl.h> 20#include <pcmcia/cistpl.h>
22#include "cs_internal.h" 21#include "cs_internal.h"
23 22
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 96f348b35fde..b187555d4388 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -29,7 +29,6 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <pcmcia/ss.h> 31#include <pcmcia/ss.h>
32#include <pcmcia/cs.h>
33#include <pcmcia/cistpl.h> 32#include <pcmcia/cistpl.h>
34#include "cs_internal.h" 33#include "cs_internal.h"
35 34
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index e09851480295..945857f8c284 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -35,7 +35,6 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37 37
38#include <pcmcia/cs.h>
39#include <pcmcia/ss.h> 38#include <pcmcia/ss.h>
40 39
41#include <asm/hardware/scoop.h> 40#include <asm/hardware/scoop.h>
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 6f1a86b43c60..689e3c02edb8 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -627,8 +627,6 @@ void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt)
627 627
628 pcmcia_unregister_socket(&skt->socket); 628 pcmcia_unregister_socket(&skt->socket);
629 629
630 flush_scheduled_work();
631
632 skt->ops->hw_shutdown(skt); 630 skt->ops->hw_shutdown(skt);
633 631
634 soc_common_pcmcia_config_skt(skt, &dead_socket); 632 soc_common_pcmcia_config_skt(skt, &dead_socket);
@@ -720,8 +718,6 @@ int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt)
720 pcmcia_unregister_socket(&skt->socket); 718 pcmcia_unregister_socket(&skt->socket);
721 719
722 out_err_7: 720 out_err_7:
723 flush_scheduled_work();
724
725 skt->ops->hw_shutdown(skt); 721 skt->ops->hw_shutdown(skt);
726 out_err_6: 722 out_err_6:
727 list_del(&skt->node); 723 list_del(&skt->node);
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 3fba3a679128..bbcd5385a221 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -11,7 +11,6 @@
11 11
12/* include the world */ 12/* include the world */
13#include <linux/cpufreq.h> 13#include <linux/cpufreq.h>
14#include <pcmcia/cs.h>
15#include <pcmcia/ss.h> 14#include <pcmcia/ss.h>
16#include <pcmcia/cistpl.h> 15#include <pcmcia/cistpl.h>
17 16
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index cb0d3ace18bd..71aeed93037c 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -27,7 +27,6 @@
27#include <asm/irq.h> 27#include <asm/irq.h>
28 28
29#include <pcmcia/ss.h> 29#include <pcmcia/ss.h>
30#include <pcmcia/cs.h>
31#include <pcmcia/cistpl.h> 30#include <pcmcia/cistpl.h>
32#include <pcmcia/cisreg.h> 31#include <pcmcia/cisreg.h>
33#include <pcmcia/ds.h> 32#include <pcmcia/ds.h>
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index be0d841c7ebd..310160bffe38 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -49,7 +49,6 @@
49#include <asm/io.h> 49#include <asm/io.h>
50#include <asm/system.h> 50#include <asm/system.h>
51 51
52#include <pcmcia/cs.h>
53#include <pcmcia/ss.h> 52#include <pcmcia/ss.h>
54#include "tcic.h" 53#include "tcic.h"
55 54
diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c
index 9b3c15827e5c..c6d36b3a6ce8 100644
--- a/drivers/pcmcia/vrc4173_cardu.c
+++ b/drivers/pcmcia/vrc4173_cardu.c
@@ -461,7 +461,7 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
461{ 461{
462 vrc4173_socket_t *socket; 462 vrc4173_socket_t *socket;
463 unsigned long start, len, flags; 463 unsigned long start, len, flags;
464 int slot, err; 464 int slot, err, ret;
465 465
466 slot = vrc4173_cardu_slots++; 466 slot = vrc4173_cardu_slots++;
467 socket = &cardu_sockets[slot]; 467 socket = &cardu_sockets[slot];
@@ -474,43 +474,63 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
474 return err; 474 return err;
475 475
476 start = pci_resource_start(dev, 0); 476 start = pci_resource_start(dev, 0);
477 if (start == 0) 477 if (start == 0) {
478 return -ENODEV; 478 ret = -ENODEV;
479 goto disable;
480 }
479 481
480 len = pci_resource_len(dev, 0); 482 len = pci_resource_len(dev, 0);
481 if (len == 0) 483 if (len == 0) {
482 return -ENODEV; 484 ret = -ENODEV;
485 goto disable;
486 }
483 487
484 if (((flags = pci_resource_flags(dev, 0)) & IORESOURCE_MEM) == 0) 488 flags = pci_resource_flags(dev, 0);
485 return -EBUSY; 489 if ((flags & IORESOURCE_MEM) == 0) {
490 ret = -EBUSY;
491 goto disable;
492 }
486 493
487 if ((err = pci_request_regions(dev, socket->name)) < 0) 494 err = pci_request_regions(dev, socket->name);
488 return err; 495 if (err < 0) {
496 ret = err;
497 goto disable;
498 }
489 499
490 socket->base = ioremap(start, len); 500 socket->base = ioremap(start, len);
491 if (socket->base == NULL) 501 if (socket->base == NULL) {
492 return -ENODEV; 502 ret = -ENODEV;
503 goto release;
504 }
493 505
494 socket->dev = dev; 506 socket->dev = dev;
495 507
496 socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1); 508 socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1);
497 if (socket->pcmcia_socket == NULL) { 509 if (socket->pcmcia_socket == NULL) {
498 iounmap(socket->base); 510 ret = -ENOMEM;
499 socket->base = NULL; 511 goto unmap;
500 return -ENOMEM;
501 } 512 }
502 513
503 if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) { 514 if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) {
504 pcmcia_unregister_socket(socket->pcmcia_socket); 515 ret = -EBUSY;
505 socket->pcmcia_socket = NULL; 516 goto unregister;
506 iounmap(socket->base);
507 socket->base = NULL;
508 return -EBUSY;
509 } 517 }
510 518
511 printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq); 519 printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq);
512 520
513 return 0; 521 return 0;
522
523unregister:
524 pcmcia_unregister_socket(socket->pcmcia_socket);
525 socket->pcmcia_socket = NULL;
526unmap:
527 iounmap(socket->base);
528 socket->base = NULL;
529release:
530 pci_release_regions(dev);
531disable:
532 pci_disable_device(dev);
533 return ret;
514} 534}
515 535
516static int __devinit vrc4173_cardu_setup(char *options) 536static int __devinit vrc4173_cardu_setup(char *options)
diff --git a/drivers/pcmcia/xxs1500_ss.c b/drivers/pcmcia/xxs1500_ss.c
index fa88c360c37a..3b67a1b6a197 100644
--- a/drivers/pcmcia/xxs1500_ss.c
+++ b/drivers/pcmcia/xxs1500_ss.c
@@ -17,7 +17,6 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19 19
20#include <pcmcia/cs.h>
21#include <pcmcia/ss.h> 20#include <pcmcia/ss.h>
22#include <pcmcia/cistpl.h> 21#include <pcmcia/cistpl.h>
23 22
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 414d9a6f9a32..408dbaa080a1 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -20,7 +20,6 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21 21
22#include <pcmcia/ss.h> 22#include <pcmcia/ss.h>
23#include <pcmcia/cs.h>
24 23
25#include "yenta_socket.h" 24#include "yenta_socket.h"
26#include "i82365.h" 25#include "i82365.h"
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 61f49bdcc0c2..e77dd02eccdd 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -49,7 +49,6 @@
49#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
50#include "aha152x.h" 50#include "aha152x.h"
51 51
52#include <pcmcia/cs.h>
53#include <pcmcia/cistpl.h> 52#include <pcmcia/cistpl.h>
54#include <pcmcia/ds.h> 53#include <pcmcia/ds.h>
55 54
@@ -86,8 +85,6 @@ static void aha152x_release_cs(struct pcmcia_device *link);
86static void aha152x_detach(struct pcmcia_device *p_dev); 85static void aha152x_detach(struct pcmcia_device *p_dev);
87static int aha152x_config_cs(struct pcmcia_device *link); 86static int aha152x_config_cs(struct pcmcia_device *link);
88 87
89static struct pcmcia_device *dev_list;
90
91static int aha152x_probe(struct pcmcia_device *link) 88static int aha152x_probe(struct pcmcia_device *link)
92{ 89{
93 scsi_info_t *info; 90 scsi_info_t *info;
@@ -100,11 +97,8 @@ static int aha152x_probe(struct pcmcia_device *link)
100 info->p_dev = link; 97 info->p_dev = link;
101 link->priv = info; 98 link->priv = info;
102 99
103 link->resource[0]->end = 0x20; 100 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
104 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 101 link->config_regs = PRESENT_OPTION;
105 link->conf.Attributes = CONF_ENABLE_IRQ;
106 link->conf.IntType = INT_MEMORY_AND_IO;
107 link->conf.Present = PRESENT_OPTION;
108 102
109 return aha152x_config_cs(link); 103 return aha152x_config_cs(link);
110} /* aha152x_attach */ 104} /* aha152x_attach */
@@ -123,25 +117,24 @@ static void aha152x_detach(struct pcmcia_device *link)
123 117
124/*====================================================================*/ 118/*====================================================================*/
125 119
126static int aha152x_config_check(struct pcmcia_device *p_dev, 120static int aha152x_config_check(struct pcmcia_device *p_dev, void *priv_data)
127 cistpl_cftable_entry_t *cfg,
128 cistpl_cftable_entry_t *dflt,
129 unsigned int vcc,
130 void *priv_data)
131{ 121{
132 p_dev->io_lines = 10; 122 p_dev->io_lines = 10;
123
133 /* For New Media T&J, look for a SCSI window */ 124 /* For New Media T&J, look for a SCSI window */
134 if (cfg->io.win[0].len >= 0x20) 125 if ((p_dev->resource[0]->end < 0x20) &&
135 p_dev->resource[0]->start = cfg->io.win[0].base; 126 (p_dev->resource[1]->end >= 0x20))
136 else if ((cfg->io.nwin > 1) && 127 p_dev->resource[0]->start = p_dev->resource[1]->start;
137 (cfg->io.win[1].len >= 0x20)) 128
138 p_dev->resource[0]->start = cfg->io.win[1].base; 129 if (p_dev->resource[0]->start >= 0xffff)
139 if ((cfg->io.nwin > 0) && 130 return -EINVAL;
140 (p_dev->resource[0]->start < 0xffff)) { 131
141 if (!pcmcia_request_io(p_dev)) 132 p_dev->resource[1]->start = p_dev->resource[1]->end = 0;
142 return 0; 133 p_dev->resource[0]->end = 0x20;
143 } 134 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
144 return -EINVAL; 135 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
136
137 return pcmcia_request_io(p_dev);
145} 138}
146 139
147static int aha152x_config_cs(struct pcmcia_device *link) 140static int aha152x_config_cs(struct pcmcia_device *link)
@@ -160,7 +153,7 @@ static int aha152x_config_cs(struct pcmcia_device *link)
160 if (!link->irq) 153 if (!link->irq)
161 goto failed; 154 goto failed;
162 155
163 ret = pcmcia_request_configuration(link, &link->conf); 156 ret = pcmcia_enable_device(link);
164 if (ret) 157 if (ret)
165 goto failed; 158 goto failed;
166 159
@@ -221,9 +214,7 @@ MODULE_DEVICE_TABLE(pcmcia, aha152x_ids);
221 214
222static struct pcmcia_driver aha152x_cs_driver = { 215static struct pcmcia_driver aha152x_cs_driver = {
223 .owner = THIS_MODULE, 216 .owner = THIS_MODULE,
224 .drv = { 217 .name = "aha152x_cs",
225 .name = "aha152x_cs",
226 },
227 .probe = aha152x_probe, 218 .probe = aha152x_probe,
228 .remove = aha152x_detach, 219 .remove = aha152x_detach,
229 .id_table = aha152x_ids, 220 .id_table = aha152x_ids,
@@ -238,7 +229,6 @@ static int __init init_aha152x_cs(void)
238static void __exit exit_aha152x_cs(void) 229static void __exit exit_aha152x_cs(void)
239{ 230{
240 pcmcia_unregister_driver(&aha152x_cs_driver); 231 pcmcia_unregister_driver(&aha152x_cs_driver);
241 BUG_ON(dev_list != NULL);
242} 232}
243 233
244module_init(init_aha152x_cs); 234module_init(init_aha152x_cs);
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 13dbe5c48492..cd69c2670f81 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -46,7 +46,6 @@
46#include <scsi/scsi_host.h> 46#include <scsi/scsi_host.h>
47#include "fdomain.h" 47#include "fdomain.h"
48 48
49#include <pcmcia/cs.h>
50#include <pcmcia/cistpl.h> 49#include <pcmcia/cistpl.h>
51#include <pcmcia/ds.h> 50#include <pcmcia/ds.h>
52 51
@@ -83,11 +82,8 @@ static int fdomain_probe(struct pcmcia_device *link)
83 82
84 info->p_dev = link; 83 info->p_dev = link;
85 link->priv = info; 84 link->priv = info;
86 link->resource[0]->end = 0x10; 85 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
87 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 86 link->config_regs = PRESENT_OPTION;
88 link->conf.Attributes = CONF_ENABLE_IRQ;
89 link->conf.IntType = INT_MEMORY_AND_IO;
90 link->conf.Present = PRESENT_OPTION;
91 87
92 return fdomain_config(link); 88 return fdomain_config(link);
93} /* fdomain_attach */ 89} /* fdomain_attach */
@@ -105,14 +101,12 @@ static void fdomain_detach(struct pcmcia_device *link)
105 101
106/*====================================================================*/ 102/*====================================================================*/
107 103
108static int fdomain_config_check(struct pcmcia_device *p_dev, 104static int fdomain_config_check(struct pcmcia_device *p_dev, void *priv_data)
109 cistpl_cftable_entry_t *cfg,
110 cistpl_cftable_entry_t *dflt,
111 unsigned int vcc,
112 void *priv_data)
113{ 105{
114 p_dev->io_lines = 10; 106 p_dev->io_lines = 10;
115 p_dev->resource[0]->start = cfg->io.win[0].base; 107 p_dev->resource[0]->end = 0x10;
108 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
109 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
116 return pcmcia_request_io(p_dev); 110 return pcmcia_request_io(p_dev);
117} 111}
118 112
@@ -132,7 +126,7 @@ static int fdomain_config(struct pcmcia_device *link)
132 126
133 if (!link->irq) 127 if (!link->irq)
134 goto failed; 128 goto failed;
135 ret = pcmcia_request_configuration(link, &link->conf); 129 ret = pcmcia_enable_device(link);
136 if (ret) 130 if (ret)
137 goto failed; 131 goto failed;
138 132
@@ -194,9 +188,7 @@ MODULE_DEVICE_TABLE(pcmcia, fdomain_ids);
194 188
195static struct pcmcia_driver fdomain_cs_driver = { 189static struct pcmcia_driver fdomain_cs_driver = {
196 .owner = THIS_MODULE, 190 .owner = THIS_MODULE,
197 .drv = { 191 .name = "fdomain_cs",
198 .name = "fdomain_cs",
199 },
200 .probe = fdomain_probe, 192 .probe = fdomain_probe,
201 .remove = fdomain_detach, 193 .remove = fdomain_detach,
202 .id_table = fdomain_ids, 194 .id_table = fdomain_ids,
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index dd9b40306f3d..9326c2c14880 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -47,7 +47,6 @@
47#include <scsi/scsi.h> 47#include <scsi/scsi.h>
48#include <scsi/scsi_ioctl.h> 48#include <scsi/scsi_ioctl.h>
49 49
50#include <pcmcia/cs.h>
51#include <pcmcia/cistpl.h> 50#include <pcmcia/cistpl.h>
52#include <pcmcia/cisreg.h> 51#include <pcmcia/cisreg.h>
53#include <pcmcia/ds.h> 52#include <pcmcia/ds.h>
@@ -1531,15 +1530,6 @@ static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
1531 PCMCIA functions 1530 PCMCIA functions
1532**********************************************************************/ 1531**********************************************************************/
1533 1532
1534/*======================================================================
1535 nsp_cs_attach() creates an "instance" of the driver, allocating
1536 local data structures for one device. The device is registered
1537 with Card Services.
1538
1539 The dev_link structure is initialized, but we don't actually
1540 configure the card at this point -- we wait until we receive a
1541 card insertion event.
1542======================================================================*/
1543static int nsp_cs_probe(struct pcmcia_device *link) 1533static int nsp_cs_probe(struct pcmcia_device *link)
1544{ 1534{
1545 scsi_info_t *info; 1535 scsi_info_t *info;
@@ -1557,14 +1547,6 @@ static int nsp_cs_probe(struct pcmcia_device *link)
1557 1547
1558 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info); 1548 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info);
1559 1549
1560 /* The io structure describes IO port mapping */
1561 link->resource[0]->end = 0x10;
1562 link->resource[0]->flags = IO_DATA_PATH_WIDTH_AUTO;
1563
1564 /* General socket configuration */
1565 link->conf.Attributes = CONF_ENABLE_IRQ;
1566 link->conf.IntType = INT_MEMORY_AND_IO;
1567
1568 ret = nsp_cs_config(link); 1550 ret = nsp_cs_config(link);
1569 1551
1570 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); 1552 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link);
@@ -1572,12 +1554,6 @@ static int nsp_cs_probe(struct pcmcia_device *link)
1572} /* nsp_cs_attach */ 1554} /* nsp_cs_attach */
1573 1555
1574 1556
1575/*======================================================================
1576 This deletes a driver "instance". The device is de-registered
1577 with Card Services. If it has been released, all local data
1578 structures are freed. Otherwise, the structures will be freed
1579 when the device is released.
1580======================================================================*/
1581static void nsp_cs_detach(struct pcmcia_device *link) 1557static void nsp_cs_detach(struct pcmcia_device *link)
1582{ 1558{
1583 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); 1559 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link);
@@ -1590,98 +1566,36 @@ static void nsp_cs_detach(struct pcmcia_device *link)
1590} /* nsp_cs_detach */ 1566} /* nsp_cs_detach */
1591 1567
1592 1568
1593/*====================================================================== 1569static int nsp_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
1594 nsp_cs_config() is scheduled to run after a CARD_INSERTION event
1595 is received, to configure the PCMCIA socket, and to make the
1596 ethernet device available to the system.
1597======================================================================*/
1598
1599struct nsp_cs_configdata {
1600 nsp_hw_data *data;
1601 win_req_t req;
1602};
1603
1604static int nsp_cs_config_check(struct pcmcia_device *p_dev,
1605 cistpl_cftable_entry_t *cfg,
1606 cistpl_cftable_entry_t *dflt,
1607 unsigned int vcc,
1608 void *priv_data)
1609{ 1570{
1610 struct nsp_cs_configdata *cfg_mem = priv_data; 1571 nsp_hw_data *data = priv_data;
1611 1572
1612 if (cfg->index == 0) 1573 if (p_dev->config_index == 0)
1613 return -ENODEV; 1574 return -ENODEV;
1614 1575
1615 /* Does this card need audio output? */ 1576 /* This reserves IO space but doesn't actually enable it */
1616 if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 1577 if (pcmcia_request_io(p_dev) != 0)
1617 p_dev->conf.Attributes |= CONF_ENABLE_SPKR; 1578 goto next_entry;
1618 p_dev->conf.Status = CCSR_AUDIO_ENA; 1579
1619 } 1580 if (resource_size(p_dev->resource[2])) {
1620 1581 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 |
1621 /* Use power settings for Vcc and Vpp if present */ 1582 WIN_MEMORY_TYPE_CM |
1622 /* Note that the CIS values need to be rescaled */ 1583 WIN_ENABLE);
1623 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1584 if (p_dev->resource[2]->end < 0x1000)
1624 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM]/10000) 1585 p_dev->resource[2]->end = 0x1000;
1625 return -ENODEV; 1586 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0)
1626 else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) { 1587 goto next_entry;
1627 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM]/10000) 1588 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2],
1628 return -ENODEV; 1589 p_dev->card_addr) != 0)
1629 } 1590 goto next_entry;
1630 1591
1631 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1592 data->MmioAddress = (unsigned long)
1632 p_dev->conf.Vpp = 1593 ioremap_nocache(p_dev->resource[2]->start,
1633 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 1594 resource_size(p_dev->resource[2]));
1634 } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1595 data->MmioLength = resource_size(p_dev->resource[2]);
1635 p_dev->conf.Vpp =
1636 dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
1637 }
1638
1639 /* Do we need to allocate an interrupt? */
1640 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
1641
1642 /* IO window settings */
1643 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
1644 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
1645 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
1646 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
1647 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
1648 p_dev->resource[0]->flags |=
1649 pcmcia_io_cfg_data_width(io->flags);
1650 p_dev->resource[0]->start = io->win[0].base;
1651 p_dev->resource[0]->end = io->win[0].len;
1652 if (io->nwin > 1) {
1653 p_dev->resource[1]->flags =
1654 p_dev->resource[0]->flags;
1655 p_dev->resource[1]->start = io->win[1].base;
1656 p_dev->resource[1]->end = io->win[1].len;
1657 }
1658 /* This reserves IO space but doesn't actually enable it */
1659 if (pcmcia_request_io(p_dev) != 0)
1660 goto next_entry;
1661 }
1662
1663 if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
1664 cistpl_mem_t *mem =
1665 (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
1666 cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
1667 cfg_mem->req.Attributes |= WIN_ENABLE;
1668 cfg_mem->req.Base = mem->win[0].host_addr;
1669 cfg_mem->req.Size = mem->win[0].len;
1670 if (cfg_mem->req.Size < 0x1000)
1671 cfg_mem->req.Size = 0x1000;
1672 cfg_mem->req.AccessSpeed = 0;
1673 if (pcmcia_request_window(p_dev, &cfg_mem->req, &p_dev->win) != 0)
1674 goto next_entry;
1675 if (pcmcia_map_mem_page(p_dev, p_dev->win,
1676 mem->win[0].card_addr) != 0)
1677 goto next_entry;
1678
1679 cfg_mem->data->MmioAddress = (unsigned long) ioremap_nocache(cfg_mem->req.Base, cfg_mem->req.Size);
1680 cfg_mem->data->MmioLength = cfg_mem->req.Size;
1681 }
1682 /* If we got this far, we're cool! */
1683 return 0;
1684 } 1596 }
1597 /* If we got this far, we're cool! */
1598 return 0;
1685 1599
1686next_entry: 1600next_entry:
1687 nsp_dbg(NSP_DEBUG_INIT, "next"); 1601 nsp_dbg(NSP_DEBUG_INIT, "next");
@@ -1693,25 +1607,23 @@ static int nsp_cs_config(struct pcmcia_device *link)
1693{ 1607{
1694 int ret; 1608 int ret;
1695 scsi_info_t *info = link->priv; 1609 scsi_info_t *info = link->priv;
1696 struct nsp_cs_configdata *cfg_mem;
1697 struct Scsi_Host *host; 1610 struct Scsi_Host *host;
1698 nsp_hw_data *data = &nsp_data_base; 1611 nsp_hw_data *data = &nsp_data_base;
1699 1612
1700 nsp_dbg(NSP_DEBUG_INIT, "in"); 1613 nsp_dbg(NSP_DEBUG_INIT, "in");
1701 1614
1702 cfg_mem = kzalloc(sizeof(*cfg_mem), GFP_KERNEL); 1615 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC |
1703 if (!cfg_mem) 1616 CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO | CONF_AUTO_SET_IOMEM |
1704 return -ENOMEM; 1617 CONF_AUTO_SET_IO;
1705 cfg_mem->data = data;
1706 1618
1707 ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem); 1619 ret = pcmcia_loop_config(link, nsp_cs_config_check, data);
1708 if (ret) 1620 if (ret)
1709 goto cs_failed; 1621 goto cs_failed;
1710 1622
1711 if (pcmcia_request_irq(link, nspintr)) 1623 if (pcmcia_request_irq(link, nspintr))
1712 goto cs_failed; 1624 goto cs_failed;
1713 1625
1714 ret = pcmcia_request_configuration(link, &link->conf); 1626 ret = pcmcia_enable_device(link);
1715 if (ret) 1627 if (ret)
1716 goto cs_failed; 1628 goto cs_failed;
1717 1629
@@ -1754,41 +1666,16 @@ static int nsp_cs_config(struct pcmcia_device *link)
1754 1666
1755 info->host = host; 1667 info->host = host;
1756 1668
1757 /* Finally, report what we've done */
1758 printk(KERN_INFO "nsp_cs: index 0x%02x: ",
1759 link->conf.ConfigIndex);
1760 if (link->conf.Vpp) {
1761 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
1762 }
1763 if (link->conf.Attributes & CONF_ENABLE_IRQ) {
1764 printk(", irq %d", link->irq);
1765 }
1766 if (link->resource[0])
1767 printk(", io %pR", link->resource[0]);
1768 if (link->resource[1])
1769 printk(" & %pR", link->resource[1]);
1770 if (link->win)
1771 printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base,
1772 cfg_mem->req.Base+cfg_mem->req.Size-1);
1773 printk("\n");
1774
1775 kfree(cfg_mem);
1776 return 0; 1669 return 0;
1777 1670
1778 cs_failed: 1671 cs_failed:
1779 nsp_dbg(NSP_DEBUG_INIT, "config fail"); 1672 nsp_dbg(NSP_DEBUG_INIT, "config fail");
1780 nsp_cs_release(link); 1673 nsp_cs_release(link);
1781 kfree(cfg_mem);
1782 1674
1783 return -ENODEV; 1675 return -ENODEV;
1784} /* nsp_cs_config */ 1676} /* nsp_cs_config */
1785 1677
1786 1678
1787/*======================================================================
1788 After a card is removed, nsp_cs_release() will unregister the net
1789 device, and release the PCMCIA configuration. If the device is
1790 still open, this will be postponed until it is closed.
1791======================================================================*/
1792static void nsp_cs_release(struct pcmcia_device *link) 1679static void nsp_cs_release(struct pcmcia_device *link)
1793{ 1680{
1794 scsi_info_t *info = link->priv; 1681 scsi_info_t *info = link->priv;
@@ -1807,7 +1694,7 @@ static void nsp_cs_release(struct pcmcia_device *link)
1807 scsi_remove_host(info->host); 1694 scsi_remove_host(info->host);
1808 } 1695 }
1809 1696
1810 if (link->win) { 1697 if (resource_size(link->resource[2])) {
1811 if (data != NULL) { 1698 if (data != NULL) {
1812 iounmap((void *)(data->MmioAddress)); 1699 iounmap((void *)(data->MmioAddress));
1813 } 1700 }
@@ -1877,9 +1764,7 @@ MODULE_DEVICE_TABLE(pcmcia, nsp_cs_ids);
1877 1764
1878static struct pcmcia_driver nsp_driver = { 1765static struct pcmcia_driver nsp_driver = {
1879 .owner = THIS_MODULE, 1766 .owner = THIS_MODULE,
1880 .drv = { 1767 .name = "nsp_cs",
1881 .name = "nsp_cs",
1882 },
1883 .probe = nsp_cs_probe, 1768 .probe = nsp_cs_probe,
1884 .remove = nsp_cs_detach, 1769 .remove = nsp_cs_detach,
1885 .id_table = nsp_cs_ids, 1770 .id_table = nsp_cs_ids,
@@ -1889,14 +1774,11 @@ static struct pcmcia_driver nsp_driver = {
1889 1774
1890static int __init nsp_cs_init(void) 1775static int __init nsp_cs_init(void)
1891{ 1776{
1892 nsp_msg(KERN_INFO, "loading...");
1893
1894 return pcmcia_register_driver(&nsp_driver); 1777 return pcmcia_register_driver(&nsp_driver);
1895} 1778}
1896 1779
1897static void __exit nsp_cs_exit(void) 1780static void __exit nsp_cs_exit(void)
1898{ 1781{
1899 nsp_msg(KERN_INFO, "unloading...");
1900 pcmcia_unregister_driver(&nsp_driver); 1782 pcmcia_unregister_driver(&nsp_driver);
1901} 1783}
1902 1784
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index eb775f1a523c..9c96ca889ec9 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -48,7 +48,6 @@
48#include <scsi/scsi_host.h> 48#include <scsi/scsi_host.h>
49#include "../qlogicfas408.h" 49#include "../qlogicfas408.h"
50 50
51#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
53#include <pcmcia/ds.h> 52#include <pcmcia/ds.h>
54#include <pcmcia/ciscode.h> 53#include <pcmcia/ciscode.h>
@@ -156,11 +155,8 @@ static int qlogic_probe(struct pcmcia_device *link)
156 return -ENOMEM; 155 return -ENOMEM;
157 info->p_dev = link; 156 info->p_dev = link;
158 link->priv = info; 157 link->priv = info;
159 link->resource[0]->end = 16; 158 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
160 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 159 link->config_regs = PRESENT_OPTION;
161 link->conf.Attributes = CONF_ENABLE_IRQ;
162 link->conf.IntType = INT_MEMORY_AND_IO;
163 link->conf.Present = PRESENT_OPTION;
164 160
165 return qlogic_config(link); 161 return qlogic_config(link);
166} /* qlogic_attach */ 162} /* qlogic_attach */
@@ -178,15 +174,11 @@ static void qlogic_detach(struct pcmcia_device *link)
178 174
179/*====================================================================*/ 175/*====================================================================*/
180 176
181static int qlogic_config_check(struct pcmcia_device *p_dev, 177static int qlogic_config_check(struct pcmcia_device *p_dev, void *priv_data)
182 cistpl_cftable_entry_t *cfg,
183 cistpl_cftable_entry_t *dflt,
184 unsigned int vcc,
185 void *priv_data)
186{ 178{
187 p_dev->io_lines = 10; 179 p_dev->io_lines = 10;
188 p_dev->resource[0]->start = cfg->io.win[0].base; 180 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
189 p_dev->resource[0]->end = cfg->io.win[0].len; 181 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
190 182
191 if (p_dev->resource[0]->start == 0) 183 if (p_dev->resource[0]->start == 0)
192 return -ENODEV; 184 return -ENODEV;
@@ -209,7 +201,7 @@ static int qlogic_config(struct pcmcia_device * link)
209 if (!link->irq) 201 if (!link->irq)
210 goto failed; 202 goto failed;
211 203
212 ret = pcmcia_request_configuration(link, &link->conf); 204 ret = pcmcia_enable_device(link);
213 if (ret) 205 if (ret)
214 goto failed; 206 goto failed;
215 207
@@ -264,7 +256,7 @@ static int qlogic_resume(struct pcmcia_device *link)
264{ 256{
265 scsi_info_t *info = link->priv; 257 scsi_info_t *info = link->priv;
266 258
267 pcmcia_request_configuration(link, &link->conf); 259 pcmcia_enable_device(link);
268 if ((info->manf_id == MANFID_MACNICA) || 260 if ((info->manf_id == MANFID_MACNICA) ||
269 (info->manf_id == MANFID_PIONEER) || 261 (info->manf_id == MANFID_PIONEER) ||
270 (info->manf_id == 0x0098)) { 262 (info->manf_id == 0x0098)) {
@@ -302,9 +294,7 @@ MODULE_DEVICE_TABLE(pcmcia, qlogic_ids);
302 294
303static struct pcmcia_driver qlogic_cs_driver = { 295static struct pcmcia_driver qlogic_cs_driver = {
304 .owner = THIS_MODULE, 296 .owner = THIS_MODULE,
305 .drv = {
306 .name = "qlogic_cs", 297 .name = "qlogic_cs",
307 },
308 .probe = qlogic_probe, 298 .probe = qlogic_probe,
309 .remove = qlogic_detach, 299 .remove = qlogic_detach,
310 .id_table = qlogic_ids, 300 .id_table = qlogic_ids,
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 321e390c9120..0ae27cb5cd6f 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -71,7 +71,6 @@
71#include <scsi/scsi.h> 71#include <scsi/scsi.h>
72#include <scsi/scsi_host.h> 72#include <scsi/scsi_host.h>
73 73
74#include <pcmcia/cs.h>
75#include <pcmcia/cistpl.h> 74#include <pcmcia/cistpl.h>
76#include <pcmcia/ds.h> 75#include <pcmcia/ds.h>
77#include <pcmcia/ciscode.h> 76#include <pcmcia/ciscode.h>
@@ -684,15 +683,11 @@ static struct scsi_host_template sym53c500_driver_template = {
684 .shost_attrs = SYM53C500_shost_attrs 683 .shost_attrs = SYM53C500_shost_attrs
685}; 684};
686 685
687static int SYM53C500_config_check(struct pcmcia_device *p_dev, 686static int SYM53C500_config_check(struct pcmcia_device *p_dev, void *priv_data)
688 cistpl_cftable_entry_t *cfg,
689 cistpl_cftable_entry_t *dflt,
690 unsigned int vcc,
691 void *priv_data)
692{ 687{
693 p_dev->io_lines = 10; 688 p_dev->io_lines = 10;
694 p_dev->resource[0]->start = cfg->io.win[0].base; 689 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
695 p_dev->resource[0]->end = cfg->io.win[0].len; 690 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
696 691
697 if (p_dev->resource[0]->start == 0) 692 if (p_dev->resource[0]->start == 0)
698 return -ENODEV; 693 return -ENODEV;
@@ -721,7 +716,7 @@ SYM53C500_config(struct pcmcia_device *link)
721 if (!link->irq) 716 if (!link->irq)
722 goto failed; 717 goto failed;
723 718
724 ret = pcmcia_request_configuration(link, &link->conf); 719 ret = pcmcia_enable_device(link);
725 if (ret) 720 if (ret)
726 goto failed; 721 goto failed;
727 722
@@ -859,10 +854,7 @@ SYM53C500_probe(struct pcmcia_device *link)
859 return -ENOMEM; 854 return -ENOMEM;
860 info->p_dev = link; 855 info->p_dev = link;
861 link->priv = info; 856 link->priv = info;
862 link->resource[0]->end = 16; 857 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
863 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
864 link->conf.Attributes = CONF_ENABLE_IRQ;
865 link->conf.IntType = INT_MEMORY_AND_IO;
866 858
867 return SYM53C500_config(link); 859 return SYM53C500_config(link);
868} /* SYM53C500_attach */ 860} /* SYM53C500_attach */
@@ -881,9 +873,7 @@ MODULE_DEVICE_TABLE(pcmcia, sym53c500_ids);
881 873
882static struct pcmcia_driver sym53c500_cs_driver = { 874static struct pcmcia_driver sym53c500_cs_driver = {
883 .owner = THIS_MODULE, 875 .owner = THIS_MODULE,
884 .drv = { 876 .name = "sym53c500_cs",
885 .name = "sym53c500_cs",
886 },
887 .probe = SYM53C500_probe, 877 .probe = SYM53C500_probe,
888 .remove = SYM53C500_detach, 878 .remove = SYM53C500_detach,
889 .id_table = sym53c500_ids, 879 .id_table = sym53c500_ids,
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 7d475b2a79e8..93760b2ea172 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -45,7 +45,6 @@
45#include <asm/io.h> 45#include <asm/io.h>
46#include <asm/system.h> 46#include <asm/system.h>
47 47
48#include <pcmcia/cs.h>
49#include <pcmcia/cistpl.h> 48#include <pcmcia/cistpl.h>
50#include <pcmcia/ciscode.h> 49#include <pcmcia/ciscode.h>
51#include <pcmcia/ds.h> 50#include <pcmcia/ds.h>
@@ -183,10 +182,8 @@ static void quirk_config_socket(struct pcmcia_device *link)
183{ 182{
184 struct serial_info *info = link->priv; 183 struct serial_info *info = link->priv;
185 184
186 if (info->multi) { 185 if (info->multi)
187 link->conf.Present |= PRESENT_EXT_STATUS; 186 link->config_flags |= CONF_ENABLE_ESR;
188 link->conf.ExtStatus = ESR_REQ_ATTN_ENA;
189 }
190} 187}
191 188
192static const struct serial_quirk quirks[] = { 189static const struct serial_quirk quirks[] = {
@@ -265,13 +262,6 @@ static const struct serial_quirk quirks[] = {
265static int serial_config(struct pcmcia_device * link); 262static int serial_config(struct pcmcia_device * link);
266 263
267 264
268/*======================================================================
269
270 After a card is removed, serial_remove() will unregister
271 the serial device(s), and release the PCMCIA configuration.
272
273======================================================================*/
274
275static void serial_remove(struct pcmcia_device *link) 265static void serial_remove(struct pcmcia_device *link)
276{ 266{
277 struct serial_info *info = link->priv; 267 struct serial_info *info = link->priv;
@@ -314,14 +304,6 @@ static int serial_resume(struct pcmcia_device *link)
314 return 0; 304 return 0;
315} 305}
316 306
317/*======================================================================
318
319 serial_attach() creates an "instance" of the driver, allocating
320 local data structures for one device. The device is registered
321 with Card Services.
322
323======================================================================*/
324
325static int serial_probe(struct pcmcia_device *link) 307static int serial_probe(struct pcmcia_device *link)
326{ 308{
327 struct serial_info *info; 309 struct serial_info *info;
@@ -335,25 +317,13 @@ static int serial_probe(struct pcmcia_device *link)
335 info->p_dev = link; 317 info->p_dev = link;
336 link->priv = info; 318 link->priv = info;
337 319
338 link->conf.Attributes = CONF_ENABLE_IRQ; 320 link->config_flags |= CONF_ENABLE_IRQ;
339 if (do_sound) { 321 if (do_sound)
340 link->conf.Attributes |= CONF_ENABLE_SPKR; 322 link->config_flags |= CONF_ENABLE_SPKR;
341 link->conf.Status = CCSR_AUDIO_ENA;
342 }
343 link->conf.IntType = INT_MEMORY_AND_IO;
344 323
345 return serial_config(link); 324 return serial_config(link);
346} 325}
347 326
348/*======================================================================
349
350 This deletes a driver "instance". The device is de-registered
351 with Card Services. If it has been released, all local data
352 structures are freed. Otherwise, the structures will be freed
353 when the device is released.
354
355======================================================================*/
356
357static void serial_detach(struct pcmcia_device *link) 327static void serial_detach(struct pcmcia_device *link)
358{ 328{
359 struct serial_info *info = link->priv; 329 struct serial_info *info = link->priv;
@@ -361,11 +331,6 @@ static void serial_detach(struct pcmcia_device *link)
361 dev_dbg(&link->dev, "serial_detach\n"); 331 dev_dbg(&link->dev, "serial_detach\n");
362 332
363 /* 333 /*
364 * Ensure any outstanding scheduled tasks are completed.
365 */
366 flush_scheduled_work();
367
368 /*
369 * Ensure that the ports have been released. 334 * Ensure that the ports have been released.
370 */ 335 */
371 serial_remove(link); 336 serial_remove(link);
@@ -430,47 +395,45 @@ static int pfc_config(struct pcmcia_device *p_dev)
430 return -ENODEV; 395 return -ENODEV;
431} 396}
432 397
433static int simple_config_check(struct pcmcia_device *p_dev, 398static int simple_config_check(struct pcmcia_device *p_dev, void *priv_data)
434 cistpl_cftable_entry_t *cf,
435 cistpl_cftable_entry_t *dflt,
436 unsigned int vcc,
437 void *priv_data)
438{ 399{
439 static const int size_table[2] = { 8, 16 }; 400 static const int size_table[2] = { 8, 16 };
440 int *try = priv_data; 401 int *try = priv_data;
441 402
442 if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 403 if (p_dev->resource[0]->start == 0)
443 p_dev->conf.Vpp = 404 return -ENODEV;
444 cf->vpp1.param[CISTPL_POWER_VNOM] / 10000;
445 405
446 p_dev->io_lines = ((*try & 0x1) == 0) ? 406 if ((*try & 0x1) == 0)
447 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 407 p_dev->io_lines = 16;
448 408
449 if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[(*try >> 1)]) 409 if (p_dev->resource[0]->end != size_table[(*try >> 1)])
450 && (cf->io.win[0].base != 0)) { 410 return -ENODEV;
451 p_dev->resource[0]->start = cf->io.win[0].base; 411
452 if (!pcmcia_request_io(p_dev)) 412 p_dev->resource[0]->end = 8;
453 return 0; 413 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
454 } 414 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
455 return -EINVAL; 415
416 return pcmcia_request_io(p_dev);
456} 417}
457 418
458static int simple_config_check_notpicky(struct pcmcia_device *p_dev, 419static int simple_config_check_notpicky(struct pcmcia_device *p_dev,
459 cistpl_cftable_entry_t *cf,
460 cistpl_cftable_entry_t *dflt,
461 unsigned int vcc,
462 void *priv_data) 420 void *priv_data)
463{ 421{
464 static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 422 static const unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
465 int j; 423 int j;
466 424
467 if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 425 if (p_dev->io_lines > 3)
468 for (j = 0; j < 5; j++) { 426 return -ENODEV;
469 p_dev->resource[0]->start = base[j]; 427
470 p_dev->io_lines = base[j] ? 16 : 3; 428 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
471 if (!pcmcia_request_io(p_dev)) 429 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
472 return 0; 430 p_dev->resource[0]->end = 8;
473 } 431
432 for (j = 0; j < 5; j++) {
433 p_dev->resource[0]->start = base[j];
434 p_dev->io_lines = base[j] ? 16 : 3;
435 if (!pcmcia_request_io(p_dev))
436 return 0;
474 } 437 }
475 return -ENODEV; 438 return -ENODEV;
476} 439}
@@ -480,11 +443,9 @@ static int simple_config(struct pcmcia_device *link)
480 struct serial_info *info = link->priv; 443 struct serial_info *info = link->priv;
481 int i = -ENODEV, try; 444 int i = -ENODEV, try;
482 445
483 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
484 link->resource[0]->end = 8;
485
486 /* First pass: look for a config entry that looks normal. 446 /* First pass: look for a config entry that looks normal.
487 * Two tries: without IO aliases, then with aliases */ 447 * Two tries: without IO aliases, then with aliases */
448 link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_SET_IO;
488 for (try = 0; try < 4; try++) 449 for (try = 0; try < 4; try++)
489 if (!pcmcia_loop_config(link, simple_config_check, &try)) 450 if (!pcmcia_loop_config(link, simple_config_check, &try))
490 goto found_port; 451 goto found_port;
@@ -500,7 +461,7 @@ static int simple_config(struct pcmcia_device *link)
500 461
501found_port: 462found_port:
502 if (info->multi && (info->manfid == MANFID_3COM)) 463 if (info->multi && (info->manfid == MANFID_3COM))
503 link->conf.ConfigIndex &= ~(0x08); 464 link->config_index &= ~(0x08);
504 465
505 /* 466 /*
506 * Apply any configuration quirks. 467 * Apply any configuration quirks.
@@ -508,51 +469,50 @@ found_port:
508 if (info->quirk && info->quirk->config) 469 if (info->quirk && info->quirk->config)
509 info->quirk->config(link); 470 info->quirk->config(link);
510 471
511 i = pcmcia_request_configuration(link, &link->conf); 472 i = pcmcia_enable_device(link);
512 if (i != 0) 473 if (i != 0)
513 return -1; 474 return -1;
514 return setup_serial(link, info, link->resource[0]->start, link->irq); 475 return setup_serial(link, info, link->resource[0]->start, link->irq);
515} 476}
516 477
517static int multi_config_check(struct pcmcia_device *p_dev, 478static int multi_config_check(struct pcmcia_device *p_dev, void *priv_data)
518 cistpl_cftable_entry_t *cf,
519 cistpl_cftable_entry_t *dflt,
520 unsigned int vcc,
521 void *priv_data)
522{ 479{
523 int *base2 = priv_data; 480 int *multi = priv_data;
481
482 if (p_dev->resource[1]->end)
483 return -EINVAL;
524 484
525 /* The quad port cards have bad CIS's, so just look for a 485 /* The quad port cards have bad CIS's, so just look for a
526 window larger than 8 ports and assume it will be right */ 486 window larger than 8 ports and assume it will be right */
527 if ((cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { 487 if (p_dev->resource[0]->end <= 8)
528 p_dev->resource[0]->start = cf->io.win[0].base; 488 return -EINVAL;
529 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 489
530 if (!pcmcia_request_io(p_dev)) { 490 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
531 *base2 = p_dev->resource[0]->start + 8; 491 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
532 return 0; 492 p_dev->resource[0]->end = *multi * 8;
533 } 493
534 } 494 if (pcmcia_request_io(p_dev))
535 return -ENODEV; 495 return -ENODEV;
496 return 0;
536} 497}
537 498
538static int multi_config_check_notpicky(struct pcmcia_device *p_dev, 499static int multi_config_check_notpicky(struct pcmcia_device *p_dev,
539 cistpl_cftable_entry_t *cf,
540 cistpl_cftable_entry_t *dflt,
541 unsigned int vcc,
542 void *priv_data) 500 void *priv_data)
543{ 501{
544 int *base2 = priv_data; 502 int *base2 = priv_data;
545 503
546 if (cf->io.nwin == 2) { 504 if (!p_dev->resource[0]->end || !p_dev->resource[1]->end)
547 p_dev->resource[0]->start = cf->io.win[0].base; 505 return -ENODEV;
548 p_dev->resource[1]->start = cf->io.win[1].base; 506
549 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 507 p_dev->resource[0]->end = p_dev->resource[1]->end = 8;
550 if (!pcmcia_request_io(p_dev)) { 508 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
551 *base2 = p_dev->resource[1]->start; 509 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
552 return 0; 510
553 } 511 if (pcmcia_request_io(p_dev))
554 } 512 return -ENODEV;
555 return -ENODEV; 513
514 *base2 = p_dev->resource[0]->start + 8;
515 return 0;
556} 516}
557 517
558static int multi_config(struct pcmcia_device *link) 518static int multi_config(struct pcmcia_device *link)
@@ -560,12 +520,12 @@ static int multi_config(struct pcmcia_device *link)
560 struct serial_info *info = link->priv; 520 struct serial_info *info = link->priv;
561 int i, base2 = 0; 521 int i, base2 = 0;
562 522
523 link->config_flags |= CONF_AUTO_SET_IO;
563 /* First, look for a generic full-sized window */ 524 /* First, look for a generic full-sized window */
564 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 525 if (!pcmcia_loop_config(link, multi_config_check, &info->multi))
565 link->resource[0]->end = info->multi * 8; 526 base2 = link->resource[0]->start + 8;
566 if (pcmcia_loop_config(link, multi_config_check, &base2)) { 527 else {
567 /* If that didn't work, look for two windows */ 528 /* If that didn't work, look for two windows */
568 link->resource[0]->end = link->resource[1]->end = 8;
569 info->multi = 2; 529 info->multi = 2;
570 if (pcmcia_loop_config(link, multi_config_check_notpicky, 530 if (pcmcia_loop_config(link, multi_config_check_notpicky,
571 &base2)) { 531 &base2)) {
@@ -584,7 +544,7 @@ static int multi_config(struct pcmcia_device *link)
584 if (info->quirk && info->quirk->config) 544 if (info->quirk && info->quirk->config)
585 info->quirk->config(link); 545 info->quirk->config(link);
586 546
587 i = pcmcia_request_configuration(link, &link->conf); 547 i = pcmcia_enable_device(link);
588 if (i != 0) 548 if (i != 0)
589 return -ENODEV; 549 return -ENODEV;
590 550
@@ -596,11 +556,11 @@ static int multi_config(struct pcmcia_device *link)
596 info->prodid == PRODID_POSSIO_GCC)) { 556 info->prodid == PRODID_POSSIO_GCC)) {
597 int err; 557 int err;
598 558
599 if (link->conf.ConfigIndex == 1 || 559 if (link->config_index == 1 ||
600 link->conf.ConfigIndex == 3) { 560 link->config_index == 3) {
601 err = setup_serial(link, info, base2, 561 err = setup_serial(link, info, base2,
602 link->irq); 562 link->irq);
603 base2 = link->resource[0]->start;; 563 base2 = link->resource[0]->start;
604 } else { 564 } else {
605 err = setup_serial(link, info, link->resource[0]->start, 565 err = setup_serial(link, info, link->resource[0]->start,
606 link->irq); 566 link->irq);
@@ -624,33 +584,24 @@ static int multi_config(struct pcmcia_device *link)
624 return 0; 584 return 0;
625} 585}
626 586
627static int serial_check_for_multi(struct pcmcia_device *p_dev, 587static int serial_check_for_multi(struct pcmcia_device *p_dev, void *priv_data)
628 cistpl_cftable_entry_t *cf,
629 cistpl_cftable_entry_t *dflt,
630 unsigned int vcc,
631 void *priv_data)
632{ 588{
633 struct serial_info *info = p_dev->priv; 589 struct serial_info *info = p_dev->priv;
634 590
635 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 591 if (!p_dev->resource[0]->end)
636 info->multi = cf->io.win[0].len >> 3; 592 return -EINVAL;
593
594 if ((!p_dev->resource[1]->end) && (p_dev->resource[0]->end % 8 == 0))
595 info->multi = p_dev->resource[0]->end >> 3;
637 596
638 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && 597 if ((p_dev->resource[1]->end) && (p_dev->resource[0]->end == 8)
639 (cf->io.win[1].len == 8)) 598 && (p_dev->resource[1]->end == 8))
640 info->multi = 2; 599 info->multi = 2;
641 600
642 return 0; /* break */ 601 return 0; /* break */
643} 602}
644 603
645 604
646/*======================================================================
647
648 serial_config() is scheduled to run after a CARD_INSERTION event
649 is received, to configure the PCMCIA socket, and to make the
650 serial device available to the system.
651
652======================================================================*/
653
654static int serial_config(struct pcmcia_device * link) 605static int serial_config(struct pcmcia_device * link)
655{ 606{
656 struct serial_info *info = link->priv; 607 struct serial_info *info = link->priv;
@@ -894,9 +845,7 @@ MODULE_FIRMWARE("cis/RS-COM-2P.cis");
894 845
895static struct pcmcia_driver serial_cs_driver = { 846static struct pcmcia_driver serial_cs_driver = {
896 .owner = THIS_MODULE, 847 .owner = THIS_MODULE,
897 .drv = { 848 .name = "serial_cs",
898 .name = "serial_cs",
899 },
900 .probe = serial_probe, 849 .probe = serial_probe,
901 .remove = serial_detach, 850 .remove = serial_detach,
902 .id_table = serial_ids, 851 .id_table = serial_ids,
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 7892ac163522..c68b3dc19e11 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -20,7 +20,6 @@
20#include <linux/mmc/sdio_func.h> 20#include <linux/mmc/sdio_func.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22 22
23#include <pcmcia/cs.h>
24#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
25#include <pcmcia/ds.h> 24#include <pcmcia/ds.h>
26 25
diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c
index 526682d68de8..c7345dbf43fa 100644
--- a/drivers/ssb/pcmcia.c
+++ b/drivers/ssb/pcmcia.c
@@ -13,7 +13,6 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/etherdevice.h> 14#include <linux/etherdevice.h>
15 15
16#include <pcmcia/cs.h>
17#include <pcmcia/cistpl.h> 16#include <pcmcia/cistpl.h>
18#include <pcmcia/ciscode.h> 17#include <pcmcia/ciscode.h>
19#include <pcmcia/ds.h> 18#include <pcmcia/ds.h>
diff --git a/drivers/ssb/scan.c b/drivers/ssb/scan.c
index 9738cad4ba13..ee079ab9fb28 100644
--- a/drivers/ssb/scan.c
+++ b/drivers/ssb/scan.c
@@ -17,7 +17,6 @@
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <linux/io.h> 18#include <linux/io.h>
19 19
20#include <pcmcia/cs.h>
21#include <pcmcia/cistpl.h> 20#include <pcmcia/cistpl.h>
22#include <pcmcia/ds.h> 21#include <pcmcia/ds.h>
23 22
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index f8ede1182ccc..0345b4caba73 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -37,7 +37,6 @@ Status: experimental
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39 39
40#include <pcmcia/cs.h>
41#include <pcmcia/cistpl.h> 40#include <pcmcia/cistpl.h>
42#include <pcmcia/ds.h> 41#include <pcmcia/ds.h>
43 42
@@ -692,10 +691,6 @@ static int das16cs_pcmcia_attach(struct pcmcia_device *link)
692 local->link = link; 691 local->link = link;
693 link->priv = local; 692 link->priv = local;
694 693
695 /* Initialize the pcmcia_device structure */
696 link->conf.Attributes = 0;
697 link->conf.IntType = INT_MEMORY_AND_IO;
698
699 cur_dev = link; 694 cur_dev = link;
700 695
701 das16cs_pcmcia_config(link); 696 das16cs_pcmcia_config(link);
@@ -715,37 +710,12 @@ static void das16cs_pcmcia_detach(struct pcmcia_device *link)
715 710
716 711
717static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev, 712static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev,
718 cistpl_cftable_entry_t *cfg,
719 cistpl_cftable_entry_t *dflt,
720 unsigned int vcc,
721 void *priv_data) 713 void *priv_data)
722{ 714{
723 if (cfg->index == 0) 715 if (p_dev->config_index == 0)
724 return -EINVAL; 716 return -EINVAL;
725 717
726 /* Do we need to allocate an interrupt? */ 718 return pcmcia_request_io(p_dev);
727 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
728
729 /* IO window settings */
730 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
731 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
732 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
733 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
734 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
735 p_dev->resource[0]->flags |=
736 pcmcia_io_cfg_data_width(io->flags);
737 p_dev->resource[0]->start = io->win[0].base;
738 p_dev->resource[0]->end = io->win[0].len;
739 if (io->nwin > 1) {
740 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
741 p_dev->resource[1]->start = io->win[1].base;
742 p_dev->resource[1]->end = io->win[1].len;
743 }
744 /* This reserves IO space but doesn't actually enable it */
745 return pcmcia_request_io(p_dev);
746 }
747
748 return 0;
749} 719}
750 720
751static void das16cs_pcmcia_config(struct pcmcia_device *link) 721static void das16cs_pcmcia_config(struct pcmcia_device *link)
@@ -754,6 +724,9 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
754 724
755 dev_dbg(&link->dev, "das16cs_pcmcia_config\n"); 725 dev_dbg(&link->dev, "das16cs_pcmcia_config\n");
756 726
727 /* Do we need to allocate an interrupt? */
728 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
729
757 ret = pcmcia_loop_config(link, das16cs_pcmcia_config_loop, NULL); 730 ret = pcmcia_loop_config(link, das16cs_pcmcia_config_loop, NULL);
758 if (ret) { 731 if (ret) {
759 dev_warn(&link->dev, "no configuration found\n"); 732 dev_warn(&link->dev, "no configuration found\n");
@@ -763,25 +736,10 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
763 if (!link->irq) 736 if (!link->irq)
764 goto failed; 737 goto failed;
765 738
766 /* 739 ret = pcmcia_enable_device(link);
767 This actually configures the PCMCIA socket -- setting up
768 the I/O windows and the interrupt mapping, and putting the
769 card and host interface into "Memory and IO" mode.
770 */
771 ret = pcmcia_request_configuration(link, &link->conf);
772 if (ret) 740 if (ret)
773 goto failed; 741 goto failed;
774 742
775 /* Finally, report what we've done */
776 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
777 if (link->conf.Attributes & CONF_ENABLE_IRQ)
778 printk(", irq %u", link->irq);
779 if (link->resource[0])
780 printk(", io %pR", link->resource[0]);
781 if (link->resource[1])
782 printk(", io %pR", link->resource[1]);
783 printk("\n");
784
785 return; 743 return;
786 744
787failed: 745failed:
@@ -832,9 +790,7 @@ struct pcmcia_driver das16cs_driver = {
832 .resume = das16cs_pcmcia_resume, 790 .resume = das16cs_pcmcia_resume,
833 .id_table = das16cs_id_table, 791 .id_table = das16cs_id_table,
834 .owner = THIS_MODULE, 792 .owner = THIS_MODULE,
835 .drv = { 793 .name = "cb_das16_cs",
836 .name = "cb_das16_cs",
837 },
838}; 794};
839 795
840static int __init init_das16cs_pcmcia_cs(void) 796static int __init init_das16cs_pcmcia_cs(void)
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c
index 48d9fb1227df..0b32a2df7768 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/staging/comedi/drivers/das08_cs.c
@@ -48,7 +48,6 @@ Command support does not exist, but could be added for this board.
48#include "das08.h" 48#include "das08.h"
49 49
50/* pcmcia includes */ 50/* pcmcia includes */
51#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
53#include <pcmcia/ds.h> 52#include <pcmcia/ds.h>
54 53
@@ -115,40 +114,15 @@ static void das08_pcmcia_release(struct pcmcia_device *link);
115static int das08_pcmcia_suspend(struct pcmcia_device *p_dev); 114static int das08_pcmcia_suspend(struct pcmcia_device *p_dev);
116static int das08_pcmcia_resume(struct pcmcia_device *p_dev); 115static int das08_pcmcia_resume(struct pcmcia_device *p_dev);
117 116
118/*
119 The attach() and detach() entry points are used to create and destroy
120 "instances" of the driver, where each instance represents everything
121 needed to manage one actual PCMCIA card.
122*/
123
124static int das08_pcmcia_attach(struct pcmcia_device *); 117static int das08_pcmcia_attach(struct pcmcia_device *);
125static void das08_pcmcia_detach(struct pcmcia_device *); 118static void das08_pcmcia_detach(struct pcmcia_device *);
126 119
127/*
128 You'll also need to prototype all the functions that will actually
129 be used to talk to your device. See 'memory_cs' for a good example
130 of a fully self-sufficient driver; the other drivers rely more or
131 less on other parts of the kernel.
132*/
133
134struct local_info_t { 120struct local_info_t {
135 struct pcmcia_device *link; 121 struct pcmcia_device *link;
136 int stop; 122 int stop;
137 struct bus_operations *bus; 123 struct bus_operations *bus;
138}; 124};
139 125
140/*======================================================================
141
142 das08_pcmcia_attach() creates an "instance" of the driver, allocating
143 local data structures for one device. The device is registered
144 with Card Services.
145
146 The dev_link structure is initialized, but we don't actually
147 configure the card at this point -- we wait until we receive a
148 card insertion event.
149
150======================================================================*/
151
152static int das08_pcmcia_attach(struct pcmcia_device *link) 126static int das08_pcmcia_attach(struct pcmcia_device *link)
153{ 127{
154 struct local_info_t *local; 128 struct local_info_t *local;
@@ -162,16 +136,6 @@ static int das08_pcmcia_attach(struct pcmcia_device *link)
162 local->link = link; 136 local->link = link;
163 link->priv = local; 137 link->priv = local;
164 138
165 /*
166 General socket configuration defaults can go here. In this
167 client, we assume very little, and rely on the CIS for almost
168 everything. In most clients, many details (i.e., number, sizes,
169 and attributes of IO windows) are fixed by the nature of the
170 device, and can be hard-wired here.
171 */
172 link->conf.Attributes = 0;
173 link->conf.IntType = INT_MEMORY_AND_IO;
174
175 cur_dev = link; 139 cur_dev = link;
176 140
177 das08_pcmcia_config(link); 141 das08_pcmcia_config(link);
@@ -179,15 +143,6 @@ static int das08_pcmcia_attach(struct pcmcia_device *link)
179 return 0; 143 return 0;
180} /* das08_pcmcia_attach */ 144} /* das08_pcmcia_attach */
181 145
182/*======================================================================
183
184 This deletes a driver "instance". The device is de-registered
185 with Card Services. If it has been released, all local data
186 structures are freed. Otherwise, the structures will be freed
187 when the device is released.
188
189======================================================================*/
190
191static void das08_pcmcia_detach(struct pcmcia_device *link) 146static void das08_pcmcia_detach(struct pcmcia_device *link)
192{ 147{
193 148
@@ -203,46 +158,13 @@ static void das08_pcmcia_detach(struct pcmcia_device *link)
203 158
204 159
205static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev, 160static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev,
206 cistpl_cftable_entry_t *cfg,
207 cistpl_cftable_entry_t *dflt,
208 unsigned int vcc,
209 void *priv_data) 161 void *priv_data)
210{ 162{
211 if (cfg->index == 0) 163 if (p_dev->config_index == 0)
212 return -ENODEV; 164 return -EINVAL;
213
214 /* Do we need to allocate an interrupt? */
215 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
216
217 /* IO window settings */
218 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
219 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
220 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
221 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
222 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
223 p_dev->resource[0]->flags |=
224 pcmcia_io_cfg_data_width(io->flags);
225 p_dev->resource[0]->start = io->win[0].base;
226 p_dev->resource[0]->end = io->win[0].len;
227 if (io->nwin > 1) {
228 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
229 p_dev->resource[1]->start = io->win[1].base;
230 p_dev->resource[1]->end = io->win[1].len;
231 }
232 /* This reserves IO space but doesn't actually enable it */
233 return pcmcia_request_io(p_dev);
234 }
235 return 0;
236}
237
238
239/*======================================================================
240
241 das08_pcmcia_config() is scheduled to run after a CARD_INSERTION event
242 is received, to configure the PCMCIA socket, and to make the
243 device available to the system.
244 165
245======================================================================*/ 166 return pcmcia_request_io(p_dev);
167}
246 168
247static void das08_pcmcia_config(struct pcmcia_device *link) 169static void das08_pcmcia_config(struct pcmcia_device *link)
248{ 170{
@@ -250,6 +172,8 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
250 172
251 dev_dbg(&link->dev, "das08_pcmcia_config\n"); 173 dev_dbg(&link->dev, "das08_pcmcia_config\n");
252 174
175 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
176
253 ret = pcmcia_loop_config(link, das08_pcmcia_config_loop, NULL); 177 ret = pcmcia_loop_config(link, das08_pcmcia_config_loop, NULL);
254 if (ret) { 178 if (ret) {
255 dev_warn(&link->dev, "no configuration found\n"); 179 dev_warn(&link->dev, "no configuration found\n");
@@ -259,25 +183,10 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
259 if (!link->irq) 183 if (!link->irq)
260 goto failed; 184 goto failed;
261 185
262 /* 186 ret = pcmcia_enable_device(link);
263 This actually configures the PCMCIA socket -- setting up
264 the I/O windows and the interrupt mapping, and putting the
265 card and host interface into "Memory and IO" mode.
266 */
267 ret = pcmcia_request_configuration(link, &link->conf);
268 if (ret) 187 if (ret)
269 goto failed; 188 goto failed;
270 189
271 /* Finally, report what we've done */
272 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
273 if (link->conf.Attributes & CONF_ENABLE_IRQ)
274 printk(", irq %u", link->irq);
275 if (link->resource[0])
276 printk(", io %pR", link->resource[0]);
277 if (link->resource[1])
278 printk(" & %pR", link->resource[1]);
279 printk("\n");
280
281 return; 190 return;
282 191
283failed: 192failed:
@@ -285,32 +194,12 @@ failed:
285 194
286} /* das08_pcmcia_config */ 195} /* das08_pcmcia_config */
287 196
288/*======================================================================
289
290 After a card is removed, das08_pcmcia_release() will unregister the
291 device, and release the PCMCIA configuration. If the device is
292 still open, this will be postponed until it is closed.
293
294======================================================================*/
295
296static void das08_pcmcia_release(struct pcmcia_device *link) 197static void das08_pcmcia_release(struct pcmcia_device *link)
297{ 198{
298 dev_dbg(&link->dev, "das08_pcmcia_release\n"); 199 dev_dbg(&link->dev, "das08_pcmcia_release\n");
299 pcmcia_disable_device(link); 200 pcmcia_disable_device(link);
300} /* das08_pcmcia_release */ 201} /* das08_pcmcia_release */
301 202
302/*======================================================================
303
304 The card status event handler. Mostly, this schedules other
305 stuff to run after an event is received.
306
307 When a CARD_REMOVAL event is received, we immediately set a
308 private flag to block future accesses to this device. All the
309 functions that actually access the device should check this flag
310 to make sure the card is still present.
311
312======================================================================*/
313
314static int das08_pcmcia_suspend(struct pcmcia_device *link) 203static int das08_pcmcia_suspend(struct pcmcia_device *link)
315{ 204{
316 struct local_info_t *local = link->priv; 205 struct local_info_t *local = link->priv;
@@ -348,9 +237,7 @@ struct pcmcia_driver das08_cs_driver = {
348 .resume = das08_pcmcia_resume, 237 .resume = das08_pcmcia_resume,
349 .id_table = das08_cs_id_table, 238 .id_table = das08_cs_id_table,
350 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
351 .drv = { 240 .name = "pcm-das08",
352 .name = "pcm-das08",
353 },
354}; 241};
355 242
356static int __init init_das08_pcmcia_cs(void) 243static int __init init_das08_pcmcia_cs(void)
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index cc15666e5cc1..fc772a8a55c6 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -47,7 +47,6 @@ IRQ is assigned but not used.
47 47
48#include <linux/ioport.h> 48#include <linux/ioport.h>
49 49
50#include <pcmcia/cs.h>
51#include <pcmcia/cistpl.h> 50#include <pcmcia/cistpl.h>
52#include <pcmcia/cisreg.h> 51#include <pcmcia/cisreg.h>
53#include <pcmcia/ds.h> 52#include <pcmcia/ds.h>
@@ -435,47 +434,20 @@ static int dio700_detach(struct comedi_device *dev)
435 return 0; 434 return 0;
436}; 435};
437 436
438/* PCMCIA crap -- watch your words, please! */
439
440static void dio700_config(struct pcmcia_device *link); 437static void dio700_config(struct pcmcia_device *link);
441static void dio700_release(struct pcmcia_device *link); 438static void dio700_release(struct pcmcia_device *link);
442static int dio700_cs_suspend(struct pcmcia_device *p_dev); 439static int dio700_cs_suspend(struct pcmcia_device *p_dev);
443static int dio700_cs_resume(struct pcmcia_device *p_dev); 440static int dio700_cs_resume(struct pcmcia_device *p_dev);
444 441
445/*
446 The attach() and detach() entry points are used to create and destroy
447 "instances" of the driver, where each instance represents everything
448 needed to manage one actual PCMCIA card.
449*/
450
451static int dio700_cs_attach(struct pcmcia_device *); 442static int dio700_cs_attach(struct pcmcia_device *);
452static void dio700_cs_detach(struct pcmcia_device *); 443static void dio700_cs_detach(struct pcmcia_device *);
453 444
454/*
455 You'll also need to prototype all the functions that will actually
456 be used to talk to your device. See 'memory_cs' for a good example
457 of a fully self-sufficient driver; the other drivers rely more or
458 less on other parts of the kernel.
459*/
460
461struct local_info_t { 445struct local_info_t {
462 struct pcmcia_device *link; 446 struct pcmcia_device *link;
463 int stop; 447 int stop;
464 struct bus_operations *bus; 448 struct bus_operations *bus;
465}; 449};
466 450
467/*======================================================================
468
469 dio700_cs_attach() creates an "instance" of the driver, allocating
470 local data structures for one device. The device is registered
471 with Card Services.
472
473 The dev_link structure is initialized, but we don't actually
474 configure the card at this point -- we wait until we receive a
475 card insertion event.
476
477======================================================================*/
478
479static int dio700_cs_attach(struct pcmcia_device *link) 451static int dio700_cs_attach(struct pcmcia_device *link)
480{ 452{
481 struct local_info_t *local; 453 struct local_info_t *local;
@@ -491,16 +463,6 @@ static int dio700_cs_attach(struct pcmcia_device *link)
491 local->link = link; 463 local->link = link;
492 link->priv = local; 464 link->priv = local;
493 465
494 /*
495 General socket configuration defaults can go here. In this
496 client, we assume very little, and rely on the CIS for almost
497 everything. In most clients, many details (i.e., number, sizes,
498 and attributes of IO windows) are fixed by the nature of the
499 device, and can be hard-wired here.
500 */
501 link->conf.Attributes = 0;
502 link->conf.IntType = INT_MEMORY_AND_IO;
503
504 pcmcia_cur_dev = link; 466 pcmcia_cur_dev = link;
505 467
506 dio700_config(link); 468 dio700_config(link);
@@ -508,15 +470,6 @@ static int dio700_cs_attach(struct pcmcia_device *link)
508 return 0; 470 return 0;
509} /* dio700_cs_attach */ 471} /* dio700_cs_attach */
510 472
511/*======================================================================
512
513 This deletes a driver "instance". The device is de-registered
514 with Card Services. If it has been released, all local data
515 structures are freed. Otherwise, the structures will be freed
516 when the device is released.
517
518======================================================================*/
519
520static void dio700_cs_detach(struct pcmcia_device *link) 473static void dio700_cs_detach(struct pcmcia_device *link)
521{ 474{
522 475
@@ -532,54 +485,13 @@ static void dio700_cs_detach(struct pcmcia_device *link)
532 485
533} /* dio700_cs_detach */ 486} /* dio700_cs_detach */
534 487
535/*======================================================================
536
537 dio700_config() is scheduled to run after a CARD_INSERTION event
538 is received, to configure the PCMCIA socket, and to make the
539 device available to the system.
540
541======================================================================*/
542
543static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev, 488static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev,
544 cistpl_cftable_entry_t *cfg,
545 cistpl_cftable_entry_t *dflt,
546 unsigned int vcc,
547 void *priv_data) 489 void *priv_data)
548{ 490{
549 if (cfg->index == 0) 491 if (p_dev->config_index == 0)
550 return -ENODEV; 492 return -EINVAL;
551
552 /* Does this card need audio output? */
553 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
554 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
555 p_dev->conf.Status = CCSR_AUDIO_ENA;
556 }
557
558 /* Do we need to allocate an interrupt? */
559 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
560
561 /* IO window settings */
562 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
563 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
564 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
565 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
566 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
567 p_dev->resource[0]->flags |=
568 pcmcia_io_cfg_data_width(io->flags);
569 p_dev->resource[0]->start = io->win[0].base;
570 p_dev->resource[0]->end = io->win[0].len;
571 if (io->nwin > 1) {
572 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
573 p_dev->resource[1]->start = io->win[1].base;
574 p_dev->resource[1]->end = io->win[1].len;
575 }
576 /* This reserves IO space but doesn't actually enable it */
577 if (pcmcia_request_io(p_dev) != 0)
578 return -ENODEV;
579 }
580 493
581 /* If we got this far, we're cool! */ 494 return pcmcia_request_io(p_dev);
582 return 0;
583} 495}
584 496
585static void dio700_config(struct pcmcia_device *link) 497static void dio700_config(struct pcmcia_device *link)
@@ -591,6 +503,9 @@ static void dio700_config(struct pcmcia_device *link)
591 503
592 dev_dbg(&link->dev, "dio700_config\n"); 504 dev_dbg(&link->dev, "dio700_config\n");
593 505
506 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO |
507 CONF_AUTO_SET_IO;
508
594 ret = pcmcia_loop_config(link, dio700_pcmcia_config_loop, NULL); 509 ret = pcmcia_loop_config(link, dio700_pcmcia_config_loop, NULL);
595 if (ret) { 510 if (ret) {
596 dev_warn(&link->dev, "no configuration found\n"); 511 dev_warn(&link->dev, "no configuration found\n");
@@ -600,25 +515,10 @@ static void dio700_config(struct pcmcia_device *link)
600 if (!link->irq) 515 if (!link->irq)
601 goto failed; 516 goto failed;
602 517
603 /* 518 ret = pcmcia_enable_device(link);
604 This actually configures the PCMCIA socket -- setting up
605 the I/O windows and the interrupt mapping, and putting the
606 card and host interface into "Memory and IO" mode.
607 */
608 ret = pcmcia_request_configuration(link, &link->conf);
609 if (ret != 0) 519 if (ret != 0)
610 goto failed; 520 goto failed;
611 521
612 /* Finally, report what we've done */
613 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
614 if (link->conf.Attributes & CONF_ENABLE_IRQ)
615 printk(", irq %d", link->irq);
616 if (link->resource[0])
617 printk(", io %pR", link->resource[0]);
618 if (link->resource[1])
619 printk(" & %pR", link->resource[1]);
620 printk("\n");
621
622 return; 522 return;
623 523
624failed: 524failed:
@@ -634,18 +534,6 @@ static void dio700_release(struct pcmcia_device *link)
634 pcmcia_disable_device(link); 534 pcmcia_disable_device(link);
635} /* dio700_release */ 535} /* dio700_release */
636 536
637/*======================================================================
638
639 The card status event handler. Mostly, this schedules other
640 stuff to run after an event is received.
641
642 When a CARD_REMOVAL event is received, we immediately set a
643 private flag to block future accesses to this device. All the
644 functions that actually access the device should check this flag
645 to make sure the card is still present.
646
647======================================================================*/
648
649static int dio700_cs_suspend(struct pcmcia_device *link) 537static int dio700_cs_suspend(struct pcmcia_device *link)
650{ 538{
651 struct local_info_t *local = link->priv; 539 struct local_info_t *local = link->priv;
@@ -685,9 +573,7 @@ struct pcmcia_driver dio700_cs_driver = {
685 .resume = dio700_cs_resume, 573 .resume = dio700_cs_resume,
686 .id_table = dio700_cs_ids, 574 .id_table = dio700_cs_ids,
687 .owner = THIS_MODULE, 575 .owner = THIS_MODULE,
688 .drv = { 576 .name = "ni_daq_700",
689 .name = "ni_daq_700",
690 },
691}; 577};
692 578
693static int __init init_dio700_cs(void) 579static int __init init_dio700_cs(void)
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c
index 773ae2044e0e..c9c28584db67 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c
@@ -48,7 +48,6 @@ the PCMCIA interface.
48 48
49#include "8255.h" 49#include "8255.h"
50 50
51#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
53#include <pcmcia/cisreg.h> 52#include <pcmcia/cisreg.h>
54#include <pcmcia/ds.h> 53#include <pcmcia/ds.h>
@@ -187,47 +186,20 @@ static int dio24_detach(struct comedi_device *dev)
187 return 0; 186 return 0;
188}; 187};
189 188
190/* PCMCIA crap -- watch your words! */
191
192static void dio24_config(struct pcmcia_device *link); 189static void dio24_config(struct pcmcia_device *link);
193static void dio24_release(struct pcmcia_device *link); 190static void dio24_release(struct pcmcia_device *link);
194static int dio24_cs_suspend(struct pcmcia_device *p_dev); 191static int dio24_cs_suspend(struct pcmcia_device *p_dev);
195static int dio24_cs_resume(struct pcmcia_device *p_dev); 192static int dio24_cs_resume(struct pcmcia_device *p_dev);
196 193
197/*
198 The attach() and detach() entry points are used to create and destroy
199 "instances" of the driver, where each instance represents everything
200 needed to manage one actual PCMCIA card.
201*/
202
203static int dio24_cs_attach(struct pcmcia_device *); 194static int dio24_cs_attach(struct pcmcia_device *);
204static void dio24_cs_detach(struct pcmcia_device *); 195static void dio24_cs_detach(struct pcmcia_device *);
205 196
206/*
207 You'll also need to prototype all the functions that will actually
208 be used to talk to your device. See 'memory_cs' for a good example
209 of a fully self-sufficient driver; the other drivers rely more or
210 less on other parts of the kernel.
211*/
212
213struct local_info_t { 197struct local_info_t {
214 struct pcmcia_device *link; 198 struct pcmcia_device *link;
215 int stop; 199 int stop;
216 struct bus_operations *bus; 200 struct bus_operations *bus;
217}; 201};
218 202
219/*======================================================================
220
221 dio24_cs_attach() creates an "instance" of the driver, allocating
222 local data structures for one device. The device is registered
223 with Card Services.
224
225 The dev_link structure is initialized, but we don't actually
226 configure the card at this point -- we wait until we receive a
227 card insertion event.
228
229======================================================================*/
230
231static int dio24_cs_attach(struct pcmcia_device *link) 203static int dio24_cs_attach(struct pcmcia_device *link)
232{ 204{
233 struct local_info_t *local; 205 struct local_info_t *local;
@@ -243,16 +215,6 @@ static int dio24_cs_attach(struct pcmcia_device *link)
243 local->link = link; 215 local->link = link;
244 link->priv = local; 216 link->priv = local;
245 217
246 /*
247 General socket configuration defaults can go here. In this
248 client, we assume very little, and rely on the CIS for almost
249 everything. In most clients, many details (i.e., number, sizes,
250 and attributes of IO windows) are fixed by the nature of the
251 device, and can be hard-wired here.
252 */
253 link->conf.Attributes = 0;
254 link->conf.IntType = INT_MEMORY_AND_IO;
255
256 pcmcia_cur_dev = link; 218 pcmcia_cur_dev = link;
257 219
258 dio24_config(link); 220 dio24_config(link);
@@ -260,15 +222,6 @@ static int dio24_cs_attach(struct pcmcia_device *link)
260 return 0; 222 return 0;
261} /* dio24_cs_attach */ 223} /* dio24_cs_attach */
262 224
263/*======================================================================
264
265 This deletes a driver "instance". The device is de-registered
266 with Card Services. If it has been released, all local data
267 structures are freed. Otherwise, the structures will be freed
268 when the device is released.
269
270======================================================================*/
271
272static void dio24_cs_detach(struct pcmcia_device *link) 225static void dio24_cs_detach(struct pcmcia_device *link)
273{ 226{
274 227
@@ -284,54 +237,13 @@ static void dio24_cs_detach(struct pcmcia_device *link)
284 237
285} /* dio24_cs_detach */ 238} /* dio24_cs_detach */
286 239
287/*======================================================================
288
289 dio24_config() is scheduled to run after a CARD_INSERTION event
290 is received, to configure the PCMCIA socket, and to make the
291 device available to the system.
292
293======================================================================*/
294
295static int dio24_pcmcia_config_loop(struct pcmcia_device *p_dev, 240static int dio24_pcmcia_config_loop(struct pcmcia_device *p_dev,
296 cistpl_cftable_entry_t *cfg,
297 cistpl_cftable_entry_t *dflt,
298 unsigned int vcc,
299 void *priv_data) 241 void *priv_data)
300{ 242{
301 if (cfg->index == 0) 243 if (p_dev->config_index == 0)
302 return -ENODEV; 244 return -EINVAL;
303
304 /* Does this card need audio output? */
305 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
306 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
307 p_dev->conf.Status = CCSR_AUDIO_ENA;
308 }
309
310 /* Do we need to allocate an interrupt? */
311 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
312
313 /* IO window settings */
314 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
315 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
316 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
317 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
318 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
319 p_dev->resource[0]->flags |=
320 pcmcia_io_cfg_data_width(io->flags);
321 p_dev->resource[0]->start = io->win[0].base;
322 p_dev->resource[0]->end = io->win[0].len;
323 if (io->nwin > 1) {
324 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
325 p_dev->resource[1]->start = io->win[1].base;
326 p_dev->resource[1]->end = io->win[1].len;
327 }
328 /* This reserves IO space but doesn't actually enable it */
329 if (pcmcia_request_io(p_dev) != 0)
330 return -ENODEV;
331 }
332 245
333 /* If we got this far, we're cool! */ 246 return pcmcia_request_io(p_dev);
334 return 0;
335} 247}
336 248
337static void dio24_config(struct pcmcia_device *link) 249static void dio24_config(struct pcmcia_device *link)
@@ -342,6 +254,9 @@ static void dio24_config(struct pcmcia_device *link)
342 254
343 dev_dbg(&link->dev, "dio24_config\n"); 255 dev_dbg(&link->dev, "dio24_config\n");
344 256
257 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO |
258 CONF_AUTO_SET_IO;
259
345 ret = pcmcia_loop_config(link, dio24_pcmcia_config_loop, NULL); 260 ret = pcmcia_loop_config(link, dio24_pcmcia_config_loop, NULL);
346 if (ret) { 261 if (ret) {
347 dev_warn(&link->dev, "no configuration found\n"); 262 dev_warn(&link->dev, "no configuration found\n");
@@ -351,25 +266,10 @@ static void dio24_config(struct pcmcia_device *link)
351 if (!link->irq) 266 if (!link->irq)
352 goto failed; 267 goto failed;
353 268
354 /* 269 ret = pcmcia_enable_device(link);
355 This actually configures the PCMCIA socket -- setting up
356 the I/O windows and the interrupt mapping, and putting the
357 card and host interface into "Memory and IO" mode.
358 */
359 ret = pcmcia_request_configuration(link, &link->conf);
360 if (ret) 270 if (ret)
361 goto failed; 271 goto failed;
362 272
363 /* Finally, report what we've done */
364 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
365 if (link->conf.Attributes & CONF_ENABLE_IRQ)
366 printk(", irq %d", link->irq);
367 if (link->resource[0])
368 printk(" & %pR", link->resource[0]);
369 if (link->resource[1])
370 printk(" & %pR", link->resource[1]);
371 printk("\n");
372
373 return; 273 return;
374 274
375failed: 275failed:
@@ -385,18 +285,6 @@ static void dio24_release(struct pcmcia_device *link)
385 pcmcia_disable_device(link); 285 pcmcia_disable_device(link);
386} /* dio24_release */ 286} /* dio24_release */
387 287
388/*======================================================================
389
390 The card status event handler. Mostly, this schedules other
391 stuff to run after an event is received.
392
393 When a CARD_REMOVAL event is received, we immediately set a
394 private flag to block future accesses to this device. All the
395 functions that actually access the device should check this flag
396 to make sure the card is still present.
397
398======================================================================*/
399
400static int dio24_cs_suspend(struct pcmcia_device *link) 288static int dio24_cs_suspend(struct pcmcia_device *link)
401{ 289{
402 struct local_info_t *local = link->priv; 290 struct local_info_t *local = link->priv;
@@ -435,9 +323,7 @@ struct pcmcia_driver dio24_cs_driver = {
435 .resume = dio24_cs_resume, 323 .resume = dio24_cs_resume,
436 .id_table = dio24_cs_ids, 324 .id_table = dio24_cs_ids,
437 .owner = THIS_MODULE, 325 .owner = THIS_MODULE,
438 .drv = { 326 .name = "ni_daq_dio24",
439 .name = "ni_daq_dio24",
440 },
441}; 327};
442 328
443static int __init init_dio24_cs(void) 329static int __init init_dio24_cs(void)
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index 68c4ecbd93ae..6facbc8bf776 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -71,7 +71,6 @@ NI manuals:
71#include "comedi_fc.h" 71#include "comedi_fc.h"
72#include "ni_labpc.h" 72#include "ni_labpc.h"
73 73
74#include <pcmcia/cs.h>
75#include <pcmcia/cistpl.h> 74#include <pcmcia/cistpl.h>
76#include <pcmcia/cisreg.h> 75#include <pcmcia/cisreg.h>
77#include <pcmcia/ds.h> 76#include <pcmcia/ds.h>
@@ -153,59 +152,20 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
153 return labpc_common_attach(dev, iobase, irq, 0); 152 return labpc_common_attach(dev, iobase, irq, 0);
154} 153}
155 154
156/*====================================================================*/
157
158/*
159 The event() function is this driver's Card Services event handler.
160 It will be called by Card Services when an appropriate card status
161 event is received. The config() and release() entry points are
162 used to configure or release a socket, in response to card
163 insertion and ejection events. They are invoked from the dummy
164 event handler.
165
166 Kernel version 2.6.16 upwards uses suspend() and resume() functions
167 instead of an event() function.
168*/
169
170static void labpc_config(struct pcmcia_device *link); 155static void labpc_config(struct pcmcia_device *link);
171static void labpc_release(struct pcmcia_device *link); 156static void labpc_release(struct pcmcia_device *link);
172static int labpc_cs_suspend(struct pcmcia_device *p_dev); 157static int labpc_cs_suspend(struct pcmcia_device *p_dev);
173static int labpc_cs_resume(struct pcmcia_device *p_dev); 158static int labpc_cs_resume(struct pcmcia_device *p_dev);
174 159
175/*
176 The attach() and detach() entry points are used to create and destroy
177 "instances" of the driver, where each instance represents everything
178 needed to manage one actual PCMCIA card.
179*/
180
181static int labpc_cs_attach(struct pcmcia_device *); 160static int labpc_cs_attach(struct pcmcia_device *);
182static void labpc_cs_detach(struct pcmcia_device *); 161static void labpc_cs_detach(struct pcmcia_device *);
183 162
184/*
185 You'll also need to prototype all the functions that will actually
186 be used to talk to your device. See 'memory_cs' for a good example
187 of a fully self-sufficient driver; the other drivers rely more or
188 less on other parts of the kernel.
189*/
190
191struct local_info_t { 163struct local_info_t {
192 struct pcmcia_device *link; 164 struct pcmcia_device *link;
193 int stop; 165 int stop;
194 struct bus_operations *bus; 166 struct bus_operations *bus;
195}; 167};
196 168
197/*======================================================================
198
199 labpc_cs_attach() creates an "instance" of the driver, allocating
200 local data structures for one device. The device is registered
201 with Card Services.
202
203 The dev_link structure is initialized, but we don't actually
204 configure the card at this point -- we wait until we receive a
205 card insertion event.
206
207======================================================================*/
208
209static int labpc_cs_attach(struct pcmcia_device *link) 169static int labpc_cs_attach(struct pcmcia_device *link)
210{ 170{
211 struct local_info_t *local; 171 struct local_info_t *local;
@@ -219,16 +179,6 @@ static int labpc_cs_attach(struct pcmcia_device *link)
219 local->link = link; 179 local->link = link;
220 link->priv = local; 180 link->priv = local;
221 181
222 /*
223 General socket configuration defaults can go here. In this
224 client, we assume very little, and rely on the CIS for almost
225 everything. In most clients, many details (i.e., number, sizes,
226 and attributes of IO windows) are fixed by the nature of the
227 device, and can be hard-wired here.
228 */
229 link->conf.Attributes = 0;
230 link->conf.IntType = INT_MEMORY_AND_IO;
231
232 pcmcia_cur_dev = link; 182 pcmcia_cur_dev = link;
233 183
234 labpc_config(link); 184 labpc_config(link);
@@ -236,15 +186,6 @@ static int labpc_cs_attach(struct pcmcia_device *link)
236 return 0; 186 return 0;
237} /* labpc_cs_attach */ 187} /* labpc_cs_attach */
238 188
239/*======================================================================
240
241 This deletes a driver "instance". The device is de-registered
242 with Card Services. If it has been released, all local data
243 structures are freed. Otherwise, the structures will be freed
244 when the device is released.
245
246======================================================================*/
247
248static void labpc_cs_detach(struct pcmcia_device *link) 189static void labpc_cs_detach(struct pcmcia_device *link)
249{ 190{
250 dev_dbg(&link->dev, "labpc_cs_detach\n"); 191 dev_dbg(&link->dev, "labpc_cs_detach\n");
@@ -263,54 +204,13 @@ static void labpc_cs_detach(struct pcmcia_device *link)
263 204
264} /* labpc_cs_detach */ 205} /* labpc_cs_detach */
265 206
266/*======================================================================
267
268 labpc_config() is scheduled to run after a CARD_INSERTION event
269 is received, to configure the PCMCIA socket, and to make the
270 device available to the system.
271
272======================================================================*/
273
274static int labpc_pcmcia_config_loop(struct pcmcia_device *p_dev, 207static int labpc_pcmcia_config_loop(struct pcmcia_device *p_dev,
275 cistpl_cftable_entry_t *cfg,
276 cistpl_cftable_entry_t *dflt,
277 unsigned int vcc,
278 void *priv_data) 208 void *priv_data)
279{ 209{
280 if (cfg->index == 0) 210 if (p_dev->config_index == 0)
281 return -ENODEV; 211 return -EINVAL;
282
283 /* Does this card need audio output? */
284 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
285 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
286 p_dev->conf.Status = CCSR_AUDIO_ENA;
287 }
288
289 /* Do we need to allocate an interrupt? */
290 p_dev->conf.Attributes |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
291
292 /* IO window settings */
293 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
294 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
295 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
296 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
297 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
298 p_dev->resource[0]->flags |=
299 pcmcia_io_cfg_data_width(io->flags);
300 p_dev->resource[0]->start = io->win[0].base;
301 p_dev->resource[0]->end = io->win[0].len;
302 if (io->nwin > 1) {
303 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
304 p_dev->resource[1]->start = io->win[1].base;
305 p_dev->resource[1]->end = io->win[1].len;
306 }
307 /* This reserves IO space but doesn't actually enable it */
308 if (pcmcia_request_io(p_dev) != 0)
309 return -ENODEV;
310 }
311 212
312 /* If we got this far, we're cool! */ 213 return pcmcia_request_io(p_dev);
313 return 0;
314} 214}
315 215
316 216
@@ -320,6 +220,9 @@ static void labpc_config(struct pcmcia_device *link)
320 220
321 dev_dbg(&link->dev, "labpc_config\n"); 221 dev_dbg(&link->dev, "labpc_config\n");
322 222
223 link->config_flags |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ |
224 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
225
323 ret = pcmcia_loop_config(link, labpc_pcmcia_config_loop, NULL); 226 ret = pcmcia_loop_config(link, labpc_pcmcia_config_loop, NULL);
324 if (ret) { 227 if (ret) {
325 dev_warn(&link->dev, "no configuration found\n"); 228 dev_warn(&link->dev, "no configuration found\n");
@@ -329,25 +232,10 @@ static void labpc_config(struct pcmcia_device *link)
329 if (!link->irq) 232 if (!link->irq)
330 goto failed; 233 goto failed;
331 234
332 /* 235 ret = pcmcia_enable_device(link);
333 This actually configures the PCMCIA socket -- setting up
334 the I/O windows and the interrupt mapping, and putting the
335 card and host interface into "Memory and IO" mode.
336 */
337 ret = pcmcia_request_configuration(link, &link->conf);
338 if (ret) 236 if (ret)
339 goto failed; 237 goto failed;
340 238
341 /* Finally, report what we've done */
342 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
343 if (link->conf.Attributes & CONF_ENABLE_IRQ)
344 printk(", irq %d", link->irq);
345 if (link->resource[0])
346 printk(" & %pR", link->resource[0]);
347 if (link->resource[1])
348 printk(" & %pR", link->resource[1]);
349 printk("\n");
350
351 return; 239 return;
352 240
353failed: 241failed:
@@ -362,18 +250,6 @@ static void labpc_release(struct pcmcia_device *link)
362 pcmcia_disable_device(link); 250 pcmcia_disable_device(link);
363} /* labpc_release */ 251} /* labpc_release */
364 252
365/*======================================================================
366
367 The card status event handler. Mostly, this schedules other
368 stuff to run after an event is received.
369
370 When a CARD_REMOVAL event is received, we immediately set a
371 private flag to block future accesses to this device. All the
372 functions that actually access the device should check this flag
373 to make sure the card is still present.
374
375======================================================================*/
376
377static int labpc_cs_suspend(struct pcmcia_device *link) 253static int labpc_cs_suspend(struct pcmcia_device *link)
378{ 254{
379 struct local_info_t *local = link->priv; 255 struct local_info_t *local = link->priv;
@@ -391,8 +267,6 @@ static int labpc_cs_resume(struct pcmcia_device *link)
391 return 0; 267 return 0;
392} /* labpc_cs_resume */ 268} /* labpc_cs_resume */
393 269
394/*====================================================================*/
395
396static struct pcmcia_device_id labpc_cs_ids[] = { 270static struct pcmcia_device_id labpc_cs_ids[] = {
397 /* N.B. These IDs should match those in labpc_cs_boards (ni_labpc.c) */ 271 /* N.B. These IDs should match those in labpc_cs_boards (ni_labpc.c) */
398 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0103), /* daqcard-1200 */ 272 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0103), /* daqcard-1200 */
@@ -411,9 +285,7 @@ struct pcmcia_driver labpc_cs_driver = {
411 .resume = labpc_cs_resume, 285 .resume = labpc_cs_resume,
412 .id_table = labpc_cs_ids, 286 .id_table = labpc_cs_ids,
413 .owner = THIS_MODULE, 287 .owner = THIS_MODULE,
414 .drv = { 288 .name = "daqcard-1200",
415 .name = "daqcard-1200",
416 },
417}; 289};
418 290
419static int __init init_labpc_cs(void) 291static int __init init_labpc_cs(void)
diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c
index 1f2426352eb5..49563273f605 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/staging/comedi/drivers/ni_mio_cs.c
@@ -48,7 +48,6 @@ See the notes in the ni_atmio.o driver.
48#include "ni_stc.h" 48#include "ni_stc.h"
49#include "8255.h" 49#include "8255.h"
50 50
51#include <pcmcia/cs.h>
52#include <pcmcia/cistpl.h> 51#include <pcmcia/cistpl.h>
53#include <pcmcia/ds.h> 52#include <pcmcia/ds.h>
54 53
@@ -263,11 +262,6 @@ static struct pcmcia_device *cur_dev = NULL;
263 262
264static int cs_attach(struct pcmcia_device *link) 263static int cs_attach(struct pcmcia_device *link)
265{ 264{
266 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
267 link->resource[0]->end = 16;
268 link->conf.Attributes = CONF_ENABLE_IRQ;
269 link->conf.IntType = INT_MEMORY_AND_IO;
270
271 cur_dev = link; 265 cur_dev = link;
272 266
273 mio_cs_config(link); 267 mio_cs_config(link);
@@ -301,16 +295,12 @@ static int mio_cs_resume(struct pcmcia_device *link)
301} 295}
302 296
303 297
304static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, 298static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
305 cistpl_cftable_entry_t *cfg,
306 cistpl_cftable_entry_t *dflt,
307 unsigned int vcc,
308 void *priv_data)
309{ 299{
310 int base, ret; 300 int base, ret;
311 301
312 p_dev->resource[0]->end = cfg->io.win[0].len; 302 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
313 p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; 303 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
314 304
315 for (base = 0x000; base < 0x400; base += 0x20) { 305 for (base = 0x000; base < 0x400; base += 0x20) {
316 p_dev->resource[0]->start = base; 306 p_dev->resource[0]->start = base;
@@ -327,6 +317,7 @@ static void mio_cs_config(struct pcmcia_device *link)
327 int ret; 317 int ret;
328 318
329 DPRINTK("mio_cs_config(link=%p)\n", link); 319 DPRINTK("mio_cs_config(link=%p)\n", link);
320 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
330 321
331 ret = pcmcia_loop_config(link, mio_pcmcia_config_loop, NULL); 322 ret = pcmcia_loop_config(link, mio_pcmcia_config_loop, NULL);
332 if (ret) { 323 if (ret) {
@@ -337,7 +328,7 @@ static void mio_cs_config(struct pcmcia_device *link)
337 if (!link->irq) 328 if (!link->irq)
338 dev_info(&link->dev, "no IRQ available\n"); 329 dev_info(&link->dev, "no IRQ available\n");
339 330
340 ret = pcmcia_request_configuration(link, &link->conf); 331 ret = pcmcia_enable_device(link);
341} 332}
342 333
343static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it) 334static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
@@ -446,9 +437,7 @@ struct pcmcia_driver ni_mio_cs_driver = {
446 .resume = &mio_cs_resume, 437 .resume = &mio_cs_resume,
447 .id_table = ni_mio_cs_ids, 438 .id_table = ni_mio_cs_ids,
448 .owner = THIS_MODULE, 439 .owner = THIS_MODULE,
449 .drv = { 440 .name = "ni_mio_cs",
450 .name = "ni_mio_cs",
451 },
452}; 441};
453 442
454int init_module(void) 443int init_module(void)
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index bf489d7f4990..ebba9bb47777 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -50,7 +50,6 @@ Devices: [Quatech] DAQP-208 (daqp), DAQP-308
50#include "../comedidev.h" 50#include "../comedidev.h"
51#include <linux/semaphore.h> 51#include <linux/semaphore.h>
52 52
53#include <pcmcia/cs.h>
54#include <pcmcia/cistpl.h> 53#include <pcmcia/cistpl.h>
55#include <pcmcia/cisreg.h> 54#include <pcmcia/cisreg.h>
56#include <pcmcia/ds.h> 55#include <pcmcia/ds.h>
@@ -969,43 +968,14 @@ static int daqp_detach(struct comedi_device *dev)
969 968
970======================================================================*/ 969======================================================================*/
971 970
972/*
973 The event() function is this driver's Card Services event handler.
974 It will be called by Card Services when an appropriate card status
975 event is received. The config() and release() entry points are
976 used to configure or release a socket, in response to card
977 insertion and ejection events.
978
979 Kernel version 2.6.16 upwards uses suspend() and resume() functions
980 instead of an event() function.
981*/
982
983static void daqp_cs_config(struct pcmcia_device *link); 971static void daqp_cs_config(struct pcmcia_device *link);
984static void daqp_cs_release(struct pcmcia_device *link); 972static void daqp_cs_release(struct pcmcia_device *link);
985static int daqp_cs_suspend(struct pcmcia_device *p_dev); 973static int daqp_cs_suspend(struct pcmcia_device *p_dev);
986static int daqp_cs_resume(struct pcmcia_device *p_dev); 974static int daqp_cs_resume(struct pcmcia_device *p_dev);
987 975
988/*
989 The attach() and detach() entry points are used to create and destroy
990 "instances" of the driver, where each instance represents everything
991 needed to manage one actual PCMCIA card.
992*/
993
994static int daqp_cs_attach(struct pcmcia_device *); 976static int daqp_cs_attach(struct pcmcia_device *);
995static void daqp_cs_detach(struct pcmcia_device *); 977static void daqp_cs_detach(struct pcmcia_device *);
996 978
997/*======================================================================
998
999 daqp_cs_attach() creates an "instance" of the driver, allocating
1000 local data structures for one device. The device is registered
1001 with Card Services.
1002
1003 The dev_link structure is initialized, but we don't actually
1004 configure the card at this point -- we wait until we receive a
1005 card insertion event.
1006
1007======================================================================*/
1008
1009static int daqp_cs_attach(struct pcmcia_device *link) 979static int daqp_cs_attach(struct pcmcia_device *link)
1010{ 980{
1011 struct local_info_t *local; 981 struct local_info_t *local;
@@ -1031,30 +1001,11 @@ static int daqp_cs_attach(struct pcmcia_device *link)
1031 local->link = link; 1001 local->link = link;
1032 link->priv = local; 1002 link->priv = local;
1033 1003
1034 /*
1035 General socket configuration defaults can go here. In this
1036 client, we assume very little, and rely on the CIS for almost
1037 everything. In most clients, many details (i.e., number, sizes,
1038 and attributes of IO windows) are fixed by the nature of the
1039 device, and can be hard-wired here.
1040 */
1041 link->conf.Attributes = 0;
1042 link->conf.IntType = INT_MEMORY_AND_IO;
1043
1044 daqp_cs_config(link); 1004 daqp_cs_config(link);
1045 1005
1046 return 0; 1006 return 0;
1047} /* daqp_cs_attach */ 1007} /* daqp_cs_attach */
1048 1008
1049/*======================================================================
1050
1051 This deletes a driver "instance". The device is de-registered
1052 with Card Services. If it has been released, all local data
1053 structures are freed. Otherwise, the structures will be freed
1054 when the device is released.
1055
1056======================================================================*/
1057
1058static void daqp_cs_detach(struct pcmcia_device *link) 1009static void daqp_cs_detach(struct pcmcia_device *link)
1059{ 1010{
1060 struct local_info_t *dev = link->priv; 1011 struct local_info_t *dev = link->priv;
@@ -1070,45 +1021,11 @@ static void daqp_cs_detach(struct pcmcia_device *link)
1070 1021
1071} /* daqp_cs_detach */ 1022} /* daqp_cs_detach */
1072 1023
1073/*====================================================================== 1024static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
1074
1075 daqp_cs_config() is scheduled to run after a CARD_INSERTION event
1076 is received, to configure the PCMCIA socket, and to make the
1077 device available to the system.
1078
1079======================================================================*/
1080
1081
1082static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev,
1083 cistpl_cftable_entry_t *cfg,
1084 cistpl_cftable_entry_t *dflt,
1085 unsigned int vcc,
1086 void *priv_data)
1087{ 1025{
1088 if (cfg->index == 0) 1026 if (p_dev->config_index == 0)
1089 return -ENODEV; 1027 return -EINVAL;
1090 1028
1091 /* Do we need to allocate an interrupt? */
1092 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
1093
1094 /* IO window settings */
1095 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
1096 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
1097 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
1098 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
1099 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
1100 p_dev->resource[0]->flags |=
1101 pcmcia_io_cfg_data_width(io->flags);
1102 p_dev->resource[0]->start = io->win[0].base;
1103 p_dev->resource[0]->end = io->win[0].len;
1104 if (io->nwin > 1) {
1105 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
1106 p_dev->resource[1]->start = io->win[1].base;
1107 p_dev->resource[1]->end = io->win[1].len;
1108 }
1109 }
1110
1111 /* This reserves IO space but doesn't actually enable it */
1112 return pcmcia_request_io(p_dev); 1029 return pcmcia_request_io(p_dev);
1113} 1030}
1114 1031
@@ -1118,6 +1035,8 @@ static void daqp_cs_config(struct pcmcia_device *link)
1118 1035
1119 dev_dbg(&link->dev, "daqp_cs_config\n"); 1036 dev_dbg(&link->dev, "daqp_cs_config\n");
1120 1037
1038 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
1039
1121 ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL); 1040 ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL);
1122 if (ret) { 1041 if (ret) {
1123 dev_warn(&link->dev, "no configuration found\n"); 1042 dev_warn(&link->dev, "no configuration found\n");
@@ -1128,25 +1047,10 @@ static void daqp_cs_config(struct pcmcia_device *link)
1128 if (ret) 1047 if (ret)
1129 goto failed; 1048 goto failed;
1130 1049
1131 /* 1050 ret = pcmcia_enable_device(link);
1132 This actually configures the PCMCIA socket -- setting up
1133 the I/O windows and the interrupt mapping, and putting the
1134 card and host interface into "Memory and IO" mode.
1135 */
1136 ret = pcmcia_request_configuration(link, &link->conf);
1137 if (ret) 1051 if (ret)
1138 goto failed; 1052 goto failed;
1139 1053
1140 /* Finally, report what we've done */
1141 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
1142 if (link->conf.Attributes & CONF_ENABLE_IRQ)
1143 printk(", irq %u", link->irq);
1144 if (link->resource[0])
1145 printk(" & %pR", link->resource[0]);
1146 if (link->resource[1])
1147 printk(" & %pR", link->resource[1]);
1148 printk("\n");
1149
1150 return; 1054 return;
1151 1055
1152failed: 1056failed:
@@ -1161,18 +1065,6 @@ static void daqp_cs_release(struct pcmcia_device *link)
1161 pcmcia_disable_device(link); 1065 pcmcia_disable_device(link);
1162} /* daqp_cs_release */ 1066} /* daqp_cs_release */
1163 1067
1164/*======================================================================
1165
1166 The card status event handler. Mostly, this schedules other
1167 stuff to run after an event is received.
1168
1169 When a CARD_REMOVAL event is received, we immediately set a
1170 private flag to block future accesses to this device. All the
1171 functions that actually access the device should check this flag
1172 to make sure the card is still present.
1173
1174======================================================================*/
1175
1176static int daqp_cs_suspend(struct pcmcia_device *link) 1068static int daqp_cs_suspend(struct pcmcia_device *link)
1177{ 1069{
1178 struct local_info_t *local = link->priv; 1070 struct local_info_t *local = link->priv;
@@ -1212,9 +1104,7 @@ static struct pcmcia_driver daqp_cs_driver = {
1212 .resume = daqp_cs_resume, 1104 .resume = daqp_cs_resume,
1213 .id_table = daqp_cs_id_table, 1105 .id_table = daqp_cs_id_table,
1214 .owner = THIS_MODULE, 1106 .owner = THIS_MODULE,
1215 .drv = { 1107 .name = "quatech_daqp_cs",
1216 .name = "quatech_daqp_cs",
1217 },
1218}; 1108};
1219 1109
1220int __init init_module(void) 1110int __init init_module(void)
diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c
index 19c335458653..6555891e149c 100644
--- a/drivers/staging/wlags49_h2/wl_cs.c
+++ b/drivers/staging/wlags49_h2/wl_cs.c
@@ -83,7 +83,6 @@
83#include <linux/if_arp.h> 83#include <linux/if_arp.h>
84#include <linux/ioport.h> 84#include <linux/ioport.h>
85 85
86#include <pcmcia/cs.h>
87#include <pcmcia/cistpl.h> 86#include <pcmcia/cistpl.h>
88#include <pcmcia/cisreg.h> 87#include <pcmcia/cisreg.h>
89#include <pcmcia/ciscode.h> 88#include <pcmcia/ciscode.h>
@@ -147,10 +146,9 @@ static int wl_adapter_attach(struct pcmcia_device *link)
147 146
148 link->resource[0]->end = HCF_NUM_IO_PORTS; 147 link->resource[0]->end = HCF_NUM_IO_PORTS;
149 link->resource[0]->flags= IO_DATA_PATH_WIDTH_16; 148 link->resource[0]->flags= IO_DATA_PATH_WIDTH_16;
150 link->conf.Attributes = CONF_ENABLE_IRQ; 149 link->config_flags |= CONF_ENABLE_IRQ;
151 link->conf.IntType = INT_MEMORY_AND_IO; 150 link->config_index = 5;
152 link->conf.ConfigIndex = 5; 151 link->config_regs = PRESENT_OPTION;
153 link->conf.Present = PRESENT_OPTION;
154 152
155 link->priv = dev; 153 link->priv = dev;
156 lp = wl_priv(dev); 154 lp = wl_priv(dev);
@@ -165,27 +163,6 @@ static int wl_adapter_attach(struct pcmcia_device *link)
165 163
166 164
167 165
168/*******************************************************************************
169 * wl_adapter_detach()
170 *******************************************************************************
171 *
172 * DESCRIPTION:
173 *
174 * This deletes a driver "instance". The device is de-registered with Card
175 * Services. If it has been released, then the net device is unregistered, and
176 * all local data structures are freed. Otherwise, the structures will be
177 * freed when the device is released.
178 *
179 * PARAMETERS:
180 *
181 * link - pointer to the dev_link_t structure representing the device to
182 * detach
183 *
184 * RETURNS:
185 *
186 * N/A
187 *
188 ******************************************************************************/
189static void wl_adapter_detach(struct pcmcia_device *link) 166static void wl_adapter_detach(struct pcmcia_device *link)
190{ 167{
191 struct net_device *dev = link->priv; 168 struct net_device *dev = link->priv;
@@ -209,26 +186,6 @@ static void wl_adapter_detach(struct pcmcia_device *link)
209/*============================================================================*/ 186/*============================================================================*/
210 187
211 188
212/*******************************************************************************
213 * wl_adapter_release()
214 *******************************************************************************
215 *
216 * DESCRIPTION:
217 *
218 * After a card is removed, this routine will release the PCMCIA
219 * configuration. If the device is still open, this will be postponed until it
220 * is closed.
221 *
222 * PARAMETERS:
223 *
224 * arg - a u_long representing a pointer to a dev_link_t structure for the
225 * device to be released.
226 *
227 * RETURNS:
228 *
229 * N/A
230 *
231 ******************************************************************************/
232void wl_adapter_release(struct pcmcia_device *link) 189void wl_adapter_release(struct pcmcia_device *link)
233{ 190{
234 DBG_FUNC("wl_adapter_release"); 191 DBG_FUNC("wl_adapter_release");
@@ -268,26 +225,6 @@ static int wl_adapter_resume(struct pcmcia_device *link)
268 return 0; 225 return 0;
269} /* wl_adapter_resume */ 226} /* wl_adapter_resume */
270 227
271/*******************************************************************************
272 * wl_adapter_insert()
273 *******************************************************************************
274 *
275 * DESCRIPTION:
276 *
277 * wl_adapter_insert() is scheduled to run after a CARD_INSERTION event is
278 * received, to configure the PCMCIA socket, and to make the ethernet device
279 * available to the system.
280 *
281 * PARAMETERS:
282 *
283 * link - pointer to the dev_link_t structure representing the device to
284 * insert
285 *
286 * RETURNS:
287 *
288 * N/A
289 *
290 ******************************************************************************/
291void wl_adapter_insert(struct pcmcia_device *link) 228void wl_adapter_insert(struct pcmcia_device *link)
292{ 229{
293 struct net_device *dev; 230 struct net_device *dev;
@@ -302,7 +239,7 @@ void wl_adapter_insert(struct pcmcia_device *link)
302 dev = link->priv; 239 dev = link->priv;
303 240
304 /* Do we need to allocate an interrupt? */ 241 /* Do we need to allocate an interrupt? */
305 link->conf.Attributes |= CONF_ENABLE_IRQ; 242 link->config_flags |= CONF_ENABLE_IRQ;
306 link->io_lines = 6; 243 link->io_lines = 6;
307 244
308 ret = pcmcia_request_io(link); 245 ret = pcmcia_request_io(link);
@@ -313,7 +250,7 @@ void wl_adapter_insert(struct pcmcia_device *link)
313 if (ret != 0) 250 if (ret != 0)
314 goto failed; 251 goto failed;
315 252
316 ret = pcmcia_request_configuration(link, &link->conf); 253 ret = pcmcia_enable_device(link);
317 if (ret != 0) 254 if (ret != 0)
318 goto failed; 255 goto failed;
319 256
@@ -457,9 +394,7 @@ MODULE_DEVICE_TABLE(pcmcia, wl_adapter_ids);
457 394
458static struct pcmcia_driver wlags49_driver = { 395static struct pcmcia_driver wlags49_driver = {
459 .owner = THIS_MODULE, 396 .owner = THIS_MODULE,
460 .drv = { 397 .name = DRIVER_NAME,
461 .name = DRIVER_NAME,
462 },
463 .probe = wl_adapter_attach, 398 .probe = wl_adapter_attach,
464 .remove = wl_adapter_detach, 399 .remove = wl_adapter_detach,
465 .id_table = wl_adapter_ids, 400 .id_table = wl_adapter_ids,
diff --git a/drivers/staging/wlags49_h2/wl_internal.h b/drivers/staging/wlags49_h2/wl_internal.h
index 02f0a20e178a..cd129b3ee6c0 100644
--- a/drivers/staging/wlags49_h2/wl_internal.h
+++ b/drivers/staging/wlags49_h2/wl_internal.h
@@ -69,7 +69,6 @@
69 ******************************************************************************/ 69 ******************************************************************************/
70#include <linux/version.h> 70#include <linux/version.h>
71#ifdef BUS_PCMCIA 71#ifdef BUS_PCMCIA
72#include <pcmcia/cs.h>
73#include <pcmcia/cistpl.h> 72#include <pcmcia/cistpl.h>
74#include <pcmcia/cisreg.h> 73#include <pcmcia/cisreg.h>
75#include <pcmcia/ciscode.h> 74#include <pcmcia/ciscode.h>
diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c
index 88d0d472142f..8e3536acbf46 100644
--- a/drivers/staging/wlags49_h2/wl_main.c
+++ b/drivers/staging/wlags49_h2/wl_main.c
@@ -414,25 +414,6 @@ extern memimage fw_image; // firmware image to be downloaded
414#endif /* HCF_STA */ 414#endif /* HCF_STA */
415 415
416 416
417/*******************************************************************************
418 * wl_insert()
419 *******************************************************************************
420 *
421 * DESCRIPTION:
422 *
423 * wl_insert() is scheduled to run after a CARD_INSERTION event is
424 * received, to configure the PCMCIA socket, and to make the ethernet device
425 * available to the system.
426 *
427 * PARAMETERS:
428 *
429 * dev - a pointer to the net_device struct of the wireless device
430 *
431 * RETURNS:
432 *
433 * TRUE or FALSE
434 *
435 ******************************************************************************/
436int wl_insert( struct net_device *dev ) 417int wl_insert( struct net_device *dev )
437{ 418{
438 int result = 0; 419 int result = 0;
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index a1900e502518..d005b9eeebbc 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -8,7 +8,6 @@
8#include <linux/errno.h> /* error codes */ 8#include <linux/errno.h> /* error codes */
9#include <linux/slab.h> 9#include <linux/slab.h>
10 10
11#include <pcmcia/cs.h>
12#include <pcmcia/cistpl.h> 11#include <pcmcia/cistpl.h>
13#include <pcmcia/ds.h> 12#include <pcmcia/ds.h>
14 13
@@ -32,9 +31,6 @@ static int ixj_probe(struct pcmcia_device *p_dev)
32{ 31{
33 dev_dbg(&p_dev->dev, "ixj_attach()\n"); 32 dev_dbg(&p_dev->dev, "ixj_attach()\n");
34 /* Create new ixj device */ 33 /* Create new ixj device */
35 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
36 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
37 p_dev->conf.IntType = INT_MEMORY_AND_IO;
38 p_dev->priv = kzalloc(sizeof(struct ixj_info_t), GFP_KERNEL); 34 p_dev->priv = kzalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
39 if (!p_dev->priv) { 35 if (!p_dev->priv) {
40 return -ENOMEM; 36 return -ENOMEM;
@@ -111,40 +107,31 @@ failed:
111 return; 107 return;
112} 108}
113 109
114static int ixj_config_check(struct pcmcia_device *p_dev, 110static int ixj_config_check(struct pcmcia_device *p_dev, void *priv_data)
115 cistpl_cftable_entry_t *cfg,
116 cistpl_cftable_entry_t *dflt,
117 unsigned int vcc,
118 void *priv_data)
119{ 111{
120 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 112 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
121 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 113 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
122 p_dev->resource[0]->start = io->win[0].base; 114 p_dev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
123 p_dev->resource[0]->end = io->win[0].len; 115 p_dev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
124 p_dev->io_lines = 3; 116 p_dev->io_lines = 3;
125 if (io->nwin == 2) { 117
126 p_dev->resource[1]->start = io->win[1].base; 118 return pcmcia_request_io(p_dev);
127 p_dev->resource[1]->end = io->win[1].len;
128 }
129 if (!pcmcia_request_io(p_dev))
130 return 0;
131 }
132 return -ENODEV;
133} 119}
134 120
135static int ixj_config(struct pcmcia_device * link) 121static int ixj_config(struct pcmcia_device * link)
136{ 122{
137 IXJ *j; 123 IXJ *j;
138 ixj_info_t *info; 124 ixj_info_t *info;
139 cistpl_cftable_entry_t dflt = { 0 };
140 125
141 info = link->priv; 126 info = link->priv;
142 dev_dbg(&link->dev, "ixj_config\n"); 127 dev_dbg(&link->dev, "ixj_config\n");
143 128
144 if (pcmcia_loop_config(link, ixj_config_check, &dflt)) 129 link->config_flags = CONF_AUTO_SET_IO;
130
131 if (pcmcia_loop_config(link, ixj_config_check, NULL))
145 goto failed; 132 goto failed;
146 133
147 if (pcmcia_request_configuration(link, &link->conf)) 134 if (pcmcia_enable_device(link))
148 goto failed; 135 goto failed;
149 136
150 /* 137 /*
@@ -178,9 +165,7 @@ MODULE_DEVICE_TABLE(pcmcia, ixj_ids);
178 165
179static struct pcmcia_driver ixj_driver = { 166static struct pcmcia_driver ixj_driver = {
180 .owner = THIS_MODULE, 167 .owner = THIS_MODULE,
181 .drv = { 168 .name = "ixj_cs",
182 .name = "ixj_cs",
183 },
184 .probe = ixj_probe, 169 .probe = ixj_probe,
185 .remove = ixj_detach, 170 .remove = ixj_detach,
186 .id_table = ixj_ids, 171 .id_table = ixj_ids,
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 0e13a00eb2ed..3775c035a6c5 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -20,7 +20,6 @@
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22 22
23#include <pcmcia/cs.h>
24#include <pcmcia/cistpl.h> 23#include <pcmcia/cistpl.h>
25#include <pcmcia/cisreg.h> 24#include <pcmcia/cisreg.h>
26#include <pcmcia/ds.h> 25#include <pcmcia/ds.h>
@@ -132,49 +131,12 @@ static void sl811_cs_release(struct pcmcia_device * link)
132 platform_device_unregister(&platform_dev); 131 platform_device_unregister(&platform_dev);
133} 132}
134 133
135static int sl811_cs_config_check(struct pcmcia_device *p_dev, 134static int sl811_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
136 cistpl_cftable_entry_t *cfg,
137 cistpl_cftable_entry_t *dflt,
138 unsigned int vcc,
139 void *priv_data)
140{ 135{
141 if (cfg->index == 0) 136 if (p_dev->config_index == 0)
142 return -ENODEV; 137 return -EINVAL;
143 138
144 /* Use power settings for Vcc and Vpp if present */ 139 return pcmcia_request_io(p_dev);
145 /* Note that the CIS values need to be rescaled */
146 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
147 if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc)
148 return -ENODEV;
149 } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
150 if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc)
151 return -ENODEV;
152 }
153
154 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
155 p_dev->conf.Vpp =
156 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
157 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
158 p_dev->conf.Vpp =
159 dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
160
161 /* we need an interrupt */
162 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
163
164 /* IO window settings */
165 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
166 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
167 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
168 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
169
170 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
171 p_dev->resource[0]->start = io->win[0].base;
172 p_dev->resource[0]->end = io->win[0].len;
173
174 return pcmcia_request_io(p_dev);
175 }
176 pcmcia_disable_device(p_dev);
177 return -ENODEV;
178} 140}
179 141
180 142
@@ -185,6 +147,9 @@ static int sl811_cs_config(struct pcmcia_device *link)
185 147
186 dev_dbg(&link->dev, "sl811_cs_config\n"); 148 dev_dbg(&link->dev, "sl811_cs_config\n");
187 149
150 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
151 CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO;
152
188 if (pcmcia_loop_config(link, sl811_cs_config_check, NULL)) 153 if (pcmcia_loop_config(link, sl811_cs_config_check, NULL))
189 goto failed; 154 goto failed;
190 155
@@ -195,18 +160,10 @@ static int sl811_cs_config(struct pcmcia_device *link)
195 if (!link->irq) 160 if (!link->irq)
196 goto failed; 161 goto failed;
197 162
198 ret = pcmcia_request_configuration(link, &link->conf); 163 ret = pcmcia_enable_device(link);
199 if (ret) 164 if (ret)
200 goto failed; 165 goto failed;
201 166
202 dev_info(&link->dev, "index 0x%02x: ",
203 link->conf.ConfigIndex);
204 if (link->conf.Vpp)
205 printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
206 printk(", irq %d", link->irq);
207 printk(", io %pR", link->resource[0]);
208 printk("\n");
209
210 if (sl811_hc_init(parent, link->resource[0]->start, link->irq) 167 if (sl811_hc_init(parent, link->resource[0]->start, link->irq)
211 < 0) { 168 < 0) {
212failed: 169failed:
@@ -227,9 +184,6 @@ static int sl811_cs_probe(struct pcmcia_device *link)
227 local->p_dev = link; 184 local->p_dev = link;
228 link->priv = local; 185 link->priv = local;
229 186
230 link->conf.Attributes = 0;
231 link->conf.IntType = INT_MEMORY_AND_IO;
232
233 return sl811_cs_config(link); 187 return sl811_cs_config(link);
234} 188}
235 189
@@ -241,9 +195,7 @@ MODULE_DEVICE_TABLE(pcmcia, sl811_ids);
241 195
242static struct pcmcia_driver sl811_cs_driver = { 196static struct pcmcia_driver sl811_cs_driver = {
243 .owner = THIS_MODULE, 197 .owner = THIS_MODULE,
244 .drv = { 198 .name = "sl811_cs",
245 .name = "sl811_cs",
246 },
247 .probe = sl811_cs_probe, 199 .probe = sl811_cs_probe,
248 .remove = sl811_cs_detach, 200 .remove = sl811_cs_detach,
249 .id_table = sl811_ids, 201 .id_table = sl811_ids,
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
deleted file mode 100644
index 68d8bde7e8d6..000000000000
--- a/include/pcmcia/cs.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * cs.h
3 *
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
6 * published by the Free Software Foundation.
7 *
8 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
11 *
12 * (C) 1999 David A. Hinds
13 */
14
15#ifndef _LINUX_CS_H
16#define _LINUX_CS_H
17
18#ifdef __KERNEL__
19#include <linux/interrupt.h>
20#endif
21
22/* ModifyConfiguration */
23typedef struct modconf_t {
24 u_int Attributes;
25 u_int Vcc, Vpp1, Vpp2;
26} modconf_t;
27
28/* Attributes for ModifyConfiguration */
29#define CONF_IRQ_CHANGE_VALID 0x0100
30#define CONF_VCC_CHANGE_VALID 0x0200
31#define CONF_VPP1_CHANGE_VALID 0x0400
32#define CONF_VPP2_CHANGE_VALID 0x0800
33#define CONF_IO_CHANGE_WIDTH 0x1000
34
35/* For RequestConfiguration */
36typedef struct config_req_t {
37 u_int Attributes;
38 u_int Vpp; /* both Vpp1 and Vpp2 */
39 u_int IntType;
40 u_int ConfigBase;
41 u_char Status, Pin, Copy, ExtStatus;
42 u_char ConfigIndex;
43 u_int Present;
44} config_req_t;
45
46/* Attributes for RequestConfiguration */
47#define CONF_ENABLE_IRQ 0x01
48#define CONF_ENABLE_DMA 0x02
49#define CONF_ENABLE_SPKR 0x04
50#define CONF_ENABLE_PULSE_IRQ 0x08
51#define CONF_VALID_CLIENT 0x100
52
53/* IntType field */
54#define INT_MEMORY 0x01
55#define INT_MEMORY_AND_IO 0x02
56#define INT_CARDBUS 0x04
57#define INT_ZOOMED_VIDEO 0x08
58
59/* Configuration registers present */
60#define PRESENT_OPTION 0x001
61#define PRESENT_STATUS 0x002
62#define PRESENT_PIN_REPLACE 0x004
63#define PRESENT_COPY 0x008
64#define PRESENT_EXT_STATUS 0x010
65#define PRESENT_IOBASE_0 0x020
66#define PRESENT_IOBASE_1 0x040
67#define PRESENT_IOBASE_2 0x080
68#define PRESENT_IOBASE_3 0x100
69#define PRESENT_IOSIZE 0x200
70
71/* For RequestWindow */
72typedef struct win_req_t {
73 u_int Attributes;
74 u_long Base;
75 u_int Size;
76 u_int AccessSpeed;
77} win_req_t;
78
79/* Attributes for RequestWindow */
80#define WIN_MEMORY_TYPE_CM 0x00 /* default */
81#define WIN_MEMORY_TYPE_AM 0x20 /* MAP_ATTRIB */
82#define WIN_DATA_WIDTH_8 0x00 /* default */
83#define WIN_DATA_WIDTH_16 0x02 /* MAP_16BIT */
84#define WIN_ENABLE 0x01 /* MAP_ACTIVE */
85#define WIN_USE_WAIT 0x40 /* MAP_USE_WAIT */
86
87#define WIN_FLAGS_MAP 0x63 /* MAP_ATTRIB | MAP_16BIT | MAP_ACTIVE |
88 MAP_USE_WAIT */
89#define WIN_FLAGS_REQ 0x1c /* mapping to socket->win[i]:
90 0x04 -> 0
91 0x08 -> 1
92 0x0c -> 2
93 0x10 -> 3 */
94
95#endif /* _LINUX_CS_H */
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 70c58ed2278c..d830c87ff0a7 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -24,9 +24,11 @@
24 24
25#ifdef __KERNEL__ 25#ifdef __KERNEL__
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/interrupt.h>
27#include <pcmcia/ss.h> 28#include <pcmcia/ss.h>
28#include <asm/atomic.h> 29#include <asm/atomic.h>
29 30
31
30/* 32/*
31 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus 33 * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus
32 * a.k.a. PCI drivers 34 * a.k.a. PCI drivers
@@ -36,8 +38,6 @@ struct pcmcia_device;
36struct config_t; 38struct config_t;
37struct net_device; 39struct net_device;
38 40
39typedef struct resource *window_handle_t;
40
41/* dynamic device IDs for PCMCIA device drivers. See 41/* dynamic device IDs for PCMCIA device drivers. See
42 * Documentation/pcmcia/driver.txt for details. 42 * Documentation/pcmcia/driver.txt for details.
43*/ 43*/
@@ -47,6 +47,8 @@ struct pcmcia_dynids {
47}; 47};
48 48
49struct pcmcia_driver { 49struct pcmcia_driver {
50 const char *name;
51
50 int (*probe) (struct pcmcia_device *dev); 52 int (*probe) (struct pcmcia_device *dev);
51 void (*remove) (struct pcmcia_device *dev); 53 void (*remove) (struct pcmcia_device *dev);
52 54
@@ -90,15 +92,17 @@ struct pcmcia_device {
90 92
91 struct list_head socket_device_list; 93 struct list_head socket_device_list;
92 94
93 /* deprecated, will be cleaned up soon */
94 config_req_t conf;
95 window_handle_t win;
96
97 /* device setup */ 95 /* device setup */
98 unsigned int irq; 96 unsigned int irq;
99 struct resource *resource[PCMCIA_NUM_RESOURCES]; 97 struct resource *resource[PCMCIA_NUM_RESOURCES];
98 resource_size_t card_addr; /* for the 1st IOMEM resource */
99 unsigned int vpp;
100 100
101 unsigned int io_lines; /* number of I/O lines */ 101 unsigned int config_flags; /* CONF_ENABLE_ flags below */
102 unsigned int config_base;
103 unsigned int config_index;
104 unsigned int config_regs; /* PRESENT_ flags below */
105 unsigned int io_lines; /* number of I/O lines */
102 106
103 /* Is the device suspended? */ 107 /* Is the device suspended? */
104 u16 suspended:1; 108 u16 suspended:1;
@@ -174,9 +178,6 @@ int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
174/* loop CIS entries for valid configuration */ 178/* loop CIS entries for valid configuration */
175int pcmcia_loop_config(struct pcmcia_device *p_dev, 179int pcmcia_loop_config(struct pcmcia_device *p_dev,
176 int (*conf_check) (struct pcmcia_device *p_dev, 180 int (*conf_check) (struct pcmcia_device *p_dev,
177 cistpl_cftable_entry_t *cf,
178 cistpl_cftable_entry_t *dflt,
179 unsigned int vcc,
180 void *priv_data), 181 void *priv_data),
181 void *priv_data); 182 void *priv_data);
182 183
@@ -206,16 +207,17 @@ pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
206int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev, 207int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
207 irq_handler_t handler); 208 irq_handler_t handler);
208 209
209int pcmcia_request_configuration(struct pcmcia_device *p_dev, 210int pcmcia_enable_device(struct pcmcia_device *p_dev);
210 config_req_t *req);
211 211
212int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, 212int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
213 window_handle_t *wh); 213 unsigned int speed);
214int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t win); 214int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res);
215int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t win, 215int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
216 unsigned int offset); 216 unsigned int offset);
217 217
218int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 218int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp);
219int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev);
220
219void pcmcia_disable_device(struct pcmcia_device *p_dev); 221void pcmcia_disable_device(struct pcmcia_device *p_dev);
220 222
221/* IO ports */ 223/* IO ports */
@@ -224,15 +226,46 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev);
224#define IO_DATA_PATH_WIDTH_16 0x08 226#define IO_DATA_PATH_WIDTH_16 0x08
225#define IO_DATA_PATH_WIDTH_AUTO 0x10 227#define IO_DATA_PATH_WIDTH_AUTO 0x10
226 228
227/* convert flag found in cfgtable to data path width parameter */ 229/* IO memory */
228static inline int pcmcia_io_cfg_data_width(unsigned int flags) 230#define WIN_MEMORY_TYPE_CM 0x00 /* default */
229{ 231#define WIN_MEMORY_TYPE_AM 0x20 /* MAP_ATTRIB */
230 if (!(flags & CISTPL_IO_8BIT)) 232#define WIN_DATA_WIDTH_8 0x00 /* default */
231 return IO_DATA_PATH_WIDTH_16; 233#define WIN_DATA_WIDTH_16 0x02 /* MAP_16BIT */
232 if (!(flags & CISTPL_IO_16BIT)) 234#define WIN_ENABLE 0x01 /* MAP_ACTIVE */
233 return IO_DATA_PATH_WIDTH_8; 235#define WIN_USE_WAIT 0x40 /* MAP_USE_WAIT */
234 return IO_DATA_PATH_WIDTH_AUTO; 236
235} 237#define WIN_FLAGS_MAP 0x63 /* MAP_ATTRIB | MAP_16BIT | MAP_ACTIVE |
238 MAP_USE_WAIT */
239#define WIN_FLAGS_REQ 0x1c /* mapping to socket->win[i]:
240 0x04 -> 0
241 0x08 -> 1
242 0x0c -> 2
243 0x10 -> 3 */
244
245/* config_reg{ister}s present for this PCMCIA device */
246#define PRESENT_OPTION 0x001
247#define PRESENT_STATUS 0x002
248#define PRESENT_PIN_REPLACE 0x004
249#define PRESENT_COPY 0x008
250#define PRESENT_EXT_STATUS 0x010
251#define PRESENT_IOBASE_0 0x020
252#define PRESENT_IOBASE_1 0x040
253#define PRESENT_IOBASE_2 0x080
254#define PRESENT_IOBASE_3 0x100
255#define PRESENT_IOSIZE 0x200
256
257/* flags to be passed to pcmcia_enable_device() */
258#define CONF_ENABLE_IRQ 0x0001
259#define CONF_ENABLE_SPKR 0x0002
260#define CONF_ENABLE_PULSE_IRQ 0x0004
261#define CONF_ENABLE_ESR 0x0008
262
263/* flags used by pcmcia_loop_config() autoconfiguration */
264#define CONF_AUTO_CHECK_VCC 0x0100 /* check for matching Vcc? */
265#define CONF_AUTO_SET_VPP 0x0200 /* set Vpp? */
266#define CONF_AUTO_AUDIO 0x0400 /* enable audio line? */
267#define CONF_AUTO_SET_IO 0x0800 /* set ->resource[0,1] */
268#define CONF_AUTO_SET_IOMEM 0x1000 /* set ->resource[2] */
236 269
237#endif /* __KERNEL__ */ 270#endif /* __KERNEL__ */
238 271
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index 626b63c33d9e..731cde010f42 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -19,7 +19,6 @@
19#include <linux/sched.h> /* task_struct, completion */ 19#include <linux/sched.h> /* task_struct, completion */
20#include <linux/mutex.h> 20#include <linux/mutex.h>
21 21
22#include <pcmcia/cs.h>
23#ifdef CONFIG_CARDBUS 22#ifdef CONFIG_CARDBUS
24#include <linux/pci.h> 23#include <linux/pci.h>
25#endif 24#endif
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index 7ab9174a8a84..8cc4733698a0 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -142,10 +142,9 @@ static int snd_pdacf_probe(struct pcmcia_device *link)
142 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 142 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
143 link->resource[0]->end = 16; 143 link->resource[0]->end = 16;
144 144
145 link->conf.Attributes = CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ; 145 link->config_flags = CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
146 link->conf.IntType = INT_MEMORY_AND_IO; 146 link->config_index = 1;
147 link->conf.ConfigIndex = 1; 147 link->config_regs = PRESENT_OPTION;
148 link->conf.Present = PRESENT_OPTION;
149 148
150 return pdacf_config(link); 149 return pdacf_config(link);
151} 150}
@@ -217,7 +216,8 @@ static int pdacf_config(struct pcmcia_device *link)
217 int ret; 216 int ret;
218 217
219 snd_printdd(KERN_DEBUG "pdacf_config called\n"); 218 snd_printdd(KERN_DEBUG "pdacf_config called\n");
220 link->conf.ConfigIndex = 0x5; 219 link->config_index = 0x5;
220 link->config_flags |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
221 221
222 ret = pcmcia_request_io(link); 222 ret = pcmcia_request_io(link);
223 if (ret) 223 if (ret)
@@ -227,7 +227,7 @@ static int pdacf_config(struct pcmcia_device *link)
227 if (ret) 227 if (ret)
228 goto failed; 228 goto failed;
229 229
230 ret = pcmcia_request_configuration(link, &link->conf); 230 ret = pcmcia_enable_device(link);
231 if (ret) 231 if (ret)
232 goto failed; 232 goto failed;
233 233
@@ -287,9 +287,7 @@ MODULE_DEVICE_TABLE(pcmcia, snd_pdacf_ids);
287 287
288static struct pcmcia_driver pdacf_cs_driver = { 288static struct pcmcia_driver pdacf_cs_driver = {
289 .owner = THIS_MODULE, 289 .owner = THIS_MODULE,
290 .drv = { 290 .name = "snd-pdaudiocf",
291 .name = "snd-pdaudiocf",
292 },
293 .probe = snd_pdacf_probe, 291 .probe = snd_pdacf_probe,
294 .remove = snd_pdacf_detach, 292 .remove = snd_pdacf_detach,
295 .id_table = snd_pdacf_ids, 293 .id_table = snd_pdacf_ids,
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h
index 5cc3e4573074..bd26e092aead 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.h
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h
@@ -24,7 +24,6 @@
24#include <sound/pcm.h> 24#include <sound/pcm.h>
25#include <asm/io.h> 25#include <asm/io.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <pcmcia/cs.h>
28#include <pcmcia/cistpl.h> 27#include <pcmcia/cistpl.h>
29#include <pcmcia/ds.h> 28#include <pcmcia/ds.h>
30 29
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index a6edfc3be29a..80000d631f88 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -2,7 +2,7 @@
2 * Driver for Digigram VXpocket V2/440 soundcards 2 * Driver for Digigram VXpocket V2/440 soundcards
3 * 3 *
4 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> 4 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
5 * 5
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
@@ -162,10 +162,9 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl,
162 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 162 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
163 link->resource[0]->end = 16; 163 link->resource[0]->end = 16;
164 164
165 link->conf.Attributes = CONF_ENABLE_IRQ; 165 link->config_flags |= CONF_ENABLE_IRQ;
166 link->conf.IntType = INT_MEMORY_AND_IO; 166 link->config_index = 1;
167 link->conf.ConfigIndex = 1; 167 link->config_regs = PRESENT_OPTION;
168 link->conf.Present = PRESENT_OPTION;
169 168
170 *chip_ret = vxp; 169 *chip_ret = vxp;
171 return 0; 170 return 0;
@@ -234,7 +233,7 @@ static int vxpocket_config(struct pcmcia_device *link)
234 if (ret) 233 if (ret)
235 goto failed; 234 goto failed;
236 235
237 ret = pcmcia_request_configuration(link, &link->conf); 236 ret = pcmcia_enable_device(link);
238 if (ret) 237 if (ret)
239 goto failed; 238 goto failed;
240 239
@@ -359,9 +358,7 @@ MODULE_DEVICE_TABLE(pcmcia, vxp_ids);
359 358
360static struct pcmcia_driver vxp_cs_driver = { 359static struct pcmcia_driver vxp_cs_driver = {
361 .owner = THIS_MODULE, 360 .owner = THIS_MODULE,
362 .drv = { 361 .name = "snd-vxpocket",
363 .name = "snd-vxpocket",
364 },
365 .probe = vxpocket_probe, 362 .probe = vxpocket_probe,
366 .remove = vxpocket_detach, 363 .remove = vxpocket_detach,
367 .id_table = vxp_ids, 364 .id_table = vxp_ids,
diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h
index d9110669d042..13d658c1a216 100644
--- a/sound/pcmcia/vx/vxpocket.h
+++ b/sound/pcmcia/vx/vxpocket.h
@@ -23,7 +23,6 @@
23 23
24#include <sound/vx_core.h> 24#include <sound/vx_core.h>
25 25
26#include <pcmcia/cs.h>
27#include <pcmcia/cistpl.h> 26#include <pcmcia/cistpl.h>
28#include <pcmcia/ds.h> 27#include <pcmcia/ds.h>
29 28