aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-05 04:45:09 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:15:57 -0500
commitfd238232cd0ff4840ae6946bb338502154096d88 (patch)
treed20e8f5871f7cff9d0867a84f6ba088fbffcbe28
parenta78f4dd331a4f6a396eb5849656a4a72a70a56d7 (diff)
[PATCH] pcmcia: embed dev_link_t into struct pcmcia_device
Embed dev_link_t into struct pcmcia_device(), as they basically address the same entity. The actual contents of dev_link_t will be cleaned up step by step. This patch includes a bugfix from and signed-off-by Andrew Morton. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
-rw-r--r--drivers/bluetooth/bluecard_cs.c31
-rw-r--r--drivers/bluetooth/bt3c_cs.c26
-rw-r--r--drivers/bluetooth/btuart_cs.c25
-rw-r--r--drivers/bluetooth/dtl1_cs.c25
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c29
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c29
-rw-r--r--drivers/char/pcmcia/synclink_cs.c21
-rw-r--r--drivers/ide/legacy/ide-cs.c13
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c45
-rw-r--r--drivers/isdn/hisax/avma1_cs.c48
-rw-r--r--drivers/isdn/hisax/elsa_cs.c14
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c16
-rw-r--r--drivers/isdn/hisax/teles_cs.c13
-rw-r--r--drivers/mtd/maps/pcmciamtd.c22
-rw-r--r--drivers/net/pcmcia/3c574_cs.c19
-rw-r--r--drivers/net/pcmcia/3c589_cs.c23
-rw-r--r--drivers/net/pcmcia/axnet_cs.c19
-rw-r--r--drivers/net/pcmcia/com20020_cs.c39
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c19
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c17
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c21
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c21
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c19
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c19
-rw-r--r--drivers/net/wireless/airo_cs.c33
-rw-r--r--drivers/net/wireless/atmel_cs.c33
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c20
-rw-r--r--drivers/net/wireless/netwave_cs.c19
-rw-r--r--drivers/net/wireless/orinoco_cs.c22
-rw-r--r--drivers/net/wireless/ray_cs.c98
-rw-r--r--drivers/net/wireless/spectrum_cs.c21
-rw-r--r--drivers/net/wireless/wavelan_cs.c46
-rw-r--r--drivers/net/wireless/wl3501.h1
-rw-r--r--drivers/net/wireless/wl3501_cs.c61
-rw-r--r--drivers/parport/parport_cs.c12
-rw-r--r--drivers/pcmcia/ds.c19
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c9
-rw-r--r--drivers/pcmcia/pcmcia_resource.c13
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c21
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c12
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c13
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h2
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c11
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c11
-rw-r--r--drivers/serial/serial_cs.c16
-rw-r--r--drivers/telephony/ixj_pcmcia.c31
-rw-r--r--drivers/usb/host/sl811_cs.c11
-rw-r--r--include/pcmcia/ds.h31
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.c12
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.h2
-rw-r--r--sound/pcmcia/vx/vxpocket.c20
-rw-r--r--sound/pcmcia/vx/vxpocket.h2
52 files changed, 446 insertions, 729 deletions
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 8e23f9ad3e63..b461411eab3e 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -65,7 +65,7 @@ MODULE_LICENSE("GPL");
65 65
66 66
67typedef struct bluecard_info_t { 67typedef struct bluecard_info_t {
68 dev_link_t link; 68 struct pcmcia_device *p_dev;
69 dev_node_t node; 69 dev_node_t node;
70 70
71 struct hci_dev *hdev; 71 struct hci_dev *hdev;
@@ -162,7 +162,7 @@ static void bluecard_detach(struct pcmcia_device *p_dev);
162static void bluecard_activity_led_timeout(u_long arg) 162static void bluecard_activity_led_timeout(u_long arg)
163{ 163{
164 bluecard_info_t *info = (bluecard_info_t *)arg; 164 bluecard_info_t *info = (bluecard_info_t *)arg;
165 unsigned int iobase = info->link.io.BasePort1; 165 unsigned int iobase = info->p_dev->io.BasePort1;
166 166
167 if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 167 if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
168 return; 168 return;
@@ -179,7 +179,7 @@ static void bluecard_activity_led_timeout(u_long arg)
179 179
180static void bluecard_enable_activity_led(bluecard_info_t *info) 180static void bluecard_enable_activity_led(bluecard_info_t *info)
181{ 181{
182 unsigned int iobase = info->link.io.BasePort1; 182 unsigned int iobase = info->p_dev->io.BasePort1;
183 183
184 if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 184 if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
185 return; 185 return;
@@ -235,7 +235,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
235 } 235 }
236 236
237 do { 237 do {
238 register unsigned int iobase = info->link.io.BasePort1; 238 register unsigned int iobase = info->p_dev->io.BasePort1;
239 register unsigned int offset; 239 register unsigned int offset;
240 register unsigned char command; 240 register unsigned char command;
241 register unsigned long ready_bit; 241 register unsigned long ready_bit;
@@ -244,7 +244,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
244 244
245 clear_bit(XMIT_WAKEUP, &(info->tx_state)); 245 clear_bit(XMIT_WAKEUP, &(info->tx_state));
246 246
247 if (!(info->link.state & DEV_PRESENT)) 247 if (!(info->p_dev->state & DEV_PRESENT))
248 return; 248 return;
249 249
250 if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) { 250 if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) {
@@ -382,7 +382,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
382 return; 382 return;
383 } 383 }
384 384
385 iobase = info->link.io.BasePort1; 385 iobase = info->p_dev->io.BasePort1;
386 386
387 if (test_bit(XMIT_SENDING_READY, &(info->tx_state))) 387 if (test_bit(XMIT_SENDING_READY, &(info->tx_state)))
388 bluecard_enable_activity_led(info); 388 bluecard_enable_activity_led(info);
@@ -512,7 +512,7 @@ static irqreturn_t bluecard_interrupt(int irq, void *dev_inst, struct pt_regs *r
512 if (!test_bit(CARD_READY, &(info->hw_state))) 512 if (!test_bit(CARD_READY, &(info->hw_state)))
513 return IRQ_HANDLED; 513 return IRQ_HANDLED;
514 514
515 iobase = info->link.io.BasePort1; 515 iobase = info->p_dev->io.BasePort1;
516 516
517 spin_lock(&(info->lock)); 517 spin_lock(&(info->lock));
518 518
@@ -626,7 +626,7 @@ static int bluecard_hci_flush(struct hci_dev *hdev)
626static int bluecard_hci_open(struct hci_dev *hdev) 626static int bluecard_hci_open(struct hci_dev *hdev)
627{ 627{
628 bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); 628 bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data);
629 unsigned int iobase = info->link.io.BasePort1; 629 unsigned int iobase = info->p_dev->io.BasePort1;
630 630
631 if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 631 if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
632 bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); 632 bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE);
@@ -646,7 +646,7 @@ static int bluecard_hci_open(struct hci_dev *hdev)
646static int bluecard_hci_close(struct hci_dev *hdev) 646static int bluecard_hci_close(struct hci_dev *hdev)
647{ 647{
648 bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); 648 bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data);
649 unsigned int iobase = info->link.io.BasePort1; 649 unsigned int iobase = info->p_dev->io.BasePort1;
650 650
651 if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) 651 if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))
652 return 0; 652 return 0;
@@ -713,7 +713,7 @@ static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned l
713 713
714static int bluecard_open(bluecard_info_t *info) 714static int bluecard_open(bluecard_info_t *info)
715{ 715{
716 unsigned int iobase = info->link.io.BasePort1; 716 unsigned int iobase = info->p_dev->io.BasePort1;
717 struct hci_dev *hdev; 717 struct hci_dev *hdev;
718 unsigned char id; 718 unsigned char id;
719 719
@@ -831,7 +831,7 @@ static int bluecard_open(bluecard_info_t *info)
831 831
832static int bluecard_close(bluecard_info_t *info) 832static int bluecard_close(bluecard_info_t *info)
833{ 833{
834 unsigned int iobase = info->link.io.BasePort1; 834 unsigned int iobase = info->p_dev->io.BasePort1;
835 struct hci_dev *hdev = info->hdev; 835 struct hci_dev *hdev = info->hdev;
836 836
837 if (!hdev) 837 if (!hdev)
@@ -859,14 +859,14 @@ static int bluecard_close(bluecard_info_t *info)
859static int bluecard_attach(struct pcmcia_device *p_dev) 859static int bluecard_attach(struct pcmcia_device *p_dev)
860{ 860{
861 bluecard_info_t *info; 861 bluecard_info_t *info;
862 dev_link_t *link; 862 dev_link_t *link = dev_to_instance(p_dev);
863 863
864 /* Create new info device */ 864 /* Create new info device */
865 info = kzalloc(sizeof(*info), GFP_KERNEL); 865 info = kzalloc(sizeof(*info), GFP_KERNEL);
866 if (!info) 866 if (!info)
867 return -ENOMEM; 867 return -ENOMEM;
868 868
869 link = &info->link; 869 info->p_dev = p_dev;
870 link->priv = info; 870 link->priv = info;
871 871
872 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 872 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -880,9 +880,6 @@ static int bluecard_attach(struct pcmcia_device *p_dev)
880 link->conf.Attributes = CONF_ENABLE_IRQ; 880 link->conf.Attributes = CONF_ENABLE_IRQ;
881 link->conf.IntType = INT_MEMORY_AND_IO; 881 link->conf.IntType = INT_MEMORY_AND_IO;
882 882
883 link->handle = p_dev;
884 p_dev->instance = link;
885
886 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 883 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
887 bluecard_config(link); 884 bluecard_config(link);
888 885
@@ -976,7 +973,7 @@ static void bluecard_config(dev_link_t *link)
976 goto failed; 973 goto failed;
977 974
978 strcpy(info->node.dev_name, info->hdev->name); 975 strcpy(info->node.dev_name, info->hdev->name);
979 link->dev = &info->node; 976 link->dev_node = &info->node;
980 link->state &= ~DEV_CONFIG_PENDING; 977 link->state &= ~DEV_CONFIG_PENDING;
981 978
982 return; 979 return;
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 0b848050b0cc..9192a754ebc0 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -72,7 +72,7 @@ MODULE_LICENSE("GPL");
72 72
73 73
74typedef struct bt3c_info_t { 74typedef struct bt3c_info_t {
75 dev_link_t link; 75 struct pcmcia_device *p_dev;
76 dev_node_t node; 76 dev_node_t node;
77 77
78 struct hci_dev *hdev; 78 struct hci_dev *hdev;
@@ -191,11 +191,11 @@ static void bt3c_write_wakeup(bt3c_info_t *info)
191 return; 191 return;
192 192
193 do { 193 do {
194 register unsigned int iobase = info->link.io.BasePort1; 194 register unsigned int iobase = info->p_dev->io.BasePort1;
195 register struct sk_buff *skb; 195 register struct sk_buff *skb;
196 register int len; 196 register int len;
197 197
198 if (!(info->link.state & DEV_PRESENT)) 198 if (!(info->p_dev->state & DEV_PRESENT))
199 break; 199 break;
200 200
201 201
@@ -229,7 +229,7 @@ static void bt3c_receive(bt3c_info_t *info)
229 return; 229 return;
230 } 230 }
231 231
232 iobase = info->link.io.BasePort1; 232 iobase = info->p_dev->io.BasePort1;
233 233
234 avail = bt3c_read(iobase, 0x7006); 234 avail = bt3c_read(iobase, 0x7006);
235 //printk("bt3c_cs: receiving %d bytes\n", avail); 235 //printk("bt3c_cs: receiving %d bytes\n", avail);
@@ -350,7 +350,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
350 return IRQ_NONE; 350 return IRQ_NONE;
351 } 351 }
352 352
353 iobase = info->link.io.BasePort1; 353 iobase = info->p_dev->io.BasePort1;
354 354
355 spin_lock(&(info->lock)); 355 spin_lock(&(info->lock));
356 356
@@ -481,7 +481,7 @@ static int bt3c_load_firmware(bt3c_info_t *info, unsigned char *firmware, int co
481 unsigned int iobase, size, addr, fcs, tmp; 481 unsigned int iobase, size, addr, fcs, tmp;
482 int i, err = 0; 482 int i, err = 0;
483 483
484 iobase = info->link.io.BasePort1; 484 iobase = info->p_dev->io.BasePort1;
485 485
486 /* Reset */ 486 /* Reset */
487 bt3c_io_write(iobase, 0x8040, 0x0404); 487 bt3c_io_write(iobase, 0x8040, 0x0404);
@@ -562,7 +562,6 @@ static int bt3c_open(bt3c_info_t *info)
562{ 562{
563 const struct firmware *firmware; 563 const struct firmware *firmware;
564 struct hci_dev *hdev; 564 struct hci_dev *hdev;
565 client_handle_t handle;
566 int err; 565 int err;
567 566
568 spin_lock_init(&(info->lock)); 567 spin_lock_init(&(info->lock));
@@ -594,10 +593,8 @@ static int bt3c_open(bt3c_info_t *info)
594 593
595 hdev->owner = THIS_MODULE; 594 hdev->owner = THIS_MODULE;
596 595
597 handle = info->link.handle;
598
599 /* Load firmware */ 596 /* Load firmware */
600 err = request_firmware(&firmware, "BT3CPCC.bin", &handle_to_dev(handle)); 597 err = request_firmware(&firmware, "BT3CPCC.bin", &info->p_dev->dev);
601 if (err < 0) { 598 if (err < 0) {
602 BT_ERR("Firmware request failed"); 599 BT_ERR("Firmware request failed");
603 goto error; 600 goto error;
@@ -651,14 +648,14 @@ static int bt3c_close(bt3c_info_t *info)
651static int bt3c_attach(struct pcmcia_device *p_dev) 648static int bt3c_attach(struct pcmcia_device *p_dev)
652{ 649{
653 bt3c_info_t *info; 650 bt3c_info_t *info;
654 dev_link_t *link; 651 dev_link_t *link = dev_to_instance(p_dev);
655 652
656 /* Create new info device */ 653 /* Create new info device */
657 info = kzalloc(sizeof(*info), GFP_KERNEL); 654 info = kzalloc(sizeof(*info), GFP_KERNEL);
658 if (!info) 655 if (!info)
659 return -ENOMEM; 656 return -ENOMEM;
660 657
661 link = &info->link; 658 info->p_dev = p_dev;
662 link->priv = info; 659 link->priv = info;
663 660
664 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 661 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -672,9 +669,6 @@ static int bt3c_attach(struct pcmcia_device *p_dev)
672 link->conf.Attributes = CONF_ENABLE_IRQ; 669 link->conf.Attributes = CONF_ENABLE_IRQ;
673 link->conf.IntType = INT_MEMORY_AND_IO; 670 link->conf.IntType = INT_MEMORY_AND_IO;
674 671
675 link->handle = p_dev;
676 p_dev->instance = link;
677
678 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 672 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
679 bt3c_config(link); 673 bt3c_config(link);
680 674
@@ -815,7 +809,7 @@ found_port:
815 goto failed; 809 goto failed;
816 810
817 strcpy(info->node.dev_name, info->hdev->name); 811 strcpy(info->node.dev_name, info->hdev->name);
818 link->dev = &info->node; 812 link->dev_node = &info->node;
819 link->state &= ~DEV_CONFIG_PENDING; 813 link->state &= ~DEV_CONFIG_PENDING;
820 814
821 return; 815 return;
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index ec19a577b429..cfe1d74a9185 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -68,7 +68,7 @@ MODULE_LICENSE("GPL");
68 68
69 69
70typedef struct btuart_info_t { 70typedef struct btuart_info_t {
71 dev_link_t link; 71 struct pcmcia_device *p_dev;
72 dev_node_t node; 72 dev_node_t node;
73 73
74 struct hci_dev *hdev; 74 struct hci_dev *hdev;
@@ -146,13 +146,13 @@ static void btuart_write_wakeup(btuart_info_t *info)
146 } 146 }
147 147
148 do { 148 do {
149 register unsigned int iobase = info->link.io.BasePort1; 149 register unsigned int iobase = info->p_dev->io.BasePort1;
150 register struct sk_buff *skb; 150 register struct sk_buff *skb;
151 register int len; 151 register int len;
152 152
153 clear_bit(XMIT_WAKEUP, &(info->tx_state)); 153 clear_bit(XMIT_WAKEUP, &(info->tx_state));
154 154
155 if (!(info->link.state & DEV_PRESENT)) 155 if (!(info->p_dev->state & DEV_PRESENT))
156 return; 156 return;
157 157
158 if (!(skb = skb_dequeue(&(info->txq)))) 158 if (!(skb = skb_dequeue(&(info->txq))))
@@ -187,7 +187,7 @@ static void btuart_receive(btuart_info_t *info)
187 return; 187 return;
188 } 188 }
189 189
190 iobase = info->link.io.BasePort1; 190 iobase = info->p_dev->io.BasePort1;
191 191
192 do { 192 do {
193 info->hdev->stat.byte_rx++; 193 info->hdev->stat.byte_rx++;
@@ -301,7 +301,7 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst, struct pt_regs *reg
301 return IRQ_NONE; 301 return IRQ_NONE;
302 } 302 }
303 303
304 iobase = info->link.io.BasePort1; 304 iobase = info->p_dev->io.BasePort1;
305 305
306 spin_lock(&(info->lock)); 306 spin_lock(&(info->lock));
307 307
@@ -357,7 +357,7 @@ static void btuart_change_speed(btuart_info_t *info, unsigned int speed)
357 return; 357 return;
358 } 358 }
359 359
360 iobase = info->link.io.BasePort1; 360 iobase = info->p_dev->io.BasePort1;
361 361
362 spin_lock_irqsave(&(info->lock), flags); 362 spin_lock_irqsave(&(info->lock), flags);
363 363
@@ -481,7 +481,7 @@ static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned lon
481static int btuart_open(btuart_info_t *info) 481static int btuart_open(btuart_info_t *info)
482{ 482{
483 unsigned long flags; 483 unsigned long flags;
484 unsigned int iobase = info->link.io.BasePort1; 484 unsigned int iobase = info->p_dev->io.BasePort1;
485 struct hci_dev *hdev; 485 struct hci_dev *hdev;
486 486
487 spin_lock_init(&(info->lock)); 487 spin_lock_init(&(info->lock));
@@ -550,7 +550,7 @@ static int btuart_open(btuart_info_t *info)
550static int btuart_close(btuart_info_t *info) 550static int btuart_close(btuart_info_t *info)
551{ 551{
552 unsigned long flags; 552 unsigned long flags;
553 unsigned int iobase = info->link.io.BasePort1; 553 unsigned int iobase = info->p_dev->io.BasePort1;
554 struct hci_dev *hdev = info->hdev; 554 struct hci_dev *hdev = info->hdev;
555 555
556 if (!hdev) 556 if (!hdev)
@@ -579,14 +579,14 @@ static int btuart_close(btuart_info_t *info)
579static int btuart_attach(struct pcmcia_device *p_dev) 579static int btuart_attach(struct pcmcia_device *p_dev)
580{ 580{
581 btuart_info_t *info; 581 btuart_info_t *info;
582 dev_link_t *link; 582 dev_link_t *link = dev_to_instance(p_dev);
583 583
584 /* Create new info device */ 584 /* Create new info device */
585 info = kzalloc(sizeof(*info), GFP_KERNEL); 585 info = kzalloc(sizeof(*info), GFP_KERNEL);
586 if (!info) 586 if (!info)
587 return -ENOMEM; 587 return -ENOMEM;
588 588
589 link = &info->link; 589 info->p_dev = p_dev;
590 link->priv = info; 590 link->priv = info;
591 591
592 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 592 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -600,9 +600,6 @@ static int btuart_attach(struct pcmcia_device *p_dev)
600 link->conf.Attributes = CONF_ENABLE_IRQ; 600 link->conf.Attributes = CONF_ENABLE_IRQ;
601 link->conf.IntType = INT_MEMORY_AND_IO; 601 link->conf.IntType = INT_MEMORY_AND_IO;
602 602
603 link->handle = p_dev;
604 p_dev->instance = link;
605
606 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 603 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
607 btuart_config(link); 604 btuart_config(link);
608 605
@@ -744,7 +741,7 @@ found_port:
744 goto failed; 741 goto failed;
745 742
746 strcpy(info->node.dev_name, info->hdev->name); 743 strcpy(info->node.dev_name, info->hdev->name);
747 link->dev = &info->node; 744 link->dev_node = &info->node;
748 link->state &= ~DEV_CONFIG_PENDING; 745 link->state &= ~DEV_CONFIG_PENDING;
749 746
750 return; 747 return;
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 86617ee80e59..389a68256fe4 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -68,7 +68,7 @@ MODULE_LICENSE("GPL");
68 68
69 69
70typedef struct dtl1_info_t { 70typedef struct dtl1_info_t {
71 dev_link_t link; 71 struct pcmcia_device *p_dev;
72 dev_node_t node; 72 dev_node_t node;
73 73
74 struct hci_dev *hdev; 74 struct hci_dev *hdev;
@@ -153,13 +153,13 @@ static void dtl1_write_wakeup(dtl1_info_t *info)
153 } 153 }
154 154
155 do { 155 do {
156 register unsigned int iobase = info->link.io.BasePort1; 156 register unsigned int iobase = info->p_dev->io.BasePort1;
157 register struct sk_buff *skb; 157 register struct sk_buff *skb;
158 register int len; 158 register int len;
159 159
160 clear_bit(XMIT_WAKEUP, &(info->tx_state)); 160 clear_bit(XMIT_WAKEUP, &(info->tx_state));
161 161
162 if (!(info->link.state & DEV_PRESENT)) 162 if (!(info->p_dev->state & DEV_PRESENT))
163 return; 163 return;
164 164
165 if (!(skb = skb_dequeue(&(info->txq)))) 165 if (!(skb = skb_dequeue(&(info->txq))))
@@ -218,7 +218,7 @@ static void dtl1_receive(dtl1_info_t *info)
218 return; 218 return;
219 } 219 }
220 220
221 iobase = info->link.io.BasePort1; 221 iobase = info->p_dev->io.BasePort1;
222 222
223 do { 223 do {
224 info->hdev->stat.byte_rx++; 224 info->hdev->stat.byte_rx++;
@@ -305,7 +305,7 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
305 return IRQ_NONE; 305 return IRQ_NONE;
306 } 306 }
307 307
308 iobase = info->link.io.BasePort1; 308 iobase = info->p_dev->io.BasePort1;
309 309
310 spin_lock(&(info->lock)); 310 spin_lock(&(info->lock));
311 311
@@ -458,7 +458,7 @@ static int dtl1_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long
458static int dtl1_open(dtl1_info_t *info) 458static int dtl1_open(dtl1_info_t *info)
459{ 459{
460 unsigned long flags; 460 unsigned long flags;
461 unsigned int iobase = info->link.io.BasePort1; 461 unsigned int iobase = info->p_dev->io.BasePort1;
462 struct hci_dev *hdev; 462 struct hci_dev *hdev;
463 463
464 spin_lock_init(&(info->lock)); 464 spin_lock_init(&(info->lock));
@@ -504,7 +504,7 @@ static int dtl1_open(dtl1_info_t *info)
504 outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */ 504 outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */
505 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR); 505 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR);
506 506
507 info->ri_latch = inb(info->link.io.BasePort1 + UART_MSR) & UART_MSR_RI; 507 info->ri_latch = inb(info->p_dev->io.BasePort1 + UART_MSR) & UART_MSR_RI;
508 508
509 /* Turn on interrupts */ 509 /* Turn on interrupts */
510 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); 510 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
@@ -529,7 +529,7 @@ static int dtl1_open(dtl1_info_t *info)
529static int dtl1_close(dtl1_info_t *info) 529static int dtl1_close(dtl1_info_t *info)
530{ 530{
531 unsigned long flags; 531 unsigned long flags;
532 unsigned int iobase = info->link.io.BasePort1; 532 unsigned int iobase = info->p_dev->io.BasePort1;
533 struct hci_dev *hdev = info->hdev; 533 struct hci_dev *hdev = info->hdev;
534 534
535 if (!hdev) 535 if (!hdev)
@@ -558,14 +558,14 @@ static int dtl1_close(dtl1_info_t *info)
558static int dtl1_attach(struct pcmcia_device *p_dev) 558static int dtl1_attach(struct pcmcia_device *p_dev)
559{ 559{
560 dtl1_info_t *info; 560 dtl1_info_t *info;
561 dev_link_t *link; 561 dev_link_t *link = dev_to_instance(p_dev);
562 562
563 /* Create new info device */ 563 /* Create new info device */
564 info = kzalloc(sizeof(*info), GFP_KERNEL); 564 info = kzalloc(sizeof(*info), GFP_KERNEL);
565 if (!info) 565 if (!info)
566 return -ENOMEM; 566 return -ENOMEM;
567 567
568 link = &info->link; 568 info->p_dev = p_dev;
569 link->priv = info; 569 link->priv = info;
570 570
571 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 571 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -579,9 +579,6 @@ static int dtl1_attach(struct pcmcia_device *p_dev)
579 link->conf.Attributes = CONF_ENABLE_IRQ; 579 link->conf.Attributes = CONF_ENABLE_IRQ;
580 link->conf.IntType = INT_MEMORY_AND_IO; 580 link->conf.IntType = INT_MEMORY_AND_IO;
581 581
582 link->handle = p_dev;
583 p_dev->instance = link;
584
585 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 582 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
586 dtl1_config(link); 583 dtl1_config(link);
587 584
@@ -696,7 +693,7 @@ static void dtl1_config(dev_link_t *link)
696 goto failed; 693 goto failed;
697 694
698 strcpy(info->node.dev_name, info->hdev->name); 695 strcpy(info->node.dev_name, info->hdev->name);
699 link->dev = &info->node; 696 link->dev_node = &info->node;
700 link->state &= ~DEV_CONFIG_PENDING; 697 link->state &= ~DEV_CONFIG_PENDING;
701 698
702 return; 699 return;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index c996ae1375be..3e6d6e0bb6ee 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -46,7 +46,7 @@
46/* #define ATR_CSUM */ 46/* #define ATR_CSUM */
47 47
48#ifdef PCMCIA_DEBUG 48#ifdef PCMCIA_DEBUG
49#define reader_to_dev(x) (&handle_to_dev(x->link.handle)) 49#define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle))
50static int pc_debug = PCMCIA_DEBUG; 50static int pc_debug = PCMCIA_DEBUG;
51module_param(pc_debug, int, 0600); 51module_param(pc_debug, int, 0600);
52#define DEBUGP(n, rdr, x, args...) do { \ 52#define DEBUGP(n, rdr, x, args...) do { \
@@ -106,7 +106,7 @@ static int major; /* major number we get from the kernel */
106#define REG_STOPBITS(x) (x + 7) 106#define REG_STOPBITS(x) (x + 7)
107 107
108struct cm4000_dev { 108struct cm4000_dev {
109 dev_link_t link; /* pcmcia link */ 109 struct pcmcia_device *p_dev;
110 dev_node_t node; /* OS node (major,minor) */ 110 dev_node_t node; /* OS node (major,minor) */
111 111
112 unsigned char atr[MAX_ATR]; 112 unsigned char atr[MAX_ATR];
@@ -454,7 +454,7 @@ static struct card_fixup card_fixups[] = {
454static void set_cardparameter(struct cm4000_dev *dev) 454static void set_cardparameter(struct cm4000_dev *dev)
455{ 455{
456 int i; 456 int i;
457 ioaddr_t iobase = dev->link.io.BasePort1; 457 ioaddr_t iobase = dev->p_dev->io.BasePort1;
458 u_int8_t stopbits = 0x02; /* ISO default */ 458 u_int8_t stopbits = 0x02; /* ISO default */
459 459
460 DEBUGP(3, dev, "-> set_cardparameter\n"); 460 DEBUGP(3, dev, "-> set_cardparameter\n");
@@ -487,7 +487,7 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
487 unsigned short num_bytes_read; 487 unsigned short num_bytes_read;
488 unsigned char pts_reply[4]; 488 unsigned char pts_reply[4];
489 ssize_t rc; 489 ssize_t rc;
490 ioaddr_t iobase = dev->link.io.BasePort1; 490 ioaddr_t iobase = dev->p_dev->io.BasePort1;
491 491
492 rc = 0; 492 rc = 0;
493 493
@@ -699,7 +699,7 @@ static void terminate_monitor(struct cm4000_dev *dev)
699static void monitor_card(unsigned long p) 699static void monitor_card(unsigned long p)
700{ 700{
701 struct cm4000_dev *dev = (struct cm4000_dev *) p; 701 struct cm4000_dev *dev = (struct cm4000_dev *) p;
702 ioaddr_t iobase = dev->link.io.BasePort1; 702 ioaddr_t iobase = dev->p_dev->io.BasePort1;
703 unsigned short s; 703 unsigned short s;
704 struct ptsreq ptsreq; 704 struct ptsreq ptsreq;
705 int i, atrc; 705 int i, atrc;
@@ -962,7 +962,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
962 loff_t *ppos) 962 loff_t *ppos)
963{ 963{
964 struct cm4000_dev *dev = filp->private_data; 964 struct cm4000_dev *dev = filp->private_data;
965 ioaddr_t iobase = dev->link.io.BasePort1; 965 ioaddr_t iobase = dev->p_dev->io.BasePort1;
966 ssize_t rc; 966 ssize_t rc;
967 int i, j, k; 967 int i, j, k;
968 968
@@ -971,7 +971,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
971 if (count == 0) /* according to manpage */ 971 if (count == 0) /* according to manpage */
972 return 0; 972 return 0;
973 973
974 if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */ 974 if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
975 test_bit(IS_CMM_ABSENT, &dev->flags)) 975 test_bit(IS_CMM_ABSENT, &dev->flags))
976 return -ENODEV; 976 return -ENODEV;
977 977
@@ -1083,7 +1083,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
1083 size_t count, loff_t *ppos) 1083 size_t count, loff_t *ppos)
1084{ 1084{
1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; 1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data;
1086 ioaddr_t iobase = dev->link.io.BasePort1; 1086 ioaddr_t iobase = dev->p_dev->io.BasePort1;
1087 unsigned short s; 1087 unsigned short s;
1088 unsigned char tmp; 1088 unsigned char tmp;
1089 unsigned char infolen; 1089 unsigned char infolen;
@@ -1108,7 +1108,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
1108 1108
1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0; 1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0;
1110 1110
1111 if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */ 1111 if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
1112 test_bit(IS_CMM_ABSENT, &dev->flags)) 1112 test_bit(IS_CMM_ABSENT, &dev->flags))
1113 return -ENODEV; 1113 return -ENODEV;
1114 1114
@@ -1440,7 +1440,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1440 unsigned long arg) 1440 unsigned long arg)
1441{ 1441{
1442 struct cm4000_dev *dev = filp->private_data; 1442 struct cm4000_dev *dev = filp->private_data;
1443 ioaddr_t iobase = dev->link.io.BasePort1; 1443 ioaddr_t iobase = dev->p_dev->io.BasePort1;
1444 dev_link_t *link; 1444 dev_link_t *link;
1445 int size; 1445 int size;
1446 int rc; 1446 int rc;
@@ -1844,7 +1844,7 @@ static void cm4000_config(dev_link_t * link, int devno)
1844 dev->node.major = major; 1844 dev->node.major = major;
1845 dev->node.minor = devno; 1845 dev->node.minor = devno;
1846 dev->node.next = NULL; 1846 dev->node.next = NULL;
1847 link->dev = &dev->node; 1847 link->dev_node = &dev->node;
1848 link->state &= ~DEV_CONFIG_PENDING; 1848 link->state &= ~DEV_CONFIG_PENDING;
1849 1849
1850 return; 1850 return;
@@ -1889,8 +1889,8 @@ static void cm4000_release(dev_link_t *link)
1889static int cm4000_attach(struct pcmcia_device *p_dev) 1889static int cm4000_attach(struct pcmcia_device *p_dev)
1890{ 1890{
1891 struct cm4000_dev *dev; 1891 struct cm4000_dev *dev;
1892 dev_link_t *link;
1893 int i; 1892 int i;
1893 dev_link_t *link = dev_to_instance(p_dev);
1894 1894
1895 for (i = 0; i < CM4000_MAX_DEV; i++) 1895 for (i = 0; i < CM4000_MAX_DEV; i++)
1896 if (dev_table[i] == NULL) 1896 if (dev_table[i] == NULL)
@@ -1906,7 +1906,7 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1906 if (dev == NULL) 1906 if (dev == NULL)
1907 return -ENOMEM; 1907 return -ENOMEM;
1908 1908
1909 link = &dev->link; 1909 dev->p_dev = p_dev;
1910 link->priv = dev; 1910 link->priv = dev;
1911 link->conf.IntType = INT_MEMORY_AND_IO; 1911 link->conf.IntType = INT_MEMORY_AND_IO;
1912 dev_table[i] = link; 1912 dev_table[i] = link;
@@ -1916,9 +1916,6 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1916 init_waitqueue_head(&dev->atrq); 1916 init_waitqueue_head(&dev->atrq);
1917 init_waitqueue_head(&dev->readq); 1917 init_waitqueue_head(&dev->readq);
1918 1918
1919 link->handle = p_dev;
1920 p_dev->instance = link;
1921
1922 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1919 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1923 cm4000_config(link, i); 1920 cm4000_config(link, i);
1924 1921
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 94ecd0342b72..97e32e7f84dc 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -41,7 +41,7 @@
41 41
42 42
43#ifdef PCMCIA_DEBUG 43#ifdef PCMCIA_DEBUG
44#define reader_to_dev(x) (&handle_to_dev(x->link.handle)) 44#define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle))
45static int pc_debug = PCMCIA_DEBUG; 45static int pc_debug = PCMCIA_DEBUG;
46module_param(pc_debug, int, 0600); 46module_param(pc_debug, int, 0600);
47#define DEBUGP(n, rdr, x, args...) do { \ 47#define DEBUGP(n, rdr, x, args...) do { \
@@ -74,7 +74,7 @@ static struct class *cmx_class;
74#define BS_WRITABLE 0x02 74#define BS_WRITABLE 0x02
75 75
76struct reader_dev { 76struct reader_dev {
77 dev_link_t link; 77 struct pcmcia_device *p_dev;
78 dev_node_t node; 78 dev_node_t node;
79 wait_queue_head_t devq; 79 wait_queue_head_t devq;
80 wait_queue_head_t poll_wait; 80 wait_queue_head_t poll_wait;
@@ -116,7 +116,7 @@ static inline unsigned char xinb(unsigned short port)
116static void cm4040_do_poll(unsigned long dummy) 116static void cm4040_do_poll(unsigned long dummy)
117{ 117{
118 struct reader_dev *dev = (struct reader_dev *) dummy; 118 struct reader_dev *dev = (struct reader_dev *) dummy;
119 unsigned int obs = xinb(dev->link.io.BasePort1 119 unsigned int obs = xinb(dev->p_dev->io.BasePort1
120 + REG_OFFSET_BUFFER_STATUS); 120 + REG_OFFSET_BUFFER_STATUS);
121 121
122 if ((obs & BSR_BULK_IN_FULL)) { 122 if ((obs & BSR_BULK_IN_FULL)) {
@@ -147,7 +147,7 @@ static void cm4040_stop_poll(struct reader_dev *dev)
147static int wait_for_bulk_out_ready(struct reader_dev *dev) 147static int wait_for_bulk_out_ready(struct reader_dev *dev)
148{ 148{
149 int i, rc; 149 int i, rc;
150 int iobase = dev->link.io.BasePort1; 150 int iobase = dev->p_dev->io.BasePort1;
151 151
152 for (i = 0; i < POLL_LOOP_COUNT; i++) { 152 for (i = 0; i < POLL_LOOP_COUNT; i++) {
153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) 153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
@@ -177,7 +177,7 @@ static int wait_for_bulk_out_ready(struct reader_dev *dev)
177/* Write to Sync Control Register */ 177/* Write to Sync Control Register */
178static int write_sync_reg(unsigned char val, struct reader_dev *dev) 178static int write_sync_reg(unsigned char val, struct reader_dev *dev)
179{ 179{
180 int iobase = dev->link.io.BasePort1; 180 int iobase = dev->p_dev->io.BasePort1;
181 int rc; 181 int rc;
182 182
183 rc = wait_for_bulk_out_ready(dev); 183 rc = wait_for_bulk_out_ready(dev);
@@ -195,7 +195,7 @@ static int write_sync_reg(unsigned char val, struct reader_dev *dev)
195static int wait_for_bulk_in_ready(struct reader_dev *dev) 195static int wait_for_bulk_in_ready(struct reader_dev *dev)
196{ 196{
197 int i, rc; 197 int i, rc;
198 int iobase = dev->link.io.BasePort1; 198 int iobase = dev->p_dev->io.BasePort1;
199 199
200 for (i = 0; i < POLL_LOOP_COUNT; i++) { 200 for (i = 0; i < POLL_LOOP_COUNT; i++) {
201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) 201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
@@ -225,7 +225,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
225 size_t count, loff_t *ppos) 225 size_t count, loff_t *ppos)
226{ 226{
227 struct reader_dev *dev = filp->private_data; 227 struct reader_dev *dev = filp->private_data;
228 int iobase = dev->link.io.BasePort1; 228 int iobase = dev->p_dev->io.BasePort1;
229 size_t bytes_to_read; 229 size_t bytes_to_read;
230 unsigned long i; 230 unsigned long i;
231 size_t min_bytes_to_read; 231 size_t min_bytes_to_read;
@@ -246,7 +246,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
246 return -EAGAIN; 246 return -EAGAIN;
247 } 247 }
248 248
249 if ((dev->link.state & DEV_PRESENT)==0) 249 if ((dev->p_dev->state & DEV_PRESENT)==0)
250 return -ENODEV; 250 return -ENODEV;
251 251
252 for (i = 0; i < 5; i++) { 252 for (i = 0; i < 5; i++) {
@@ -328,7 +328,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
328 size_t count, loff_t *ppos) 328 size_t count, loff_t *ppos)
329{ 329{
330 struct reader_dev *dev = filp->private_data; 330 struct reader_dev *dev = filp->private_data;
331 int iobase = dev->link.io.BasePort1; 331 int iobase = dev->p_dev->io.BasePort1;
332 ssize_t rc; 332 ssize_t rc;
333 int i; 333 int i;
334 unsigned int bytes_to_write; 334 unsigned int bytes_to_write;
@@ -351,7 +351,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
351 return -EAGAIN; 351 return -EAGAIN;
352 } 352 }
353 353
354 if ((dev->link.state & DEV_PRESENT) == 0) 354 if ((dev->p_dev->state & DEV_PRESENT) == 0)
355 return -ENODEV; 355 return -ENODEV;
356 356
357 bytes_to_write = count; 357 bytes_to_write = count;
@@ -606,7 +606,7 @@ static void reader_config(dev_link_t *link, int devno)
606 dev->node.major = major; 606 dev->node.major = major;
607 dev->node.minor = devno; 607 dev->node.minor = devno;
608 dev->node.next = NULL; 608 dev->node.next = NULL;
609 link->dev = &dev->node; 609 link->dev_node = &dev->node;
610 link->state &= ~DEV_CONFIG_PENDING; 610 link->state &= ~DEV_CONFIG_PENDING;
611 611
612 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno, 612 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
@@ -631,8 +631,8 @@ static void reader_release(dev_link_t *link)
631static int reader_attach(struct pcmcia_device *p_dev) 631static int reader_attach(struct pcmcia_device *p_dev)
632{ 632{
633 struct reader_dev *dev; 633 struct reader_dev *dev;
634 dev_link_t *link;
635 int i; 634 int i;
635 dev_link_t *link = dev_to_instance(p_dev);
636 636
637 for (i = 0; i < CM_MAX_DEV; i++) { 637 for (i = 0; i < CM_MAX_DEV; i++) {
638 if (dev_table[i] == NULL) 638 if (dev_table[i] == NULL)
@@ -649,8 +649,8 @@ static int reader_attach(struct pcmcia_device *p_dev)
649 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 649 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
650 dev->buffer_status = 0; 650 dev->buffer_status = 0;
651 651
652 link = &dev->link;
653 link->priv = dev; 652 link->priv = dev;
653 dev->p_dev = p_dev;
654 654
655 link->conf.IntType = INT_MEMORY_AND_IO; 655 link->conf.IntType = INT_MEMORY_AND_IO;
656 dev_table[i] = link; 656 dev_table[i] = link;
@@ -662,9 +662,6 @@ static int reader_attach(struct pcmcia_device *p_dev)
662 init_timer(&dev->poll_timer); 662 init_timer(&dev->poll_timer);
663 dev->poll_timer.function = &cm4040_do_poll; 663 dev->poll_timer.function = &cm4040_do_poll;
664 664
665 link->handle = p_dev;
666 p_dev->instance = link;
667
668 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 665 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
669 reader_config(link, i); 666 reader_config(link, i);
670 667
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index a6cbd3239921..7b1e055184d1 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -228,7 +228,7 @@ typedef struct _mgslpc_info {
228 struct _input_signal_events input_signal_events; 228 struct _input_signal_events input_signal_events;
229 229
230 /* PCMCIA support */ 230 /* PCMCIA support */
231 dev_link_t link; 231 struct pcmcia_device *p_dev;
232 dev_node_t node; 232 dev_node_t node;
233 int stop; 233 int stop;
234 234
@@ -536,11 +536,11 @@ static void ldisc_receive_buf(struct tty_struct *tty,
536static int mgslpc_attach(struct pcmcia_device *p_dev) 536static int mgslpc_attach(struct pcmcia_device *p_dev)
537{ 537{
538 MGSLPC_INFO *info; 538 MGSLPC_INFO *info;
539 dev_link_t *link; 539 dev_link_t *link = dev_to_instance(p_dev);
540 540
541 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
542 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
543 543
544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
545 if (!info) { 545 if (!info) {
546 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
@@ -565,22 +565,19 @@ static int mgslpc_attach(struct pcmcia_device *p_dev)
565 info->imrb_value = 0xffff; 565 info->imrb_value = 0xffff;
566 info->pim_value = 0xff; 566 info->pim_value = 0xff;
567 567
568 link = &info->link; 568 info->p_dev = p_dev;
569 link->priv = info; 569 link->priv = info;
570 570
571 /* Initialize the dev_link_t structure */ 571 /* Initialize the dev_link_t structure */
572 572
573 /* Interrupt setup */ 573 /* Interrupt setup */
574 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 574 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
575 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 575 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
576 link->irq.Handler = NULL; 576 link->irq.Handler = NULL;
577 577
578 link->conf.Attributes = 0; 578 link->conf.Attributes = 0;
579 link->conf.IntType = INT_MEMORY_AND_IO; 579 link->conf.IntType = INT_MEMORY_AND_IO;
580 580
581 link->handle = p_dev;
582 p_dev->instance = link;
583
584 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 581 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
585 mgslpc_config(link); 582 mgslpc_config(link);
586 583
@@ -673,7 +670,7 @@ static void mgslpc_config(dev_link_t *link)
673 /* add to linked list of devices */ 670 /* add to linked list of devices */
674 sprintf(info->node.dev_name, "mgslpc0"); 671 sprintf(info->node.dev_name, "mgslpc0");
675 info->node.major = info->node.minor = 0; 672 info->node.major = info->node.minor = 0;
676 link->dev = &info->node; 673 link->dev_node = &info->node;
677 674
678 printk(KERN_INFO "%s: index 0x%02x:", 675 printk(KERN_INFO "%s: index 0x%02x:",
679 info->node.dev_name, link->conf.ConfigIndex); 676 info->node.dev_name, link->conf.ConfigIndex);
@@ -1259,7 +1256,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id, struct pt_regs * regs)
1259 if (!info) 1256 if (!info)
1260 return IRQ_NONE; 1257 return IRQ_NONE;
1261 1258
1262 if (!(info->link.state & DEV_CONFIG)) 1259 if (!(info->p_dev->state & DEV_CONFIG))
1263 return IRQ_HANDLED; 1260 return IRQ_HANDLED;
1264 1261
1265 spin_lock(&info->lock); 1262 spin_lock(&info->lock);
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 3b5b55f85e23..70bb1b8bab09 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -81,7 +81,7 @@ static const char ide_major[] = {
81}; 81};
82 82
83typedef struct ide_info_t { 83typedef struct ide_info_t {
84 dev_link_t link; 84 struct pcmcia_device *p_dev;
85 int ndev; 85 int ndev;
86 dev_node_t node; 86 dev_node_t node;
87 int hd; 87 int hd;
@@ -106,7 +106,7 @@ static void ide_detach(struct pcmcia_device *p_dev);
106static int ide_attach(struct pcmcia_device *p_dev) 106static int ide_attach(struct pcmcia_device *p_dev)
107{ 107{
108 ide_info_t *info; 108 ide_info_t *info;
109 dev_link_t *link; 109 dev_link_t *link = dev_to_instance(p_dev);
110 110
111 DEBUG(0, "ide_attach()\n"); 111 DEBUG(0, "ide_attach()\n");
112 112
@@ -114,7 +114,9 @@ static int ide_attach(struct pcmcia_device *p_dev)
114 info = kzalloc(sizeof(*info), GFP_KERNEL); 114 info = kzalloc(sizeof(*info), GFP_KERNEL);
115 if (!info) 115 if (!info)
116 return -ENOMEM; 116 return -ENOMEM;
117 link = &info->link; link->priv = info; 117
118 info->p_dev = p_dev;
119 link->priv = info;
118 120
119 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 121 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
120 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 122 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
@@ -124,9 +126,6 @@ static int ide_attach(struct pcmcia_device *p_dev)
124 link->conf.Attributes = CONF_ENABLE_IRQ; 126 link->conf.Attributes = CONF_ENABLE_IRQ;
125 link->conf.IntType = INT_MEMORY_AND_IO; 127 link->conf.IntType = INT_MEMORY_AND_IO;
126 128
127 link->handle = p_dev;
128 p_dev->instance = link;
129
130 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 129 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
131 ide_config(link); 130 ide_config(link);
132 131
@@ -326,7 +325,7 @@ static void ide_config(dev_link_t *link)
326 info->node.major = ide_major[hd]; 325 info->node.major = ide_major[hd];
327 info->node.minor = 0; 326 info->node.minor = 0;
328 info->hd = hd; 327 info->hd = hd;
329 link->dev = &info->node; 328 link->dev_node = &info->node;
330 printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", 329 printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n",
331 info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); 330 info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10);
332 331
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 0c504dc49acf..3b7461ece505 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -101,49 +101,37 @@ typedef struct local_info_t {
101 101
102static int avmcs_attach(struct pcmcia_device *p_dev) 102static int avmcs_attach(struct pcmcia_device *p_dev)
103{ 103{
104 dev_link_t *link;
105 local_info_t *local; 104 local_info_t *local;
106 105
107 /* Initialize the dev_link_t structure */
108 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
109 if (!link)
110 goto err;
111 memset(link, 0, sizeof(struct dev_link_t));
112
113 /* The io structure describes IO port mapping */ 106 /* The io structure describes IO port mapping */
114 link->io.NumPorts1 = 16; 107 p_dev->io.NumPorts1 = 16;
115 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 108 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
116 link->io.NumPorts2 = 0; 109 p_dev->io.NumPorts2 = 0;
117 110
118 /* Interrupt setup */ 111 /* Interrupt setup */
119 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 112 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
120 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 113 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
114
115 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
121 116
122 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
123
124 /* General socket configuration */ 117 /* General socket configuration */
125 link->conf.Attributes = CONF_ENABLE_IRQ; 118 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
126 link->conf.IntType = INT_MEMORY_AND_IO; 119 p_dev->conf.IntType = INT_MEMORY_AND_IO;
127 link->conf.ConfigIndex = 1; 120 p_dev->conf.ConfigIndex = 1;
128 link->conf.Present = PRESENT_OPTION; 121 p_dev->conf.Present = PRESENT_OPTION;
129 122
130 /* Allocate space for private device-specific data */ 123 /* Allocate space for private device-specific data */
131 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 124 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
132 if (!local) 125 if (!local)
133 goto err_kfree; 126 goto err;
134 memset(local, 0, sizeof(local_info_t)); 127 memset(local, 0, sizeof(local_info_t));
135 link->priv = local; 128 p_dev->priv = local;
136
137 link->handle = p_dev;
138 p_dev->instance = link;
139 129
140 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 130 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
141 avmcs_config(link); 131 avmcs_config(p_dev);
142 132
143 return 0; 133 return 0;
144 134
145 err_kfree:
146 kfree(link);
147 err: 135 err:
148 return -EINVAL; 136 return -EINVAL;
149} /* avmcs_attach */ 137} /* avmcs_attach */
@@ -165,7 +153,6 @@ static void avmcs_detach(struct pcmcia_device *p_dev)
165 avmcs_release(link); 153 avmcs_release(link);
166 154
167 kfree(link->priv); 155 kfree(link->priv);
168 kfree(link);
169} /* avmcs_detach */ 156} /* avmcs_detach */
170 157
171/*====================================================================== 158/*======================================================================
@@ -330,7 +317,7 @@ found_port:
330 317
331 dev->node.major = 64; 318 dev->node.major = 64;
332 dev->node.minor = 0; 319 dev->node.minor = 0;
333 link->dev = &dev->node; 320 link->dev_node = &dev->node;
334 321
335 link->state &= ~DEV_CONFIG_PENDING; 322 link->state &= ~DEV_CONFIG_PENDING;
336 /* If any step failed, release any partially configured state */ 323 /* If any step failed, release any partially configured state */
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 8d23e5ab8d01..f7143fe1a2e7 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -118,50 +118,39 @@ typedef struct local_info_t {
118 118
119static int avma1cs_attach(struct pcmcia_device *p_dev) 119static int avma1cs_attach(struct pcmcia_device *p_dev)
120{ 120{
121 dev_link_t *link;
122 local_info_t *local; 121 local_info_t *local;
123 122
124 DEBUG(0, "avma1cs_attach()\n"); 123 DEBUG(0, "avma1cs_attach()\n");
125 124
126 /* Initialize the dev_link_t structure */
127 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
128 if (!link)
129 return -ENOMEM;
130 memset(link, 0, sizeof(struct dev_link_t));
131
132 /* Allocate space for private device-specific data */ 125 /* Allocate space for private device-specific data */
133 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 126 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
134 if (!local) { 127 if (!local)
135 kfree(link);
136 return -ENOMEM; 128 return -ENOMEM;
137 } 129
138 memset(local, 0, sizeof(local_info_t)); 130 memset(local, 0, sizeof(local_info_t));
139 link->priv = local; 131 p_dev->priv = local;
140 132
141 /* The io structure describes IO port mapping */ 133 /* The io structure describes IO port mapping */
142 link->io.NumPorts1 = 16; 134 p_dev->io.NumPorts1 = 16;
143 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 135 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
144 link->io.NumPorts2 = 16; 136 p_dev->io.NumPorts2 = 16;
145 link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; 137 p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_16;
146 link->io.IOAddrLines = 5; 138 p_dev->io.IOAddrLines = 5;
147 139
148 /* Interrupt setup */ 140 /* Interrupt setup */
149 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 141 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
150 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 142 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
151 143
152 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 144 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
153 145
154 /* General socket configuration */ 146 /* General socket configuration */
155 link->conf.Attributes = CONF_ENABLE_IRQ; 147 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
156 link->conf.IntType = INT_MEMORY_AND_IO; 148 p_dev->conf.IntType = INT_MEMORY_AND_IO;
157 link->conf.ConfigIndex = 1; 149 p_dev->conf.ConfigIndex = 1;
158 link->conf.Present = PRESENT_OPTION; 150 p_dev->conf.Present = PRESENT_OPTION;
159
160 link->handle = p_dev;
161 p_dev->instance = link;
162 151
163 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 152 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
164 avma1cs_config(link); 153 avma1cs_config(p_dev);
165 154
166 return 0; 155 return 0;
167} /* avma1cs_attach */ 156} /* avma1cs_attach */
@@ -185,7 +174,6 @@ static void avma1cs_detach(struct pcmcia_device *p_dev)
185 avma1cs_release(link); 174 avma1cs_release(link);
186 175
187 kfree(link->priv); 176 kfree(link->priv);
188 kfree(link);
189} /* avma1cs_detach */ 177} /* avma1cs_detach */
190 178
191/*====================================================================== 179/*======================================================================
@@ -335,7 +323,7 @@ found_port:
335 strcpy(dev->node.dev_name, "A1"); 323 strcpy(dev->node.dev_name, "A1");
336 dev->node.major = 45; 324 dev->node.major = 45;
337 dev->node.minor = 0; 325 dev->node.minor = 0;
338 link->dev = &dev->node; 326 link->dev_node = &dev->node;
339 327
340 link->state &= ~DEV_CONFIG_PENDING; 328 link->state &= ~DEV_CONFIG_PENDING;
341 /* If any step failed, release any partially configured state */ 329 /* If any step failed, release any partially configured state */
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index 00835d537c10..bcda675e9103 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -121,7 +121,7 @@ static void elsa_cs_detach(struct pcmcia_device *p_dev);
121*/ 121*/
122 122
123typedef struct local_info_t { 123typedef struct local_info_t {
124 dev_link_t link; 124 struct pcmcia_device *p_dev;
125 dev_node_t node; 125 dev_node_t node;
126 int busy; 126 int busy;
127 int cardnr; 127 int cardnr;
@@ -141,8 +141,8 @@ typedef struct local_info_t {
141 141
142static int elsa_cs_attach(struct pcmcia_device *p_dev) 142static int elsa_cs_attach(struct pcmcia_device *p_dev)
143{ 143{
144 dev_link_t *link;
145 local_info_t *local; 144 local_info_t *local;
145 dev_link_t *link = dev_to_instance(p_dev);
146 146
147 DEBUG(0, "elsa_cs_attach()\n"); 147 DEBUG(0, "elsa_cs_attach()\n");
148 148
@@ -150,8 +150,11 @@ static int elsa_cs_attach(struct pcmcia_device *p_dev)
150 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 150 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
151 if (!local) return -ENOMEM; 151 if (!local) return -ENOMEM;
152 memset(local, 0, sizeof(local_info_t)); 152 memset(local, 0, sizeof(local_info_t));
153
154 local->p_dev = p_dev;
155 link->priv = local;
156
153 local->cardnr = -1; 157 local->cardnr = -1;
154 link = &local->link; link->priv = local;
155 158
156 /* Interrupt setup */ 159 /* Interrupt setup */
157 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 160 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
@@ -172,9 +175,6 @@ static int elsa_cs_attach(struct pcmcia_device *p_dev)
172 link->conf.Attributes = CONF_ENABLE_IRQ; 175 link->conf.Attributes = CONF_ENABLE_IRQ;
173 link->conf.IntType = INT_MEMORY_AND_IO; 176 link->conf.IntType = INT_MEMORY_AND_IO;
174 177
175 link->handle = p_dev;
176 p_dev->instance = link;
177
178 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 178 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
179 elsa_cs_config(link); 179 elsa_cs_config(link);
180 180
@@ -320,7 +320,7 @@ static void elsa_cs_config(dev_link_t *link)
320 sprintf(dev->node.dev_name, "elsa"); 320 sprintf(dev->node.dev_name, "elsa");
321 dev->node.major = dev->node.minor = 0x0; 321 dev->node.major = dev->node.minor = 0x0;
322 322
323 link->dev = &dev->node; 323 link->dev_node = &dev->node;
324 324
325 /* Finally, report what we've done */ 325 /* Finally, report what we've done */
326 printk(KERN_INFO "%s: index 0x%02x: ", 326 printk(KERN_INFO "%s: index 0x%02x: ",
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index a3cd1c556352..6025722001fa 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -130,7 +130,7 @@ static void sedlbauer_detach(struct pcmcia_device *p_dev);
130*/ 130*/
131 131
132typedef struct local_info_t { 132typedef struct local_info_t {
133 dev_link_t link; 133 struct pcmcia_device *p_dev;
134 dev_node_t node; 134 dev_node_t node;
135 int stop; 135 int stop;
136 int cardnr; 136 int cardnr;
@@ -151,7 +151,7 @@ typedef struct local_info_t {
151static int sedlbauer_attach(struct pcmcia_device *p_dev) 151static int sedlbauer_attach(struct pcmcia_device *p_dev)
152{ 152{
153 local_info_t *local; 153 local_info_t *local;
154 dev_link_t *link; 154 dev_link_t *link = dev_to_instance(p_dev);
155 155
156 DEBUG(0, "sedlbauer_attach()\n"); 156 DEBUG(0, "sedlbauer_attach()\n");
157 157
@@ -160,8 +160,10 @@ static int sedlbauer_attach(struct pcmcia_device *p_dev)
160 if (!local) return -ENOMEM; 160 if (!local) return -ENOMEM;
161 memset(local, 0, sizeof(local_info_t)); 161 memset(local, 0, sizeof(local_info_t));
162 local->cardnr = -1; 162 local->cardnr = -1;
163 link = &local->link; link->priv = local; 163
164 164 local->p_dev = p_dev;
165 link->priv = local;
166
165 /* Interrupt setup */ 167 /* Interrupt setup */
166 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 168 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
167 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 169 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
@@ -182,13 +184,9 @@ static int sedlbauer_attach(struct pcmcia_device *p_dev)
182 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 184 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
183 link->io.IOAddrLines = 3; 185 link->io.IOAddrLines = 3;
184 186
185
186 link->conf.Attributes = 0; 187 link->conf.Attributes = 0;
187 link->conf.IntType = INT_MEMORY_AND_IO; 188 link->conf.IntType = INT_MEMORY_AND_IO;
188 189
189 link->handle = p_dev;
190 p_dev->instance = link;
191
192 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 190 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
193 sedlbauer_config(link); 191 sedlbauer_config(link);
194 192
@@ -397,7 +395,7 @@ static void sedlbauer_config(dev_link_t *link)
397 */ 395 */
398 sprintf(dev->node.dev_name, "sedlbauer"); 396 sprintf(dev->node.dev_name, "sedlbauer");
399 dev->node.major = dev->node.minor = 0; 397 dev->node.major = dev->node.minor = 0;
400 link->dev = &dev->node; 398 link->dev_node = &dev->node;
401 399
402 /* Finally, report what we've done */ 400 /* Finally, report what we've done */
403 printk(KERN_INFO "%s: index 0x%02x:", 401 printk(KERN_INFO "%s: index 0x%02x:",
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index 040f098d4b26..ea16ebfc028a 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -112,7 +112,7 @@ static void teles_detach(struct pcmcia_device *p_dev);
112*/ 112*/
113 113
114typedef struct local_info_t { 114typedef struct local_info_t {
115 dev_link_t link; 115 struct pcmcia_device *p_dev;
116 dev_node_t node; 116 dev_node_t node;
117 int busy; 117 int busy;
118 int cardnr; 118 int cardnr;
@@ -132,8 +132,8 @@ typedef struct local_info_t {
132 132
133static int teles_attach(struct pcmcia_device *p_dev) 133static int teles_attach(struct pcmcia_device *p_dev)
134{ 134{
135 dev_link_t *link;
136 local_info_t *local; 135 local_info_t *local;
136 dev_link_t *link = dev_to_instance(p_dev);
137 137
138 DEBUG(0, "teles_attach()\n"); 138 DEBUG(0, "teles_attach()\n");
139 139
@@ -142,7 +142,9 @@ static int teles_attach(struct pcmcia_device *p_dev)
142 if (!local) return -ENOMEM; 142 if (!local) return -ENOMEM;
143 memset(local, 0, sizeof(local_info_t)); 143 memset(local, 0, sizeof(local_info_t));
144 local->cardnr = -1; 144 local->cardnr = -1;
145 link = &local->link; link->priv = local; 145
146 local->p_dev = p_dev;
147 link->priv = local;
146 148
147 /* Interrupt setup */ 149 /* Interrupt setup */
148 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 150 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED;
@@ -163,9 +165,6 @@ static int teles_attach(struct pcmcia_device *p_dev)
163 link->conf.Attributes = CONF_ENABLE_IRQ; 165 link->conf.Attributes = CONF_ENABLE_IRQ;
164 link->conf.IntType = INT_MEMORY_AND_IO; 166 link->conf.IntType = INT_MEMORY_AND_IO;
165 167
166 link->handle = p_dev;
167 p_dev->instance = link;
168
169 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 168 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
170 teles_cs_config(link); 169 teles_cs_config(link);
171 170
@@ -311,7 +310,7 @@ static void teles_cs_config(dev_link_t *link)
311 sprintf(dev->node.dev_name, "teles"); 310 sprintf(dev->node.dev_name, "teles");
312 dev->node.major = dev->node.minor = 0x0; 311 dev->node.major = dev->node.minor = 0x0;
313 312
314 link->dev = &dev->node; 313 link->dev_node = &dev->node;
315 314
316 /* Finally, report what we've done */ 315 /* Finally, report what we've done */
317 printk(KERN_INFO "%s: index 0x%02x:", 316 printk(KERN_INFO "%s: index 0x%02x:",
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 0026460be153..8259dca97e20 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -54,7 +54,7 @@ static const int debug = 0;
54#define MAX_PCMCIA_ADDR 0x4000000 54#define MAX_PCMCIA_ADDR 0x4000000
55 55
56struct pcmciamtd_dev { 56struct pcmciamtd_dev {
57 dev_link_t link; /* PCMCIA link */ 57 struct pcmcia_device *p_dev;
58 dev_node_t node; /* device node */ 58 dev_node_t node; /* device node */
59 caddr_t win_base; /* ioremapped address of PCMCIA window */ 59 caddr_t win_base; /* ioremapped address of PCMCIA window */
60 unsigned int win_size; /* size of window */ 60 unsigned int win_size; /* size of window */
@@ -111,8 +111,8 @@ static caddr_t remap_window(struct map_info *map, unsigned long to)
111 memreq_t mrq; 111 memreq_t mrq;
112 int ret; 112 int ret;
113 113
114 if(!(dev->link.state & DEV_PRESENT)) { 114 if(!(dev->p_dev->state & DEV_PRESENT)) {
115 DEBUG(1, "device removed state = 0x%4.4X", dev->link.state); 115 DEBUG(1, "device removed state = 0x%4.4X", dev->p_dev->state);
116 return 0; 116 return 0;
117 } 117 }
118 118
@@ -122,7 +122,7 @@ static caddr_t remap_window(struct map_info *map, unsigned long to)
122 dev->offset, mrq.CardOffset); 122 dev->offset, mrq.CardOffset);
123 mrq.Page = 0; 123 mrq.Page = 0;
124 if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) { 124 if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) {
125 cs_error(dev->link.handle, MapMemPage, ret); 125 cs_error(dev->p_dev->handle, MapMemPage, ret);
126 return NULL; 126 return NULL;
127 } 127 }
128 dev->offset = mrq.CardOffset; 128 dev->offset = mrq.CardOffset;
@@ -319,7 +319,7 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
319static void pcmciamtd_set_vpp(struct map_info *map, int on) 319static void pcmciamtd_set_vpp(struct map_info *map, int on)
320{ 320{
321 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 321 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
322 dev_link_t *link = &dev->link; 322 dev_link_t *link = dev->p_dev;
323 modconf_t mod; 323 modconf_t mod;
324 int ret; 324 int ret;
325 325
@@ -650,7 +650,7 @@ static void pcmciamtd_config(dev_link_t *link)
650 use the faster non-remapping read/write functions */ 650 use the faster non-remapping read/write functions */
651 if(mtd->size <= dev->win_size) { 651 if(mtd->size <= dev->win_size) {
652 DEBUG(1, "Using non remapping memory functions"); 652 DEBUG(1, "Using non remapping memory functions");
653 dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->link.state); 653 dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->p_dev->state);
654 dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; 654 dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base;
655 if (dev->pcmcia_map.bankwidth == 1) { 655 if (dev->pcmcia_map.bankwidth == 1) {
656 dev->pcmcia_map.read = pcmcia_read8; 656 dev->pcmcia_map.read = pcmcia_read8;
@@ -673,7 +673,7 @@ static void pcmciamtd_config(dev_link_t *link)
673 snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); 673 snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
674 info("mtd%d: %s", mtd->index, mtd->name); 674 info("mtd%d: %s", mtd->index, mtd->name);
675 link->state &= ~DEV_CONFIG_PENDING; 675 link->state &= ~DEV_CONFIG_PENDING;
676 link->dev = &dev->node; 676 link->dev_node = &dev->node;
677 return; 677 return;
678 678
679 cs_failed: 679 cs_failed:
@@ -735,7 +735,7 @@ static void pcmciamtd_detach(struct pcmcia_device *p_dev)
735static int pcmciamtd_attach(struct pcmcia_device *p_dev) 735static int pcmciamtd_attach(struct pcmcia_device *p_dev)
736{ 736{
737 struct pcmciamtd_dev *dev; 737 struct pcmciamtd_dev *dev;
738 dev_link_t *link; 738 dev_link_t *link = dev_to_instance(p_dev);
739 739
740 /* Create new memory card device */ 740 /* Create new memory card device */
741 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 741 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
@@ -743,16 +743,12 @@ static int pcmciamtd_attach(struct pcmcia_device *p_dev)
743 DEBUG(1, "dev=0x%p", dev); 743 DEBUG(1, "dev=0x%p", dev);
744 744
745 memset(dev, 0, sizeof(*dev)); 745 memset(dev, 0, sizeof(*dev));
746 link = &dev->link; 746 dev->p_dev = p_dev;
747 link->priv = dev; 747 link->priv = dev;
748 748
749 link->conf.Attributes = 0; 749 link->conf.Attributes = 0;
750 link->conf.IntType = INT_MEMORY; 750 link->conf.IntType = INT_MEMORY;
751 751
752 link->next = NULL;
753 link->handle = p_dev;
754 p_dev->instance = link;
755
756 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 752 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
757 pcmciamtd_config(link); 753 pcmciamtd_config(link);
758 754
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 179c9b7ad044..b65758d3c6c5 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -204,7 +204,7 @@ enum Window4 { /* Window 4: Xcvr/media bits. */
204#define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */ 204#define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */
205 205
206struct el3_private { 206struct el3_private {
207 dev_link_t link; 207 struct pcmcia_device *p_dev;
208 dev_node_t node; 208 dev_node_t node;
209 struct net_device_stats stats; 209 struct net_device_stats stats;
210 u16 advertising, partner; /* NWay media advertisement */ 210 u16 advertising, partner; /* NWay media advertisement */
@@ -259,8 +259,8 @@ static void tc574_detach(struct pcmcia_device *p_dev);
259static int tc574_attach(struct pcmcia_device *p_dev) 259static int tc574_attach(struct pcmcia_device *p_dev)
260{ 260{
261 struct el3_private *lp; 261 struct el3_private *lp;
262 dev_link_t *link;
263 struct net_device *dev; 262 struct net_device *dev;
263 dev_link_t *link = dev_to_instance(p_dev);
264 264
265 DEBUG(0, "3c574_attach()\n"); 265 DEBUG(0, "3c574_attach()\n");
266 266
@@ -269,8 +269,8 @@ static int tc574_attach(struct pcmcia_device *p_dev)
269 if (!dev) 269 if (!dev)
270 return -ENOMEM; 270 return -ENOMEM;
271 lp = netdev_priv(dev); 271 lp = netdev_priv(dev);
272 link = &lp->link;
273 link->priv = dev; 272 link->priv = dev;
273 lp->p_dev = p_dev;
274 274
275 spin_lock_init(&lp->window_lock); 275 spin_lock_init(&lp->window_lock);
276 link->io.NumPorts1 = 32; 276 link->io.NumPorts1 = 32;
@@ -297,9 +297,6 @@ static int tc574_attach(struct pcmcia_device *p_dev)
297 dev->watchdog_timeo = TX_TIMEOUT; 297 dev->watchdog_timeo = TX_TIMEOUT;
298#endif 298#endif
299 299
300 link->handle = p_dev;
301 p_dev->instance = link;
302
303 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 300 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
304 tc574_config(link); 301 tc574_config(link);
305 302
@@ -322,7 +319,7 @@ static void tc574_detach(struct pcmcia_device *p_dev)
322 319
323 DEBUG(0, "3c574_detach(0x%p)\n", link); 320 DEBUG(0, "3c574_detach(0x%p)\n", link);
324 321
325 if (link->dev) 322 if (link->dev_node)
326 unregister_netdev(dev); 323 unregister_netdev(dev);
327 324
328 if (link->state & DEV_CONFIG) 325 if (link->state & DEV_CONFIG)
@@ -473,12 +470,12 @@ static void tc574_config(dev_link_t *link)
473 } 470 }
474 471
475 link->state &= ~DEV_CONFIG_PENDING; 472 link->state &= ~DEV_CONFIG_PENDING;
476 link->dev = &lp->node; 473 link->dev_node = &lp->node;
477 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 474 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
478 475
479 if (register_netdev(dev) != 0) { 476 if (register_netdev(dev) != 0) {
480 printk(KERN_NOTICE "3c574_cs: register_netdev() failed\n"); 477 printk(KERN_NOTICE "3c574_cs: register_netdev() failed\n");
481 link->dev = NULL; 478 link->dev_node = NULL;
482 goto failed; 479 goto failed;
483 } 480 }
484 481
@@ -742,7 +739,7 @@ static void tc574_reset(struct net_device *dev)
742static int el3_open(struct net_device *dev) 739static int el3_open(struct net_device *dev)
743{ 740{
744 struct el3_private *lp = netdev_priv(dev); 741 struct el3_private *lp = netdev_priv(dev);
745 dev_link_t *link = &lp->link; 742 dev_link_t *link = lp->p_dev;
746 743
747 if (!DEV_OK(link)) 744 if (!DEV_OK(link))
748 return -ENODEV; 745 return -ENODEV;
@@ -1188,7 +1185,7 @@ static int el3_close(struct net_device *dev)
1188{ 1185{
1189 kio_addr_t ioaddr = dev->base_addr; 1186 kio_addr_t ioaddr = dev->base_addr;
1190 struct el3_private *lp = netdev_priv(dev); 1187 struct el3_private *lp = netdev_priv(dev);
1191 dev_link_t *link = &lp->link; 1188 dev_link_t *link = lp->p_dev;
1192 1189
1193 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 1190 DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
1194 1191
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 7e8036f2e19e..4faf1fa08254 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -105,7 +105,7 @@ enum RxFilter {
105#define TX_TIMEOUT ((400*HZ)/1000) 105#define TX_TIMEOUT ((400*HZ)/1000)
106 106
107struct el3_private { 107struct el3_private {
108 dev_link_t link; 108 struct pcmcia_device *p_dev;
109 dev_node_t node; 109 dev_node_t node;
110 struct net_device_stats stats; 110 struct net_device_stats stats;
111 /* For transceiver monitoring */ 111 /* For transceiver monitoring */
@@ -173,8 +173,8 @@ static void tc589_detach(struct pcmcia_device *p_dev);
173static int tc589_attach(struct pcmcia_device *p_dev) 173static int tc589_attach(struct pcmcia_device *p_dev)
174{ 174{
175 struct el3_private *lp; 175 struct el3_private *lp;
176 dev_link_t *link;
177 struct net_device *dev; 176 struct net_device *dev;
177 dev_link_t *link = dev_to_instance(p_dev);
178 178
179 DEBUG(0, "3c589_attach()\n"); 179 DEBUG(0, "3c589_attach()\n");
180 180
@@ -183,8 +183,8 @@ static int tc589_attach(struct pcmcia_device *p_dev)
183 if (!dev) 183 if (!dev)
184 return -ENOMEM; 184 return -ENOMEM;
185 lp = netdev_priv(dev); 185 lp = netdev_priv(dev);
186 link = &lp->link;
187 link->priv = dev; 186 link->priv = dev;
187 lp->p_dev = p_dev;
188 188
189 spin_lock_init(&lp->lock); 189 spin_lock_init(&lp->lock);
190 link->io.NumPorts1 = 16; 190 link->io.NumPorts1 = 16;
@@ -212,9 +212,6 @@ static int tc589_attach(struct pcmcia_device *p_dev)
212#endif 212#endif
213 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 213 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
214 214
215 link->handle = p_dev;
216 p_dev->instance = link;
217
218 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 215 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
219 tc589_config(link); 216 tc589_config(link);
220 217
@@ -237,7 +234,7 @@ static void tc589_detach(struct pcmcia_device *p_dev)
237 234
238 DEBUG(0, "3c589_detach(0x%p)\n", link); 235 DEBUG(0, "3c589_detach(0x%p)\n", link);
239 236
240 if (link->dev) 237 if (link->dev_node)
241 unregister_netdev(dev); 238 unregister_netdev(dev);
242 239
243 if (link->state & DEV_CONFIG) 240 if (link->state & DEV_CONFIG)
@@ -345,13 +342,13 @@ static void tc589_config(dev_link_t *link)
345 else 342 else
346 printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); 343 printk(KERN_ERR "3c589_cs: invalid if_port requested\n");
347 344
348 link->dev = &lp->node; 345 link->dev_node = &lp->node;
349 link->state &= ~DEV_CONFIG_PENDING; 346 link->state &= ~DEV_CONFIG_PENDING;
350 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 347 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
351 348
352 if (register_netdev(dev) != 0) { 349 if (register_netdev(dev) != 0) {
353 printk(KERN_ERR "3c589_cs: register_netdev() failed\n"); 350 printk(KERN_ERR "3c589_cs: register_netdev() failed\n");
354 link->dev = NULL; 351 link->dev_node = NULL;
355 goto failed; 352 goto failed;
356 } 353 }
357 354
@@ -572,7 +569,7 @@ static int el3_config(struct net_device *dev, struct ifmap *map)
572static int el3_open(struct net_device *dev) 569static int el3_open(struct net_device *dev)
573{ 570{
574 struct el3_private *lp = netdev_priv(dev); 571 struct el3_private *lp = netdev_priv(dev);
575 dev_link_t *link = &lp->link; 572 dev_link_t *link = lp->p_dev;
576 573
577 if (!DEV_OK(link)) 574 if (!DEV_OK(link))
578 return -ENODEV; 575 return -ENODEV;
@@ -833,7 +830,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
833{ 830{
834 struct el3_private *lp = netdev_priv(dev); 831 struct el3_private *lp = netdev_priv(dev);
835 unsigned long flags; 832 unsigned long flags;
836 dev_link_t *link = &lp->link; 833 dev_link_t *link = lp->p_dev;
837 834
838 if (DEV_OK(link)) { 835 if (DEV_OK(link)) {
839 spin_lock_irqsave(&lp->lock, flags); 836 spin_lock_irqsave(&lp->lock, flags);
@@ -935,7 +932,7 @@ static int el3_rx(struct net_device *dev)
935static void set_multicast_list(struct net_device *dev) 932static void set_multicast_list(struct net_device *dev)
936{ 933{
937 struct el3_private *lp = netdev_priv(dev); 934 struct el3_private *lp = netdev_priv(dev);
938 dev_link_t *link = &lp->link; 935 dev_link_t *link = lp->p_dev;
939 kio_addr_t ioaddr = dev->base_addr; 936 kio_addr_t ioaddr = dev->base_addr;
940 u16 opts = SetRxFilter | RxStation | RxBroadcast; 937 u16 opts = SetRxFilter | RxStation | RxBroadcast;
941 938
@@ -950,7 +947,7 @@ static void set_multicast_list(struct net_device *dev)
950static int el3_close(struct net_device *dev) 947static int el3_close(struct net_device *dev)
951{ 948{
952 struct el3_private *lp = netdev_priv(dev); 949 struct el3_private *lp = netdev_priv(dev);
953 dev_link_t *link = &lp->link; 950 dev_link_t *link = lp->p_dev;
954 kio_addr_t ioaddr = dev->base_addr; 951 kio_addr_t ioaddr = dev->base_addr;
955 952
956 DEBUG(1, "%s: shutting down ethercard.\n", dev->name); 953 DEBUG(1, "%s: shutting down ethercard.\n", dev->name);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 5ca0d5718583..58dc7c3835f4 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -117,7 +117,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id, struct pt_regs *regs);
117/*====================================================================*/ 117/*====================================================================*/
118 118
119typedef struct axnet_dev_t { 119typedef struct axnet_dev_t {
120 dev_link_t link; 120 struct pcmcia_device *p_dev;
121 dev_node_t node; 121 dev_node_t node;
122 caddr_t base; 122 caddr_t base;
123 struct timer_list watchdog; 123 struct timer_list watchdog;
@@ -145,8 +145,8 @@ static inline axnet_dev_t *PRIV(struct net_device *dev)
145static int axnet_attach(struct pcmcia_device *p_dev) 145static int axnet_attach(struct pcmcia_device *p_dev)
146{ 146{
147 axnet_dev_t *info; 147 axnet_dev_t *info;
148 dev_link_t *link;
149 struct net_device *dev; 148 struct net_device *dev;
149 dev_link_t *link = dev_to_instance(p_dev);
150 150
151 DEBUG(0, "axnet_attach()\n"); 151 DEBUG(0, "axnet_attach()\n");
152 152
@@ -157,7 +157,7 @@ static int axnet_attach(struct pcmcia_device *p_dev)
157 return -ENOMEM; 157 return -ENOMEM;
158 158
159 info = PRIV(dev); 159 info = PRIV(dev);
160 link = &info->link; 160 info->p_dev = p_dev;
161 link->priv = dev; 161 link->priv = dev;
162 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 162 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
163 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 163 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
@@ -169,9 +169,6 @@ static int axnet_attach(struct pcmcia_device *p_dev)
169 dev->do_ioctl = &axnet_ioctl; 169 dev->do_ioctl = &axnet_ioctl;
170 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 170 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
171 171
172 link->handle = p_dev;
173 p_dev->instance = link;
174
175 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 172 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
176 axnet_config(link); 173 axnet_config(link);
177 174
@@ -194,7 +191,7 @@ static void axnet_detach(struct pcmcia_device *p_dev)
194 191
195 DEBUG(0, "axnet_detach(0x%p)\n", link); 192 DEBUG(0, "axnet_detach(0x%p)\n", link);
196 193
197 if (link->dev) 194 if (link->dev_node)
198 unregister_netdev(dev); 195 unregister_netdev(dev);
199 196
200 if (link->state & DEV_CONFIG) 197 if (link->state & DEV_CONFIG)
@@ -409,13 +406,13 @@ static void axnet_config(dev_link_t *link)
409 } 406 }
410 407
411 info->phy_id = (i < 32) ? i : -1; 408 info->phy_id = (i < 32) ? i : -1;
412 link->dev = &info->node; 409 link->dev_node = &info->node;
413 link->state &= ~DEV_CONFIG_PENDING; 410 link->state &= ~DEV_CONFIG_PENDING;
414 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 411 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
415 412
416 if (register_netdev(dev) != 0) { 413 if (register_netdev(dev) != 0) {
417 printk(KERN_NOTICE "axnet_cs: register_netdev() failed\n"); 414 printk(KERN_NOTICE "axnet_cs: register_netdev() failed\n");
418 link->dev = NULL; 415 link->dev_node = NULL;
419 goto failed; 416 goto failed;
420 } 417 }
421 418
@@ -543,7 +540,7 @@ static void mdio_write(kio_addr_t addr, int phy_id, int loc, int value)
543static int axnet_open(struct net_device *dev) 540static int axnet_open(struct net_device *dev)
544{ 541{
545 axnet_dev_t *info = PRIV(dev); 542 axnet_dev_t *info = PRIV(dev);
546 dev_link_t *link = &info->link; 543 dev_link_t *link = info->p_dev;
547 544
548 DEBUG(2, "axnet_open('%s')\n", dev->name); 545 DEBUG(2, "axnet_open('%s')\n", dev->name);
549 546
@@ -569,7 +566,7 @@ static int axnet_open(struct net_device *dev)
569static int axnet_close(struct net_device *dev) 566static int axnet_close(struct net_device *dev)
570{ 567{
571 axnet_dev_t *info = PRIV(dev); 568 axnet_dev_t *info = PRIV(dev);
572 dev_link_t *link = &info->link; 569 dev_link_t *link = info->p_dev;
573 570
574 DEBUG(2, "axnet_close('%s')\n", dev->name); 571 DEBUG(2, "axnet_close('%s')\n", dev->name);
575 572
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index e14d3d18b97d..44da01cdd26f 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -140,7 +140,6 @@ typedef struct com20020_dev_t {
140 140
141static int com20020_attach(struct pcmcia_device *p_dev) 141static int com20020_attach(struct pcmcia_device *p_dev)
142{ 142{
143 dev_link_t *link;
144 com20020_dev_t *info; 143 com20020_dev_t *info;
145 struct net_device *dev; 144 struct net_device *dev;
146 struct arcnet_local *lp; 145 struct arcnet_local *lp;
@@ -148,10 +147,6 @@ static int com20020_attach(struct pcmcia_device *p_dev)
148 DEBUG(0, "com20020_attach()\n"); 147 DEBUG(0, "com20020_attach()\n");
149 148
150 /* Create new network device */ 149 /* Create new network device */
151 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
152 if (!link)
153 return -ENOMEM;
154
155 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); 150 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
156 if (!info) 151 if (!info)
157 goto fail_alloc_info; 152 goto fail_alloc_info;
@@ -161,7 +156,6 @@ static int com20020_attach(struct pcmcia_device *p_dev)
161 goto fail_alloc_dev; 156 goto fail_alloc_dev;
162 157
163 memset(info, 0, sizeof(struct com20020_dev_t)); 158 memset(info, 0, sizeof(struct com20020_dev_t));
164 memset(link, 0, sizeof(struct dev_link_t));
165 lp = dev->priv; 159 lp = dev->priv;
166 lp->timeout = timeout; 160 lp->timeout = timeout;
167 lp->backplane = backplane; 161 lp->backplane = backplane;
@@ -172,27 +166,26 @@ static int com20020_attach(struct pcmcia_device *p_dev)
172 /* fill in our module parameters as defaults */ 166 /* fill in our module parameters as defaults */
173 dev->dev_addr[0] = node; 167 dev->dev_addr[0] = node;
174 168
175 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 169 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
176 link->io.NumPorts1 = 16; 170 p_dev->io.NumPorts1 = 16;
177 link->io.IOAddrLines = 16; 171 p_dev->io.IOAddrLines = 16;
178 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 172 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
179 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 173 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
180 link->conf.Attributes = CONF_ENABLE_IRQ; 174 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
181 link->conf.IntType = INT_MEMORY_AND_IO; 175 p_dev->conf.IntType = INT_MEMORY_AND_IO;
182 link->conf.Present = PRESENT_OPTION; 176 p_dev->conf.Present = PRESENT_OPTION;
183 177
184 link->irq.Instance = info->dev = dev; 178 p_dev->irq.Instance = info->dev = dev;
185 link->priv = info; 179 p_dev->priv = info;
186 180
187 link->state |= DEV_PRESENT; 181 p_dev->state |= DEV_PRESENT;
188 com20020_config(link); 182 com20020_config(p_dev);
189 183
190 return 0; 184 return 0;
191 185
192fail_alloc_dev: 186fail_alloc_dev:
193 kfree(info); 187 kfree(info);
194fail_alloc_info: 188fail_alloc_info:
195 kfree(link);
196 return -ENOMEM; 189 return -ENOMEM;
197} /* com20020_attach */ 190} /* com20020_attach */
198 191
@@ -215,7 +208,7 @@ static void com20020_detach(struct pcmcia_device *p_dev)
215 208
216 DEBUG(0, "com20020_detach(0x%p)\n", link); 209 DEBUG(0, "com20020_detach(0x%p)\n", link);
217 210
218 if (link->dev) { 211 if (link->dev_node) {
219 DEBUG(1,"unregister...\n"); 212 DEBUG(1,"unregister...\n");
220 213
221 unregister_netdev(dev); 214 unregister_netdev(dev);
@@ -244,8 +237,6 @@ static void com20020_detach(struct pcmcia_device *p_dev)
244 DEBUG(1,"kfree2...\n"); 237 DEBUG(1,"kfree2...\n");
245 kfree(info); 238 kfree(info);
246 } 239 }
247 DEBUG(1,"kfree3...\n");
248 kfree(link);
249 240
250} /* com20020_detach */ 241} /* com20020_detach */
251 242
@@ -341,7 +332,7 @@ static void com20020_config(dev_link_t *link)
341 lp->card_name = "PCMCIA COM20020"; 332 lp->card_name = "PCMCIA COM20020";
342 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */ 333 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
343 334
344 link->dev = &info->node; 335 link->dev_node = &info->node;
345 link->state &= ~DEV_CONFIG_PENDING; 336 link->state &= ~DEV_CONFIG_PENDING;
346 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 337 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
347 338
@@ -349,7 +340,7 @@ static void com20020_config(dev_link_t *link)
349 340
350 if (i != 0) { 341 if (i != 0) {
351 DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n"); 342 DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n");
352 link->dev = NULL; 343 link->dev_node = NULL;
353 goto failed; 344 goto failed;
354 } 345 }
355 346
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 34bf963b1296..3f0ace4ed732 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -116,7 +116,7 @@ typedef enum { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN,
116 driver specific data structure 116 driver specific data structure
117*/ 117*/
118typedef struct local_info_t { 118typedef struct local_info_t {
119 dev_link_t link; 119 struct pcmcia_device *p_dev;
120 dev_node_t node; 120 dev_node_t node;
121 struct net_device_stats stats; 121 struct net_device_stats stats;
122 long open_time; 122 long open_time;
@@ -231,8 +231,8 @@ typedef struct local_info_t {
231static int fmvj18x_attach(struct pcmcia_device *p_dev) 231static int fmvj18x_attach(struct pcmcia_device *p_dev)
232{ 232{
233 local_info_t *lp; 233 local_info_t *lp;
234 dev_link_t *link;
235 struct net_device *dev; 234 struct net_device *dev;
235 dev_link_t *link = dev_to_instance(p_dev);
236 236
237 DEBUG(0, "fmvj18x_attach()\n"); 237 DEBUG(0, "fmvj18x_attach()\n");
238 238
@@ -241,8 +241,8 @@ static int fmvj18x_attach(struct pcmcia_device *p_dev)
241 if (!dev) 241 if (!dev)
242 return -ENOMEM; 242 return -ENOMEM;
243 lp = netdev_priv(dev); 243 lp = netdev_priv(dev);
244 link = &lp->link;
245 link->priv = dev; 244 link->priv = dev;
245 lp->p_dev = p_dev;
246 246
247 /* The io structure describes IO port mapping */ 247 /* The io structure describes IO port mapping */
248 link->io.NumPorts1 = 32; 248 link->io.NumPorts1 = 32;
@@ -273,9 +273,6 @@ static int fmvj18x_attach(struct pcmcia_device *p_dev)
273#endif 273#endif
274 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 274 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
275 275
276 link->handle = p_dev;
277 p_dev->instance = link;
278
279 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 276 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
280 fmvj18x_config(link); 277 fmvj18x_config(link);
281 278
@@ -291,7 +288,7 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev)
291 288
292 DEBUG(0, "fmvj18x_detach(0x%p)\n", link); 289 DEBUG(0, "fmvj18x_detach(0x%p)\n", link);
293 290
294 if (link->dev) 291 if (link->dev_node)
295 unregister_netdev(dev); 292 unregister_netdev(dev);
296 293
297 if (link->state & DEV_CONFIG) 294 if (link->state & DEV_CONFIG)
@@ -539,13 +536,13 @@ static void fmvj18x_config(dev_link_t *link)
539 } 536 }
540 537
541 lp->cardtype = cardtype; 538 lp->cardtype = cardtype;
542 link->dev = &lp->node; 539 link->dev_node = &lp->node;
543 link->state &= ~DEV_CONFIG_PENDING; 540 link->state &= ~DEV_CONFIG_PENDING;
544 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 541 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
545 542
546 if (register_netdev(dev) != 0) { 543 if (register_netdev(dev) != 0) {
547 printk(KERN_NOTICE "fmvj18x_cs: register_netdev() failed\n"); 544 printk(KERN_NOTICE "fmvj18x_cs: register_netdev() failed\n");
548 link->dev = NULL; 545 link->dev_node = NULL;
549 goto failed; 546 goto failed;
550 } 547 }
551 548
@@ -1125,7 +1122,7 @@ static int fjn_config(struct net_device *dev, struct ifmap *map){
1125static int fjn_open(struct net_device *dev) 1122static int fjn_open(struct net_device *dev)
1126{ 1123{
1127 struct local_info_t *lp = netdev_priv(dev); 1124 struct local_info_t *lp = netdev_priv(dev);
1128 dev_link_t *link = &lp->link; 1125 dev_link_t *link = lp->p_dev;
1129 1126
1130 DEBUG(4, "fjn_open('%s').\n", dev->name); 1127 DEBUG(4, "fjn_open('%s').\n", dev->name);
1131 1128
@@ -1150,7 +1147,7 @@ static int fjn_open(struct net_device *dev)
1150static int fjn_close(struct net_device *dev) 1147static int fjn_close(struct net_device *dev)
1151{ 1148{
1152 struct local_info_t *lp = netdev_priv(dev); 1149 struct local_info_t *lp = netdev_priv(dev);
1153 dev_link_t *link = &lp->link; 1150 dev_link_t *link = lp->p_dev;
1154 kio_addr_t ioaddr = dev->base_addr; 1151 kio_addr_t ioaddr = dev->base_addr;
1155 1152
1156 DEBUG(4, "fjn_close('%s').\n", dev->name); 1153 DEBUG(4, "fjn_close('%s').\n", dev->name);
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 904c5cb04e71..f4c3dd870aca 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -113,7 +113,7 @@ static void ibmtr_detach(struct pcmcia_device *p_dev);
113/*====================================================================*/ 113/*====================================================================*/
114 114
115typedef struct ibmtr_dev_t { 115typedef struct ibmtr_dev_t {
116 dev_link_t link; 116 struct pcmcia_device *p_dev;
117 struct net_device *dev; 117 struct net_device *dev;
118 dev_node_t node; 118 dev_node_t node;
119 window_handle_t sram_win_handle; 119 window_handle_t sram_win_handle;
@@ -141,8 +141,8 @@ static struct ethtool_ops netdev_ethtool_ops = {
141static int ibmtr_attach(struct pcmcia_device *p_dev) 141static int ibmtr_attach(struct pcmcia_device *p_dev)
142{ 142{
143 ibmtr_dev_t *info; 143 ibmtr_dev_t *info;
144 dev_link_t *link;
145 struct net_device *dev; 144 struct net_device *dev;
145 dev_link_t *link = dev_to_instance(p_dev);
146 146
147 DEBUG(0, "ibmtr_attach()\n"); 147 DEBUG(0, "ibmtr_attach()\n");
148 148
@@ -156,7 +156,7 @@ static int ibmtr_attach(struct pcmcia_device *p_dev)
156 return -ENOMEM; 156 return -ENOMEM;
157 } 157 }
158 158
159 link = &info->link; 159 info->p_dev = p_dev;
160 link->priv = info; 160 link->priv = info;
161 info->ti = netdev_priv(dev); 161 info->ti = netdev_priv(dev);
162 162
@@ -171,11 +171,8 @@ static int ibmtr_attach(struct pcmcia_device *p_dev)
171 link->conf.Present = PRESENT_OPTION; 171 link->conf.Present = PRESENT_OPTION;
172 172
173 link->irq.Instance = info->dev = dev; 173 link->irq.Instance = info->dev = dev;
174
175 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
176 174
177 link->handle = p_dev; 175 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
178 p_dev->instance = link;
179 176
180 link->state |= DEV_PRESENT; 177 link->state |= DEV_PRESENT;
181 ibmtr_config(link); 178 ibmtr_config(link);
@@ -200,7 +197,7 @@ static void ibmtr_detach(struct pcmcia_device *p_dev)
200 197
201 DEBUG(0, "ibmtr_detach(0x%p)\n", link); 198 DEBUG(0, "ibmtr_detach(0x%p)\n", link);
202 199
203 if (link->dev) 200 if (link->dev_node)
204 unregister_netdev(dev); 201 unregister_netdev(dev);
205 202
206 { 203 {
@@ -308,14 +305,14 @@ static void ibmtr_config(dev_link_t *link)
308 Adapters Technical Reference" SC30-3585 for this info. */ 305 Adapters Technical Reference" SC30-3585 for this info. */
309 ibmtr_hw_setup(dev, mmiobase); 306 ibmtr_hw_setup(dev, mmiobase);
310 307
311 link->dev = &info->node; 308 link->dev_node = &info->node;
312 link->state &= ~DEV_CONFIG_PENDING; 309 link->state &= ~DEV_CONFIG_PENDING;
313 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 310 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
314 311
315 i = ibmtr_probe_card(dev); 312 i = ibmtr_probe_card(dev);
316 if (i != 0) { 313 if (i != 0) {
317 printk(KERN_NOTICE "ibmtr_cs: register_netdev() failed\n"); 314 printk(KERN_NOTICE "ibmtr_cs: register_netdev() failed\n");
318 link->dev = NULL; 315 link->dev_node = NULL;
319 goto failed; 316 goto failed;
320 } 317 }
321 318
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index c25d9451d574..0ccca12d9d6e 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -362,7 +362,7 @@ typedef struct _mace_statistics {
362} mace_statistics; 362} mace_statistics;
363 363
364typedef struct _mace_private { 364typedef struct _mace_private {
365 dev_link_t link; 365 struct pcmcia_device *p_dev;
366 dev_node_t node; 366 dev_node_t node;
367 struct net_device_stats linux_stats; /* Linux statistics counters */ 367 struct net_device_stats linux_stats; /* Linux statistics counters */
368 mace_statistics mace_stats; /* MACE chip statistics counters */ 368 mace_statistics mace_stats; /* MACE chip statistics counters */
@@ -446,8 +446,8 @@ nmclan_attach
446static int nmclan_attach(struct pcmcia_device *p_dev) 446static int nmclan_attach(struct pcmcia_device *p_dev)
447{ 447{
448 mace_private *lp; 448 mace_private *lp;
449 dev_link_t *link;
450 struct net_device *dev; 449 struct net_device *dev;
450 dev_link_t *link = dev_to_instance(p_dev);
451 451
452 DEBUG(0, "nmclan_attach()\n"); 452 DEBUG(0, "nmclan_attach()\n");
453 DEBUG(1, "%s\n", rcsid); 453 DEBUG(1, "%s\n", rcsid);
@@ -457,7 +457,7 @@ static int nmclan_attach(struct pcmcia_device *p_dev)
457 if (!dev) 457 if (!dev)
458 return -ENOMEM; 458 return -ENOMEM;
459 lp = netdev_priv(dev); 459 lp = netdev_priv(dev);
460 link = &lp->link; 460 lp->p_dev = p_dev;
461 link->priv = dev; 461 link->priv = dev;
462 462
463 spin_lock_init(&lp->bank_lock); 463 spin_lock_init(&lp->bank_lock);
@@ -488,9 +488,6 @@ static int nmclan_attach(struct pcmcia_device *p_dev)
488 dev->watchdog_timeo = TX_TIMEOUT; 488 dev->watchdog_timeo = TX_TIMEOUT;
489#endif 489#endif
490 490
491 link->handle = p_dev;
492 p_dev->instance = link;
493
494 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 491 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
495 nmclan_config(link); 492 nmclan_config(link);
496 493
@@ -512,7 +509,7 @@ static void nmclan_detach(struct pcmcia_device *p_dev)
512 509
513 DEBUG(0, "nmclan_detach(0x%p)\n", link); 510 DEBUG(0, "nmclan_detach(0x%p)\n", link);
514 511
515 if (link->dev) 512 if (link->dev_node)
516 unregister_netdev(dev); 513 unregister_netdev(dev);
517 514
518 if (link->state & DEV_CONFIG) 515 if (link->state & DEV_CONFIG)
@@ -729,14 +726,14 @@ static void nmclan_config(dev_link_t *link)
729 else 726 else
730 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n"); 727 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n");
731 728
732 link->dev = &lp->node; 729 link->dev_node = &lp->node;
733 link->state &= ~DEV_CONFIG_PENDING; 730 link->state &= ~DEV_CONFIG_PENDING;
734 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 731 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
735 732
736 i = register_netdev(dev); 733 i = register_netdev(dev);
737 if (i != 0) { 734 if (i != 0) {
738 printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n"); 735 printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n");
739 link->dev = NULL; 736 link->dev_node = NULL;
740 goto failed; 737 goto failed;
741 } 738 }
742 739
@@ -869,7 +866,7 @@ static int mace_open(struct net_device *dev)
869{ 866{
870 kio_addr_t ioaddr = dev->base_addr; 867 kio_addr_t ioaddr = dev->base_addr;
871 mace_private *lp = netdev_priv(dev); 868 mace_private *lp = netdev_priv(dev);
872 dev_link_t *link = &lp->link; 869 dev_link_t *link = lp->p_dev;
873 870
874 if (!DEV_OK(link)) 871 if (!DEV_OK(link))
875 return -ENODEV; 872 return -ENODEV;
@@ -892,7 +889,7 @@ static int mace_close(struct net_device *dev)
892{ 889{
893 kio_addr_t ioaddr = dev->base_addr; 890 kio_addr_t ioaddr = dev->base_addr;
894 mace_private *lp = netdev_priv(dev); 891 mace_private *lp = netdev_priv(dev);
895 dev_link_t *link = &lp->link; 892 dev_link_t *link = lp->p_dev;
896 893
897 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 894 DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
898 895
@@ -947,7 +944,7 @@ mace_start_xmit
947static void mace_tx_timeout(struct net_device *dev) 944static void mace_tx_timeout(struct net_device *dev)
948{ 945{
949 mace_private *lp = netdev_priv(dev); 946 mace_private *lp = netdev_priv(dev);
950 dev_link_t *link = &lp->link; 947 dev_link_t *link = lp->p_dev;
951 948
952 printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); 949 printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name);
953#if RESET_ON_TIMEOUT 950#if RESET_ON_TIMEOUT
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 5a7e58af0b3b..8ed6a410ea10 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -214,7 +214,7 @@ static hw_info_t dl10019_info = { 0, 0, 0, 0, IS_DL10019|HAS_MII };
214static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII }; 214static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII };
215 215
216typedef struct pcnet_dev_t { 216typedef struct pcnet_dev_t {
217 dev_link_t link; 217 struct pcmcia_device *p_dev;
218 dev_node_t node; 218 dev_node_t node;
219 u_int flags; 219 u_int flags;
220 void __iomem *base; 220 void __iomem *base;
@@ -243,8 +243,8 @@ static inline pcnet_dev_t *PRIV(struct net_device *dev)
243static int pcnet_probe(struct pcmcia_device *p_dev) 243static int pcnet_probe(struct pcmcia_device *p_dev)
244{ 244{
245 pcnet_dev_t *info; 245 pcnet_dev_t *info;
246 dev_link_t *link;
247 struct net_device *dev; 246 struct net_device *dev;
247 dev_link_t *link = dev_to_instance(p_dev);
248 248
249 DEBUG(0, "pcnet_attach()\n"); 249 DEBUG(0, "pcnet_attach()\n");
250 250
@@ -252,7 +252,7 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
253 if (!dev) return -ENOMEM; 253 if (!dev) return -ENOMEM;
254 info = PRIV(dev); 254 info = PRIV(dev);
255 link = &info->link; 255 info->p_dev = p_dev;
256 link->priv = dev; 256 link->priv = dev;
257 257
258 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 258 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
@@ -265,9 +265,6 @@ static int pcnet_probe(struct pcmcia_device *p_dev)
265 dev->stop = &pcnet_close; 265 dev->stop = &pcnet_close;
266 dev->set_config = &set_config; 266 dev->set_config = &set_config;
267 267
268 link->handle = p_dev;
269 p_dev->instance = link;
270
271 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 268 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
272 pcnet_config(link); 269 pcnet_config(link);
273 270
@@ -290,7 +287,7 @@ static void pcnet_detach(struct pcmcia_device *p_dev)
290 287
291 DEBUG(0, "pcnet_detach(0x%p)\n", link); 288 DEBUG(0, "pcnet_detach(0x%p)\n", link);
292 289
293 if (link->dev) 290 if (link->dev_node)
294 unregister_netdev(dev); 291 unregister_netdev(dev);
295 292
296 if (link->state & DEV_CONFIG) 293 if (link->state & DEV_CONFIG)
@@ -674,7 +671,7 @@ static void pcnet_config(dev_link_t *link)
674 info->eth_phy = 0; 671 info->eth_phy = 0;
675 } 672 }
676 673
677 link->dev = &info->node; 674 link->dev_node = &info->node;
678 link->state &= ~DEV_CONFIG_PENDING; 675 link->state &= ~DEV_CONFIG_PENDING;
679 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 676 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
680 677
@@ -684,7 +681,7 @@ static void pcnet_config(dev_link_t *link)
684 681
685 if (register_netdev(dev) != 0) { 682 if (register_netdev(dev) != 0) {
686 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n"); 683 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n");
687 link->dev = NULL; 684 link->dev_node = NULL;
688 goto failed; 685 goto failed;
689 } 686 }
690 687
@@ -1005,8 +1002,8 @@ static void mii_phy_probe(struct net_device *dev)
1005static int pcnet_open(struct net_device *dev) 1002static int pcnet_open(struct net_device *dev)
1006{ 1003{
1007 pcnet_dev_t *info = PRIV(dev); 1004 pcnet_dev_t *info = PRIV(dev);
1008 dev_link_t *link = &info->link; 1005 dev_link_t *link = info->p_dev;
1009 1006
1010 DEBUG(2, "pcnet_open('%s')\n", dev->name); 1007 DEBUG(2, "pcnet_open('%s')\n", dev->name);
1011 1008
1012 if (!DEV_OK(link)) 1009 if (!DEV_OK(link))
@@ -1033,7 +1030,7 @@ static int pcnet_open(struct net_device *dev)
1033static int pcnet_close(struct net_device *dev) 1030static int pcnet_close(struct net_device *dev)
1034{ 1031{
1035 pcnet_dev_t *info = PRIV(dev); 1032 pcnet_dev_t *info = PRIV(dev);
1036 dev_link_t *link = &info->link; 1033 dev_link_t *link = info->p_dev;
1037 1034
1038 DEBUG(2, "pcnet_close('%s')\n", dev->name); 1035 DEBUG(2, "pcnet_close('%s')\n", dev->name);
1039 1036
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index b46b7e148390..a18b02a9a687 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -104,7 +104,7 @@ static const char *version =
104#define MEMORY_WAIT_TIME 8 104#define MEMORY_WAIT_TIME 8
105 105
106struct smc_private { 106struct smc_private {
107 dev_link_t link; 107 struct pcmcia_device *p_dev;
108 spinlock_t lock; 108 spinlock_t lock;
109 u_short manfid; 109 u_short manfid;
110 u_short cardid; 110 u_short cardid;
@@ -312,8 +312,8 @@ static struct ethtool_ops ethtool_ops;
312static int smc91c92_attach(struct pcmcia_device *p_dev) 312static int smc91c92_attach(struct pcmcia_device *p_dev)
313{ 313{
314 struct smc_private *smc; 314 struct smc_private *smc;
315 dev_link_t *link;
316 struct net_device *dev; 315 struct net_device *dev;
316 dev_link_t *link = dev_to_instance(p_dev);
317 317
318 DEBUG(0, "smc91c92_attach()\n"); 318 DEBUG(0, "smc91c92_attach()\n");
319 319
@@ -322,7 +322,7 @@ static int smc91c92_attach(struct pcmcia_device *p_dev)
322 if (!dev) 322 if (!dev)
323 return -ENOMEM; 323 return -ENOMEM;
324 smc = netdev_priv(dev); 324 smc = netdev_priv(dev);
325 link = &smc->link; 325 smc->p_dev = p_dev;
326 link->priv = dev; 326 link->priv = dev;
327 327
328 spin_lock_init(&smc->lock); 328 spin_lock_init(&smc->lock);
@@ -357,9 +357,6 @@ static int smc91c92_attach(struct pcmcia_device *p_dev)
357 smc->mii_if.phy_id_mask = 0x1f; 357 smc->mii_if.phy_id_mask = 0x1f;
358 smc->mii_if.reg_num_mask = 0x1f; 358 smc->mii_if.reg_num_mask = 0x1f;
359 359
360 link->handle = p_dev;
361 p_dev->instance = link;
362
363 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 360 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
364 smc91c92_config(link); 361 smc91c92_config(link);
365 362
@@ -382,7 +379,7 @@ static void smc91c92_detach(struct pcmcia_device *p_dev)
382 379
383 DEBUG(0, "smc91c92_detach(0x%p)\n", link); 380 DEBUG(0, "smc91c92_detach(0x%p)\n", link);
384 381
385 if (link->dev) 382 if (link->dev_node)
386 unregister_netdev(dev); 383 unregister_netdev(dev);
387 384
388 if (link->state & DEV_CONFIG) 385 if (link->state & DEV_CONFIG)
@@ -1120,13 +1117,13 @@ static void smc91c92_config(dev_link_t *link)
1120 SMC_SELECT_BANK(0); 1117 SMC_SELECT_BANK(0);
1121 } 1118 }
1122 1119
1123 link->dev = &smc->node; 1120 link->dev_node = &smc->node;
1124 link->state &= ~DEV_CONFIG_PENDING; 1121 link->state &= ~DEV_CONFIG_PENDING;
1125 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 1122 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
1126 1123
1127 if (register_netdev(dev) != 0) { 1124 if (register_netdev(dev) != 0) {
1128 printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); 1125 printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n");
1129 link->dev = NULL; 1126 link->dev_node = NULL;
1130 goto config_undo; 1127 goto config_undo;
1131 } 1128 }
1132 1129
@@ -1272,7 +1269,7 @@ static void smc_dump(struct net_device *dev)
1272static int smc_open(struct net_device *dev) 1269static int smc_open(struct net_device *dev)
1273{ 1270{
1274 struct smc_private *smc = netdev_priv(dev); 1271 struct smc_private *smc = netdev_priv(dev);
1275 dev_link_t *link = &smc->link; 1272 dev_link_t *link = smc->p_dev;
1276 1273
1277#ifdef PCMCIA_DEBUG 1274#ifdef PCMCIA_DEBUG
1278 DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n", 1275 DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n",
@@ -1309,7 +1306,7 @@ static int smc_open(struct net_device *dev)
1309static int smc_close(struct net_device *dev) 1306static int smc_close(struct net_device *dev)
1310{ 1307{
1311 struct smc_private *smc = netdev_priv(dev); 1308 struct smc_private *smc = netdev_priv(dev);
1312 dev_link_t *link = &smc->link; 1309 dev_link_t *link = smc->p_dev;
1313 kio_addr_t ioaddr = dev->base_addr; 1310 kio_addr_t ioaddr = dev->base_addr;
1314 1311
1315 DEBUG(0, "%s: smc_close(), status %4.4x.\n", 1312 DEBUG(0, "%s: smc_close(), status %4.4x.\n",
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index f5fa86d046d4..94a1e644abdc 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -332,7 +332,7 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs
332 */ 332 */
333 333
334typedef struct local_info_t { 334typedef struct local_info_t {
335 dev_link_t link; 335 struct pcmcia_device *p_dev;
336 dev_node_t node; 336 dev_node_t node;
337 struct net_device_stats stats; 337 struct net_device_stats stats;
338 int card_type; 338 int card_type;
@@ -555,9 +555,9 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len)
555static int 555static int
556xirc2ps_attach(struct pcmcia_device *p_dev) 556xirc2ps_attach(struct pcmcia_device *p_dev)
557{ 557{
558 dev_link_t *link;
559 struct net_device *dev; 558 struct net_device *dev;
560 local_info_t *local; 559 local_info_t *local;
560 dev_link_t *link = dev_to_instance(p_dev);
561 561
562 DEBUG(0, "attach()\n"); 562 DEBUG(0, "attach()\n");
563 563
@@ -566,7 +566,7 @@ xirc2ps_attach(struct pcmcia_device *p_dev)
566 if (!dev) 566 if (!dev)
567 return -ENOMEM; 567 return -ENOMEM;
568 local = netdev_priv(dev); 568 local = netdev_priv(dev);
569 link = &local->link; 569 local->p_dev = p_dev;
570 link->priv = dev; 570 link->priv = dev;
571 571
572 /* General socket configuration */ 572 /* General socket configuration */
@@ -592,9 +592,6 @@ xirc2ps_attach(struct pcmcia_device *p_dev)
592 dev->watchdog_timeo = TX_TIMEOUT; 592 dev->watchdog_timeo = TX_TIMEOUT;
593#endif 593#endif
594 594
595 link->handle = p_dev;
596 p_dev->instance = link;
597
598 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 595 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
599 xirc2ps_config(link); 596 xirc2ps_config(link);
600 597
@@ -616,7 +613,7 @@ xirc2ps_detach(struct pcmcia_device *p_dev)
616 613
617 DEBUG(0, "detach(0x%p)\n", link); 614 DEBUG(0, "detach(0x%p)\n", link);
618 615
619 if (link->dev) 616 if (link->dev_node)
620 unregister_netdev(dev); 617 unregister_netdev(dev);
621 618
622 if (link->state & DEV_CONFIG) 619 if (link->state & DEV_CONFIG)
@@ -1049,13 +1046,13 @@ xirc2ps_config(dev_link_t * link)
1049 if (local->dingo) 1046 if (local->dingo)
1050 do_reset(dev, 1); /* a kludge to make the cem56 work */ 1047 do_reset(dev, 1); /* a kludge to make the cem56 work */
1051 1048
1052 link->dev = &local->node; 1049 link->dev_node = &local->node;
1053 link->state &= ~DEV_CONFIG_PENDING; 1050 link->state &= ~DEV_CONFIG_PENDING;
1054 SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 1051 SET_NETDEV_DEV(dev, &handle_to_dev(handle));
1055 1052
1056 if ((err=register_netdev(dev))) { 1053 if ((err=register_netdev(dev))) {
1057 printk(KNOT_XIRC "register_netdev() failed\n"); 1054 printk(KNOT_XIRC "register_netdev() failed\n");
1058 link->dev = NULL; 1055 link->dev_node = NULL;
1059 goto config_error; 1056 goto config_error;
1060 } 1057 }
1061 1058
@@ -1537,7 +1534,7 @@ static int
1537do_open(struct net_device *dev) 1534do_open(struct net_device *dev)
1538{ 1535{
1539 local_info_t *lp = netdev_priv(dev); 1536 local_info_t *lp = netdev_priv(dev);
1540 dev_link_t *link = &lp->link; 1537 dev_link_t *link = lp->p_dev;
1541 1538
1542 DEBUG(0, "do_open(%p)\n", dev); 1539 DEBUG(0, "do_open(%p)\n", dev);
1543 1540
@@ -1867,7 +1864,7 @@ do_stop(struct net_device *dev)
1867{ 1864{
1868 kio_addr_t ioaddr = dev->base_addr; 1865 kio_addr_t ioaddr = dev->base_addr;
1869 local_info_t *lp = netdev_priv(dev); 1866 local_info_t *lp = netdev_priv(dev);
1870 dev_link_t *link = &lp->link; 1867 dev_link_t *link = lp->p_dev;
1871 1868
1872 DEBUG(0, "do_stop(%p)\n", dev); 1869 DEBUG(0, "do_stop(%p)\n", dev);
1873 1870
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 2216c04a02af..836c71ff7762 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -143,22 +143,14 @@ typedef struct local_info_t {
143 143
144static int airo_attach(struct pcmcia_device *p_dev) 144static int airo_attach(struct pcmcia_device *p_dev)
145{ 145{
146 dev_link_t *link;
147 local_info_t *local; 146 local_info_t *local;
148 147
149 DEBUG(0, "airo_attach()\n"); 148 DEBUG(0, "airo_attach()\n");
150 149
151 /* Initialize the dev_link_t structure */
152 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
153 if (!link) {
154 printk(KERN_ERR "airo_cs: no memory for new device\n");
155 return -ENOMEM;
156 }
157
158 /* Interrupt setup */ 150 /* Interrupt setup */
159 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 151 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
160 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 152 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
161 link->irq.Handler = NULL; 153 p_dev->irq.Handler = NULL;
162 154
163 /* 155 /*
164 General socket configuration defaults can go here. In this 156 General socket configuration defaults can go here. In this
@@ -167,23 +159,19 @@ static int airo_attach(struct pcmcia_device *p_dev)
167 and attributes of IO windows) are fixed by the nature of the 159 and attributes of IO windows) are fixed by the nature of the
168 device, and can be hard-wired here. 160 device, and can be hard-wired here.
169 */ 161 */
170 link->conf.Attributes = 0; 162 p_dev->conf.Attributes = 0;
171 link->conf.IntType = INT_MEMORY_AND_IO; 163 p_dev->conf.IntType = INT_MEMORY_AND_IO;
172 164
173 /* Allocate space for private device-specific data */ 165 /* Allocate space for private device-specific data */
174 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 166 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
175 if (!local) { 167 if (!local) {
176 printk(KERN_ERR "airo_cs: no memory for new device\n"); 168 printk(KERN_ERR "airo_cs: no memory for new device\n");
177 kfree (link);
178 return -ENOMEM; 169 return -ENOMEM;
179 } 170 }
180 link->priv = local; 171 p_dev->priv = local;
181
182 link->handle = p_dev;
183 p_dev->instance = link;
184 172
185 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 173 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
186 airo_config(link); 174 airo_config(p_dev);
187 175
188 return 0; 176 return 0;
189} /* airo_attach */ 177} /* airo_attach */
@@ -212,7 +200,6 @@ static void airo_detach(struct pcmcia_device *p_dev)
212 ((local_info_t*)link->priv)->eth_dev = NULL; 200 ((local_info_t*)link->priv)->eth_dev = NULL;
213 201
214 kfree(link->priv); 202 kfree(link->priv);
215 kfree(link);
216} /* airo_detach */ 203} /* airo_detach */
217 204
218/*====================================================================== 205/*======================================================================
@@ -378,11 +365,11 @@ static void airo_config(dev_link_t *link)
378 365
379 /* 366 /*
380 At this point, the dev_node_t structure(s) need to be 367 At this point, the dev_node_t structure(s) need to be
381 initialized and arranged in a linked list at link->dev. 368 initialized and arranged in a linked list at link->dev_node.
382 */ 369 */
383 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 370 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
384 dev->node.major = dev->node.minor = 0; 371 dev->node.major = dev->node.minor = 0;
385 link->dev = &dev->node; 372 link->dev_node = &dev->node;
386 373
387 /* Finally, report what we've done */ 374 /* Finally, report what we've done */
388 printk(KERN_INFO "%s: index 0x%02x: ", 375 printk(KERN_INFO "%s: index 0x%02x: ",
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 53fdaa22226d..522bbed47a05 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -154,22 +154,14 @@ typedef struct local_info_t {
154 154
155static int atmel_attach(struct pcmcia_device *p_dev) 155static int atmel_attach(struct pcmcia_device *p_dev)
156{ 156{
157 dev_link_t *link;
158 local_info_t *local; 157 local_info_t *local;
159 158
160 DEBUG(0, "atmel_attach()\n"); 159 DEBUG(0, "atmel_attach()\n");
161 160
162 /* Initialize the dev_link_t structure */
163 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
164 if (!link) {
165 printk(KERN_ERR "atmel_cs: no memory for new device\n");
166 return -ENOMEM;
167 }
168
169 /* Interrupt setup */ 161 /* Interrupt setup */
170 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 162 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
171 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 163 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
172 link->irq.Handler = NULL; 164 p_dev->irq.Handler = NULL;
173 165
174 /* 166 /*
175 General socket configuration defaults can go here. In this 167 General socket configuration defaults can go here. In this
@@ -178,23 +170,19 @@ static int atmel_attach(struct pcmcia_device *p_dev)
178 and attributes of IO windows) are fixed by the nature of the 170 and attributes of IO windows) are fixed by the nature of the
179 device, and can be hard-wired here. 171 device, and can be hard-wired here.
180 */ 172 */
181 link->conf.Attributes = 0; 173 p_dev->conf.Attributes = 0;
182 link->conf.IntType = INT_MEMORY_AND_IO; 174 p_dev->conf.IntType = INT_MEMORY_AND_IO;
183 175
184 /* Allocate space for private device-specific data */ 176 /* Allocate space for private device-specific data */
185 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 177 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
186 if (!local) { 178 if (!local) {
187 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 179 printk(KERN_ERR "atmel_cs: no memory for new device\n");
188 kfree (link);
189 return -ENOMEM; 180 return -ENOMEM;
190 } 181 }
191 link->priv = local; 182 p_dev->priv = local;
192
193 link->handle = p_dev;
194 p_dev->instance = link;
195 183
196 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 184 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
197 atmel_config(link); 185 atmel_config(p_dev);
198 186
199 return 0; 187 return 0;
200} /* atmel_attach */ 188} /* atmel_attach */
@@ -218,7 +206,6 @@ static void atmel_detach(struct pcmcia_device *p_dev)
218 atmel_release(link); 206 atmel_release(link);
219 207
220 kfree(link->priv); 208 kfree(link->priv);
221 kfree(link);
222} 209}
223 210
224/*====================================================================== 211/*======================================================================
@@ -387,11 +374,11 @@ static void atmel_config(dev_link_t *link)
387 374
388 /* 375 /*
389 At this point, the dev_node_t structure(s) need to be 376 At this point, the dev_node_t structure(s) need to be
390 initialized and arranged in a linked list at link->dev. 377 initialized and arranged in a linked list at link->dev_node.
391 */ 378 */
392 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 379 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
393 dev->node.major = dev->node.minor = 0; 380 dev->node.major = dev->node.minor = 0;
394 link->dev = &dev->node; 381 link->dev_node = &dev->node;
395 382
396 link->state &= ~DEV_CONFIG_PENDING; 383 link->state &= ~DEV_CONFIG_PENDING;
397 return; 384 return;
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 69024bfb5bba..e3095a88745c 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -503,22 +503,11 @@ static struct prism2_helper_functions prism2_pccard_funcs =
503 * initialize dev_link structure, but do not configure the card yet */ 503 * initialize dev_link structure, but do not configure the card yet */
504static int prism2_attach(struct pcmcia_device *p_dev) 504static int prism2_attach(struct pcmcia_device *p_dev)
505{ 505{
506 dev_link_t *link;
507
508 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
509 if (link == NULL)
510 return -ENOMEM;
511
512 memset(link, 0, sizeof(dev_link_t));
513
514 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 506 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
515 link->conf.IntType = INT_MEMORY_AND_IO; 507 p_dev->conf.IntType = INT_MEMORY_AND_IO;
516
517 link->handle = p_dev;
518 p_dev->instance = link;
519 508
520 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 509 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
521 if (prism2_config(link)) 510 if (prism2_config(p_dev))
522 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); 511 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
523 512
524 return 0; 513 return 0;
@@ -546,7 +535,6 @@ static void prism2_detach(struct pcmcia_device *p_dev)
546 prism2_free_local_data(dev); 535 prism2_free_local_data(dev);
547 kfree(hw_priv); 536 kfree(hw_priv);
548 } 537 }
549 kfree(link);
550} 538}
551 539
552 540
@@ -713,7 +701,7 @@ static int prism2_config(dev_link_t *link)
713 local->hw_priv = hw_priv; 701 local->hw_priv = hw_priv;
714 hw_priv->link = link; 702 hw_priv->link = link;
715 strcpy(hw_priv->node.dev_name, dev->name); 703 strcpy(hw_priv->node.dev_name, dev->name);
716 link->dev = &hw_priv->node; 704 link->dev_node = &hw_priv->node;
717 705
718 /* 706 /*
719 * Allocate an interrupt line. Note that this does not assign a 707 * Allocate an interrupt line. Note that this does not assign a
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 23d6b3376e6e..68dfe68ffecf 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -268,7 +268,7 @@ struct site_survey {
268}; 268};
269 269
270typedef struct netwave_private { 270typedef struct netwave_private {
271 dev_link_t link; 271 struct pcmcia_device *p_dev;
272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ 272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */
273 dev_node_t node; 273 dev_node_t node;
274 u_char __iomem *ramBase; 274 u_char __iomem *ramBase;
@@ -378,9 +378,9 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
378 */ 378 */
379static int netwave_attach(struct pcmcia_device *p_dev) 379static int netwave_attach(struct pcmcia_device *p_dev)
380{ 380{
381 dev_link_t *link;
382 struct net_device *dev; 381 struct net_device *dev;
383 netwave_private *priv; 382 netwave_private *priv;
383 dev_link_t *link = dev_to_instance(p_dev);
384 384
385 DEBUG(0, "netwave_attach()\n"); 385 DEBUG(0, "netwave_attach()\n");
386 386
@@ -389,7 +389,7 @@ static int netwave_attach(struct pcmcia_device *p_dev)
389 if (!dev) 389 if (!dev)
390 return -ENOMEM; 390 return -ENOMEM;
391 priv = netdev_priv(dev); 391 priv = netdev_priv(dev);
392 link = &priv->link; 392 priv->p_dev = p_dev;
393 link->priv = dev; 393 link->priv = dev;
394 394
395 /* The io structure describes IO port mapping */ 395 /* The io structure describes IO port mapping */
@@ -429,9 +429,6 @@ static int netwave_attach(struct pcmcia_device *p_dev)
429 dev->stop = &netwave_close; 429 dev->stop = &netwave_close;
430 link->irq.Instance = dev; 430 link->irq.Instance = dev;
431 431
432 link->handle = p_dev;
433 p_dev->instance = link;
434
435 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 432 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
436 netwave_pcmcia_config( link); 433 netwave_pcmcia_config( link);
437 434
@@ -456,7 +453,7 @@ static void netwave_detach(struct pcmcia_device *p_dev)
456 if (link->state & DEV_CONFIG) 453 if (link->state & DEV_CONFIG)
457 netwave_release(link); 454 netwave_release(link);
458 455
459 if (link->dev) 456 if (link->dev_node)
460 unregister_netdev(dev); 457 unregister_netdev(dev);
461 458
462 free_netdev(dev); 459 free_netdev(dev);
@@ -830,7 +827,7 @@ static void netwave_pcmcia_config(dev_link_t *link) {
830 } 827 }
831 828
832 strcpy(priv->node.dev_name, dev->name); 829 strcpy(priv->node.dev_name, dev->name);
833 link->dev = &priv->node; 830 link->dev_node = &priv->node;
834 link->state &= ~DEV_CONFIG_PENDING; 831 link->state &= ~DEV_CONFIG_PENDING;
835 832
836 /* Reset card before reading physical address */ 833 /* Reset card before reading physical address */
@@ -1103,7 +1100,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs
1103 u_char __iomem *ramBase; 1100 u_char __iomem *ramBase;
1104 struct net_device *dev = (struct net_device *)dev_id; 1101 struct net_device *dev = (struct net_device *)dev_id;
1105 struct netwave_private *priv = netdev_priv(dev); 1102 struct netwave_private *priv = netdev_priv(dev);
1106 dev_link_t *link = &priv->link; 1103 dev_link_t *link = priv->p_dev;
1107 int i; 1104 int i;
1108 1105
1109 if (!netif_device_present(dev)) 1106 if (!netif_device_present(dev))
@@ -1357,7 +1354,7 @@ static int netwave_rx(struct net_device *dev)
1357 1354
1358static int netwave_open(struct net_device *dev) { 1355static int netwave_open(struct net_device *dev) {
1359 netwave_private *priv = netdev_priv(dev); 1356 netwave_private *priv = netdev_priv(dev);
1360 dev_link_t *link = &priv->link; 1357 dev_link_t *link = priv->p_dev;
1361 1358
1362 DEBUG(1, "netwave_open: starting.\n"); 1359 DEBUG(1, "netwave_open: starting.\n");
1363 1360
@@ -1374,7 +1371,7 @@ static int netwave_open(struct net_device *dev) {
1374 1371
1375static int netwave_close(struct net_device *dev) { 1372static int netwave_close(struct net_device *dev) {
1376 netwave_private *priv = netdev_priv(dev); 1373 netwave_private *priv = netdev_priv(dev);
1377 dev_link_t *link = &priv->link; 1374 dev_link_t *link = priv->p_dev;
1378 1375
1379 DEBUG(1, "netwave_close: finishing.\n"); 1376 DEBUG(1, "netwave_close: finishing.\n");
1380 1377
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index 75981d88a1e2..f10d97bc45f0 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -49,7 +49,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket
49/* PCMCIA specific device information (goes in the card field of 49/* PCMCIA specific device information (goes in the card field of
50 * struct orinoco_private */ 50 * struct orinoco_private */
51struct orinoco_pccard { 51struct orinoco_pccard {
52 dev_link_t link; 52 struct pcmcia_device *p_dev;
53 dev_node_t node; 53 dev_node_t node;
54 54
55 /* Used to handle hard reset */ 55 /* Used to handle hard reset */
@@ -75,7 +75,7 @@ static int
75orinoco_cs_hard_reset(struct orinoco_private *priv) 75orinoco_cs_hard_reset(struct orinoco_private *priv)
76{ 76{
77 struct orinoco_pccard *card = priv->card; 77 struct orinoco_pccard *card = priv->card;
78 dev_link_t *link = &card->link; 78 dev_link_t *link = card->p_dev;
79 int err; 79 int err;
80 80
81 /* We need atomic ops here, because we're not holding the lock */ 81 /* We need atomic ops here, because we're not holding the lock */
@@ -109,7 +109,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
109 struct net_device *dev; 109 struct net_device *dev;
110 struct orinoco_private *priv; 110 struct orinoco_private *priv;
111 struct orinoco_pccard *card; 111 struct orinoco_pccard *card;
112 dev_link_t *link; 112 dev_link_t *link = dev_to_instance(p_dev);
113 113
114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); 114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset);
115 if (! dev) 115 if (! dev)
@@ -118,7 +118,7 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
118 card = priv->card; 118 card = priv->card;
119 119
120 /* Link both structures together */ 120 /* Link both structures together */
121 link = &card->link; 121 card->p_dev = p_dev;
122 link->priv = dev; 122 link->priv = dev;
123 123
124 /* Interrupt setup */ 124 /* Interrupt setup */
@@ -135,12 +135,6 @@ orinoco_cs_attach(struct pcmcia_device *p_dev)
135 link->conf.Attributes = 0; 135 link->conf.Attributes = 0;
136 link->conf.IntType = INT_MEMORY_AND_IO; 136 link->conf.IntType = INT_MEMORY_AND_IO;
137 137
138 /* Register with Card Services */
139 link->next = NULL;
140
141 link->handle = p_dev;
142 p_dev->instance = link;
143
144 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 138 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
145 orinoco_cs_config(link); 139 orinoco_cs_config(link);
146 140
@@ -161,8 +155,8 @@ static void orinoco_cs_detach(struct pcmcia_device *p_dev)
161 if (link->state & DEV_CONFIG) 155 if (link->state & DEV_CONFIG)
162 orinoco_cs_release(link); 156 orinoco_cs_release(link);
163 157
164 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 158 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
165 if (link->dev) { 159 if (link->dev_node) {
166 DEBUG(0, PFX "About to unregister net device %p\n", 160 DEBUG(0, PFX "About to unregister net device %p\n",
167 dev); 161 dev);
168 unregister_netdev(dev); 162 unregister_netdev(dev);
@@ -364,9 +358,9 @@ orinoco_cs_config(dev_link_t *link)
364 } 358 }
365 359
366 /* At this point, the dev_node_t structure(s) needs to be 360 /* At this point, the dev_node_t structure(s) needs to be
367 * initialized and arranged in a linked list at link->dev. */ 361 * initialized and arranged in a linked list at link->dev_node. */
368 strcpy(card->node.dev_name, dev->name); 362 strcpy(card->node.dev_name, dev->name);
369 link->dev = &card->node; /* link->dev being non-NULL is also 363 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
370 used to indicate that the 364 used to indicate that the
371 net_device has been registered */ 365 net_device has been registered */
372 link->state &= ~DEV_CONFIG_PENDING; 366 link->state &= ~DEV_CONFIG_PENDING;
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 7d95587d09db..60297460debd 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -190,12 +190,6 @@ static int bc;
190static char *phy_addr = NULL; 190static char *phy_addr = NULL;
191 191
192 192
193/* A linked list of "instances" of the ray device. Each actual
194 PCMCIA card corresponds to one device instance, and is described
195 by one dev_link_t structure (defined in ds.h).
196*/
197static dev_link_t *dev_list = NULL;
198
199/* A dev_link_t structure has fields for most things that are needed 193/* A dev_link_t structure has fields for most things that are needed
200 to keep track of a socket, but there will usually be some device 194 to keep track of a socket, but there will usually be some device
201 specific information that also needs to be kept track of. The 195 specific information that also needs to be kept track of. The
@@ -204,6 +198,9 @@ static dev_link_t *dev_list = NULL;
204*/ 198*/
205static unsigned int ray_mem_speed = 500; 199static unsigned int ray_mem_speed = 500;
206 200
201/* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
202static struct pcmcia_device *this_device = NULL;
203
207MODULE_AUTHOR("Corey Thomas <corey@world.std.com>"); 204MODULE_AUTHOR("Corey Thomas <corey@world.std.com>");
208MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver"); 205MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver");
209MODULE_LICENSE("GPL"); 206MODULE_LICENSE("GPL");
@@ -308,53 +305,44 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
308=============================================================================*/ 305=============================================================================*/
309static int ray_attach(struct pcmcia_device *p_dev) 306static int ray_attach(struct pcmcia_device *p_dev)
310{ 307{
311 dev_link_t *link;
312 ray_dev_t *local; 308 ray_dev_t *local;
313 struct net_device *dev; 309 struct net_device *dev;
314
315 DEBUG(1, "ray_attach()\n");
316
317 /* Initialize the dev_link_t structure */
318 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
319 310
320 if (!link) 311 DEBUG(1, "ray_attach()\n");
321 return -ENOMEM;
322 312
323 /* Allocate space for private device-specific data */ 313 /* Allocate space for private device-specific data */
324 dev = alloc_etherdev(sizeof(ray_dev_t)); 314 dev = alloc_etherdev(sizeof(ray_dev_t));
325
326 if (!dev) 315 if (!dev)
327 goto fail_alloc_dev; 316 goto fail_alloc_dev;
328 317
329 local = dev->priv; 318 local = dev->priv;
330 319 local->finder = p_dev;
331 memset(link, 0, sizeof(struct dev_link_t));
332 320
333 /* The io structure describes IO port mapping. None used here */ 321 /* The io structure describes IO port mapping. None used here */
334 link->io.NumPorts1 = 0; 322 p_dev->io.NumPorts1 = 0;
335 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 323 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
336 link->io.IOAddrLines = 5; 324 p_dev->io.IOAddrLines = 5;
337 325
338 /* Interrupt setup. For PCMCIA, driver takes what's given */ 326 /* Interrupt setup. For PCMCIA, driver takes what's given */
339 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 327 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
340 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 328 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
341 link->irq.Handler = &ray_interrupt; 329 p_dev->irq.Handler = &ray_interrupt;
342 330
343 /* General socket configuration */ 331 /* General socket configuration */
344 link->conf.Attributes = CONF_ENABLE_IRQ; 332 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
345 link->conf.IntType = INT_MEMORY_AND_IO; 333 p_dev->conf.IntType = INT_MEMORY_AND_IO;
346 link->conf.ConfigIndex = 1; 334 p_dev->conf.ConfigIndex = 1;
347 link->conf.Present = PRESENT_OPTION; 335 p_dev->conf.Present = PRESENT_OPTION;
348 336
349 link->priv = dev; 337 p_dev->priv = dev;
350 link->irq.Instance = dev; 338 p_dev->irq.Instance = dev;
351 339
352 local->finder = link; 340 local->finder = p_dev;
353 local->card_status = CARD_INSERTED; 341 local->card_status = CARD_INSERTED;
354 local->authentication_state = UNAUTHENTICATED; 342 local->authentication_state = UNAUTHENTICATED;
355 local->num_multi = 0; 343 local->num_multi = 0;
356 DEBUG(2,"ray_attach link = %p, dev = %p, local = %p, intr = %p\n", 344 DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
357 link,dev,local,&ray_interrupt); 345 p_dev,dev,local,&ray_interrupt);
358 346
359 /* Raylink entries in the device structure */ 347 /* Raylink entries in the device structure */
360 dev->hard_start_xmit = &ray_dev_start_xmit; 348 dev->hard_start_xmit = &ray_dev_start_xmit;
@@ -378,16 +366,13 @@ static int ray_attach(struct pcmcia_device *p_dev)
378 366
379 init_timer(&local->timer); 367 init_timer(&local->timer);
380 368
381 link->handle = p_dev; 369 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
382 p_dev->instance = link; 370 this_device = p_dev;
383 371 ray_config(p_dev);
384 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
385 ray_config(link);
386 372
387 return 0; 373 return 0;
388 374
389fail_alloc_dev: 375fail_alloc_dev:
390 kfree(link);
391 return -ENOMEM; 376 return -ENOMEM;
392} /* ray_attach */ 377} /* ray_attach */
393/*============================================================================= 378/*=============================================================================
@@ -399,18 +384,12 @@ fail_alloc_dev:
399static void ray_detach(struct pcmcia_device *p_dev) 384static void ray_detach(struct pcmcia_device *p_dev)
400{ 385{
401 dev_link_t *link = dev_to_instance(p_dev); 386 dev_link_t *link = dev_to_instance(p_dev);
402 dev_link_t **linkp;
403 struct net_device *dev; 387 struct net_device *dev;
404 ray_dev_t *local; 388 ray_dev_t *local;
405 389
406 DEBUG(1, "ray_detach(0x%p)\n", link); 390 DEBUG(1, "ray_detach(0x%p)\n", link);
407
408 /* Locate device structure */
409 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
410 if (*linkp == link) break;
411 if (*linkp == NULL)
412 return;
413 391
392 this_device = NULL;
414 dev = link->priv; 393 dev = link->priv;
415 394
416 if (link->state & DEV_CONFIG) { 395 if (link->state & DEV_CONFIG) {
@@ -420,13 +399,10 @@ static void ray_detach(struct pcmcia_device *p_dev)
420 del_timer(&local->timer); 399 del_timer(&local->timer);
421 } 400 }
422 401
423 /* Unlink device structure, free pieces */
424 *linkp = link->next;
425 if (link->priv) { 402 if (link->priv) {
426 if (link->dev) unregister_netdev(dev); 403 if (link->dev_node) unregister_netdev(dev);
427 free_netdev(dev); 404 free_netdev(dev);
428 } 405 }
429 kfree(link);
430 DEBUG(2,"ray_cs ray_detach ending\n"); 406 DEBUG(2,"ray_cs ray_detach ending\n");
431} /* ray_detach */ 407} /* ray_detach */
432/*============================================================================= 408/*=============================================================================
@@ -537,7 +513,7 @@ static void ray_config(dev_link_t *link)
537 } 513 }
538 514
539 strcpy(local->node.dev_name, dev->name); 515 strcpy(local->node.dev_name, dev->name);
540 link->dev = &local->node; 516 link->dev_node = &local->node;
541 517
542 link->state &= ~DEV_CONFIG_PENDING; 518 link->state &= ~DEV_CONFIG_PENDING;
543 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", 519 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ",
@@ -1640,18 +1616,14 @@ static const struct iw_handler_def ray_handler_def =
1640/*===========================================================================*/ 1616/*===========================================================================*/
1641static int ray_open(struct net_device *dev) 1617static int ray_open(struct net_device *dev)
1642{ 1618{
1643 dev_link_t *link;
1644 ray_dev_t *local = (ray_dev_t *)dev->priv; 1619 ray_dev_t *local = (ray_dev_t *)dev->priv;
1620 dev_link_t *link;
1621 link = local->finder;
1645 1622
1646 DEBUG(1, "ray_open('%s')\n", dev->name); 1623 DEBUG(1, "ray_open('%s')\n", dev->name);
1647 1624
1648 for (link = dev_list; link; link = link->next) 1625 if (link->open == 0)
1649 if (link->priv == dev) break; 1626 local->num_multi = 0;
1650 if (!DEV_OK(link)) {
1651 return -ENODEV;
1652 }
1653
1654 if (link->open == 0) local->num_multi = 0;
1655 link->open++; 1627 link->open++;
1656 1628
1657 /* If the card is not started, time to start it ! - Jean II */ 1629 /* If the card is not started, time to start it ! - Jean II */
@@ -1678,15 +1650,12 @@ static int ray_open(struct net_device *dev)
1678/*===========================================================================*/ 1650/*===========================================================================*/
1679static int ray_dev_close(struct net_device *dev) 1651static int ray_dev_close(struct net_device *dev)
1680{ 1652{
1653 ray_dev_t *local = (ray_dev_t *)dev->priv;
1681 dev_link_t *link; 1654 dev_link_t *link;
1655 link = local->finder;
1682 1656
1683 DEBUG(1, "ray_dev_close('%s')\n", dev->name); 1657 DEBUG(1, "ray_dev_close('%s')\n", dev->name);
1684 1658
1685 for (link = dev_list; link; link = link->next)
1686 if (link->priv == dev) break;
1687 if (link == NULL)
1688 return -ENODEV;
1689
1690 link->open--; 1659 link->open--;
1691 netif_stop_queue(dev); 1660 netif_stop_queue(dev);
1692 1661
@@ -2679,7 +2648,7 @@ static int ray_cs_proc_read(char *buf, char **start, off_t offset, int len)
2679 struct freq_hop_element *pfh; 2648 struct freq_hop_element *pfh;
2680 UCHAR c[33]; 2649 UCHAR c[33];
2681 2650
2682 link = dev_list; 2651 link = this_device;
2683 if (!link) 2652 if (!link)
2684 return 0; 2653 return 0;
2685 dev = (struct net_device *)link->priv; 2654 dev = (struct net_device *)link->priv;
@@ -2923,7 +2892,6 @@ static void __exit exit_ray_cs(void)
2923#endif 2892#endif
2924 2893
2925 pcmcia_unregister_driver(&ray_driver); 2894 pcmcia_unregister_driver(&ray_driver);
2926 BUG_ON(dev_list != NULL);
2927} /* exit_ray_cs */ 2895} /* exit_ray_cs */
2928 2896
2929module_init(init_ray_cs); 2897module_init(init_ray_cs);
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 7a4a80b01f9c..be36679c8c95 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -63,7 +63,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket
63/* PCMCIA specific device information (goes in the card field of 63/* PCMCIA specific device information (goes in the card field of
64 * struct orinoco_private */ 64 * struct orinoco_private */
65struct orinoco_pccard { 65struct orinoco_pccard {
66 dev_link_t link; 66 struct pcmcia_device *p_dev;
67 dev_node_t node; 67 dev_node_t node;
68}; 68};
69 69
@@ -554,12 +554,12 @@ static int
554spectrum_cs_hard_reset(struct orinoco_private *priv) 554spectrum_cs_hard_reset(struct orinoco_private *priv)
555{ 555{
556 struct orinoco_pccard *card = priv->card; 556 struct orinoco_pccard *card = priv->card;
557 dev_link_t *link = &card->link; 557 dev_link_t *link = card->p_dev;
558 int err; 558 int err;
559 559
560 if (!hermes_present(&priv->hw)) { 560 if (!hermes_present(&priv->hw)) {
561 /* The firmware needs to be reloaded */ 561 /* The firmware needs to be reloaded */
562 if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) { 562 if (spectrum_dl_firmware(&priv->hw, link) != 0) {
563 printk(KERN_ERR PFX "Firmware download failed\n"); 563 printk(KERN_ERR PFX "Firmware download failed\n");
564 err = -ENODEV; 564 err = -ENODEV;
565 } 565 }
@@ -589,7 +589,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
589 struct net_device *dev; 589 struct net_device *dev;
590 struct orinoco_private *priv; 590 struct orinoco_private *priv;
591 struct orinoco_pccard *card; 591 struct orinoco_pccard *card;
592 dev_link_t *link; 592 dev_link_t *link = dev_to_instance(p_dev);
593 593
594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); 594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
595 if (! dev) 595 if (! dev)
@@ -598,7 +598,7 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
598 card = priv->card; 598 card = priv->card;
599 599
600 /* Link both structures together */ 600 /* Link both structures together */
601 link = &card->link; 601 card->p_dev = p_dev;
602 link->priv = dev; 602 link->priv = dev;
603 603
604 /* Interrupt setup */ 604 /* Interrupt setup */
@@ -615,9 +615,6 @@ spectrum_cs_attach(struct pcmcia_device *p_dev)
615 link->conf.Attributes = 0; 615 link->conf.Attributes = 0;
616 link->conf.IntType = INT_MEMORY_AND_IO; 616 link->conf.IntType = INT_MEMORY_AND_IO;
617 617
618 link->handle = p_dev;
619 p_dev->instance = link;
620
621 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 618 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
622 spectrum_cs_config(link); 619 spectrum_cs_config(link);
623 620
@@ -638,8 +635,8 @@ static void spectrum_cs_detach(struct pcmcia_device *p_dev)
638 if (link->state & DEV_CONFIG) 635 if (link->state & DEV_CONFIG)
639 spectrum_cs_release(link); 636 spectrum_cs_release(link);
640 637
641 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 638 DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
642 if (link->dev) { 639 if (link->dev_node) {
643 DEBUG(0, PFX "About to unregister net device %p\n", 640 DEBUG(0, PFX "About to unregister net device %p\n",
644 dev); 641 dev);
645 unregister_netdev(dev); 642 unregister_netdev(dev);
@@ -842,9 +839,9 @@ spectrum_cs_config(dev_link_t *link)
842 } 839 }
843 840
844 /* At this point, the dev_node_t structure(s) needs to be 841 /* At this point, the dev_node_t structure(s) needs to be
845 * initialized and arranged in a linked list at link->dev. */ 842 * initialized and arranged in a linked list at link->dev_node. */
846 strcpy(card->node.dev_name, dev->name); 843 strcpy(card->node.dev_name, dev->name);
847 link->dev = &card->node; /* link->dev being non-NULL is also 844 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
848 used to indicate that the 845 used to indicate that the
849 net_device has been registered */ 846 net_device has been registered */
850 link->state &= ~DEV_CONFIG_PENDING; 847 link->state &= ~DEV_CONFIG_PENDING;
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index daa17dc34320..baa1011e70e0 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4081,7 +4081,7 @@ wv_pcmcia_config(dev_link_t * link)
4081 } 4081 }
4082 4082
4083 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name); 4083 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name);
4084 link->dev = &((net_local *) netdev_priv(dev))->node; 4084 link->dev_node = &((net_local *) netdev_priv(dev))->node;
4085 4085
4086#ifdef DEBUG_CONFIG_TRACE 4086#ifdef DEBUG_CONFIG_TRACE
4087 printk(KERN_DEBUG "<-wv_pcmcia_config()\n"); 4087 printk(KERN_DEBUG "<-wv_pcmcia_config()\n");
@@ -4583,7 +4583,6 @@ wavelan_close(struct net_device * dev)
4583static int 4583static int
4584wavelan_attach(struct pcmcia_device *p_dev) 4584wavelan_attach(struct pcmcia_device *p_dev)
4585{ 4585{
4586 dev_link_t * link; /* Info for cardmgr */
4587 struct net_device * dev; /* Interface generic data */ 4586 struct net_device * dev; /* Interface generic data */
4588 net_local * lp; /* Interface specific data */ 4587 net_local * lp; /* Interface specific data */
4589 4588
@@ -4591,34 +4590,26 @@ wavelan_attach(struct pcmcia_device *p_dev)
4591 printk(KERN_DEBUG "-> wavelan_attach()\n"); 4590 printk(KERN_DEBUG "-> wavelan_attach()\n");
4592#endif 4591#endif
4593 4592
4594 /* Initialize the dev_link_t structure */
4595 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
4596 if (!link) return -ENOMEM;
4597
4598 /* The io structure describes IO port mapping */ 4593 /* The io structure describes IO port mapping */
4599 link->io.NumPorts1 = 8; 4594 p_dev->io.NumPorts1 = 8;
4600 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 4595 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
4601 link->io.IOAddrLines = 3; 4596 p_dev->io.IOAddrLines = 3;
4602 4597
4603 /* Interrupt setup */ 4598 /* Interrupt setup */
4604 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 4599 p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
4605 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 4600 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
4606 link->irq.Handler = wavelan_interrupt; 4601 p_dev->irq.Handler = wavelan_interrupt;
4607 4602
4608 /* General socket configuration */ 4603 /* General socket configuration */
4609 link->conf.Attributes = CONF_ENABLE_IRQ; 4604 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
4610 link->conf.IntType = INT_MEMORY_AND_IO; 4605 p_dev->conf.IntType = INT_MEMORY_AND_IO;
4611
4612 /* Chain drivers */
4613 link->next = NULL;
4614 4606
4615 /* Allocate the generic data structure */ 4607 /* Allocate the generic data structure */
4616 dev = alloc_etherdev(sizeof(net_local)); 4608 dev = alloc_etherdev(sizeof(net_local));
4617 if (!dev) { 4609 if (!dev)
4618 kfree(link);
4619 return -ENOMEM; 4610 return -ENOMEM;
4620 } 4611
4621 link->priv = link->irq.Instance = dev; 4612 p_dev->priv = p_dev->irq.Instance = dev;
4622 4613
4623 lp = netdev_priv(dev); 4614 lp = netdev_priv(dev);
4624 4615
@@ -4635,7 +4626,6 @@ wavelan_attach(struct pcmcia_device *p_dev)
4635 spin_lock_init(&lp->spinlock); 4626 spin_lock_init(&lp->spinlock);
4636 4627
4637 /* back links */ 4628 /* back links */
4638 lp->link = link;
4639 lp->dev = dev; 4629 lp->dev = dev;
4640 4630
4641 /* wavelan NET3 callbacks */ 4631 /* wavelan NET3 callbacks */
@@ -4661,11 +4651,8 @@ wavelan_attach(struct pcmcia_device *p_dev)
4661 /* Other specific data */ 4651 /* Other specific data */
4662 dev->mtu = WAVELAN_MTU; 4652 dev->mtu = WAVELAN_MTU;
4663 4653
4664 link->handle = p_dev; 4654 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4665 p_dev->instance = link; 4655 if(wv_pcmcia_config(p_dev) &&
4666
4667 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4668 if(wv_pcmcia_config(link) &&
4669 wv_hw_config(dev)) 4656 wv_hw_config(dev))
4670 wv_init_info(dev); 4657 wv_init_info(dev);
4671 else 4658 else
@@ -4713,14 +4700,13 @@ wavelan_detach(struct pcmcia_device *p_dev)
4713 4700
4714 /* Remove ourselves from the kernel list of ethernet devices */ 4701 /* Remove ourselves from the kernel list of ethernet devices */
4715 /* Warning : can't be called from interrupt, timer or wavelan_close() */ 4702 /* Warning : can't be called from interrupt, timer or wavelan_close() */
4716 if (link->dev) 4703 if (link->dev_node)
4717 unregister_netdev(dev); 4704 unregister_netdev(dev);
4718 link->dev = NULL; 4705 link->dev_node = NULL;
4719 ((net_local *)netdev_priv(dev))->link = NULL; 4706 ((net_local *)netdev_priv(dev))->link = NULL;
4720 ((net_local *)netdev_priv(dev))->dev = NULL; 4707 ((net_local *)netdev_priv(dev))->dev = NULL;
4721 free_netdev(dev); 4708 free_netdev(dev);
4722 } 4709 }
4723 kfree(link);
4724 4710
4725#ifdef DEBUG_CALLBACK_TRACE 4711#ifdef DEBUG_CALLBACK_TRACE
4726 printk(KERN_DEBUG "<- wavelan_detach()\n"); 4712 printk(KERN_DEBUG "<- wavelan_detach()\n");
diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h
index 4303c50c2ab6..65ceb088f700 100644
--- a/drivers/net/wireless/wl3501.h
+++ b/drivers/net/wireless/wl3501.h
@@ -611,5 +611,6 @@ struct wl3501_card {
611 struct iw_spy_data spy_data; 611 struct iw_spy_data spy_data;
612 struct iw_public_data wireless_data; 612 struct iw_public_data wireless_data;
613 struct dev_node_t node; 613 struct dev_node_t node;
614 struct pcmcia_device *p_dev;
614}; 615};
615#endif 616#endif
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 393b5cb7a52c..4b054f54e9d5 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -226,17 +226,6 @@ static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to,
226 iw_set_mgmt_info_element(from->id, to, from->data, from->len); 226 iw_set_mgmt_info_element(from->id, to, from->data, from->len);
227} 227}
228 228
229/*
230 * A linked list of "instances" of the wl24 device. Each actual PCMCIA card
231 * corresponds to one device instance, and is described by one dev_link_t
232 * structure (defined in ds.h).
233 *
234 * You may not want to use a linked list for this -- for example, the memory
235 * card driver uses an array of dev_link_t pointers, where minor device numbers
236 * are used to derive the corresponding array index.
237 */
238static dev_link_t *wl3501_dev_list;
239
240static inline void wl3501_switch_page(struct wl3501_card *this, u8 page) 229static inline void wl3501_switch_page(struct wl3501_card *this, u8 page)
241{ 230{
242 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS); 231 wl3501_outb(page, this->base_addr + WL3501_NIC_BSS);
@@ -1282,14 +1271,9 @@ static int wl3501_close(struct net_device *dev)
1282 int rc = -ENODEV; 1271 int rc = -ENODEV;
1283 unsigned long flags; 1272 unsigned long flags;
1284 dev_link_t *link; 1273 dev_link_t *link;
1274 link = this->p_dev;
1285 1275
1286 spin_lock_irqsave(&this->lock, flags); 1276 spin_lock_irqsave(&this->lock, flags);
1287 /* Check if the device is in wl3501_dev_list */
1288 for (link = wl3501_dev_list; link; link = link->next)
1289 if (link->priv == dev)
1290 break;
1291 if (!link)
1292 goto out;
1293 link->open--; 1277 link->open--;
1294 1278
1295 /* Stop wl3501_hard_start_xmit() from now on */ 1279 /* Stop wl3501_hard_start_xmit() from now on */
@@ -1301,7 +1285,6 @@ static int wl3501_close(struct net_device *dev)
1301 1285
1302 rc = 0; 1286 rc = 0;
1303 printk(KERN_INFO "%s: WL3501 closed\n", dev->name); 1287 printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
1304out:
1305 spin_unlock_irqrestore(&this->lock, flags); 1288 spin_unlock_irqrestore(&this->lock, flags);
1306 return rc; 1289 return rc;
1307} 1290}
@@ -1401,12 +1384,9 @@ static int wl3501_open(struct net_device *dev)
1401 struct wl3501_card *this = dev->priv; 1384 struct wl3501_card *this = dev->priv;
1402 unsigned long flags; 1385 unsigned long flags;
1403 dev_link_t *link; 1386 dev_link_t *link;
1387 link = this->p_dev;
1404 1388
1405 spin_lock_irqsave(&this->lock, flags); 1389 spin_lock_irqsave(&this->lock, flags);
1406 /* Check if the device is in wl3501_dev_list */
1407 for (link = wl3501_dev_list; link; link = link->next)
1408 if (link->priv == dev)
1409 break;
1410 if (!DEV_OK(link)) 1390 if (!DEV_OK(link))
1411 goto out; 1391 goto out;
1412 netif_device_attach(dev); 1392 netif_device_attach(dev);
@@ -1500,16 +1480,8 @@ static struct ethtool_ops ops = {
1500static void wl3501_detach(struct pcmcia_device *p_dev) 1480static void wl3501_detach(struct pcmcia_device *p_dev)
1501{ 1481{
1502 dev_link_t *link = dev_to_instance(p_dev); 1482 dev_link_t *link = dev_to_instance(p_dev);
1503 dev_link_t **linkp;
1504 struct net_device *dev = link->priv; 1483 struct net_device *dev = link->priv;
1505 1484
1506 /* Locate device structure */
1507 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
1508 if (*linkp == link)
1509 break;
1510 if (!*linkp)
1511 goto out;
1512
1513 /* If the device is currently configured and active, we won't actually 1485 /* If the device is currently configured and active, we won't actually
1514 * delete it yet. Instead, it is marked so that when the release() 1486 * delete it yet. Instead, it is marked so that when the release()
1515 * function is called, that will trigger a proper detach(). */ 1487 * function is called, that will trigger a proper detach(). */
@@ -1522,13 +1494,9 @@ static void wl3501_detach(struct pcmcia_device *p_dev)
1522 wl3501_release(link); 1494 wl3501_release(link);
1523 } 1495 }
1524 1496
1525 /* Unlink device structure, free pieces */
1526 *linkp = link->next;
1527
1528 if (link->priv) 1497 if (link->priv)
1529 free_netdev(link->priv); 1498 free_netdev(link->priv);
1530 kfree(link); 1499
1531out:
1532 return; 1500 return;
1533} 1501}
1534 1502
@@ -1955,14 +1923,9 @@ static const struct iw_handler_def wl3501_handler_def = {
1955 */ 1923 */
1956static int wl3501_attach(struct pcmcia_device *p_dev) 1924static int wl3501_attach(struct pcmcia_device *p_dev)
1957{ 1925{
1958 dev_link_t *link;
1959 struct net_device *dev; 1926 struct net_device *dev;
1960 struct wl3501_card *this; 1927 struct wl3501_card *this;
1961 1928 dev_link_t *link = dev_to_instance(p_dev);
1962 /* Initialize the dev_link_t structure */
1963 link = kzalloc(sizeof(*link), GFP_KERNEL);
1964 if (!link)
1965 return -ENOMEM;
1966 1929
1967 /* The io structure describes IO port mapping */ 1930 /* The io structure describes IO port mapping */
1968 link->io.NumPorts1 = 16; 1931 link->io.NumPorts1 = 16;
@@ -1991,22 +1954,18 @@ static int wl3501_attach(struct pcmcia_device *p_dev)
1991 dev->get_stats = wl3501_get_stats; 1954 dev->get_stats = wl3501_get_stats;
1992 this = dev->priv; 1955 this = dev->priv;
1993 this->wireless_data.spy_data = &this->spy_data; 1956 this->wireless_data.spy_data = &this->spy_data;
1957 this->p_dev = p_dev;
1994 dev->wireless_data = &this->wireless_data; 1958 dev->wireless_data = &this->wireless_data;
1995 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; 1959 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def;
1996 SET_ETHTOOL_OPS(dev, &ops); 1960 SET_ETHTOOL_OPS(dev, &ops);
1997 netif_stop_queue(dev); 1961 netif_stop_queue(dev);
1998 link->priv = link->irq.Instance = dev; 1962 link->priv = link->irq.Instance = dev;
1999 1963
2000 link->handle = p_dev;
2001 p_dev->instance = link;
2002
2003 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1964 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2004 wl3501_config(link); 1965 wl3501_config(p_dev);
2005 1966
2006 return 0; 1967 return 0;
2007out_link: 1968out_link:
2008 kfree(link);
2009 link = NULL;
2010 return -ENOMEM; 1969 return -ENOMEM;
2011} 1970}
2012 1971
@@ -2087,9 +2046,9 @@ static void wl3501_config(dev_link_t *link)
2087 this = dev->priv; 2046 this = dev->priv;
2088 /* 2047 /*
2089 * At this point, the dev_node_t structure(s) should be initialized and 2048 * At this point, the dev_node_t structure(s) should be initialized and
2090 * arranged in a linked list at link->dev. 2049 * arranged in a linked list at link->dev_node.
2091 */ 2050 */
2092 link->dev = &this->node; 2051 link->dev_node = &this->node;
2093 link->state &= ~DEV_CONFIG_PENDING; 2052 link->state &= ~DEV_CONFIG_PENDING;
2094 2053
2095 this->base_addr = dev->base_addr; 2054 this->base_addr = dev->base_addr;
@@ -2148,7 +2107,7 @@ static void wl3501_release(dev_link_t *link)
2148 struct net_device *dev = link->priv; 2107 struct net_device *dev = link->priv;
2149 2108
2150 /* Unlink the device chain */ 2109 /* Unlink the device chain */
2151 if (link->dev) 2110 if (link->dev_node)
2152 unregister_netdev(dev); 2111 unregister_netdev(dev);
2153 2112
2154 pcmcia_disable_device(link->handle); 2113 pcmcia_disable_device(link->handle);
@@ -2206,9 +2165,7 @@ static int __init wl3501_init_module(void)
2206 2165
2207static void __exit wl3501_exit_module(void) 2166static void __exit wl3501_exit_module(void)
2208{ 2167{
2209 dprintk(0, ": unloading");
2210 pcmcia_unregister_driver(&wl3501_driver); 2168 pcmcia_unregister_driver(&wl3501_driver);
2211 BUG_ON(wl3501_dev_list != NULL);
2212} 2169}
2213 2170
2214module_init(wl3501_init_module); 2171module_init(wl3501_init_module);
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 8d60146c7213..ad2738ae2222 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -81,7 +81,7 @@ static char *version =
81#define FORCE_EPP_MODE 0x08 81#define FORCE_EPP_MODE 0x08
82 82
83typedef struct parport_info_t { 83typedef struct parport_info_t {
84 dev_link_t link; 84 struct pcmcia_device *p_dev;
85 int ndev; 85 int ndev;
86 dev_node_t node; 86 dev_node_t node;
87 struct parport *port; 87 struct parport *port;
@@ -102,7 +102,7 @@ static void parport_cs_release(dev_link_t *);
102static int parport_attach(struct pcmcia_device *p_dev) 102static int parport_attach(struct pcmcia_device *p_dev)
103{ 103{
104 parport_info_t *info; 104 parport_info_t *info;
105 dev_link_t *link; 105 dev_link_t *link = dev_to_instance(p_dev);
106 106
107 DEBUG(0, "parport_attach()\n"); 107 DEBUG(0, "parport_attach()\n");
108 108
@@ -110,7 +110,8 @@ static int parport_attach(struct pcmcia_device *p_dev)
110 info = kmalloc(sizeof(*info), GFP_KERNEL); 110 info = kmalloc(sizeof(*info), GFP_KERNEL);
111 if (!info) return -ENOMEM; 111 if (!info) return -ENOMEM;
112 memset(info, 0, sizeof(*info)); 112 memset(info, 0, sizeof(*info));
113 link = &info->link; link->priv = info; 113 link->priv = info;
114 info->p_dev = p_dev;
114 115
115 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 116 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
116 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 117 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
@@ -119,9 +120,6 @@ static int parport_attach(struct pcmcia_device *p_dev)
119 link->conf.Attributes = CONF_ENABLE_IRQ; 120 link->conf.Attributes = CONF_ENABLE_IRQ;
120 link->conf.IntType = INT_MEMORY_AND_IO; 121 link->conf.IntType = INT_MEMORY_AND_IO;
121 122
122 link->handle = p_dev;
123 p_dev->instance = link;
124
125 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 123 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
126 parport_config(link); 124 parport_config(link);
127 125
@@ -239,7 +237,7 @@ void parport_config(dev_link_t *link)
239 info->node.minor = p->number; 237 info->node.minor = p->number;
240 info->port = p; 238 info->port = p;
241 strcpy(info->node.dev_name, p->name); 239 strcpy(info->node.dev_name, p->name);
242 link->dev = &info->node; 240 link->dev_node = &info->node;
243 241
244 link->state &= ~DEV_CONFIG_PENDING; 242 link->state &= ~DEV_CONFIG_PENDING;
245 return; 243 return;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 488448a12b2f..4ab956843d86 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -391,6 +391,7 @@ static int pcmcia_device_probe(struct device * dev)
391 } 391 }
392 392
393 p_dev->p_state &= ~CLIENT_UNBOUND; 393 p_dev->p_state &= ~CLIENT_UNBOUND;
394 p_dev->handle = p_dev;
394 395
395 ret = p_drv->probe(p_dev); 396 ret = p_drv->probe(p_dev);
396 if (ret) 397 if (ret)
@@ -1039,12 +1040,10 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1039 ret = p_drv->suspend(p_dev); 1040 ret = p_drv->suspend(p_dev);
1040 if (ret) 1041 if (ret)
1041 return ret; 1042 return ret;
1042 if (p_dev->instance) { 1043 p_dev->state |= DEV_SUSPEND;
1043 p_dev->instance->state |= DEV_SUSPEND; 1044 if ((p_dev->state & DEV_CONFIG) &&
1044 if ((p_dev->instance->state & DEV_CONFIG) && 1045 !(p_dev->state & DEV_SUSPEND_NORELEASE))
1045 !(p_dev->instance->state & DEV_SUSPEND_NORELEASE))
1046 pcmcia_release_configuration(p_dev); 1046 pcmcia_release_configuration(p_dev);
1047 }
1048 } 1047 }
1049 1048
1050 return 0; 1049 return 0;
@@ -1061,16 +1060,14 @@ static int pcmcia_dev_resume(struct device * dev)
1061 p_drv = to_pcmcia_drv(dev->driver); 1060 p_drv = to_pcmcia_drv(dev->driver);
1062 1061
1063 if (p_drv && p_drv->resume) { 1062 if (p_drv && p_drv->resume) {
1064 if (p_dev->instance) { 1063 p_dev->state &= ~DEV_SUSPEND;
1065 p_dev->instance->state &= ~DEV_SUSPEND; 1064 if ((p_dev->state & DEV_CONFIG) &&
1066 if ((p_dev->instance->state & DEV_CONFIG) && 1065 !(p_dev->state & DEV_SUSPEND_NORELEASE)){
1067 !(p_dev->instance->state & DEV_SUSPEND_NORELEASE)){
1068 ret = pcmcia_request_configuration(p_dev, 1066 ret = pcmcia_request_configuration(p_dev,
1069 &p_dev->instance->conf); 1067 &p_dev->conf);
1070 if (ret) 1068 if (ret)
1071 return ret; 1069 return ret;
1072 } 1070 }
1073 }
1074 return p_drv->resume(p_dev); 1071 return p_drv->resume(p_dev);
1075 } 1072 }
1076 1073
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index be08bc9e99fd..2b11a332175e 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -229,7 +229,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
229 * by userspace before, we need to 229 * by userspace before, we need to
230 * return the "instance". */ 230 * return the "instance". */
231 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 231 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
232 bind_info->instance = p_dev->instance; 232 bind_info->instance = p_dev;
233 ret = -EBUSY; 233 ret = -EBUSY;
234 goto err_put_module; 234 goto err_put_module;
235 } else { 235 } else {
@@ -358,16 +358,15 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
358 found: 358 found:
359 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 359 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
360 360
361 if ((!p_dev->instance) || 361 if (p_dev->state & DEV_CONFIG_PENDING) {
362 (p_dev->instance->state & DEV_CONFIG_PENDING)) {
363 ret = -EAGAIN; 362 ret = -EAGAIN;
364 goto err_put; 363 goto err_put;
365 } 364 }
366 365
367 if (first) 366 if (first)
368 node = p_dev->instance->dev; 367 node = p_dev->dev_node;
369 else 368 else
370 for (node = p_dev->instance->dev; node; node = node->next) 369 for (node = p_dev->dev_node; node; node = node->next)
371 if (node == bind_info->next) 370 if (node == bind_info->next)
372 break; 371 break;
373 if (!node) { 372 if (!node) {
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index ab0bbb6207b2..93ab9402d37f 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -942,15 +942,12 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
942EXPORT_SYMBOL(pcmcia_request_window); 942EXPORT_SYMBOL(pcmcia_request_window);
943 943
944void pcmcia_disable_device(struct pcmcia_device *p_dev) { 944void pcmcia_disable_device(struct pcmcia_device *p_dev) {
945 if (!p_dev->instance)
946 return;
947
948 pcmcia_release_configuration(p_dev); 945 pcmcia_release_configuration(p_dev);
949 pcmcia_release_io(p_dev, &p_dev->instance->io); 946 pcmcia_release_io(p_dev, &p_dev->io);
950 pcmcia_release_irq(p_dev, &p_dev->instance->irq); 947 pcmcia_release_irq(p_dev, &p_dev->irq);
951 if (&p_dev->instance->win) 948 if (&p_dev->win)
952 pcmcia_release_window(p_dev->instance->win); 949 pcmcia_release_window(p_dev->win);
953 950
954 p_dev->instance->dev = NULL; 951 p_dev->dev_node = NULL;
955} 952}
956EXPORT_SYMBOL(pcmcia_disable_device); 953EXPORT_SYMBOL(pcmcia_disable_device);
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 12ec94d6ef14..0c196fbb3121 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -89,7 +89,7 @@ MODULE_LICENSE("Dual MPL/GPL");
89/*====================================================================*/ 89/*====================================================================*/
90 90
91typedef struct scsi_info_t { 91typedef struct scsi_info_t {
92 dev_link_t link; 92 struct pcmcia_device *p_dev;
93 dev_node_t node; 93 dev_node_t node;
94 struct Scsi_Host *host; 94 struct Scsi_Host *host;
95} scsi_info_t; 95} scsi_info_t;
@@ -103,7 +103,7 @@ static dev_link_t *dev_list;
103static int aha152x_attach(struct pcmcia_device *p_dev) 103static int aha152x_attach(struct pcmcia_device *p_dev)
104{ 104{
105 scsi_info_t *info; 105 scsi_info_t *info;
106 dev_link_t *link; 106 dev_link_t *link = dev_to_instance(p_dev);
107 107
108 DEBUG(0, "aha152x_attach()\n"); 108 DEBUG(0, "aha152x_attach()\n");
109 109
@@ -111,7 +111,8 @@ static int aha152x_attach(struct pcmcia_device *p_dev)
111 info = kmalloc(sizeof(*info), GFP_KERNEL); 111 info = kmalloc(sizeof(*info), GFP_KERNEL);
112 if (!info) return -ENOMEM; 112 if (!info) return -ENOMEM;
113 memset(info, 0, sizeof(*info)); 113 memset(info, 0, sizeof(*info));
114 link = &info->link; link->priv = info; 114 info->p_dev = p_dev;
115 link->priv = info;
115 116
116 link->io.NumPorts1 = 0x20; 117 link->io.NumPorts1 = 0x20;
117 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 118 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -122,9 +123,6 @@ static int aha152x_attach(struct pcmcia_device *p_dev)
122 link->conf.IntType = INT_MEMORY_AND_IO; 123 link->conf.IntType = INT_MEMORY_AND_IO;
123 link->conf.Present = PRESENT_OPTION; 124 link->conf.Present = PRESENT_OPTION;
124 125
125 link->handle = p_dev;
126 p_dev->instance = link;
127
128 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 126 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
129 aha152x_config_cs(link); 127 aha152x_config_cs(link);
130 128
@@ -136,23 +134,14 @@ static int aha152x_attach(struct pcmcia_device *p_dev)
136static void aha152x_detach(struct pcmcia_device *p_dev) 134static void aha152x_detach(struct pcmcia_device *p_dev)
137{ 135{
138 dev_link_t *link = dev_to_instance(p_dev); 136 dev_link_t *link = dev_to_instance(p_dev);
139 dev_link_t **linkp;
140 137
141 DEBUG(0, "aha152x_detach(0x%p)\n", link); 138 DEBUG(0, "aha152x_detach(0x%p)\n", link);
142
143 /* Locate device structure */
144 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
145 if (*linkp == link) break;
146 if (*linkp == NULL)
147 return;
148 139
149 if (link->state & DEV_CONFIG) 140 if (link->state & DEV_CONFIG)
150 aha152x_release_cs(link); 141 aha152x_release_cs(link);
151 142
152 /* Unlink device structure, free bits */ 143 /* Unlink device structure, free bits */
153 *linkp = link->next;
154 kfree(link->priv); 144 kfree(link->priv);
155
156} /* aha152x_detach */ 145} /* aha152x_detach */
157 146
158/*====================================================================*/ 147/*====================================================================*/
@@ -230,7 +219,7 @@ static void aha152x_config_cs(dev_link_t *link)
230 } 219 }
231 220
232 sprintf(info->node.dev_name, "scsi%d", host->host_no); 221 sprintf(info->node.dev_name, "scsi%d", host->host_no);
233 link->dev = &info->node; 222 link->dev_node = &info->node;
234 info->host = host; 223 info->host = host;
235 224
236 link->state &= ~DEV_CONFIG_PENDING; 225 link->state &= ~DEV_CONFIG_PENDING;
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index b3cd206ad652..94dcee9f285a 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -73,7 +73,7 @@ static char *version =
73/*====================================================================*/ 73/*====================================================================*/
74 74
75typedef struct scsi_info_t { 75typedef struct scsi_info_t {
76 dev_link_t link; 76 struct pcmcia_device *p_dev;
77 dev_node_t node; 77 dev_node_t node;
78 struct Scsi_Host *host; 78 struct Scsi_Host *host;
79} scsi_info_t; 79} scsi_info_t;
@@ -86,7 +86,7 @@ static void fdomain_config(dev_link_t *link);
86static int fdomain_attach(struct pcmcia_device *p_dev) 86static int fdomain_attach(struct pcmcia_device *p_dev)
87{ 87{
88 scsi_info_t *info; 88 scsi_info_t *info;
89 dev_link_t *link; 89 dev_link_t *link = dev_to_instance(p_dev);
90 90
91 DEBUG(0, "fdomain_attach()\n"); 91 DEBUG(0, "fdomain_attach()\n");
92 92
@@ -94,7 +94,8 @@ static int fdomain_attach(struct pcmcia_device *p_dev)
94 info = kmalloc(sizeof(*info), GFP_KERNEL); 94 info = kmalloc(sizeof(*info), GFP_KERNEL);
95 if (!info) return -ENOMEM; 95 if (!info) return -ENOMEM;
96 memset(info, 0, sizeof(*info)); 96 memset(info, 0, sizeof(*info));
97 link = &info->link; link->priv = info; 97 info->p_dev = p_dev;
98 link->priv = info;
98 link->io.NumPorts1 = 0x10; 99 link->io.NumPorts1 = 0x10;
99 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 100 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
100 link->io.IOAddrLines = 10; 101 link->io.IOAddrLines = 10;
@@ -104,9 +105,6 @@ static int fdomain_attach(struct pcmcia_device *p_dev)
104 link->conf.IntType = INT_MEMORY_AND_IO; 105 link->conf.IntType = INT_MEMORY_AND_IO;
105 link->conf.Present = PRESENT_OPTION; 106 link->conf.Present = PRESENT_OPTION;
106 107
107 link->handle = p_dev;
108 p_dev->instance = link;
109
110 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 108 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
111 fdomain_config(link); 109 fdomain_config(link);
112 110
@@ -191,7 +189,7 @@ static void fdomain_config(dev_link_t *link)
191 scsi_scan_host(host); 189 scsi_scan_host(host);
192 190
193 sprintf(info->node.dev_name, "scsi%d", host->host_no); 191 sprintf(info->node.dev_name, "scsi%d", host->host_no);
194 link->dev = &info->node; 192 link->dev_node = &info->node;
195 info->host = host; 193 info->host = host;
196 194
197 link->state &= ~DEV_CONFIG_PENDING; 195 link->state &= ~DEV_CONFIG_PENDING;
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index e41e1febe895..23548fbf4898 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1596,8 +1596,8 @@ static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt)
1596static int nsp_cs_attach(struct pcmcia_device *p_dev) 1596static int nsp_cs_attach(struct pcmcia_device *p_dev)
1597{ 1597{
1598 scsi_info_t *info; 1598 scsi_info_t *info;
1599 dev_link_t *link;
1600 nsp_hw_data *data = &nsp_data_base; 1599 nsp_hw_data *data = &nsp_data_base;
1600 dev_link_t *link = dev_to_instance(p_dev);
1601 1601
1602 nsp_dbg(NSP_DEBUG_INIT, "in"); 1602 nsp_dbg(NSP_DEBUG_INIT, "in");
1603 1603
@@ -1605,7 +1605,7 @@ static int nsp_cs_attach(struct pcmcia_device *p_dev)
1605 info = kmalloc(sizeof(*info), GFP_KERNEL); 1605 info = kmalloc(sizeof(*info), GFP_KERNEL);
1606 if (info == NULL) { return -ENOMEM; } 1606 if (info == NULL) { return -ENOMEM; }
1607 memset(info, 0, sizeof(*info)); 1607 memset(info, 0, sizeof(*info));
1608 link = &info->link; 1608 info->p_dev = p_dev;
1609 link->priv = info; 1609 link->priv = info;
1610 data->ScsiInfo = info; 1610 data->ScsiInfo = info;
1611 1611
@@ -1630,9 +1630,6 @@ static int nsp_cs_attach(struct pcmcia_device *p_dev)
1630 link->conf.IntType = INT_MEMORY_AND_IO; 1630 link->conf.IntType = INT_MEMORY_AND_IO;
1631 link->conf.Present = PRESENT_OPTION; 1631 link->conf.Present = PRESENT_OPTION;
1632 1632
1633 link->handle = p_dev;
1634 p_dev->instance = link;
1635
1636 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1633 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1637 nsp_cs_config(link); 1634 nsp_cs_config(link);
1638 1635
@@ -1853,12 +1850,12 @@ static void nsp_cs_config(dev_link_t *link)
1853 scsi_scan_host(host); 1850 scsi_scan_host(host);
1854 1851
1855 snprintf(info->node.dev_name, sizeof(info->node.dev_name), "scsi%d", host->host_no); 1852 snprintf(info->node.dev_name, sizeof(info->node.dev_name), "scsi%d", host->host_no);
1856 link->dev = &info->node; 1853 link->dev_node = &info->node;
1857 info->host = host; 1854 info->host = host;
1858 1855
1859#else 1856#else
1860 nsp_dbg(NSP_DEBUG_INIT, "GET_SCSI_INFO"); 1857 nsp_dbg(NSP_DEBUG_INIT, "GET_SCSI_INFO");
1861 tail = &link->dev; 1858 tail = &link->dev_node;
1862 info->ndev = 0; 1859 info->ndev = 0;
1863 1860
1864 nsp_dbg(NSP_DEBUG_INIT, "host=0x%p", host); 1861 nsp_dbg(NSP_DEBUG_INIT, "host=0x%p", host);
@@ -1962,7 +1959,7 @@ static void nsp_cs_release(dev_link_t *link)
1962#else 1959#else
1963 scsi_unregister_host(&nsp_driver_template); 1960 scsi_unregister_host(&nsp_driver_template);
1964#endif 1961#endif
1965 link->dev = NULL; 1962 link->dev_node = NULL;
1966 1963
1967 if (link->win) { 1964 if (link->win) {
1968 if (data != NULL) { 1965 if (data != NULL) {
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index b66b140a745e..2e1fde467c27 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -225,7 +225,7 @@
225/*====================================================================*/ 225/*====================================================================*/
226 226
227typedef struct scsi_info_t { 227typedef struct scsi_info_t {
228 dev_link_t link; 228 struct pcmcia_device *p_dev;
229 struct Scsi_Host *host; 229 struct Scsi_Host *host;
230#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)) 230#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74))
231 dev_node_t node; 231 dev_node_t node;
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 4f28589bbf34..c6b3e9587ff3 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -91,7 +91,7 @@ static struct scsi_host_template qlogicfas_driver_template = {
91/*====================================================================*/ 91/*====================================================================*/
92 92
93typedef struct scsi_info_t { 93typedef struct scsi_info_t {
94 dev_link_t link; 94 struct pcmcia_device *p_dev;
95 dev_node_t node; 95 dev_node_t node;
96 struct Scsi_Host *host; 96 struct Scsi_Host *host;
97 unsigned short manf_id; 97 unsigned short manf_id;
@@ -159,7 +159,7 @@ err:
159static int qlogic_attach(struct pcmcia_device *p_dev) 159static int qlogic_attach(struct pcmcia_device *p_dev)
160{ 160{
161 scsi_info_t *info; 161 scsi_info_t *info;
162 dev_link_t *link; 162 dev_link_t *link = dev_to_instance(p_dev);
163 163
164 DEBUG(0, "qlogic_attach()\n"); 164 DEBUG(0, "qlogic_attach()\n");
165 165
@@ -168,7 +168,7 @@ static int qlogic_attach(struct pcmcia_device *p_dev)
168 if (!info) 168 if (!info)
169 return -ENOMEM; 169 return -ENOMEM;
170 memset(info, 0, sizeof(*info)); 170 memset(info, 0, sizeof(*info));
171 link = &info->link; 171 info->p_dev = p_dev;
172 link->priv = info; 172 link->priv = info;
173 link->io.NumPorts1 = 16; 173 link->io.NumPorts1 = 16;
174 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 174 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -179,9 +179,6 @@ static int qlogic_attach(struct pcmcia_device *p_dev)
179 link->conf.IntType = INT_MEMORY_AND_IO; 179 link->conf.IntType = INT_MEMORY_AND_IO;
180 link->conf.Present = PRESENT_OPTION; 180 link->conf.Present = PRESENT_OPTION;
181 181
182 link->handle = p_dev;
183 p_dev->instance = link;
184
185 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 182 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
186 qlogic_config(link); 183 qlogic_config(link);
187 184
@@ -278,7 +275,7 @@ static void qlogic_config(dev_link_t * link)
278 } 275 }
279 276
280 sprintf(info->node.dev_name, "scsi%d", host->host_no); 277 sprintf(info->node.dev_name, "scsi%d", host->host_no);
281 link->dev = &info->node; 278 link->dev_node = &info->node;
282 info->host = host; 279 info->host = host;
283 280
284out: 281out:
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 2bce7b070a4e..1ef3109418c9 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -202,7 +202,7 @@ static char *version =
202/* ================================================================== */ 202/* ================================================================== */
203 203
204struct scsi_info_t { 204struct scsi_info_t {
205 dev_link_t link; 205 struct pcmcia_device *p_dev;
206 dev_node_t node; 206 dev_node_t node;
207 struct Scsi_Host *host; 207 struct Scsi_Host *host;
208 unsigned short manf_id; 208 unsigned short manf_id;
@@ -829,7 +829,7 @@ next_entry:
829 data->fast_pio = USE_FAST_PIO; 829 data->fast_pio = USE_FAST_PIO;
830 830
831 sprintf(info->node.dev_name, "scsi%d", host->host_no); 831 sprintf(info->node.dev_name, "scsi%d", host->host_no);
832 link->dev = &info->node; 832 link->dev_node = &info->node;
833 info->host = host; 833 info->host = host;
834 834
835 if (scsi_add_host(host, NULL)) 835 if (scsi_add_host(host, NULL))
@@ -899,7 +899,7 @@ static int
899SYM53C500_attach(struct pcmcia_device *p_dev) 899SYM53C500_attach(struct pcmcia_device *p_dev)
900{ 900{
901 struct scsi_info_t *info; 901 struct scsi_info_t *info;
902 dev_link_t *link; 902 dev_link_t *link = dev_to_instance(p_dev);
903 903
904 DEBUG(0, "SYM53C500_attach()\n"); 904 DEBUG(0, "SYM53C500_attach()\n");
905 905
@@ -908,7 +908,7 @@ SYM53C500_attach(struct pcmcia_device *p_dev)
908 if (!info) 908 if (!info)
909 return -ENOMEM; 909 return -ENOMEM;
910 memset(info, 0, sizeof(*info)); 910 memset(info, 0, sizeof(*info));
911 link = &info->link; 911 info->p_dev = p_dev;
912 link->priv = info; 912 link->priv = info;
913 link->io.NumPorts1 = 16; 913 link->io.NumPorts1 = 16;
914 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 914 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -919,9 +919,6 @@ SYM53C500_attach(struct pcmcia_device *p_dev)
919 link->conf.IntType = INT_MEMORY_AND_IO; 919 link->conf.IntType = INT_MEMORY_AND_IO;
920 link->conf.Present = PRESENT_OPTION; 920 link->conf.Present = PRESENT_OPTION;
921 921
922 link->handle = p_dev;
923 p_dev->instance = link;
924
925 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 922 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
926 SYM53C500_config(link); 923 SYM53C500_config(link);
927 924
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 1e6889f52b38..6bcde2c7b159 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -97,7 +97,7 @@ static const struct multi_id multi_id[] = {
97#define MULTI_COUNT (sizeof(multi_id)/sizeof(struct multi_id)) 97#define MULTI_COUNT (sizeof(multi_id)/sizeof(struct multi_id))
98 98
99struct serial_info { 99struct serial_info {
100 dev_link_t link; 100 struct pcmcia_device *p_dev;
101 int ndev; 101 int ndev;
102 int multi; 102 int multi;
103 int slave; 103 int slave;
@@ -135,16 +135,16 @@ static void serial_remove(dev_link_t *link)
135 /* 135 /*
136 * Recheck to see if the device is still configured. 136 * Recheck to see if the device is still configured.
137 */ 137 */
138 if (info->link.state & DEV_CONFIG) { 138 if (info->p_dev->state & DEV_CONFIG) {
139 for (i = 0; i < info->ndev; i++) 139 for (i = 0; i < info->ndev; i++)
140 serial8250_unregister_port(info->line[i]); 140 serial8250_unregister_port(info->line[i]);
141 141
142 info->link.dev = NULL; 142 info->p_dev->dev_node = NULL;
143 143
144 if (!info->slave) 144 if (!info->slave)
145 pcmcia_disable_device(link->handle); 145 pcmcia_disable_device(link->handle);
146 146
147 info->link.state &= ~DEV_CONFIG; 147 info->p_dev->state &= ~DEV_CONFIG;
148 } 148 }
149} 149}
150 150
@@ -192,7 +192,7 @@ static int serial_resume(struct pcmcia_device *dev)
192static int serial_probe(struct pcmcia_device *p_dev) 192static int serial_probe(struct pcmcia_device *p_dev)
193{ 193{
194 struct serial_info *info; 194 struct serial_info *info;
195 dev_link_t *link; 195 dev_link_t *link = dev_to_instance(p_dev);
196 196
197 DEBUG(0, "serial_attach()\n"); 197 DEBUG(0, "serial_attach()\n");
198 198
@@ -201,7 +201,7 @@ static int serial_probe(struct pcmcia_device *p_dev)
201 if (!info) 201 if (!info)
202 return -ENOMEM; 202 return -ENOMEM;
203 memset(info, 0, sizeof (*info)); 203 memset(info, 0, sizeof (*info));
204 link = &info->link; 204 info->p_dev = p_dev;
205 link->priv = info; 205 link->priv = info;
206 206
207 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 207 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -215,8 +215,6 @@ static int serial_probe(struct pcmcia_device *p_dev)
215 } 215 }
216 link->conf.IntType = INT_MEMORY_AND_IO; 216 link->conf.IntType = INT_MEMORY_AND_IO;
217 217
218 link->handle = p_dev;
219 p_dev->instance = link;
220 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 218 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
221 serial_config(link); 219 serial_config(link);
222 220
@@ -660,7 +658,7 @@ void serial_config(dev_link_t * link)
660 } 658 }
661 } 659 }
662 660
663 link->dev = &info->node[0]; 661 link->dev_node = &info->node[0];
664 link->state &= ~DEV_CONFIG_PENDING; 662 link->state &= ~DEV_CONFIG_PENDING;
665 kfree(cfg_mem); 663 kfree(cfg_mem);
666 return; 664 return;
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index de794b21d7ff..0afd6c04f2f8 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -40,30 +40,20 @@ static void ixj_cs_release(dev_link_t * link);
40 40
41static int ixj_attach(struct pcmcia_device *p_dev) 41static int ixj_attach(struct pcmcia_device *p_dev)
42{ 42{
43 dev_link_t *link;
44
45 DEBUG(0, "ixj_attach()\n"); 43 DEBUG(0, "ixj_attach()\n");
46 /* Create new ixj device */ 44 /* Create new ixj device */
47 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 45 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
48 if (!link) 46 p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
49 return -ENOMEM; 47 p_dev->io.IOAddrLines = 3;
50 memset(link, 0, sizeof(struct dev_link_t)); 48 p_dev->conf.IntType = INT_MEMORY_AND_IO;
51 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 49 p_dev->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
52 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 50 if (!p_dev->priv) {
53 link->io.IOAddrLines = 3;
54 link->conf.IntType = INT_MEMORY_AND_IO;
55 link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
56 if (!link->priv) {
57 kfree(link);
58 return -ENOMEM; 51 return -ENOMEM;
59 } 52 }
60 memset(link->priv, 0, sizeof(struct ixj_info_t)); 53 memset(p_dev->priv, 0, sizeof(struct ixj_info_t));
61
62 link->handle = p_dev;
63 p_dev->instance = link;
64 54
65 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 55 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
66 ixj_config(link); 56 ixj_config(p_dev);
67 57
68 return 0; 58 return 0;
69} 59}
@@ -79,7 +69,6 @@ static void ixj_detach(struct pcmcia_device *p_dev)
79 ixj_cs_release(link); 69 ixj_cs_release(link);
80 70
81 kfree(link->priv); 71 kfree(link->priv);
82 kfree(link);
83} 72}
84 73
85#define CS_CHECK(fn, ret) \ 74#define CS_CHECK(fn, ret) \
@@ -212,7 +201,7 @@ static void ixj_config(dev_link_t * link)
212 201
213 info->ndev = 1; 202 info->ndev = 1;
214 info->node.major = PHONE_MAJOR; 203 info->node.major = PHONE_MAJOR;
215 link->dev = &info->node; 204 link->dev_node = &info->node;
216 ixj_get_serial(link, j); 205 ixj_get_serial(link, j);
217 link->state &= ~DEV_CONFIG_PENDING; 206 link->state &= ~DEV_CONFIG_PENDING;
218 return; 207 return;
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index c6f1baf541ab..8e61faa120fc 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -67,7 +67,7 @@ module_param(pc_debug, int, 0644);
67static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; 67static const char driver_name[DEV_NAME_LEN] = "sl811_cs";
68 68
69typedef struct local_info_t { 69typedef struct local_info_t {
70 dev_link_t link; 70 struct pcmcia_device *p_dev;
71 dev_node_t node; 71 dev_node_t node;
72} local_info_t; 72} local_info_t;
73 73
@@ -268,7 +268,7 @@ next_entry:
268 268
269 sprintf(dev->node.dev_name, driver_name); 269 sprintf(dev->node.dev_name, driver_name);
270 dev->node.major = dev->node.minor = 0; 270 dev->node.major = dev->node.minor = 0;
271 link->dev = &dev->node; 271 link->dev_node = &dev->node;
272 272
273 printk(KERN_INFO "%s: index 0x%02x: ", 273 printk(KERN_INFO "%s: index 0x%02x: ",
274 dev->node.dev_name, link->conf.ConfigIndex); 274 dev->node.dev_name, link->conf.ConfigIndex);
@@ -294,13 +294,13 @@ cs_failed:
294static int sl811_cs_attach(struct pcmcia_device *p_dev) 294static int sl811_cs_attach(struct pcmcia_device *p_dev)
295{ 295{
296 local_info_t *local; 296 local_info_t *local;
297 dev_link_t *link; 297 dev_link_t *link = dev_to_instance(p_dev);
298 298
299 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 299 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
300 if (!local) 300 if (!local)
301 return -ENOMEM; 301 return -ENOMEM;
302 memset(local, 0, sizeof(local_info_t)); 302 memset(local, 0, sizeof(local_info_t));
303 link = &local->link; 303 local->p_dev = p_dev;
304 link->priv = local; 304 link->priv = local;
305 305
306 /* Initialize */ 306 /* Initialize */
@@ -311,9 +311,6 @@ static int sl811_cs_attach(struct pcmcia_device *p_dev)
311 link->conf.Attributes = 0; 311 link->conf.Attributes = 0;
312 link->conf.IntType = INT_MEMORY_AND_IO; 312 link->conf.IntType = INT_MEMORY_AND_IO;
313 313
314 link->handle = p_dev;
315 p_dev->instance = link;
316
317 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 314 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
318 sl811_cs_config(link); 315 sl811_cs_config(link);
319 316
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 7f712df3e297..61f7d2dec199 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -39,7 +39,7 @@ typedef struct win_info_t {
39typedef struct bind_info_t { 39typedef struct bind_info_t {
40 dev_info_t dev_info; 40 dev_info_t dev_info;
41 u_char function; 41 u_char function;
42 struct dev_link_t *instance; 42 struct pcmcia_device *instance;
43 char name[DEV_NAME_LEN]; 43 char name[DEV_NAME_LEN];
44 u_short major, minor; 44 u_short major, minor;
45 void *next; 45 void *next;
@@ -103,18 +103,6 @@ typedef struct dev_node_t {
103 struct dev_node_t *next; 103 struct dev_node_t *next;
104} dev_node_t; 104} dev_node_t;
105 105
106typedef struct dev_link_t {
107 dev_node_t *dev;
108 u_int state, open;
109 client_handle_t handle;
110 io_req_t io;
111 irq_req_t irq;
112 config_req_t conf;
113 window_handle_t win;
114 void *priv;
115 struct dev_link_t *next;
116} dev_link_t;
117
118/* Flags for device state */ 106/* Flags for device state */
119#define DEV_PRESENT 0x01 107#define DEV_PRESENT 0x01
120#define DEV_CONFIG 0x02 108#define DEV_CONFIG 0x02
@@ -163,9 +151,17 @@ struct pcmcia_device {
163 151
164 struct list_head socket_device_list; 152 struct list_head socket_device_list;
165 153
166 /* deprecated, a cleaned up version will be moved into this 154 /* deprecated, will be cleaned up soon */
167 struct soon */ 155 dev_node_t *dev_node;
168 dev_link_t *instance; 156 u_int state;
157 u_int open;
158 struct pcmcia_device *handle;
159 io_req_t io;
160 irq_req_t irq;
161 config_req_t conf;
162 window_handle_t win;
163 void *priv;
164
169 u_int p_state; 165 u_int p_state;
170 166
171 /* information about this device */ 167 /* information about this device */
@@ -189,6 +185,7 @@ struct pcmcia_device {
189 struct pcmcia_driver * cardmgr; 185 struct pcmcia_driver * cardmgr;
190#endif 186#endif
191}; 187};
188typedef struct pcmcia_device dev_link_t;
192 189
193#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) 190#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
194#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) 191#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
@@ -196,7 +193,7 @@ struct pcmcia_device {
196#define handle_to_pdev(handle) (handle) 193#define handle_to_pdev(handle) (handle)
197#define handle_to_dev(handle) (handle->dev) 194#define handle_to_dev(handle) (handle->dev)
198 195
199#define dev_to_instance(dev) (dev->instance) 196#define dev_to_instance(dev) (dev)
200 197
201/* error reporting */ 198/* error reporting */
202void cs_error(client_handle_t handle, int func, int ret); 199void cs_error(client_handle_t handle, int func, int ret);
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index 7c4091a57b69..b4158201e9e6 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -70,7 +70,7 @@ static void pdacf_release(dev_link_t *link)
70 */ 70 */
71static int snd_pdacf_free(struct snd_pdacf *pdacf) 71static int snd_pdacf_free(struct snd_pdacf *pdacf)
72{ 72{
73 dev_link_t *link = &pdacf->link; 73 dev_link_t *link = pdacf->p_dev;
74 74
75 pdacf_release(link); 75 pdacf_release(link);
76 76
@@ -100,6 +100,8 @@ static int snd_pdacf_attach(struct pcmcia_device *p_dev)
100 .dev_free = snd_pdacf_dev_free, 100 .dev_free = snd_pdacf_dev_free,
101 }; 101 };
102 102
103 link = dev_to_instance(p_dev);
104
103 snd_printdd(KERN_DEBUG "pdacf_attach called\n"); 105 snd_printdd(KERN_DEBUG "pdacf_attach called\n");
104 /* find an empty slot from the card list */ 106 /* find an empty slot from the card list */
105 for (i = 0; i < SNDRV_CARDS; i++) { 107 for (i = 0; i < SNDRV_CARDS; i++) {
@@ -133,7 +135,7 @@ static int snd_pdacf_attach(struct pcmcia_device *p_dev)
133 pdacf->index = i; 135 pdacf->index = i;
134 card_list[i] = card; 136 card_list[i] = card;
135 137
136 link = &pdacf->link; 138 pdacf->p_dev = p_dev;
137 link->priv = pdacf; 139 link->priv = pdacf;
138 140
139 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 141 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -150,10 +152,6 @@ static int snd_pdacf_attach(struct pcmcia_device *p_dev)
150 link->conf.ConfigIndex = 1; 152 link->conf.ConfigIndex = 1;
151 link->conf.Present = PRESENT_OPTION; 153 link->conf.Present = PRESENT_OPTION;
152 154
153 /* Chain drivers */
154 link->next = NULL;
155
156 link->handle = p_dev;
157 pdacf_config(link); 155 pdacf_config(link);
158 156
159 return 0; 157 return 0;
@@ -262,7 +260,7 @@ static void pdacf_config(dev_link_t *link)
262 if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0) 260 if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
263 goto failed; 261 goto failed;
264 262
265 link->dev = &pdacf->node; 263 link->dev_node = &pdacf->node;
266 link->state &= ~DEV_CONFIG_PENDING; 264 link->state &= ~DEV_CONFIG_PENDING;
267 return; 265 return;
268 266
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h
index 2744f189a613..9a14a4f64bd3 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.h
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h
@@ -116,7 +116,7 @@ struct snd_pdacf {
116 void *pcm_area; 116 void *pcm_area;
117 117
118 /* pcmcia stuff */ 118 /* pcmcia stuff */
119 dev_link_t link; 119 struct pcmcia_device *p_dev;
120 dev_node_t node; 120 dev_node_t node;
121}; 121};
122 122
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index ff2f927559fc..87ec48c6af28 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -126,7 +126,8 @@ static struct snd_vx_hardware vxp440_hw = {
126/* 126/*
127 * create vxpocket instance 127 * create vxpocket instance
128 */ 128 */
129static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) 129static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl,
130 struct pcmcia_device *p_dev)
130{ 131{
131 dev_link_t *link; /* Info for cardmgr */ 132 dev_link_t *link; /* Info for cardmgr */
132 struct vx_core *chip; 133 struct vx_core *chip;
@@ -135,6 +136,8 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl)
135 .dev_free = snd_vxpocket_dev_free, 136 .dev_free = snd_vxpocket_dev_free,
136 }; 137 };
137 138
139 link = dev_to_instance(p_dev);
140
138 chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops, 141 chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops,
139 sizeof(struct snd_vxpocket) - sizeof(struct vx_core)); 142 sizeof(struct snd_vxpocket) - sizeof(struct vx_core));
140 if (! chip) 143 if (! chip)
@@ -148,7 +151,7 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl)
148 151
149 vxp = (struct snd_vxpocket *)chip; 152 vxp = (struct snd_vxpocket *)chip;
150 153
151 link = &vxp->link; 154 vxp->p_dev = p_dev;
152 link->priv = chip; 155 link->priv = chip;
153 156
154 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 157 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -263,7 +266,7 @@ static void vxpocket_config(dev_link_t *link)
263 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0) 266 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
264 goto failed; 267 goto failed;
265 268
266 link->dev = &vxp->node; 269 link->dev_node = &vxp->node;
267 link->state &= ~DEV_CONFIG_PENDING; 270 link->state &= ~DEV_CONFIG_PENDING;
268 kfree(parse); 271 kfree(parse);
269 return; 272 return;
@@ -339,7 +342,7 @@ static int vxpocket_attach(struct pcmcia_device *p_dev)
339 return -ENOMEM; 342 return -ENOMEM;
340 } 343 }
341 344
342 vxp = snd_vxpocket_new(card, ibl[i]); 345 vxp = snd_vxpocket_new(card, ibl[i], p_dev);
343 if (! vxp) { 346 if (! vxp) {
344 snd_card_free(card); 347 snd_card_free(card);
345 return -ENODEV; 348 return -ENODEV;
@@ -349,13 +352,10 @@ static int vxpocket_attach(struct pcmcia_device *p_dev)
349 vxp->index = i; 352 vxp->index = i;
350 card_alloc |= 1 << i; 353 card_alloc |= 1 << i;
351 354
352 /* Chain drivers */ 355 vxp->p_dev = p_dev;
353 vxp->link.next = NULL; 356 vxp->p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
354 357
355 vxp->link.handle = p_dev; 358 vxpocket_config(p_dev);
356 vxp->link.state |= DEV_PRESENT | DEV_CONFIG_PENDING;
357 p_dev->instance = &vxp->link;
358 vxpocket_config(&vxp->link);
359 359
360 return 0; 360 return 0;
361} 361}
diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h
index 67efae3f6c8d..27ea002294c0 100644
--- a/sound/pcmcia/vx/vxpocket.h
+++ b/sound/pcmcia/vx/vxpocket.h
@@ -42,7 +42,7 @@ struct snd_vxpocket {
42 int index; /* card index */ 42 int index; /* card index */
43 43
44 /* pcmcia stuff */ 44 /* pcmcia stuff */
45 dev_link_t link; 45 struct pcmcia_device *p_dev;
46 dev_node_t node; 46 dev_node_t node;
47}; 47};
48 48