aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/pcmcia/driver-changes.txt6
-rw-r--r--drivers/bluetooth/bluecard_cs.c46
-rw-r--r--drivers/bluetooth/bt3c_cs.c45
-rw-r--r--drivers/bluetooth/btuart_cs.c46
-rw-r--r--drivers/bluetooth/dtl1_cs.c45
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c68
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c67
-rw-r--r--drivers/char/pcmcia/synclink_cs.c49
-rw-r--r--drivers/ide/legacy/ide-cs.c56
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c56
-rw-r--r--drivers/isdn/hisax/avma1_cs.c70
-rw-r--r--drivers/isdn/hisax/elsa_cs.c78
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c75
-rw-r--r--drivers/isdn/hisax/teles_cs.c67
-rw-r--r--drivers/mtd/maps/pcmciamtd.c54
-rw-r--r--drivers/net/pcmcia/3c574_cs.c55
-rw-r--r--drivers/net/pcmcia/3c589_cs.c63
-rw-r--r--drivers/net/pcmcia/axnet_cs.c59
-rw-r--r--drivers/net/pcmcia/com20020_cs.c59
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c54
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c69
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c57
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c45
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c57
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c67
-rw-r--r--drivers/net/wireless/airo_cs.c74
-rw-r--r--drivers/net/wireless/atmel_cs.c80
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c55
-rw-r--r--drivers/net/wireless/netwave_cs.c68
-rw-r--r--drivers/net/wireless/orinoco_cs.c58
-rw-r--r--drivers/net/wireless/ray_cs.c68
-rw-r--r--drivers/net/wireless/spectrum_cs.c63
-rw-r--r--drivers/net/wireless/wavelan_cs.c84
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h8
-rw-r--r--drivers/net/wireless/wl3501_cs.c60
-rw-r--r--drivers/parport/parport_cs.c61
-rw-r--r--drivers/pcmcia/ds.c177
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c52
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c56
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c67
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h2
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c49
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c53
-rw-r--r--drivers/serial/serial_cs.c58
-rw-r--r--drivers/telephony/ixj_pcmcia.c48
-rw-r--r--drivers/usb/host/sl811_cs.c44
-rw-r--r--include/pcmcia/cs.h1
-rw-r--r--include/pcmcia/ds.h6
48 files changed, 472 insertions, 2233 deletions
diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt
index 45c25c7a3445..97420f08c786 100644
--- a/Documentation/pcmcia/driver-changes.txt
+++ b/Documentation/pcmcia/driver-changes.txt
@@ -1,7 +1,9 @@
1This file details changes in 2.6 which affect PCMCIA card driver authors: 1This file details changes in 2.6 which affect PCMCIA card driver authors:
2 2
3* Unify detach and REMOVAL event code (as of 2.6.16) 3* Unify detach and REMOVAL event code, as well as attach and INSERTION
4 void (*remove) (struct pcmcia_device *dev); 4 code (as of 2.6.16)
5 void (*remove) (struct pcmcia_device *dev);
6 int (*probe) (struct pcmcia_device *dev);
5 7
6* Move suspend, resume and reset out of event handler (as of 2.6.16) 8* Move suspend, resume and reset out of event handler (as of 2.6.16)
7 int (*suspend) (struct pcmcia_device *dev); 9 int (*suspend) (struct pcmcia_device *dev);
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index bd80535646fa..9888bc151755 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -87,11 +87,7 @@ typedef struct bluecard_info_t {
87 87
88static void bluecard_config(dev_link_t *link); 88static void bluecard_config(dev_link_t *link);
89static void bluecard_release(dev_link_t *link); 89static void bluecard_release(dev_link_t *link);
90static int bluecard_event(event_t event, int priority, event_callback_args_t *args);
91 90
92static dev_info_t dev_info = "bluecard_cs";
93
94static dev_link_t *bluecard_attach(void);
95static void bluecard_detach(struct pcmcia_device *p_dev); 91static void bluecard_detach(struct pcmcia_device *p_dev);
96 92
97 93
@@ -860,17 +856,15 @@ static int bluecard_close(bluecard_info_t *info)
860 return 0; 856 return 0;
861} 857}
862 858
863static dev_link_t *bluecard_attach(void) 859static int bluecard_attach(struct pcmcia_device *p_dev)
864{ 860{
865 bluecard_info_t *info; 861 bluecard_info_t *info;
866 client_reg_t client_reg;
867 dev_link_t *link; 862 dev_link_t *link;
868 int ret;
869 863
870 /* Create new info device */ 864 /* Create new info device */
871 info = kzalloc(sizeof(*info), GFP_KERNEL); 865 info = kzalloc(sizeof(*info), GFP_KERNEL);
872 if (!info) 866 if (!info)
873 return NULL; 867 return -ENOMEM;
874 868
875 link = &info->link; 869 link = &info->link;
876 link->priv = info; 870 link->priv = info;
@@ -887,20 +881,13 @@ static dev_link_t *bluecard_attach(void)
887 link->conf.Vcc = 50; 881 link->conf.Vcc = 50;
888 link->conf.IntType = INT_MEMORY_AND_IO; 882 link->conf.IntType = INT_MEMORY_AND_IO;
889 883
890 /* Register with Card Services */ 884 link->handle = p_dev;
891 link->next = NULL; 885 p_dev->instance = link;
892 client_reg.dev_info = &dev_info; 886
893 client_reg.Version = 0x0210; 887 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
894 client_reg.event_callback_args.client_data = link; 888 bluecard_config(link);
895
896 ret = pcmcia_register_client(&link->handle, &client_reg);
897 if (ret != CS_SUCCESS) {
898 cs_error(link->handle, RegisterClient, ret);
899 bluecard_detach(link->handle);
900 return NULL;
901 }
902 889
903 return link; 890 return 0;
904} 891}
905 892
906 893
@@ -1046,20 +1033,6 @@ static int bluecard_resume(struct pcmcia_device *dev)
1046 return 0; 1033 return 0;
1047} 1034}
1048 1035
1049static int bluecard_event(event_t event, int priority, event_callback_args_t *args)
1050{
1051 dev_link_t *link = args->client_data;
1052
1053 switch (event) {
1054 case CS_EVENT_CARD_INSERTION:
1055 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1056 bluecard_config(link);
1057 break;
1058 }
1059
1060 return 0;
1061}
1062
1063static struct pcmcia_device_id bluecard_ids[] = { 1036static struct pcmcia_device_id bluecard_ids[] = {
1064 PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e), 1037 PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e),
1065 PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c), 1038 PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c),
@@ -1073,8 +1046,7 @@ static struct pcmcia_driver bluecard_driver = {
1073 .drv = { 1046 .drv = {
1074 .name = "bluecard_cs", 1047 .name = "bluecard_cs",
1075 }, 1048 },
1076 .attach = bluecard_attach, 1049 .probe = bluecard_attach,
1077 .event = bluecard_event,
1078 .remove = bluecard_detach, 1050 .remove = bluecard_detach,
1079 .id_table = bluecard_ids, 1051 .id_table = bluecard_ids,
1080 .suspend = bluecard_suspend, 1052 .suspend = bluecard_suspend,
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 50aa52b3cd20..e522d19ad886 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -90,11 +90,7 @@ typedef struct bt3c_info_t {
90 90
91static void bt3c_config(dev_link_t *link); 91static void bt3c_config(dev_link_t *link);
92static void bt3c_release(dev_link_t *link); 92static void bt3c_release(dev_link_t *link);
93static int bt3c_event(event_t event, int priority, event_callback_args_t *args);
94 93
95static dev_info_t dev_info = "bt3c_cs";
96
97static dev_link_t *bt3c_attach(void);
98static void bt3c_detach(struct pcmcia_device *p_dev); 94static void bt3c_detach(struct pcmcia_device *p_dev);
99 95
100 96
@@ -661,17 +657,15 @@ static int bt3c_close(bt3c_info_t *info)
661 return 0; 657 return 0;
662} 658}
663 659
664static dev_link_t *bt3c_attach(void) 660static int bt3c_attach(struct pcmcia_device *p_dev)
665{ 661{
666 bt3c_info_t *info; 662 bt3c_info_t *info;
667 client_reg_t client_reg;
668 dev_link_t *link; 663 dev_link_t *link;
669 int ret;
670 664
671 /* Create new info device */ 665 /* Create new info device */
672 info = kzalloc(sizeof(*info), GFP_KERNEL); 666 info = kzalloc(sizeof(*info), GFP_KERNEL);
673 if (!info) 667 if (!info)
674 return NULL; 668 return -ENOMEM;
675 669
676 link = &info->link; 670 link = &info->link;
677 link->priv = info; 671 link->priv = info;
@@ -688,20 +682,13 @@ static dev_link_t *bt3c_attach(void)
688 link->conf.Vcc = 50; 682 link->conf.Vcc = 50;
689 link->conf.IntType = INT_MEMORY_AND_IO; 683 link->conf.IntType = INT_MEMORY_AND_IO;
690 684
691 /* Register with Card Services */ 685 link->handle = p_dev;
692 link->next = NULL; 686 p_dev->instance = link;
693 client_reg.dev_info = &dev_info;
694 client_reg.Version = 0x0210;
695 client_reg.event_callback_args.client_data = link;
696
697 ret = pcmcia_register_client(&link->handle, &client_reg);
698 if (ret != CS_SUCCESS) {
699 cs_error(link->handle, RegisterClient, ret);
700 bt3c_detach(link->handle);
701 return NULL;
702 }
703 687
704 return link; 688 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
689 bt3c_config(link);
690
691 return 0;
705} 692}
706 693
707 694
@@ -892,19 +879,6 @@ static int bt3c_resume(struct pcmcia_device *dev)
892 return 0; 879 return 0;
893} 880}
894 881
895static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
896{
897 dev_link_t *link = args->client_data;
898
899 switch (event) {
900 case CS_EVENT_CARD_INSERTION:
901 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
902 bt3c_config(link);
903 break;
904 }
905
906 return 0;
907}
908 882
909static struct pcmcia_device_id bt3c_ids[] = { 883static struct pcmcia_device_id bt3c_ids[] = {
910 PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02), 884 PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02),
@@ -917,8 +891,7 @@ static struct pcmcia_driver bt3c_driver = {
917 .drv = { 891 .drv = {
918 .name = "bt3c_cs", 892 .name = "bt3c_cs",
919 }, 893 },
920 .attach = bt3c_attach, 894 .probe = bt3c_attach,
921 .event = bt3c_event,
922 .remove = bt3c_detach, 895 .remove = bt3c_detach,
923 .id_table = bt3c_ids, 896 .id_table = bt3c_ids,
924 .suspend = bt3c_suspend, 897 .suspend = bt3c_suspend,
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 7b04f89f7a71..7b4bff4cfa2d 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -86,11 +86,7 @@ typedef struct btuart_info_t {
86 86
87static void btuart_config(dev_link_t *link); 87static void btuart_config(dev_link_t *link);
88static void btuart_release(dev_link_t *link); 88static void btuart_release(dev_link_t *link);
89static int btuart_event(event_t event, int priority, event_callback_args_t *args);
90 89
91static dev_info_t dev_info = "btuart_cs";
92
93static dev_link_t *btuart_attach(void);
94static void btuart_detach(struct pcmcia_device *p_dev); 90static void btuart_detach(struct pcmcia_device *p_dev);
95 91
96 92
@@ -580,17 +576,15 @@ static int btuart_close(btuart_info_t *info)
580 return 0; 576 return 0;
581} 577}
582 578
583static dev_link_t *btuart_attach(void) 579static int btuart_attach(struct pcmcia_device *p_dev)
584{ 580{
585 btuart_info_t *info; 581 btuart_info_t *info;
586 client_reg_t client_reg;
587 dev_link_t *link; 582 dev_link_t *link;
588 int ret;
589 583
590 /* Create new info device */ 584 /* Create new info device */
591 info = kzalloc(sizeof(*info), GFP_KERNEL); 585 info = kzalloc(sizeof(*info), GFP_KERNEL);
592 if (!info) 586 if (!info)
593 return NULL; 587 return -ENOMEM;
594 588
595 link = &info->link; 589 link = &info->link;
596 link->priv = info; 590 link->priv = info;
@@ -607,20 +601,13 @@ static dev_link_t *btuart_attach(void)
607 link->conf.Vcc = 50; 601 link->conf.Vcc = 50;
608 link->conf.IntType = INT_MEMORY_AND_IO; 602 link->conf.IntType = INT_MEMORY_AND_IO;
609 603
610 /* Register with Card Services */ 604 link->handle = p_dev;
611 link->next = NULL; 605 p_dev->instance = link;
612 client_reg.dev_info = &dev_info; 606
613 client_reg.Version = 0x0210; 607 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
614 client_reg.event_callback_args.client_data = link; 608 btuart_config(link);
615
616 ret = pcmcia_register_client(&link->handle, &client_reg);
617 if (ret != CS_SUCCESS) {
618 cs_error(link->handle, RegisterClient, ret);
619 btuart_detach(link->handle);
620 return NULL;
621 }
622 609
623 return link; 610 return 0;
624} 611}
625 612
626 613
@@ -813,20 +800,6 @@ static int btuart_resume(struct pcmcia_device *dev)
813} 800}
814 801
815 802
816static int btuart_event(event_t event, int priority, event_callback_args_t *args)
817{
818 dev_link_t *link = args->client_data;
819
820 switch (event) {
821 case CS_EVENT_CARD_INSERTION:
822 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
823 btuart_config(link);
824 break;
825 }
826
827 return 0;
828}
829
830static struct pcmcia_device_id btuart_ids[] = { 803static struct pcmcia_device_id btuart_ids[] = {
831 /* don't use this driver. Use serial_cs + hci_uart instead */ 804 /* don't use this driver. Use serial_cs + hci_uart instead */
832 PCMCIA_DEVICE_NULL 805 PCMCIA_DEVICE_NULL
@@ -838,8 +811,7 @@ static struct pcmcia_driver btuart_driver = {
838 .drv = { 811 .drv = {
839 .name = "btuart_cs", 812 .name = "btuart_cs",
840 }, 813 },
841 .attach = btuart_attach, 814 .probe = btuart_attach,
842 .event = btuart_event,
843 .remove = btuart_detach, 815 .remove = btuart_detach,
844 .id_table = btuart_ids, 816 .id_table = btuart_ids,
845 .suspend = btuart_suspend, 817 .suspend = btuart_suspend,
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index c39d4576cfff..787c5eb9950e 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -89,11 +89,7 @@ typedef struct dtl1_info_t {
89 89
90static void dtl1_config(dev_link_t *link); 90static void dtl1_config(dev_link_t *link);
91static void dtl1_release(dev_link_t *link); 91static void dtl1_release(dev_link_t *link);
92static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
93 92
94static dev_info_t dev_info = "dtl1_cs";
95
96static dev_link_t *dtl1_attach(void);
97static void dtl1_detach(struct pcmcia_device *p_dev); 93static void dtl1_detach(struct pcmcia_device *p_dev);
98 94
99 95
@@ -559,17 +555,15 @@ static int dtl1_close(dtl1_info_t *info)
559 return 0; 555 return 0;
560} 556}
561 557
562static dev_link_t *dtl1_attach(void) 558static int dtl1_attach(struct pcmcia_device *p_dev)
563{ 559{
564 dtl1_info_t *info; 560 dtl1_info_t *info;
565 client_reg_t client_reg;
566 dev_link_t *link; 561 dev_link_t *link;
567 int ret;
568 562
569 /* Create new info device */ 563 /* Create new info device */
570 info = kzalloc(sizeof(*info), GFP_KERNEL); 564 info = kzalloc(sizeof(*info), GFP_KERNEL);
571 if (!info) 565 if (!info)
572 return NULL; 566 return -ENOMEM;
573 567
574 link = &info->link; 568 link = &info->link;
575 link->priv = info; 569 link->priv = info;
@@ -586,20 +580,13 @@ static dev_link_t *dtl1_attach(void)
586 link->conf.Vcc = 50; 580 link->conf.Vcc = 50;
587 link->conf.IntType = INT_MEMORY_AND_IO; 581 link->conf.IntType = INT_MEMORY_AND_IO;
588 582
589 /* Register with Card Services */ 583 link->handle = p_dev;
590 link->next = NULL; 584 p_dev->instance = link;
591 client_reg.dev_info = &dev_info;
592 client_reg.Version = 0x0210;
593 client_reg.event_callback_args.client_data = link;
594
595 ret = pcmcia_register_client(&link->handle, &client_reg);
596 if (ret != CS_SUCCESS) {
597 cs_error(link->handle, RegisterClient, ret);
598 dtl1_detach(link->handle);
599 return NULL;
600 }
601 585
602 return link; 586 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
587 dtl1_config(link);
588
589 return 0;
603} 590}
604 591
605 592
@@ -764,19 +751,6 @@ static int dtl1_resume(struct pcmcia_device *dev)
764 return 0; 751 return 0;
765} 752}
766 753
767static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
768{
769 dev_link_t *link = args->client_data;
770
771 switch (event) {
772 case CS_EVENT_CARD_INSERTION:
773 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
774 dtl1_config(link);
775 break;
776 }
777
778 return 0;
779}
780 754
781static struct pcmcia_device_id dtl1_ids[] = { 755static struct pcmcia_device_id dtl1_ids[] = {
782 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), 756 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
@@ -790,8 +764,7 @@ static struct pcmcia_driver dtl1_driver = {
790 .drv = { 764 .drv = {
791 .name = "dtl1_cs", 765 .name = "dtl1_cs",
792 }, 766 },
793 .attach = dtl1_attach, 767 .probe = dtl1_attach,
794 .event = dtl1_event,
795 .remove = dtl1_detach, 768 .remove = dtl1_detach,
796 .id_table = dtl1_ids, 769 .id_table = dtl1_ids,
797 .suspend = dtl1_suspend, 770 .suspend = dtl1_suspend,
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 8a064f2f005d..649677b5dc36 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -66,7 +66,6 @@ static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte";
66#define T_100MSEC msecs_to_jiffies(100) 66#define T_100MSEC msecs_to_jiffies(100)
67#define T_500MSEC msecs_to_jiffies(500) 67#define T_500MSEC msecs_to_jiffies(500)
68 68
69static void cm4000_detach(struct pcmcia_device *p_dev);
70static void cm4000_release(dev_link_t *link); 69static void cm4000_release(dev_link_t *link);
71 70
72static int major; /* major number we get from the kernel */ 71static int major; /* major number we get from the kernel */
@@ -156,7 +155,6 @@ struct cm4000_dev {
156 /*sbuf*/ 512*sizeof(char) - \ 155 /*sbuf*/ 512*sizeof(char) - \
157 /*queue*/ 4*sizeof(wait_queue_head_t)) 156 /*queue*/ 4*sizeof(wait_queue_head_t))
158 157
159static dev_info_t dev_info = MODULE_NAME;
160static dev_link_t *dev_table[CM4000_MAX_DEV]; 158static dev_link_t *dev_table[CM4000_MAX_DEV];
161 159
162/* This table doesn't use spaces after the comma between fields and thus 160/* This table doesn't use spaces after the comma between fields and thus
@@ -1864,38 +1862,6 @@ cs_release:
1864 link->state &= ~DEV_CONFIG_PENDING; 1862 link->state &= ~DEV_CONFIG_PENDING;
1865} 1863}
1866 1864
1867static int cm4000_event(event_t event, int priority,
1868 event_callback_args_t *args)
1869{
1870 dev_link_t *link;
1871 struct cm4000_dev *dev;
1872 int devno;
1873
1874 link = args->client_data;
1875 dev = link->priv;
1876
1877 DEBUGP(3, dev, "-> cm4000_event\n");
1878 for (devno = 0; devno < CM4000_MAX_DEV; devno++)
1879 if (dev_table[devno] == link)
1880 break;
1881
1882 if (devno == CM4000_MAX_DEV)
1883 return CS_BAD_ADAPTER;
1884
1885 switch (event) {
1886 case CS_EVENT_CARD_INSERTION:
1887 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
1888 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1889 cm4000_config(link, devno);
1890 break;
1891 default:
1892 DEBUGP(5, dev, "unknown event %.2x\n", event);
1893 break;
1894 }
1895 DEBUGP(3, dev, "<- cm4000_event\n");
1896 return CS_SUCCESS;
1897}
1898
1899static int cm4000_suspend(struct pcmcia_device *p_dev) 1865static int cm4000_suspend(struct pcmcia_device *p_dev)
1900{ 1866{
1901 dev_link_t *link = dev_to_instance(p_dev); 1867 dev_link_t *link = dev_to_instance(p_dev);
@@ -1935,11 +1901,10 @@ static void cm4000_release(dev_link_t *link)
1935 pcmcia_release_io(link->handle, &link->io); 1901 pcmcia_release_io(link->handle, &link->io);
1936} 1902}
1937 1903
1938static dev_link_t *cm4000_attach(void) 1904static int cm4000_attach(struct pcmcia_device *p_dev)
1939{ 1905{
1940 struct cm4000_dev *dev; 1906 struct cm4000_dev *dev;
1941 dev_link_t *link; 1907 dev_link_t *link;
1942 client_reg_t client_reg;
1943 int i; 1908 int i;
1944 1909
1945 for (i = 0; i < CM4000_MAX_DEV; i++) 1910 for (i = 0; i < CM4000_MAX_DEV; i++)
@@ -1948,41 +1913,31 @@ static dev_link_t *cm4000_attach(void)
1948 1913
1949 if (i == CM4000_MAX_DEV) { 1914 if (i == CM4000_MAX_DEV) {
1950 printk(KERN_NOTICE MODULE_NAME ": all devices in use\n"); 1915 printk(KERN_NOTICE MODULE_NAME ": all devices in use\n");
1951 return NULL; 1916 return -ENODEV;
1952 } 1917 }
1953 1918
1954 /* create a new cm4000_cs device */ 1919 /* create a new cm4000_cs device */
1955 dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL); 1920 dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL);
1956 if (dev == NULL) 1921 if (dev == NULL)
1957 return NULL; 1922 return -ENOMEM;
1958 1923
1959 link = &dev->link; 1924 link = &dev->link;
1960 link->priv = dev; 1925 link->priv = dev;
1961 link->conf.IntType = INT_MEMORY_AND_IO; 1926 link->conf.IntType = INT_MEMORY_AND_IO;
1962 dev_table[i] = link; 1927 dev_table[i] = link;
1963 1928
1964 /* register with card services */
1965 client_reg.dev_info = &dev_info;
1966 client_reg.EventMask =
1967 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
1968 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
1969 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
1970 client_reg.Version = 0x0210;
1971 client_reg.event_callback_args.client_data = link;
1972
1973 i = pcmcia_register_client(&link->handle, &client_reg);
1974 if (i) {
1975 cs_error(link->handle, RegisterClient, i);
1976 cm4000_detach(link->handle);
1977 return NULL;
1978 }
1979
1980 init_waitqueue_head(&dev->devq); 1929 init_waitqueue_head(&dev->devq);
1981 init_waitqueue_head(&dev->ioq); 1930 init_waitqueue_head(&dev->ioq);
1982 init_waitqueue_head(&dev->atrq); 1931 init_waitqueue_head(&dev->atrq);
1983 init_waitqueue_head(&dev->readq); 1932 init_waitqueue_head(&dev->readq);
1984 1933
1985 return link; 1934 link->handle = p_dev;
1935 p_dev->instance = link;
1936
1937 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1938 cm4000_config(link, i);
1939
1940 return 0;
1986} 1941}
1987 1942
1988static void cm4000_detach(struct pcmcia_device *p_dev) 1943static void cm4000_detach(struct pcmcia_device *p_dev)
@@ -2031,11 +1986,10 @@ static struct pcmcia_driver cm4000_driver = {
2031 .drv = { 1986 .drv = {
2032 .name = "cm4000_cs", 1987 .name = "cm4000_cs",
2033 }, 1988 },
2034 .attach = cm4000_attach, 1989 .probe = cm4000_attach,
2035 .remove = cm4000_detach, 1990 .remove = cm4000_detach,
2036 .suspend = cm4000_suspend, 1991 .suspend = cm4000_suspend,
2037 .resume = cm4000_resume, 1992 .resume = cm4000_resume,
2038 .event = cm4000_event,
2039 .id_table = cm4000_ids, 1993 .id_table = cm4000_ids,
2040}; 1994};
2041 1995
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index e08ab949c116..46eb371bf17e 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -65,7 +65,6 @@ static char *version =
65#define POLL_PERIOD msecs_to_jiffies(10) 65#define POLL_PERIOD msecs_to_jiffies(10)
66 66
67static void reader_release(dev_link_t *link); 67static void reader_release(dev_link_t *link);
68static void reader_detach(struct pcmcia_device *p_dev);
69 68
70static int major; 69static int major;
71 70
@@ -86,7 +85,6 @@ struct reader_dev {
86 struct timer_list poll_timer; 85 struct timer_list poll_timer;
87}; 86};
88 87
89static dev_info_t dev_info = MODULE_NAME;
90static dev_link_t *dev_table[CM_MAX_DEV]; 88static dev_link_t *dev_table[CM_MAX_DEV];
91 89
92#ifndef PCMCIA_DEBUG 90#ifndef PCMCIA_DEBUG
@@ -629,39 +627,6 @@ cs_release:
629 link->state &= ~DEV_CONFIG_PENDING; 627 link->state &= ~DEV_CONFIG_PENDING;
630} 628}
631 629
632static int reader_event(event_t event, int priority,
633 event_callback_args_t *args)
634{
635 dev_link_t *link;
636 struct reader_dev *dev;
637 int devno;
638
639 link = args->client_data;
640 dev = link->priv;
641 DEBUGP(3, dev, "-> reader_event\n");
642 for (devno = 0; devno < CM_MAX_DEV; devno++) {
643 if (dev_table[devno] == link)
644 break;
645 }
646 if (devno == CM_MAX_DEV)
647 return CS_BAD_ADAPTER;
648
649 switch (event) {
650 case CS_EVENT_CARD_INSERTION:
651 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
652 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
653 reader_config(link, devno);
654 break;
655
656 default:
657 DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
658 event);
659 break;
660 }
661 DEBUGP(3, dev, "<- reader_event\n");
662 return CS_SUCCESS;
663}
664
665static int reader_suspend(struct pcmcia_device *p_dev) 630static int reader_suspend(struct pcmcia_device *p_dev)
666{ 631{
667 dev_link_t *link = dev_to_instance(p_dev); 632 dev_link_t *link = dev_to_instance(p_dev);
@@ -691,11 +656,10 @@ static void reader_release(dev_link_t *link)
691 pcmcia_release_io(link->handle, &link->io); 656 pcmcia_release_io(link->handle, &link->io);
692} 657}
693 658
694static dev_link_t *reader_attach(void) 659static int reader_attach(struct pcmcia_device *p_dev)
695{ 660{
696 struct reader_dev *dev; 661 struct reader_dev *dev;
697 dev_link_t *link; 662 dev_link_t *link;
698 client_reg_t client_reg;
699 int i; 663 int i;
700 664
701 for (i = 0; i < CM_MAX_DEV; i++) { 665 for (i = 0; i < CM_MAX_DEV; i++) {
@@ -704,11 +668,11 @@ static dev_link_t *reader_attach(void)
704 } 668 }
705 669
706 if (i == CM_MAX_DEV) 670 if (i == CM_MAX_DEV)
707 return NULL; 671 return -ENODEV;
708 672
709 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL); 673 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL);
710 if (dev == NULL) 674 if (dev == NULL)
711 return NULL; 675 return -ENOMEM;
712 676
713 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 677 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
714 dev->buffer_status = 0; 678 dev->buffer_status = 0;
@@ -719,20 +683,6 @@ static dev_link_t *reader_attach(void)
719 link->conf.IntType = INT_MEMORY_AND_IO; 683 link->conf.IntType = INT_MEMORY_AND_IO;
720 dev_table[i] = link; 684 dev_table[i] = link;
721 685
722 client_reg.dev_info = &dev_info;
723 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
724 client_reg.EventMask=
725 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
726 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
727 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
728 client_reg.Version = 0x0210;
729 client_reg.event_callback_args.client_data = link;
730 i = pcmcia_register_client(&link->handle, &client_reg);
731 if (i) {
732 cs_error(link->handle, RegisterClient, i);
733 reader_detach(link->handle);
734 return NULL;
735 }
736 init_waitqueue_head(&dev->devq); 686 init_waitqueue_head(&dev->devq);
737 init_waitqueue_head(&dev->poll_wait); 687 init_waitqueue_head(&dev->poll_wait);
738 init_waitqueue_head(&dev->read_wait); 688 init_waitqueue_head(&dev->read_wait);
@@ -740,7 +690,13 @@ static dev_link_t *reader_attach(void)
740 init_timer(&dev->poll_timer); 690 init_timer(&dev->poll_timer);
741 dev->poll_timer.function = &cm4040_do_poll; 691 dev->poll_timer.function = &cm4040_do_poll;
742 692
743 return link; 693 link->handle = p_dev;
694 p_dev->instance = link;
695
696 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
697 reader_config(link, i);
698
699 return 0;
744} 700}
745 701
746static void reader_detach(struct pcmcia_device *p_dev) 702static void reader_detach(struct pcmcia_device *p_dev)
@@ -790,11 +746,10 @@ static struct pcmcia_driver reader_driver = {
790 .drv = { 746 .drv = {
791 .name = "cm4040_cs", 747 .name = "cm4040_cs",
792 }, 748 },
793 .attach = reader_attach, 749 .probe = reader_attach,
794 .remove = reader_detach, 750 .remove = reader_detach,
795 .suspend = reader_suspend, 751 .suspend = reader_suspend,
796 .resume = reader_resume, 752 .resume = reader_resume,
797 .event = reader_event,
798 .id_table = cm4040_ids, 753 .id_table = cm4040_ids,
799}; 754};
800 755
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index dc38b1d0a725..cf45b100eff1 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -486,13 +486,8 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout);
486 486
487static void mgslpc_config(dev_link_t *link); 487static void mgslpc_config(dev_link_t *link);
488static void mgslpc_release(u_long arg); 488static void mgslpc_release(u_long arg);
489static int mgslpc_event(event_t event, int priority,
490 event_callback_args_t *args);
491static dev_link_t *mgslpc_attach(void);
492static void mgslpc_detach(struct pcmcia_device *p_dev); 489static void mgslpc_detach(struct pcmcia_device *p_dev);
493 490
494static dev_info_t dev_info = "synclink_cs";
495
496/* 491/*
497 * 1st function defined in .text section. Calling this function in 492 * 1st function defined in .text section. Calling this function in
498 * init_module() followed by a breakpoint allows a remote debugger 493 * init_module() followed by a breakpoint allows a remote debugger
@@ -538,12 +533,10 @@ static void ldisc_receive_buf(struct tty_struct *tty,
538 } 533 }
539} 534}
540 535
541static dev_link_t *mgslpc_attach(void) 536static int mgslpc_attach(struct pcmcia_device *p_dev)
542{ 537{
543 MGSLPC_INFO *info; 538 MGSLPC_INFO *info;
544 dev_link_t *link; 539 dev_link_t *link;
545 client_reg_t client_reg;
546 int ret;
547 540
548 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
549 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
@@ -551,7 +544,7 @@ static dev_link_t *mgslpc_attach(void)
551 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
552 if (!info) { 545 if (!info) {
553 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
554 return NULL; 547 return -ENOMEM;
555 } 548 }
556 549
557 memset(info, 0, sizeof(MGSLPC_INFO)); 550 memset(info, 0, sizeof(MGSLPC_INFO));
@@ -586,23 +579,15 @@ static dev_link_t *mgslpc_attach(void)
586 link->conf.Vcc = 50; 579 link->conf.Vcc = 50;
587 link->conf.IntType = INT_MEMORY_AND_IO; 580 link->conf.IntType = INT_MEMORY_AND_IO;
588 581
589 /* Register with Card Services */ 582 link->handle = p_dev;
590 link->next = NULL; 583 p_dev->instance = link;
591
592 client_reg.dev_info = &dev_info;
593 client_reg.Version = 0x0210;
594 client_reg.event_callback_args.client_data = link;
595 584
596 ret = pcmcia_register_client(&link->handle, &client_reg); 585 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
597 if (ret != CS_SUCCESS) { 586 mgslpc_config(link);
598 cs_error(link->handle, RegisterClient, ret);
599 mgslpc_detach(link->handle);
600 return NULL;
601 }
602 587
603 mgslpc_add_device(info); 588 mgslpc_add_device(info);
604 589
605 return link; 590 return 0;
606} 591}
607 592
608/* Card has been inserted. 593/* Card has been inserted.
@@ -778,23 +763,6 @@ static int mgslpc_resume(struct pcmcia_device *dev)
778} 763}
779 764
780 765
781static int mgslpc_event(event_t event, int priority,
782 event_callback_args_t *args)
783{
784 dev_link_t *link = args->client_data;
785
786 if (debug_level >= DEBUG_LEVEL_INFO)
787 printk("mgslpc_event(0x%06x)\n", event);
788
789 switch (event) {
790 case CS_EVENT_CARD_INSERTION:
791 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
792 mgslpc_config(link);
793 break;
794 }
795 return 0;
796}
797
798static inline int mgslpc_paranoia_check(MGSLPC_INFO *info, 766static inline int mgslpc_paranoia_check(MGSLPC_INFO *info,
799 char *name, const char *routine) 767 char *name, const char *routine)
800{ 768{
@@ -3071,8 +3039,7 @@ static struct pcmcia_driver mgslpc_driver = {
3071 .drv = { 3039 .drv = {
3072 .name = "synclink_cs", 3040 .name = "synclink_cs",
3073 }, 3041 },
3074 .attach = mgslpc_attach, 3042 .probe = mgslpc_attach,
3075 .event = mgslpc_event,
3076 .remove = mgslpc_detach, 3043 .remove = mgslpc_detach,
3077 .id_table = mgslpc_ids, 3044 .id_table = mgslpc_ids,
3078 .suspend = mgslpc_suspend, 3045 .suspend = mgslpc_suspend,
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index c83068dd42a0..e36e6fbbf9e0 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -88,12 +88,8 @@ typedef struct ide_info_t {
88} ide_info_t; 88} ide_info_t;
89 89
90static void ide_release(dev_link_t *); 90static void ide_release(dev_link_t *);
91static int ide_event(event_t event, int priority, 91static void ide_config(dev_link_t *);
92 event_callback_args_t *args);
93 92
94static dev_info_t dev_info = "ide-cs";
95
96static dev_link_t *ide_attach(void);
97static void ide_detach(struct pcmcia_device *p_dev); 93static void ide_detach(struct pcmcia_device *p_dev);
98 94
99 95
@@ -107,18 +103,17 @@ static void ide_detach(struct pcmcia_device *p_dev);
107 103
108======================================================================*/ 104======================================================================*/
109 105
110static dev_link_t *ide_attach(void) 106static int ide_attach(struct pcmcia_device *p_dev)
111{ 107{
112 ide_info_t *info; 108 ide_info_t *info;
113 dev_link_t *link; 109 dev_link_t *link;
114 client_reg_t client_reg; 110
115 int ret;
116
117 DEBUG(0, "ide_attach()\n"); 111 DEBUG(0, "ide_attach()\n");
118 112
119 /* Create new ide device */ 113 /* Create new ide device */
120 info = kzalloc(sizeof(*info), GFP_KERNEL); 114 info = kzalloc(sizeof(*info), GFP_KERNEL);
121 if (!info) return NULL; 115 if (!info)
116 return -ENOMEM;
122 link = &info->link; link->priv = info; 117 link = &info->link; link->priv = info;
123 118
124 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 119 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -129,20 +124,14 @@ static dev_link_t *ide_attach(void)
129 link->conf.Attributes = CONF_ENABLE_IRQ; 124 link->conf.Attributes = CONF_ENABLE_IRQ;
130 link->conf.Vcc = 50; 125 link->conf.Vcc = 50;
131 link->conf.IntType = INT_MEMORY_AND_IO; 126 link->conf.IntType = INT_MEMORY_AND_IO;
132 127
133 /* Register with Card Services */ 128 link->handle = p_dev;
134 link->next = NULL; 129 p_dev->instance = link;
135 client_reg.dev_info = &dev_info; 130
136 client_reg.Version = 0x0210; 131 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
137 client_reg.event_callback_args.client_data = link; 132 ide_config(link);
138 ret = pcmcia_register_client(&link->handle, &client_reg); 133
139 if (ret != CS_SUCCESS) { 134 return 0;
140 cs_error(link->handle, RegisterClient, ret);
141 ide_detach(link->handle);
142 return NULL;
143 }
144
145 return link;
146} /* ide_attach */ 135} /* ide_attach */
147 136
148/*====================================================================== 137/*======================================================================
@@ -421,22 +410,6 @@ static int ide_resume(struct pcmcia_device *dev)
421 410
422======================================================================*/ 411======================================================================*/
423 412
424int ide_event(event_t event, int priority,
425 event_callback_args_t *args)
426{
427 dev_link_t *link = args->client_data;
428
429 DEBUG(1, "ide_event(0x%06x)\n", event);
430
431 switch (event) {
432 case CS_EVENT_CARD_INSERTION:
433 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
434 ide_config(link);
435 break;
436 }
437 return 0;
438} /* ide_event */
439
440static struct pcmcia_device_id ide_ids[] = { 413static struct pcmcia_device_id ide_ids[] = {
441 PCMCIA_DEVICE_FUNC_ID(4), 414 PCMCIA_DEVICE_FUNC_ID(4),
442 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), 415 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704),
@@ -481,8 +454,7 @@ static struct pcmcia_driver ide_cs_driver = {
481 .drv = { 454 .drv = {
482 .name = "ide-cs", 455 .name = "ide-cs",
483 }, 456 },
484 .attach = ide_attach, 457 .probe = ide_attach,
485 .event = ide_event,
486 .remove = ide_detach, 458 .remove = ide_detach,
487 .id_table = ide_ids, 459 .id_table = ide_ids,
488 .suspend = ide_suspend, 460 .suspend = ide_suspend,
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 0a8c1da10b4b..2a2b03ff096b 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -53,8 +53,6 @@ MODULE_LICENSE("GPL");
53 53
54static void avmcs_config(dev_link_t *link); 54static void avmcs_config(dev_link_t *link);
55static void avmcs_release(dev_link_t *link); 55static void avmcs_release(dev_link_t *link);
56static int avmcs_event(event_t event, int priority,
57 event_callback_args_t *args);
58 56
59/* 57/*
60 The attach() and detach() entry points are used to create and destroy 58 The attach() and detach() entry points are used to create and destroy
@@ -62,18 +60,9 @@ static int avmcs_event(event_t event, int priority,
62 needed to manage one actual PCMCIA card. 60 needed to manage one actual PCMCIA card.
63*/ 61*/
64 62
65static dev_link_t *avmcs_attach(void);
66static void avmcs_detach(struct pcmcia_device *p_dev); 63static void avmcs_detach(struct pcmcia_device *p_dev);
67 64
68/* 65/*
69 The dev_info variable is the "key" that is used to match up this
70 device driver with appropriate cards, through the card configuration
71 database.
72*/
73
74static dev_info_t dev_info = "avm_cs";
75
76/*
77 A linked list of "instances" of the skeleton device. Each actual 66 A linked list of "instances" of the skeleton device. Each actual
78 PCMCIA card corresponds to one device instance, and is described 67 PCMCIA card corresponds to one device instance, and is described
79 by one dev_link_t structure (defined in ds.h). 68 by one dev_link_t structure (defined in ds.h).
@@ -110,13 +99,11 @@ typedef struct local_info_t {
110 99
111======================================================================*/ 100======================================================================*/
112 101
113static dev_link_t *avmcs_attach(void) 102static int avmcs_attach(struct pcmcia_device *p_dev)
114{ 103{
115 client_reg_t client_reg;
116 dev_link_t *link; 104 dev_link_t *link;
117 local_info_t *local; 105 local_info_t *local;
118 int ret; 106
119
120 /* Initialize the dev_link_t structure */ 107 /* Initialize the dev_link_t structure */
121 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 108 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
122 if (!link) 109 if (!link)
@@ -147,24 +134,19 @@ static dev_link_t *avmcs_attach(void)
147 goto err_kfree; 134 goto err_kfree;
148 memset(local, 0, sizeof(local_info_t)); 135 memset(local, 0, sizeof(local_info_t));
149 link->priv = local; 136 link->priv = local;
150 137
151 /* Register with Card Services */ 138 link->handle = p_dev;
152 link->next = NULL; 139 p_dev->instance = link;
153 client_reg.dev_info = &dev_info; 140
154 client_reg.Version = 0x0210; 141 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
155 client_reg.event_callback_args.client_data = link; 142 avmcs_config(link);
156 ret = pcmcia_register_client(&link->handle, &client_reg); 143
157 if (ret != 0) { 144 return 0;
158 cs_error(link->handle, RegisterClient, ret);
159 avmcs_detach(link->handle);
160 goto err;
161 }
162 return link;
163 145
164 err_kfree: 146 err_kfree:
165 kfree(link); 147 kfree(link);
166 err: 148 err:
167 return NULL; 149 return -EINVAL;
168} /* avmcs_attach */ 150} /* avmcs_attach */
169 151
170/*====================================================================== 152/*======================================================================
@@ -433,19 +415,6 @@ static int avmcs_resume(struct pcmcia_device *dev)
433 415
434======================================================================*/ 416======================================================================*/
435 417
436static int avmcs_event(event_t event, int priority,
437 event_callback_args_t *args)
438{
439 dev_link_t *link = args->client_data;
440
441 switch (event) {
442 case CS_EVENT_CARD_INSERTION:
443 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
444 avmcs_config(link);
445 break;
446 }
447 return 0;
448} /* avmcs_event */
449 418
450static struct pcmcia_device_id avmcs_ids[] = { 419static struct pcmcia_device_id avmcs_ids[] = {
451 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335), 420 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335),
@@ -460,8 +429,7 @@ static struct pcmcia_driver avmcs_driver = {
460 .drv = { 429 .drv = {
461 .name = "avm_cs", 430 .name = "avm_cs",
462 }, 431 },
463 .attach = avmcs_attach, 432 .probe = avmcs_attach,
464 .event = avmcs_event,
465 .remove = avmcs_detach, 433 .remove = avmcs_detach,
466 .id_table = avmcs_ids, 434 .id_table = avmcs_ids,
467 .suspend= avmcs_suspend, 435 .suspend= avmcs_suspend,
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index b6ea653f881e..969da40c4248 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -69,8 +69,6 @@ module_param(isdnprot, int, 0);
69 69
70static void avma1cs_config(dev_link_t *link); 70static void avma1cs_config(dev_link_t *link);
71static void avma1cs_release(dev_link_t *link); 71static void avma1cs_release(dev_link_t *link);
72static int avma1cs_event(event_t event, int priority,
73 event_callback_args_t *args);
74 72
75/* 73/*
76 The attach() and detach() entry points are used to create and destroy 74 The attach() and detach() entry points are used to create and destroy
@@ -78,16 +76,8 @@ static int avma1cs_event(event_t event, int priority,
78 needed to manage one actual PCMCIA card. 76 needed to manage one actual PCMCIA card.
79*/ 77*/
80 78
81static dev_link_t *avma1cs_attach(void);
82static void avma1cs_detach(struct pcmcia_device *p_dev); 79static void avma1cs_detach(struct pcmcia_device *p_dev);
83 80
84/*
85 The dev_info variable is the "key" that is used to match up this
86 device driver with appropriate cards, through the card configuration
87 database.
88*/
89
90static dev_info_t dev_info = "avma1_cs";
91 81
92/* 82/*
93 A linked list of "instances" of the skeleton device. Each actual 83 A linked list of "instances" of the skeleton device. Each actual
@@ -126,26 +116,24 @@ typedef struct local_info_t {
126 116
127======================================================================*/ 117======================================================================*/
128 118
129static dev_link_t *avma1cs_attach(void) 119static int avma1cs_attach(struct pcmcia_device *p_dev)
130{ 120{
131 client_reg_t client_reg;
132 dev_link_t *link; 121 dev_link_t *link;
133 local_info_t *local; 122 local_info_t *local;
134 int ret; 123
135
136 DEBUG(0, "avma1cs_attach()\n"); 124 DEBUG(0, "avma1cs_attach()\n");
137 125
138 /* Initialize the dev_link_t structure */ 126 /* Initialize the dev_link_t structure */
139 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 127 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
140 if (!link) 128 if (!link)
141 return NULL; 129 return -ENOMEM;
142 memset(link, 0, sizeof(struct dev_link_t)); 130 memset(link, 0, sizeof(struct dev_link_t));
143 131
144 /* Allocate space for private device-specific data */ 132 /* Allocate space for private device-specific data */
145 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 133 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
146 if (!local) { 134 if (!local) {
147 kfree(link); 135 kfree(link);
148 return NULL; 136 return -ENOMEM;
149 } 137 }
150 memset(local, 0, sizeof(local_info_t)); 138 memset(local, 0, sizeof(local_info_t));
151 link->priv = local; 139 link->priv = local;
@@ -170,19 +158,13 @@ static dev_link_t *avma1cs_attach(void)
170 link->conf.ConfigIndex = 1; 158 link->conf.ConfigIndex = 1;
171 link->conf.Present = PRESENT_OPTION; 159 link->conf.Present = PRESENT_OPTION;
172 160
173 /* Register with Card Services */ 161 link->handle = p_dev;
174 link->next = NULL; 162 p_dev->instance = link;
175 client_reg.dev_info = &dev_info; 163
176 client_reg.Version = 0x0210; 164 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
177 client_reg.event_callback_args.client_data = link; 165 avma1cs_config(link);
178 ret = pcmcia_register_client(&link->handle, &client_reg);
179 if (ret != 0) {
180 cs_error(link->handle, RegisterClient, ret);
181 avma1cs_detach(link->handle);
182 return NULL;
183 }
184 166
185 return link; 167 return 0;
186} /* avma1cs_attach */ 168} /* avma1cs_attach */
187 169
188/*====================================================================== 170/*======================================================================
@@ -430,35 +412,6 @@ static int avma1cs_resume(struct pcmcia_device *dev)
430 return 0; 412 return 0;
431} 413}
432 414
433/*======================================================================
434
435 The card status event handler. Mostly, this schedules other
436 stuff to run after an event is received. A CARD_REMOVAL event
437 also sets some flags to discourage the net drivers from trying
438 to talk to the card any more.
439
440 When a CARD_REMOVAL event is received, we immediately set a flag
441 to block future accesses to this device. All the functions that
442 actually access the device should check this flag to make sure
443 the card is still present.
444
445======================================================================*/
446
447static int avma1cs_event(event_t event, int priority,
448 event_callback_args_t *args)
449{
450 dev_link_t *link = args->client_data;
451
452 DEBUG(1, "avma1cs_event(0x%06x)\n", event);
453
454 switch (event) {
455 case CS_EVENT_CARD_INSERTION:
456 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
457 avma1cs_config(link);
458 break;
459 }
460 return 0;
461} /* avma1cs_event */
462 415
463static struct pcmcia_device_id avma1cs_ids[] = { 416static struct pcmcia_device_id avma1cs_ids[] = {
464 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb), 417 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb),
@@ -472,8 +425,7 @@ static struct pcmcia_driver avma1cs_driver = {
472 .drv = { 425 .drv = {
473 .name = "avma1_cs", 426 .name = "avma1_cs",
474 }, 427 },
475 .attach = avma1cs_attach, 428 .probe = avma1cs_attach,
476 .event = avma1cs_event,
477 .remove = avma1cs_detach, 429 .remove = avma1cs_detach,
478 .id_table = avma1cs_ids, 430 .id_table = avma1cs_ids,
479 .suspend = avma1cs_suspend, 431 .suspend = avma1cs_suspend,
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index a0c5bad7bc6b..062fb8f0739f 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -96,8 +96,6 @@ module_param(protocol, int, 0);
96 96
97static void elsa_cs_config(dev_link_t *link); 97static void elsa_cs_config(dev_link_t *link);
98static void elsa_cs_release(dev_link_t *link); 98static void elsa_cs_release(dev_link_t *link);
99static int elsa_cs_event(event_t event, int priority,
100 event_callback_args_t *args);
101 99
102/* 100/*
103 The attach() and detach() entry points are used to create and destroy 101 The attach() and detach() entry points are used to create and destroy
@@ -105,28 +103,9 @@ static int elsa_cs_event(event_t event, int priority,
105 needed to manage one actual PCMCIA card. 103 needed to manage one actual PCMCIA card.
106*/ 104*/
107 105
108static dev_link_t *elsa_cs_attach(void);
109static void elsa_cs_detach(struct pcmcia_device *p_dev); 106static void elsa_cs_detach(struct pcmcia_device *p_dev);
110 107
111/* 108/*
112 The dev_info variable is the "key" that is used to match up this
113 device driver with appropriate cards, through the card configuration
114 database.
115*/
116
117static dev_info_t dev_info = "elsa_cs";
118
119/*
120 A linked list of "instances" of the elsa_cs device. Each actual
121 PCMCIA card corresponds to one device instance, and is described
122 by one dev_link_t structure (defined in ds.h).
123
124 You may not want to use a linked list for this -- for example, the
125 memory card driver uses an array of dev_link_t pointers, where minor
126 device numbers are used to derive the corresponding array index.
127*/
128
129/*
130 A driver needs to provide a dev_node_t structure for each device 109 A driver needs to provide a dev_node_t structure for each device
131 on a card. In some cases, there is only one device per card (for 110 on a card. In some cases, there is only one device per card (for
132 example, ethernet cards, modems). In other cases, there may be 111 example, ethernet cards, modems). In other cases, there may be
@@ -160,18 +139,16 @@ typedef struct local_info_t {
160 139
161======================================================================*/ 140======================================================================*/
162 141
163static dev_link_t *elsa_cs_attach(void) 142static int elsa_cs_attach(struct pcmcia_device *p_dev)
164{ 143{
165 client_reg_t client_reg;
166 dev_link_t *link; 144 dev_link_t *link;
167 local_info_t *local; 145 local_info_t *local;
168 int ret;
169 146
170 DEBUG(0, "elsa_cs_attach()\n"); 147 DEBUG(0, "elsa_cs_attach()\n");
171 148
172 /* Allocate space for private device-specific data */ 149 /* Allocate space for private device-specific data */
173 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 150 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
174 if (!local) return NULL; 151 if (!local) return -ENOMEM;
175 memset(local, 0, sizeof(local_info_t)); 152 memset(local, 0, sizeof(local_info_t));
176 local->cardnr = -1; 153 local->cardnr = -1;
177 link = &local->link; link->priv = local; 154 link = &local->link; link->priv = local;
@@ -196,19 +173,13 @@ static dev_link_t *elsa_cs_attach(void)
196 link->conf.Vcc = 50; 173 link->conf.Vcc = 50;
197 link->conf.IntType = INT_MEMORY_AND_IO; 174 link->conf.IntType = INT_MEMORY_AND_IO;
198 175
199 /* Register with Card Services */ 176 link->handle = p_dev;
200 link->next = NULL; 177 p_dev->instance = link;
201 client_reg.dev_info = &dev_info;
202 client_reg.Version = 0x0210;
203 client_reg.event_callback_args.client_data = link;
204 ret = pcmcia_register_client(&link->handle, &client_reg);
205 if (ret != CS_SUCCESS) {
206 cs_error(link->handle, RegisterClient, ret);
207 elsa_cs_detach(link->handle);
208 return NULL;
209 }
210 178
211 return link; 179 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
180 elsa_cs_config(link);
181
182 return 0;
212} /* elsa_cs_attach */ 183} /* elsa_cs_attach */
213 184
214/*====================================================================== 185/*======================================================================
@@ -447,36 +418,6 @@ static int elsa_resume(struct pcmcia_device *p_dev)
447 return 0; 418 return 0;
448} 419}
449 420
450/*======================================================================
451
452 The card status event handler. Mostly, this schedules other
453 stuff to run after an event is received. A CARD_REMOVAL event
454 also sets some flags to discourage the net drivers from trying
455 to talk to the card any more.
456
457 When a CARD_REMOVAL event is received, we immediately set a flag
458 to block future accesses to this device. All the functions that
459 actually access the device should check this flag to make sure
460 the card is still present.
461
462======================================================================*/
463
464static int elsa_cs_event(event_t event, int priority,
465 event_callback_args_t *args)
466{
467 dev_link_t *link = args->client_data;
468
469 DEBUG(1, "elsa_cs_event(%d)\n", event);
470
471 switch (event) {
472 case CS_EVENT_CARD_INSERTION:
473 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
474 elsa_cs_config(link);
475 break;
476 }
477 return 0;
478} /* elsa_cs_event */
479
480static struct pcmcia_device_id elsa_ids[] = { 421static struct pcmcia_device_id elsa_ids[] = {
481 PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257), 422 PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257),
482 PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257), 423 PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257),
@@ -489,8 +430,7 @@ static struct pcmcia_driver elsa_cs_driver = {
489 .drv = { 430 .drv = {
490 .name = "elsa_cs", 431 .name = "elsa_cs",
491 }, 432 },
492 .attach = elsa_cs_attach, 433 .probe = elsa_cs_attach,
493 .event = elsa_cs_event,
494 .remove = elsa_cs_detach, 434 .remove = elsa_cs_detach,
495 .id_table = elsa_ids, 435 .id_table = elsa_ids,
496 .suspend = elsa_suspend, 436 .suspend = elsa_suspend,
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 814b32a9ef3b..6f5213a18a8d 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -97,8 +97,6 @@ module_param(protocol, int, 0);
97 97
98static void sedlbauer_config(dev_link_t *link); 98static void sedlbauer_config(dev_link_t *link);
99static void sedlbauer_release(dev_link_t *link); 99static void sedlbauer_release(dev_link_t *link);
100static int sedlbauer_event(event_t event, int priority,
101 event_callback_args_t *args);
102 100
103/* 101/*
104 The attach() and detach() entry points are used to create and destroy 102 The attach() and detach() entry points are used to create and destroy
@@ -106,7 +104,6 @@ static int sedlbauer_event(event_t event, int priority,
106 needed to manage one actual PCMCIA card. 104 needed to manage one actual PCMCIA card.
107*/ 105*/
108 106
109static dev_link_t *sedlbauer_attach(void);
110static void sedlbauer_detach(struct pcmcia_device *p_dev); 107static void sedlbauer_detach(struct pcmcia_device *p_dev);
111 108
112/* 109/*
@@ -117,24 +114,6 @@ static void sedlbauer_detach(struct pcmcia_device *p_dev);
117*/ 114*/
118 115
119/* 116/*
120 The dev_info variable is the "key" that is used to match up this
121 device driver with appropriate cards, through the card configuration
122 database.
123*/
124
125static dev_info_t dev_info = "sedlbauer_cs";
126
127/*
128 A linked list of "instances" of the sedlbauer device. Each actual
129 PCMCIA card corresponds to one device instance, and is described
130 by one dev_link_t structure (defined in ds.h).
131
132 You may not want to use a linked list for this -- for example, the
133 memory card driver uses an array of dev_link_t pointers, where minor
134 device numbers are used to derive the corresponding array index.
135*/
136
137/*
138 A driver needs to provide a dev_node_t structure for each device 117 A driver needs to provide a dev_node_t structure for each device
139 on a card. In some cases, there is only one device per card (for 118 on a card. In some cases, there is only one device per card (for
140 example, ethernet cards, modems). In other cases, there may be 119 example, ethernet cards, modems). In other cases, there may be
@@ -169,18 +148,16 @@ typedef struct local_info_t {
169 148
170======================================================================*/ 149======================================================================*/
171 150
172static dev_link_t *sedlbauer_attach(void) 151static int sedlbauer_attach(struct pcmcia_device *p_dev)
173{ 152{
174 local_info_t *local; 153 local_info_t *local;
175 dev_link_t *link; 154 dev_link_t *link;
176 client_reg_t client_reg;
177 int ret;
178 155
179 DEBUG(0, "sedlbauer_attach()\n"); 156 DEBUG(0, "sedlbauer_attach()\n");
180 157
181 /* Allocate space for private device-specific data */ 158 /* Allocate space for private device-specific data */
182 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 159 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
183 if (!local) return NULL; 160 if (!local) return -ENOMEM;
184 memset(local, 0, sizeof(local_info_t)); 161 memset(local, 0, sizeof(local_info_t));
185 local->cardnr = -1; 162 local->cardnr = -1;
186 link = &local->link; link->priv = local; 163 link = &local->link; link->priv = local;
@@ -210,19 +187,13 @@ static dev_link_t *sedlbauer_attach(void)
210 link->conf.Vcc = 50; 187 link->conf.Vcc = 50;
211 link->conf.IntType = INT_MEMORY_AND_IO; 188 link->conf.IntType = INT_MEMORY_AND_IO;
212 189
213 /* Register with Card Services */ 190 link->handle = p_dev;
214 link->next = NULL; 191 p_dev->instance = link;
215 client_reg.dev_info = &dev_info;
216 client_reg.Version = 0x0210;
217 client_reg.event_callback_args.client_data = link;
218 ret = pcmcia_register_client(&link->handle, &client_reg);
219 if (ret != CS_SUCCESS) {
220 cs_error(link->handle, RegisterClient, ret);
221 sedlbauer_detach(link->handle);
222 return NULL;
223 }
224 192
225 return link; 193 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
194 sedlbauer_config(link);
195
196 return 0;
226} /* sedlbauer_attach */ 197} /* sedlbauer_attach */
227 198
228/*====================================================================== 199/*======================================================================
@@ -541,33 +512,6 @@ static int sedlbauer_resume(struct pcmcia_device *p_dev)
541 return 0; 512 return 0;
542} 513}
543 514
544/*======================================================================
545
546 The card status event handler. Mostly, this schedules other
547 stuff to run after an event is received.
548
549 When a CARD_REMOVAL event is received, we immediately set a
550 private flag to block future accesses to this device. All the
551 functions that actually access the device should check this flag
552 to make sure the card is still present.
553
554======================================================================*/
555
556static int sedlbauer_event(event_t event, int priority,
557 event_callback_args_t *args)
558{
559 dev_link_t *link = args->client_data;
560
561 DEBUG(1, "sedlbauer_event(0x%06x)\n", event);
562
563 switch (event) {
564 case CS_EVENT_CARD_INSERTION:
565 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
566 sedlbauer_config(link);
567 break;
568 }
569 return 0;
570} /* sedlbauer_event */
571 515
572static struct pcmcia_device_id sedlbauer_ids[] = { 516static struct pcmcia_device_id sedlbauer_ids[] = {
573 PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a), 517 PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a),
@@ -586,8 +530,7 @@ static struct pcmcia_driver sedlbauer_driver = {
586 .drv = { 530 .drv = {
587 .name = "sedlbauer_cs", 531 .name = "sedlbauer_cs",
588 }, 532 },
589 .attach = sedlbauer_attach, 533 .probe = sedlbauer_attach,
590 .event = sedlbauer_event,
591 .remove = sedlbauer_detach, 534 .remove = sedlbauer_detach,
592 .id_table = sedlbauer_ids, 535 .id_table = sedlbauer_ids,
593 .suspend = sedlbauer_suspend, 536 .suspend = sedlbauer_suspend,
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index f956fceb9db2..4e5c14c7240e 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -77,8 +77,6 @@ module_param(protocol, int, 0);
77 77
78static void teles_cs_config(dev_link_t *link); 78static void teles_cs_config(dev_link_t *link);
79static void teles_cs_release(dev_link_t *link); 79static void teles_cs_release(dev_link_t *link);
80static int teles_cs_event(event_t event, int priority,
81 event_callback_args_t *args);
82 80
83/* 81/*
84 The attach() and detach() entry points are used to create and destroy 82 The attach() and detach() entry points are used to create and destroy
@@ -86,18 +84,9 @@ static int teles_cs_event(event_t event, int priority,
86 needed to manage one actual PCMCIA card. 84 needed to manage one actual PCMCIA card.
87*/ 85*/
88 86
89static dev_link_t *teles_attach(void);
90static void teles_detach(struct pcmcia_device *p_dev); 87static void teles_detach(struct pcmcia_device *p_dev);
91 88
92/* 89/*
93 The dev_info variable is the "key" that is used to match up this
94 device driver with appropriate cards, through the card configuration
95 database.
96*/
97
98static dev_info_t dev_info = "teles_cs";
99
100/*
101 A linked list of "instances" of the teles_cs device. Each actual 90 A linked list of "instances" of the teles_cs device. Each actual
102 PCMCIA card corresponds to one device instance, and is described 91 PCMCIA card corresponds to one device instance, and is described
103 by one dev_link_t structure (defined in ds.h). 92 by one dev_link_t structure (defined in ds.h).
@@ -141,18 +130,16 @@ typedef struct local_info_t {
141 130
142======================================================================*/ 131======================================================================*/
143 132
144static dev_link_t *teles_attach(void) 133static int teles_attach(struct pcmcia_device *p_dev)
145{ 134{
146 client_reg_t client_reg;
147 dev_link_t *link; 135 dev_link_t *link;
148 local_info_t *local; 136 local_info_t *local;
149 int ret;
150 137
151 DEBUG(0, "teles_attach()\n"); 138 DEBUG(0, "teles_attach()\n");
152 139
153 /* Allocate space for private device-specific data */ 140 /* Allocate space for private device-specific data */
154 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 141 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
155 if (!local) return NULL; 142 if (!local) return -ENOMEM;
156 memset(local, 0, sizeof(local_info_t)); 143 memset(local, 0, sizeof(local_info_t));
157 local->cardnr = -1; 144 local->cardnr = -1;
158 link = &local->link; link->priv = local; 145 link = &local->link; link->priv = local;
@@ -177,19 +164,13 @@ static dev_link_t *teles_attach(void)
177 link->conf.Vcc = 50; 164 link->conf.Vcc = 50;
178 link->conf.IntType = INT_MEMORY_AND_IO; 165 link->conf.IntType = INT_MEMORY_AND_IO;
179 166
180 /* Register with Card Services */ 167 link->handle = p_dev;
181 link->next = NULL; 168 p_dev->instance = link;
182 client_reg.dev_info = &dev_info;
183 client_reg.Version = 0x0210;
184 client_reg.event_callback_args.client_data = link;
185 ret = pcmcia_register_client(&link->handle, &client_reg);
186 if (ret != CS_SUCCESS) {
187 cs_error(link->handle, RegisterClient, ret);
188 teles_detach(link->handle);
189 return NULL;
190 }
191 169
192 return link; 170 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
171 teles_cs_config(link);
172
173 return 0;
193} /* teles_attach */ 174} /* teles_attach */
194 175
195/*====================================================================== 176/*======================================================================
@@ -428,35 +409,6 @@ static int teles_resume(struct pcmcia_device *p_dev)
428 return 0; 409 return 0;
429} 410}
430 411
431/*======================================================================
432
433 The card status event handler. Mostly, this schedules other
434 stuff to run after an event is received. A CARD_REMOVAL event
435 also sets some flags to discourage the net drivers from trying
436 to talk to the card any more.
437
438 When a CARD_REMOVAL event is received, we immediately set a flag
439 to block future accesses to this device. All the functions that
440 actually access the device should check this flag to make sure
441 the card is still present.
442
443======================================================================*/
444
445static int teles_cs_event(event_t event, int priority,
446 event_callback_args_t *args)
447{
448 dev_link_t *link = args->client_data;
449
450 DEBUG(1, "teles_cs_event(%d)\n", event);
451
452 switch (event) {
453 case CS_EVENT_CARD_INSERTION:
454 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
455 teles_cs_config(link);
456 break;
457 }
458 return 0;
459} /* teles_cs_event */
460 412
461static struct pcmcia_device_id teles_ids[] = { 413static struct pcmcia_device_id teles_ids[] = {
462 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119), 414 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119),
@@ -469,8 +421,7 @@ static struct pcmcia_driver teles_cs_driver = {
469 .drv = { 421 .drv = {
470 .name = "teles_cs", 422 .name = "teles_cs",
471 }, 423 },
472 .attach = teles_attach, 424 .probe = teles_attach,
473 .event = teles_cs_event,
474 .remove = teles_detach, 425 .remove = teles_detach,
475 .id_table = teles_ids, 426 .id_table = teles_ids,
476 .suspend = teles_suspend, 427 .suspend = teles_suspend,
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 93c05dfa030d..f0f8916da7ad 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -66,8 +66,6 @@ struct pcmciamtd_dev {
66}; 66};
67 67
68 68
69static dev_info_t dev_info = "pcmciamtd";
70
71/* Module parameters */ 69/* Module parameters */
72 70
73/* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ 71/* 2 = do 16-bit transfers, 1 = do 8-bit transfers */
@@ -708,30 +706,6 @@ static int pcmciamtd_resume(struct pcmcia_device *dev)
708 return 0; 706 return 0;
709} 707}
710 708
711/* The card status event handler. Mostly, this schedules other
712 * stuff to run after an event is received. A CARD_REMOVAL event
713 * also sets some flags to discourage the driver from trying
714 * to talk to the card any more.
715 */
716
717static int pcmciamtd_event(event_t event, int priority,
718 event_callback_args_t *args)
719{
720 dev_link_t *link = args->client_data;
721
722 DEBUG(1, "event=0x%06x", event);
723 switch (event) {
724 case CS_EVENT_CARD_INSERTION:
725 DEBUG(2, "EVENT_CARD_INSERTION");
726 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
727 pcmciamtd_config(link);
728 break;
729 default:
730 DEBUG(2, "Unknown event %d", event);
731 }
732 return 0;
733}
734
735 709
736/* This deletes a driver "instance". The device is de-registered 710/* This deletes a driver "instance". The device is de-registered
737 * with Card Services. If it has been released, all local data 711 * with Card Services. If it has been released, all local data
@@ -762,16 +736,14 @@ static void pcmciamtd_detach(struct pcmcia_device *p_dev)
762 * with Card Services. 736 * with Card Services.
763 */ 737 */
764 738
765static dev_link_t *pcmciamtd_attach(void) 739static int pcmciamtd_attach(struct pcmcia_device *p_dev)
766{ 740{
767 struct pcmciamtd_dev *dev; 741 struct pcmciamtd_dev *dev;
768 dev_link_t *link; 742 dev_link_t *link;
769 client_reg_t client_reg;
770 int ret;
771 743
772 /* Create new memory card device */ 744 /* Create new memory card device */
773 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 745 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
774 if (!dev) return NULL; 746 if (!dev) return -ENOMEM;
775 DEBUG(1, "dev=0x%p", dev); 747 DEBUG(1, "dev=0x%p", dev);
776 748
777 memset(dev, 0, sizeof(*dev)); 749 memset(dev, 0, sizeof(*dev));
@@ -782,20 +754,13 @@ static dev_link_t *pcmciamtd_attach(void)
782 link->conf.IntType = INT_MEMORY; 754 link->conf.IntType = INT_MEMORY;
783 755
784 link->next = NULL; 756 link->next = NULL;
757 link->handle = p_dev;
758 p_dev->instance = link;
785 759
786 /* Register with Card Services */ 760 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
787 client_reg.dev_info = &dev_info; 761 pcmciamtd_config(link);
788 client_reg.Version = 0x0210; 762
789 client_reg.event_callback_args.client_data = link; 763 return 0;
790 DEBUG(2, "Calling RegisterClient");
791 ret = pcmcia_register_client(&link->handle, &client_reg);
792 if (ret != 0) {
793 cs_error(link->handle, RegisterClient, ret);
794 pcmciamtd_detach(link->handle);
795 return NULL;
796 }
797 DEBUG(2, "link = %p", link);
798 return link;
799} 764}
800 765
801static struct pcmcia_device_id pcmciamtd_ids[] = { 766static struct pcmcia_device_id pcmciamtd_ids[] = {
@@ -829,8 +794,7 @@ static struct pcmcia_driver pcmciamtd_driver = {
829 .drv = { 794 .drv = {
830 .name = "pcmciamtd" 795 .name = "pcmciamtd"
831 }, 796 },
832 .attach = pcmciamtd_attach, 797 .probe = pcmciamtd_attach,
833 .event = pcmciamtd_event,
834 .remove = pcmciamtd_detach, 798 .remove = pcmciamtd_detach,
835 .owner = THIS_MODULE, 799 .owner = THIS_MODULE,
836 .id_table = pcmciamtd_ids, 800 .id_table = pcmciamtd_ids,
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 8fcb63698ef1..48774efeec71 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -227,8 +227,6 @@ static char mii_preamble_required = 0;
227 227
228static void tc574_config(dev_link_t *link); 228static void tc574_config(dev_link_t *link);
229static void tc574_release(dev_link_t *link); 229static void tc574_release(dev_link_t *link);
230static int tc574_event(event_t event, int priority,
231 event_callback_args_t *args);
232 230
233static void mdio_sync(kio_addr_t ioaddr, int bits); 231static void mdio_sync(kio_addr_t ioaddr, int bits);
234static int mdio_read(kio_addr_t ioaddr, int phy_id, int location); 232static int mdio_read(kio_addr_t ioaddr, int phy_id, int location);
@@ -250,9 +248,6 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
250static struct ethtool_ops netdev_ethtool_ops; 248static struct ethtool_ops netdev_ethtool_ops;
251static void set_rx_mode(struct net_device *dev); 249static void set_rx_mode(struct net_device *dev);
252 250
253static dev_info_t dev_info = "3c574_cs";
254
255static dev_link_t *tc574_attach(void);
256static void tc574_detach(struct pcmcia_device *p_dev); 251static void tc574_detach(struct pcmcia_device *p_dev);
257 252
258/* 253/*
@@ -261,20 +256,18 @@ static void tc574_detach(struct pcmcia_device *p_dev);
261 with Card Services. 256 with Card Services.
262*/ 257*/
263 258
264static dev_link_t *tc574_attach(void) 259static int tc574_attach(struct pcmcia_device *p_dev)
265{ 260{
266 struct el3_private *lp; 261 struct el3_private *lp;
267 client_reg_t client_reg;
268 dev_link_t *link; 262 dev_link_t *link;
269 struct net_device *dev; 263 struct net_device *dev;
270 int ret;
271 264
272 DEBUG(0, "3c574_attach()\n"); 265 DEBUG(0, "3c574_attach()\n");
273 266
274 /* Create the PC card device object. */ 267 /* Create the PC card device object. */
275 dev = alloc_etherdev(sizeof(struct el3_private)); 268 dev = alloc_etherdev(sizeof(struct el3_private));
276 if (!dev) 269 if (!dev)
277 return NULL; 270 return -ENOMEM;
278 lp = netdev_priv(dev); 271 lp = netdev_priv(dev);
279 link = &lp->link; 272 link = &lp->link;
280 link->priv = dev; 273 link->priv = dev;
@@ -305,19 +298,13 @@ static dev_link_t *tc574_attach(void)
305 dev->watchdog_timeo = TX_TIMEOUT; 298 dev->watchdog_timeo = TX_TIMEOUT;
306#endif 299#endif
307 300
308 /* Register with Card Services */ 301 link->handle = p_dev;
309 link->next = NULL; 302 p_dev->instance = link;
310 client_reg.dev_info = &dev_info;
311 client_reg.Version = 0x0210;
312 client_reg.event_callback_args.client_data = link;
313 ret = pcmcia_register_client(&link->handle, &client_reg);
314 if (ret != 0) {
315 cs_error(link->handle, RegisterClient, ret);
316 tc574_detach(link->handle);
317 return NULL;
318 }
319 303
320 return link; 304 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
305 tc574_config(link);
306
307 return 0;
321} /* tc574_attach */ 308} /* tc574_attach */
322 309
323/* 310/*
@@ -565,29 +552,6 @@ static int tc574_resume(struct pcmcia_device *p_dev)
565 return 0; 552 return 0;
566} 553}
567 554
568/*
569 The card status event handler. Mostly, this schedules other
570 stuff to run after an event is received. A CARD_REMOVAL event
571 also sets some flags to discourage the net drivers from trying
572 to talk to the card any more.
573*/
574
575static int tc574_event(event_t event, int priority,
576 event_callback_args_t *args)
577{
578 dev_link_t *link = args->client_data;
579
580 DEBUG(1, "3c574_event(0x%06x)\n", event);
581
582 switch (event) {
583 case CS_EVENT_CARD_INSERTION:
584 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
585 tc574_config(link);
586 break;
587 }
588 return 0;
589} /* tc574_event */
590
591static void dump_status(struct net_device *dev) 555static void dump_status(struct net_device *dev)
592{ 556{
593 kio_addr_t ioaddr = dev->base_addr; 557 kio_addr_t ioaddr = dev->base_addr;
@@ -1282,8 +1246,7 @@ static struct pcmcia_driver tc574_driver = {
1282 .drv = { 1246 .drv = {
1283 .name = "3c574_cs", 1247 .name = "3c574_cs",
1284 }, 1248 },
1285 .attach = tc574_attach, 1249 .probe = tc574_attach,
1286 .event = tc574_event,
1287 .remove = tc574_detach, 1250 .remove = tc574_detach,
1288 .id_table = tc574_ids, 1251 .id_table = tc574_ids,
1289 .suspend = tc574_suspend, 1252 .suspend = tc574_suspend,
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 3516c02b9c89..1c3c9c666f74 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -143,8 +143,6 @@ DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)";
143 143
144static void tc589_config(dev_link_t *link); 144static void tc589_config(dev_link_t *link);
145static void tc589_release(dev_link_t *link); 145static void tc589_release(dev_link_t *link);
146static int tc589_event(event_t event, int priority,
147 event_callback_args_t *args);
148 146
149static u16 read_eeprom(kio_addr_t ioaddr, int index); 147static u16 read_eeprom(kio_addr_t ioaddr, int index);
150static void tc589_reset(struct net_device *dev); 148static void tc589_reset(struct net_device *dev);
@@ -161,9 +159,6 @@ static void el3_tx_timeout(struct net_device *dev);
161static void set_multicast_list(struct net_device *dev); 159static void set_multicast_list(struct net_device *dev);
162static struct ethtool_ops netdev_ethtool_ops; 160static struct ethtool_ops netdev_ethtool_ops;
163 161
164static dev_info_t dev_info = "3c589_cs";
165
166static dev_link_t *tc589_attach(void);
167static void tc589_detach(struct pcmcia_device *p_dev); 162static void tc589_detach(struct pcmcia_device *p_dev);
168 163
169/*====================================================================== 164/*======================================================================
@@ -174,20 +169,18 @@ static void tc589_detach(struct pcmcia_device *p_dev);
174 169
175======================================================================*/ 170======================================================================*/
176 171
177static dev_link_t *tc589_attach(void) 172static int tc589_attach(struct pcmcia_device *p_dev)
178{ 173{
179 struct el3_private *lp; 174 struct el3_private *lp;
180 client_reg_t client_reg;
181 dev_link_t *link; 175 dev_link_t *link;
182 struct net_device *dev; 176 struct net_device *dev;
183 int ret;
184 177
185 DEBUG(0, "3c589_attach()\n"); 178 DEBUG(0, "3c589_attach()\n");
186 179
187 /* Create new ethernet device */ 180 /* Create new ethernet device */
188 dev = alloc_etherdev(sizeof(struct el3_private)); 181 dev = alloc_etherdev(sizeof(struct el3_private));
189 if (!dev) 182 if (!dev)
190 return NULL; 183 return -ENOMEM;
191 lp = netdev_priv(dev); 184 lp = netdev_priv(dev);
192 link = &lp->link; 185 link = &lp->link;
193 link->priv = dev; 186 link->priv = dev;
@@ -204,7 +197,7 @@ static dev_link_t *tc589_attach(void)
204 link->conf.IntType = INT_MEMORY_AND_IO; 197 link->conf.IntType = INT_MEMORY_AND_IO;
205 link->conf.ConfigIndex = 1; 198 link->conf.ConfigIndex = 1;
206 link->conf.Present = PRESENT_OPTION; 199 link->conf.Present = PRESENT_OPTION;
207 200
208 /* The EL3-specific entries in the device structure. */ 201 /* The EL3-specific entries in the device structure. */
209 SET_MODULE_OWNER(dev); 202 SET_MODULE_OWNER(dev);
210 dev->hard_start_xmit = &el3_start_xmit; 203 dev->hard_start_xmit = &el3_start_xmit;
@@ -219,19 +212,13 @@ static dev_link_t *tc589_attach(void)
219#endif 212#endif
220 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 213 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
221 214
222 /* Register with Card Services */ 215 link->handle = p_dev;
223 link->next = NULL; 216 p_dev->instance = link;
224 client_reg.dev_info = &dev_info; 217
225 client_reg.Version = 0x0210; 218 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
226 client_reg.event_callback_args.client_data = link; 219 tc589_config(link);
227 ret = pcmcia_register_client(&link->handle, &client_reg); 220
228 if (ret != 0) { 221 return 0;
229 cs_error(link->handle, RegisterClient, ret);
230 tc589_detach(link->handle);
231 return NULL;
232 }
233
234 return link;
235} /* tc589_attach */ 222} /* tc589_attach */
236 223
237/*====================================================================== 224/*======================================================================
@@ -439,31 +426,6 @@ static int tc589_resume(struct pcmcia_device *p_dev)
439 return 0; 426 return 0;
440} 427}
441 428
442/*======================================================================
443
444 The card status event handler. Mostly, this schedules other
445 stuff to run after an event is received. A CARD_REMOVAL event
446 also sets some flags to discourage the net drivers from trying
447 to talk to the card any more.
448
449======================================================================*/
450
451static int tc589_event(event_t event, int priority,
452 event_callback_args_t *args)
453{
454 dev_link_t *link = args->client_data;
455
456 DEBUG(1, "3c589_event(0x%06x)\n", event);
457
458 switch (event) {
459 case CS_EVENT_CARD_INSERTION:
460 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
461 tc589_config(link);
462 break;
463 }
464 return 0;
465} /* tc589_event */
466
467/*====================================================================*/ 429/*====================================================================*/
468 430
469/* 431/*
@@ -1057,8 +1019,7 @@ static struct pcmcia_driver tc589_driver = {
1057 .drv = { 1019 .drv = {
1058 .name = "3c589_cs", 1020 .name = "3c589_cs",
1059 }, 1021 },
1060 .attach = tc589_attach, 1022 .probe = tc589_attach,
1061 .event = tc589_event,
1062 .remove = tc589_detach, 1023 .remove = tc589_detach,
1063 .id_table = tc589_ids, 1024 .id_table = tc589_ids,
1064 .suspend = tc589_suspend, 1025 .suspend = tc589_suspend,
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 3d36207d3332..01ddfc8cce3f 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -87,8 +87,6 @@ static char *version =
87 87
88static void axnet_config(dev_link_t *link); 88static void axnet_config(dev_link_t *link);
89static void axnet_release(dev_link_t *link); 89static void axnet_release(dev_link_t *link);
90static int axnet_event(event_t event, int priority,
91 event_callback_args_t *args);
92static int axnet_open(struct net_device *dev); 90static int axnet_open(struct net_device *dev);
93static int axnet_close(struct net_device *dev); 91static int axnet_close(struct net_device *dev);
94static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 92static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -107,11 +105,8 @@ static void block_input(struct net_device *dev, int count,
107static void block_output(struct net_device *dev, int count, 105static void block_output(struct net_device *dev, int count,
108 const u_char *buf, const int start_page); 106 const u_char *buf, const int start_page);
109 107
110static dev_link_t *axnet_attach(void);
111static void axnet_detach(struct pcmcia_device *p_dev); 108static void axnet_detach(struct pcmcia_device *p_dev);
112 109
113static dev_info_t dev_info = "axnet_cs";
114
115static void axdev_setup(struct net_device *dev); 110static void axdev_setup(struct net_device *dev);
116static void AX88190_init(struct net_device *dev, int startp); 111static void AX88190_init(struct net_device *dev, int startp);
117static int ax_open(struct net_device *dev); 112static int ax_open(struct net_device *dev);
@@ -146,13 +141,11 @@ static inline axnet_dev_t *PRIV(struct net_device *dev)
146 141
147======================================================================*/ 142======================================================================*/
148 143
149static dev_link_t *axnet_attach(void) 144static int axnet_attach(struct pcmcia_device *p_dev)
150{ 145{
151 axnet_dev_t *info; 146 axnet_dev_t *info;
152 dev_link_t *link; 147 dev_link_t *link;
153 struct net_device *dev; 148 struct net_device *dev;
154 client_reg_t client_reg;
155 int ret;
156 149
157 DEBUG(0, "axnet_attach()\n"); 150 DEBUG(0, "axnet_attach()\n");
158 151
@@ -160,7 +153,7 @@ static dev_link_t *axnet_attach(void)
160 "eth%d", axdev_setup); 153 "eth%d", axdev_setup);
161 154
162 if (!dev) 155 if (!dev)
163 return NULL; 156 return -ENOMEM;
164 157
165 info = PRIV(dev); 158 info = PRIV(dev);
166 link = &info->link; 159 link = &info->link;
@@ -175,19 +168,13 @@ static dev_link_t *axnet_attach(void)
175 dev->do_ioctl = &axnet_ioctl; 168 dev->do_ioctl = &axnet_ioctl;
176 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 169 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
177 170
178 /* Register with Card Services */ 171 link->handle = p_dev;
179 link->next = NULL; 172 p_dev->instance = link;
180 client_reg.dev_info = &dev_info;
181 client_reg.Version = 0x0210;
182 client_reg.event_callback_args.client_data = link;
183 ret = pcmcia_register_client(&link->handle, &client_reg);
184 if (ret != CS_SUCCESS) {
185 cs_error(link->handle, RegisterClient, ret);
186 axnet_detach(link->handle);
187 return NULL;
188 }
189 173
190 return link; 174 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
175 axnet_config(link);
176
177 return 0;
191} /* axnet_attach */ 178} /* axnet_attach */
192 179
193/*====================================================================== 180/*======================================================================
@@ -513,31 +500,6 @@ static int axnet_resume(struct pcmcia_device *p_dev)
513 500
514/*====================================================================== 501/*======================================================================
515 502
516 The card status event handler. Mostly, this schedules other
517 stuff to run after an event is received. A CARD_REMOVAL event
518 also sets some flags to discourage the net drivers from trying
519 to talk to the card any more.
520
521======================================================================*/
522
523static int axnet_event(event_t event, int priority,
524 event_callback_args_t *args)
525{
526 dev_link_t *link = args->client_data;
527
528 DEBUG(2, "axnet_event(0x%06x)\n", event);
529
530 switch (event) {
531 case CS_EVENT_CARD_INSERTION:
532 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
533 axnet_config(link);
534 break;
535 }
536 return 0;
537} /* axnet_event */
538
539/*======================================================================
540
541 MII interface support 503 MII interface support
542 504
543======================================================================*/ 505======================================================================*/
@@ -608,7 +570,7 @@ static int axnet_open(struct net_device *dev)
608 570
609 link->open++; 571 link->open++;
610 572
611 request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev); 573 request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, "axnet_cs", dev);
612 574
613 info->link_status = 0x00; 575 info->link_status = 0x00;
614 init_timer(&info->watchdog); 576 init_timer(&info->watchdog);
@@ -869,8 +831,7 @@ static struct pcmcia_driver axnet_cs_driver = {
869 .drv = { 831 .drv = {
870 .name = "axnet_cs", 832 .name = "axnet_cs",
871 }, 833 },
872 .attach = axnet_attach, 834 .probe = axnet_attach,
873 .event = axnet_event,
874 .remove = axnet_detach, 835 .remove = axnet_detach,
875 .id_table = axnet_ids, 836 .id_table = axnet_ids,
876 .suspend = axnet_suspend, 837 .suspend = axnet_suspend,
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index d48dbd3e153a..2827a48ea37c 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -120,12 +120,7 @@ MODULE_LICENSE("GPL");
120 120
121static void com20020_config(dev_link_t *link); 121static void com20020_config(dev_link_t *link);
122static void com20020_release(dev_link_t *link); 122static void com20020_release(dev_link_t *link);
123static int com20020_event(event_t event, int priority,
124 event_callback_args_t *args);
125 123
126static dev_info_t dev_info = "com20020_cs";
127
128static dev_link_t *com20020_attach(void);
129static void com20020_detach(struct pcmcia_device *p_dev); 124static void com20020_detach(struct pcmcia_device *p_dev);
130 125
131/*====================================================================*/ 126/*====================================================================*/
@@ -143,21 +138,19 @@ typedef struct com20020_dev_t {
143 138
144======================================================================*/ 139======================================================================*/
145 140
146static dev_link_t *com20020_attach(void) 141static int com20020_attach(struct pcmcia_device *p_dev)
147{ 142{
148 client_reg_t client_reg;
149 dev_link_t *link; 143 dev_link_t *link;
150 com20020_dev_t *info; 144 com20020_dev_t *info;
151 struct net_device *dev; 145 struct net_device *dev;
152 int ret;
153 struct arcnet_local *lp; 146 struct arcnet_local *lp;
154 147
155 DEBUG(0, "com20020_attach()\n"); 148 DEBUG(0, "com20020_attach()\n");
156 149
157 /* Create new network device */ 150 /* Create new network device */
158 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 151 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
159 if (!link) 152 if (!link)
160 return NULL; 153 return -ENOMEM;
161 154
162 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); 155 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
163 if (!info) 156 if (!info)
@@ -189,29 +182,19 @@ static dev_link_t *com20020_attach(void)
189 link->conf.IntType = INT_MEMORY_AND_IO; 182 link->conf.IntType = INT_MEMORY_AND_IO;
190 link->conf.Present = PRESENT_OPTION; 183 link->conf.Present = PRESENT_OPTION;
191 184
192
193 link->irq.Instance = info->dev = dev; 185 link->irq.Instance = info->dev = dev;
194 link->priv = info; 186 link->priv = info;
195 187
196 /* Register with Card Services */ 188 link->state |= DEV_PRESENT;
197 link->next = NULL; 189 com20020_config(link);
198 client_reg.dev_info = &dev_info;
199 client_reg.Version = 0x0210;
200 client_reg.event_callback_args.client_data = link;
201 ret = pcmcia_register_client(&link->handle, &client_reg);
202 if (ret != 0) {
203 cs_error(link->handle, RegisterClient, ret);
204 com20020_detach(link->handle);
205 return NULL;
206 }
207 190
208 return link; 191 return 0;
209 192
210fail_alloc_dev: 193fail_alloc_dev:
211 kfree(info); 194 kfree(info);
212fail_alloc_info: 195fail_alloc_info:
213 kfree(link); 196 kfree(link);
214 return NULL; 197 return -ENOMEM;
215} /* com20020_attach */ 198} /* com20020_attach */
216 199
217/*====================================================================== 200/*======================================================================
@@ -442,31 +425,6 @@ static int com20020_resume(struct pcmcia_device *p_dev)
442 return 0; 425 return 0;
443} 426}
444 427
445/*======================================================================
446
447 The card status event handler. Mostly, this schedules other
448 stuff to run after an event is received. A CARD_REMOVAL event
449 also sets some flags to discourage the net drivers from trying
450 to talk to the card any more.
451
452======================================================================*/
453
454static int com20020_event(event_t event, int priority,
455 event_callback_args_t *args)
456{
457 dev_link_t *link = args->client_data;
458
459 DEBUG(1, "com20020_event(0x%06x)\n", event);
460
461 switch (event) {
462 case CS_EVENT_CARD_INSERTION:
463 link->state |= DEV_PRESENT;
464 com20020_config(link);
465 break;
466 }
467 return 0;
468} /* com20020_event */
469
470static struct pcmcia_device_id com20020_ids[] = { 428static struct pcmcia_device_id com20020_ids[] = {
471 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), 429 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
472 PCMCIA_DEVICE_NULL 430 PCMCIA_DEVICE_NULL
@@ -478,8 +436,7 @@ static struct pcmcia_driver com20020_cs_driver = {
478 .drv = { 436 .drv = {
479 .name = "com20020_cs", 437 .name = "com20020_cs",
480 }, 438 },
481 .attach = com20020_attach, 439 .probe = com20020_attach,
482 .event = com20020_event,
483 .remove = com20020_detach, 440 .remove = com20020_detach,
484 .id_table = com20020_ids, 441 .id_table = com20020_ids,
485 .suspend = com20020_suspend, 442 .suspend = com20020_suspend,
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index dad6393052ff..28fe2fb4d6c0 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -88,9 +88,6 @@ static void fmvj18x_config(dev_link_t *link);
88static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id); 88static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id);
89static int fmvj18x_setup_mfc(dev_link_t *link); 89static int fmvj18x_setup_mfc(dev_link_t *link);
90static void fmvj18x_release(dev_link_t *link); 90static void fmvj18x_release(dev_link_t *link);
91static int fmvj18x_event(event_t event, int priority,
92 event_callback_args_t *args);
93static dev_link_t *fmvj18x_attach(void);
94static void fmvj18x_detach(struct pcmcia_device *p_dev); 91static void fmvj18x_detach(struct pcmcia_device *p_dev);
95 92
96/* 93/*
@@ -108,8 +105,6 @@ static void set_rx_mode(struct net_device *dev);
108static void fjn_tx_timeout(struct net_device *dev); 105static void fjn_tx_timeout(struct net_device *dev);
109static struct ethtool_ops netdev_ethtool_ops; 106static struct ethtool_ops netdev_ethtool_ops;
110 107
111static dev_info_t dev_info = "fmvj18x_cs";
112
113/* 108/*
114 card type 109 card type
115 */ 110 */
@@ -233,20 +228,18 @@ typedef struct local_info_t {
233#define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ 228#define BANK_1U 0x24 /* bank 1 (CONFIG_1) */
234#define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ 229#define BANK_2U 0x28 /* bank 2 (CONFIG_1) */
235 230
236static dev_link_t *fmvj18x_attach(void) 231static int fmvj18x_attach(struct pcmcia_device *p_dev)
237{ 232{
238 local_info_t *lp; 233 local_info_t *lp;
239 dev_link_t *link; 234 dev_link_t *link;
240 struct net_device *dev; 235 struct net_device *dev;
241 client_reg_t client_reg; 236
242 int ret;
243
244 DEBUG(0, "fmvj18x_attach()\n"); 237 DEBUG(0, "fmvj18x_attach()\n");
245 238
246 /* Make up a FMVJ18x specific data structure */ 239 /* Make up a FMVJ18x specific data structure */
247 dev = alloc_etherdev(sizeof(local_info_t)); 240 dev = alloc_etherdev(sizeof(local_info_t));
248 if (!dev) 241 if (!dev)
249 return NULL; 242 return -ENOMEM;
250 lp = netdev_priv(dev); 243 lp = netdev_priv(dev);
251 link = &lp->link; 244 link = &lp->link;
252 link->priv = dev; 245 link->priv = dev;
@@ -261,7 +254,7 @@ static dev_link_t *fmvj18x_attach(void)
261 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 254 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
262 link->irq.Handler = &fjn_interrupt; 255 link->irq.Handler = &fjn_interrupt;
263 link->irq.Instance = dev; 256 link->irq.Instance = dev;
264 257
265 /* General socket configuration */ 258 /* General socket configuration */
266 link->conf.Attributes = CONF_ENABLE_IRQ; 259 link->conf.Attributes = CONF_ENABLE_IRQ;
267 link->conf.Vcc = 50; 260 link->conf.Vcc = 50;
@@ -280,20 +273,14 @@ static dev_link_t *fmvj18x_attach(void)
280 dev->watchdog_timeo = TX_TIMEOUT; 273 dev->watchdog_timeo = TX_TIMEOUT;
281#endif 274#endif
282 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 275 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
283
284 /* Register with Card Services */
285 link->next = NULL;
286 client_reg.dev_info = &dev_info;
287 client_reg.Version = 0x0210;
288 client_reg.event_callback_args.client_data = link;
289 ret = pcmcia_register_client(&link->handle, &client_reg);
290 if (ret != 0) {
291 cs_error(link->handle, RegisterClient, ret);
292 fmvj18x_detach(link->handle);
293 return NULL;
294 }
295 276
296 return link; 277 link->handle = p_dev;
278 p_dev->instance = link;
279
280 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
281 fmvj18x_config(link);
282
283 return 0;
297} /* fmvj18x_attach */ 284} /* fmvj18x_attach */
298 285
299/*====================================================================*/ 286/*====================================================================*/
@@ -734,22 +721,6 @@ static int fmvj18x_resume(struct pcmcia_device *p_dev)
734 721
735/*====================================================================*/ 722/*====================================================================*/
736 723
737static int fmvj18x_event(event_t event, int priority,
738 event_callback_args_t *args)
739{
740 dev_link_t *link = args->client_data;
741
742 DEBUG(1, "fmvj18x_event(0x%06x)\n", event);
743
744 switch (event) {
745 case CS_EVENT_CARD_INSERTION:
746 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
747 fmvj18x_config(link);
748 break;
749 }
750 return 0;
751} /* fmvj18x_event */
752
753static struct pcmcia_device_id fmvj18x_ids[] = { 724static struct pcmcia_device_id fmvj18x_ids[] = {
754 PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004), 725 PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004),
755 PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59), 726 PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59),
@@ -780,8 +751,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = {
780 .drv = { 751 .drv = {
781 .name = "fmvj18x_cs", 752 .name = "fmvj18x_cs",
782 }, 753 },
783 .attach = fmvj18x_attach, 754 .probe = fmvj18x_attach,
784 .event = fmvj18x_event,
785 .remove = fmvj18x_detach, 755 .remove = fmvj18x_detach,
786 .id_table = fmvj18x_ids, 756 .id_table = fmvj18x_ids,
787 .suspend = fmvj18x_suspend, 757 .suspend = fmvj18x_suspend,
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 90da35d1f4a5..b9c7e39576f5 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -108,12 +108,6 @@ MODULE_LICENSE("GPL");
108static void ibmtr_config(dev_link_t *link); 108static void ibmtr_config(dev_link_t *link);
109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase); 109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase);
110static void ibmtr_release(dev_link_t *link); 110static void ibmtr_release(dev_link_t *link);
111static int ibmtr_event(event_t event, int priority,
112 event_callback_args_t *args);
113
114static dev_info_t dev_info = "ibmtr_cs";
115
116static dev_link_t *ibmtr_attach(void);
117static void ibmtr_detach(struct pcmcia_device *p_dev); 111static void ibmtr_detach(struct pcmcia_device *p_dev);
118 112
119/*====================================================================*/ 113/*====================================================================*/
@@ -144,25 +138,23 @@ static struct ethtool_ops netdev_ethtool_ops = {
144 138
145======================================================================*/ 139======================================================================*/
146 140
147static dev_link_t *ibmtr_attach(void) 141static int ibmtr_attach(struct pcmcia_device *p_dev)
148{ 142{
149 ibmtr_dev_t *info; 143 ibmtr_dev_t *info;
150 dev_link_t *link; 144 dev_link_t *link;
151 struct net_device *dev; 145 struct net_device *dev;
152 client_reg_t client_reg;
153 int ret;
154 146
155 DEBUG(0, "ibmtr_attach()\n"); 147 DEBUG(0, "ibmtr_attach()\n");
156 148
157 /* Create new token-ring device */ 149 /* Create new token-ring device */
158 info = kmalloc(sizeof(*info), GFP_KERNEL); 150 info = kmalloc(sizeof(*info), GFP_KERNEL);
159 if (!info) return NULL; 151 if (!info) return -ENOMEM;
160 memset(info,0,sizeof(*info)); 152 memset(info,0,sizeof(*info));
161 dev = alloc_trdev(sizeof(struct tok_info)); 153 dev = alloc_trdev(sizeof(struct tok_info));
162 if (!dev) { 154 if (!dev) {
163 kfree(info); 155 kfree(info);
164 return NULL; 156 return -ENOMEM;
165 } 157 }
166 158
167 link = &info->link; 159 link = &info->link;
168 link->priv = info; 160 link->priv = info;
@@ -183,24 +175,13 @@ static dev_link_t *ibmtr_attach(void)
183 175
184 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 176 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
185 177
186 /* Register with Card Services */ 178 link->handle = p_dev;
187 link->next = NULL; 179 p_dev->instance = link;
188 client_reg.dev_info = &dev_info;
189 client_reg.Version = 0x0210;
190 client_reg.event_callback_args.client_data = link;
191 ret = pcmcia_register_client(&link->handle, &client_reg);
192 if (ret != 0) {
193 cs_error(link->handle, RegisterClient, ret);
194 goto out_detach;
195 }
196 180
197out: 181 link->state |= DEV_PRESENT;
198 return link; 182 ibmtr_config(link);
199 183
200out_detach: 184 return 0;
201 ibmtr_detach(link->handle);
202 link = NULL;
203 goto out;
204} /* ibmtr_attach */ 185} /* ibmtr_attach */
205 186
206/*====================================================================== 187/*======================================================================
@@ -420,31 +401,6 @@ static int ibmtr_resume(struct pcmcia_device *p_dev)
420} 401}
421 402
422 403
423/*======================================================================
424
425 The card status event handler. Mostly, this schedules other
426 stuff to run after an event is received. A CARD_REMOVAL event
427 also sets some flags to discourage the net drivers from trying
428 to talk to the card any more.
429
430======================================================================*/
431
432static int ibmtr_event(event_t event, int priority,
433 event_callback_args_t *args)
434{
435 dev_link_t *link = args->client_data;
436
437 DEBUG(1, "ibmtr_event(0x%06x)\n", event);
438
439 switch (event) {
440 case CS_EVENT_CARD_INSERTION:
441 link->state |= DEV_PRESENT;
442 ibmtr_config(link);
443 break;
444 }
445 return 0;
446} /* ibmtr_event */
447
448/*====================================================================*/ 404/*====================================================================*/
449 405
450static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase) 406static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase)
@@ -500,8 +456,7 @@ static struct pcmcia_driver ibmtr_cs_driver = {
500 .drv = { 456 .drv = {
501 .name = "ibmtr_cs", 457 .name = "ibmtr_cs",
502 }, 458 },
503 .attach = ibmtr_attach, 459 .probe = ibmtr_attach,
504 .event = ibmtr_event,
505 .remove = ibmtr_detach, 460 .remove = ibmtr_detach,
506 .id_table = ibmtr_ids, 461 .id_table = ibmtr_ids,
507 .suspend = ibmtr_suspend, 462 .suspend = ibmtr_suspend,
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 0c9cb9f49a81..4a232254a497 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -388,8 +388,6 @@ static char *version =
388DRV_NAME " " DRV_VERSION " (Roger C. Pao)"; 388DRV_NAME " " DRV_VERSION " (Roger C. Pao)";
389#endif 389#endif
390 390
391static dev_info_t dev_info="nmclan_cs";
392
393static char *if_names[]={ 391static char *if_names[]={
394 "Auto", "10baseT", "BNC", 392 "Auto", "10baseT", "BNC",
395}; 393};
@@ -421,8 +419,6 @@ Function Prototypes
421 419
422static void nmclan_config(dev_link_t *link); 420static void nmclan_config(dev_link_t *link);
423static void nmclan_release(dev_link_t *link); 421static void nmclan_release(dev_link_t *link);
424static int nmclan_event(event_t event, int priority,
425 event_callback_args_t *args);
426 422
427static void nmclan_reset(struct net_device *dev); 423static void nmclan_reset(struct net_device *dev);
428static int mace_config(struct net_device *dev, struct ifmap *map); 424static int mace_config(struct net_device *dev, struct ifmap *map);
@@ -438,7 +434,6 @@ static void set_multicast_list(struct net_device *dev);
438static struct ethtool_ops netdev_ethtool_ops; 434static struct ethtool_ops netdev_ethtool_ops;
439 435
440 436
441static dev_link_t *nmclan_attach(void);
442static void nmclan_detach(struct pcmcia_device *p_dev); 437static void nmclan_detach(struct pcmcia_device *p_dev);
443 438
444/* ---------------------------------------------------------------------------- 439/* ----------------------------------------------------------------------------
@@ -448,13 +443,11 @@ nmclan_attach
448 Services. 443 Services.
449---------------------------------------------------------------------------- */ 444---------------------------------------------------------------------------- */
450 445
451static dev_link_t *nmclan_attach(void) 446static int nmclan_attach(struct pcmcia_device *p_dev)
452{ 447{
453 mace_private *lp; 448 mace_private *lp;
454 dev_link_t *link; 449 dev_link_t *link;
455 struct net_device *dev; 450 struct net_device *dev;
456 client_reg_t client_reg;
457 int ret;
458 451
459 DEBUG(0, "nmclan_attach()\n"); 452 DEBUG(0, "nmclan_attach()\n");
460 DEBUG(1, "%s\n", rcsid); 453 DEBUG(1, "%s\n", rcsid);
@@ -462,7 +455,7 @@ static dev_link_t *nmclan_attach(void)
462 /* Create new ethernet device */ 455 /* Create new ethernet device */
463 dev = alloc_etherdev(sizeof(mace_private)); 456 dev = alloc_etherdev(sizeof(mace_private));
464 if (!dev) 457 if (!dev)
465 return NULL; 458 return -ENOMEM;
466 lp = netdev_priv(dev); 459 lp = netdev_priv(dev);
467 link = &lp->link; 460 link = &lp->link;
468 link->priv = dev; 461 link->priv = dev;
@@ -496,19 +489,13 @@ static dev_link_t *nmclan_attach(void)
496 dev->watchdog_timeo = TX_TIMEOUT; 489 dev->watchdog_timeo = TX_TIMEOUT;
497#endif 490#endif
498 491
499 /* Register with Card Services */ 492 link->handle = p_dev;
500 link->next = NULL; 493 p_dev->instance = link;
501 client_reg.dev_info = &dev_info; 494
502 client_reg.Version = 0x0210; 495 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
503 client_reg.event_callback_args.client_data = link; 496 nmclan_config(link);
504 ret = pcmcia_register_client(&link->handle, &client_reg);
505 if (ret != 0) {
506 cs_error(link->handle, RegisterClient, ret);
507 nmclan_detach(link->handle);
508 return NULL;
509 }
510 497
511 return link; 498 return 0;
512} /* nmclan_attach */ 499} /* nmclan_attach */
513 500
514/* ---------------------------------------------------------------------------- 501/* ----------------------------------------------------------------------------
@@ -821,31 +808,6 @@ static int nmclan_resume(struct pcmcia_device *p_dev)
821 return 0; 808 return 0;
822} 809}
823 810
824/* ----------------------------------------------------------------------------
825nmclan_event
826 The card status event handler. Mostly, this schedules other
827 stuff to run after an event is received. A CARD_REMOVAL event
828 also sets some flags to discourage the net drivers from trying
829 to talk to the card any more.
830---------------------------------------------------------------------------- */
831static int nmclan_event(event_t event, int priority,
832 event_callback_args_t *args)
833{
834 dev_link_t *link = args->client_data;
835
836 DEBUG(1, "nmclan_event(0x%06x)\n", event);
837
838 switch (event) {
839 case CS_EVENT_CARD_INSERTION:
840 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
841 nmclan_config(link);
842 break;
843 case CS_EVENT_RESET_REQUEST:
844 return 1;
845 break;
846 }
847 return 0;
848} /* nmclan_event */
849 811
850/* ---------------------------------------------------------------------------- 812/* ----------------------------------------------------------------------------
851nmclan_reset 813nmclan_reset
@@ -1673,8 +1635,7 @@ static struct pcmcia_driver nmclan_cs_driver = {
1673 .drv = { 1635 .drv = {
1674 .name = "nmclan_cs", 1636 .name = "nmclan_cs",
1675 }, 1637 },
1676 .attach = nmclan_attach, 1638 .probe = nmclan_attach,
1677 .event = nmclan_event,
1678 .remove = nmclan_detach, 1639 .remove = nmclan_detach,
1679 .id_table = nmclan_ids, 1640 .id_table = nmclan_ids,
1680 .suspend = nmclan_suspend, 1641 .suspend = nmclan_suspend,
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index b35c951fc6fa..d85b758f3efa 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -105,8 +105,6 @@ module_param_array(hw_addr, int, NULL, 0);
105static void mii_phy_probe(struct net_device *dev); 105static void mii_phy_probe(struct net_device *dev);
106static void pcnet_config(dev_link_t *link); 106static void pcnet_config(dev_link_t *link);
107static void pcnet_release(dev_link_t *link); 107static void pcnet_release(dev_link_t *link);
108static int pcnet_event(event_t event, int priority,
109 event_callback_args_t *args);
110static int pcnet_open(struct net_device *dev); 108static int pcnet_open(struct net_device *dev);
111static int pcnet_close(struct net_device *dev); 109static int pcnet_close(struct net_device *dev);
112static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 110static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -120,7 +118,6 @@ static int setup_shmem_window(dev_link_t *link, int start_pg,
120static int setup_dma_config(dev_link_t *link, int start_pg, 118static int setup_dma_config(dev_link_t *link, int start_pg,
121 int stop_pg); 119 int stop_pg);
122 120
123static dev_link_t *pcnet_attach(void);
124static void pcnet_detach(struct pcmcia_device *p_dev); 121static void pcnet_detach(struct pcmcia_device *p_dev);
125 122
126static dev_info_t dev_info = "pcnet_cs"; 123static dev_info_t dev_info = "pcnet_cs";
@@ -243,19 +240,17 @@ static inline pcnet_dev_t *PRIV(struct net_device *dev)
243 240
244======================================================================*/ 241======================================================================*/
245 242
246static dev_link_t *pcnet_attach(void) 243static int pcnet_probe(struct pcmcia_device *p_dev)
247{ 244{
248 pcnet_dev_t *info; 245 pcnet_dev_t *info;
249 dev_link_t *link; 246 dev_link_t *link;
250 struct net_device *dev; 247 struct net_device *dev;
251 client_reg_t client_reg;
252 int ret;
253 248
254 DEBUG(0, "pcnet_attach()\n"); 249 DEBUG(0, "pcnet_attach()\n");
255 250
256 /* Create new ethernet device */ 251 /* Create new ethernet device */
257 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
258 if (!dev) return NULL; 253 if (!dev) return -ENOMEM;
259 info = PRIV(dev); 254 info = PRIV(dev);
260 link = &info->link; 255 link = &info->link;
261 link->priv = dev; 256 link->priv = dev;
@@ -270,19 +265,13 @@ static dev_link_t *pcnet_attach(void)
270 dev->stop = &pcnet_close; 265 dev->stop = &pcnet_close;
271 dev->set_config = &set_config; 266 dev->set_config = &set_config;
272 267
273 /* Register with Card Services */ 268 link->handle = p_dev;
274 link->next = NULL; 269 p_dev->instance = link;
275 client_reg.dev_info = &dev_info; 270
276 client_reg.Version = 0x0210; 271 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
277 client_reg.event_callback_args.client_data = link; 272 pcnet_config(link);
278 ret = pcmcia_register_client(&link->handle, &client_reg);
279 if (ret != CS_SUCCESS) {
280 cs_error(link->handle, RegisterClient, ret);
281 pcnet_detach(link->handle);
282 return NULL;
283 }
284 273
285 return link; 274 return 0;
286} /* pcnet_attach */ 275} /* pcnet_attach */
287 276
288/*====================================================================== 277/*======================================================================
@@ -800,21 +789,6 @@ static int pcnet_resume(struct pcmcia_device *p_dev)
800 return 0; 789 return 0;
801} 790}
802 791
803static int pcnet_event(event_t event, int priority,
804 event_callback_args_t *args)
805{
806 dev_link_t *link = args->client_data;
807
808 DEBUG(2, "pcnet_event(0x%06x)\n", event);
809
810 switch (event) {
811 case CS_EVENT_CARD_INSERTION:
812 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
813 pcnet_config(link);
814 break;
815 }
816 return 0;
817} /* pcnet_event */
818 792
819/*====================================================================== 793/*======================================================================
820 794
@@ -1835,8 +1809,7 @@ static struct pcmcia_driver pcnet_driver = {
1835 .drv = { 1809 .drv = {
1836 .name = "pcnet_cs", 1810 .name = "pcnet_cs",
1837 }, 1811 },
1838 .attach = pcnet_attach, 1812 .probe = pcnet_probe,
1839 .event = pcnet_event,
1840 .remove = pcnet_detach, 1813 .remove = pcnet_detach,
1841 .owner = THIS_MODULE, 1814 .owner = THIS_MODULE,
1842 .id_table = pcnet_ids, 1815 .id_table = pcnet_ids,
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 9eb5cecfb2f5..0122415dfeef 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -102,8 +102,6 @@ static const char *version =
102 currently have room for another Tx packet. */ 102 currently have room for another Tx packet. */
103#define MEMORY_WAIT_TIME 8 103#define MEMORY_WAIT_TIME 8
104 104
105static dev_info_t dev_info = "smc91c92_cs";
106
107struct smc_private { 105struct smc_private {
108 dev_link_t link; 106 dev_link_t link;
109 spinlock_t lock; 107 spinlock_t lock;
@@ -279,12 +277,9 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002,
279 277
280/*====================================================================*/ 278/*====================================================================*/
281 279
282static dev_link_t *smc91c92_attach(void);
283static void smc91c92_detach(struct pcmcia_device *p_dev); 280static void smc91c92_detach(struct pcmcia_device *p_dev);
284static void smc91c92_config(dev_link_t *link); 281static void smc91c92_config(dev_link_t *link);
285static void smc91c92_release(dev_link_t *link); 282static void smc91c92_release(dev_link_t *link);
286static int smc91c92_event(event_t event, int priority,
287 event_callback_args_t *args);
288 283
289static int smc_open(struct net_device *dev); 284static int smc_open(struct net_device *dev);
290static int smc_close(struct net_device *dev); 285static int smc_close(struct net_device *dev);
@@ -313,20 +308,18 @@ static struct ethtool_ops ethtool_ops;
313 308
314======================================================================*/ 309======================================================================*/
315 310
316static dev_link_t *smc91c92_attach(void) 311static int smc91c92_attach(struct pcmcia_device *p_dev)
317{ 312{
318 client_reg_t client_reg;
319 struct smc_private *smc; 313 struct smc_private *smc;
320 dev_link_t *link; 314 dev_link_t *link;
321 struct net_device *dev; 315 struct net_device *dev;
322 int ret;
323 316
324 DEBUG(0, "smc91c92_attach()\n"); 317 DEBUG(0, "smc91c92_attach()\n");
325 318
326 /* Create new ethernet device */ 319 /* Create new ethernet device */
327 dev = alloc_etherdev(sizeof(struct smc_private)); 320 dev = alloc_etherdev(sizeof(struct smc_private));
328 if (!dev) 321 if (!dev)
329 return NULL; 322 return -ENOMEM;
330 smc = netdev_priv(dev); 323 smc = netdev_priv(dev);
331 link = &smc->link; 324 link = &smc->link;
332 link->priv = dev; 325 link->priv = dev;
@@ -364,19 +357,13 @@ static dev_link_t *smc91c92_attach(void)
364 smc->mii_if.phy_id_mask = 0x1f; 357 smc->mii_if.phy_id_mask = 0x1f;
365 smc->mii_if.reg_num_mask = 0x1f; 358 smc->mii_if.reg_num_mask = 0x1f;
366 359
367 /* Register with Card Services */ 360 link->handle = p_dev;
368 link->next = NULL; 361 p_dev->instance = link;
369 client_reg.dev_info = &dev_info;
370 client_reg.Version = 0x0210;
371 client_reg.event_callback_args.client_data = link;
372 ret = pcmcia_register_client(&link->handle, &client_reg);
373 if (ret != 0) {
374 cs_error(link->handle, RegisterClient, ret);
375 smc91c92_detach(link->handle);
376 return NULL;
377 }
378 362
379 return link; 363 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
364 smc91c92_config(link);
365
366 return 0;
380} /* smc91c92_attach */ 367} /* smc91c92_attach */
381 368
382/*====================================================================== 369/*======================================================================
@@ -1212,31 +1199,6 @@ static void smc91c92_release(dev_link_t *link)
1212 1199
1213/*====================================================================== 1200/*======================================================================
1214 1201
1215 The card status event handler. Mostly, this schedules other
1216 stuff to run after an event is received. A CARD_REMOVAL event
1217 also sets some flags to discourage the net drivers from trying
1218 to talk to the card any more.
1219
1220======================================================================*/
1221
1222static int smc91c92_event(event_t event, int priority,
1223 event_callback_args_t *args)
1224{
1225 dev_link_t *link = args->client_data;
1226
1227 DEBUG(1, "smc91c92_event(0x%06x)\n", event);
1228
1229 switch (event) {
1230 case CS_EVENT_CARD_INSERTION:
1231 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1232 smc91c92_config(link);
1233 break;
1234 }
1235 return 0;
1236} /* smc91c92_event */
1237
1238/*======================================================================
1239
1240 MII interface support for SMC91cXX based cards 1202 MII interface support for SMC91cXX based cards
1241======================================================================*/ 1203======================================================================*/
1242 1204
@@ -2349,8 +2311,7 @@ static struct pcmcia_driver smc91c92_cs_driver = {
2349 .drv = { 2311 .drv = {
2350 .name = "smc91c92_cs", 2312 .name = "smc91c92_cs",
2351 }, 2313 },
2352 .attach = smc91c92_attach, 2314 .probe = smc91c92_attach,
2353 .event = smc91c92_event,
2354 .remove = smc91c92_detach, 2315 .remove = smc91c92_detach,
2355 .id_table = smc91c92_ids, 2316 .id_table = smc91c92_ids,
2356 .suspend = smc91c92_suspend, 2317 .suspend = smc91c92_suspend,
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 8c8cc40bbb7d..049c34b37067 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -292,8 +292,6 @@ static void mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg,
292static int has_ce2_string(dev_link_t * link); 292static int has_ce2_string(dev_link_t * link);
293static void xirc2ps_config(dev_link_t * link); 293static void xirc2ps_config(dev_link_t * link);
294static void xirc2ps_release(dev_link_t * link); 294static void xirc2ps_release(dev_link_t * link);
295static int xirc2ps_event(event_t event, int priority,
296 event_callback_args_t * args);
297 295
298/**************** 296/****************
299 * The attach() and detach() entry points are used to create and destroy 297 * The attach() and detach() entry points are used to create and destroy
@@ -301,7 +299,6 @@ static int xirc2ps_event(event_t event, int priority,
301 * needed to manage one actual PCMCIA card. 299 * needed to manage one actual PCMCIA card.
302 */ 300 */
303 301
304static dev_link_t *xirc2ps_attach(void);
305static void xirc2ps_detach(struct pcmcia_device *p_dev); 302static void xirc2ps_detach(struct pcmcia_device *p_dev);
306 303
307/**************** 304/****************
@@ -313,14 +310,6 @@ static void xirc2ps_detach(struct pcmcia_device *p_dev);
313 310
314static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs); 311static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs);
315 312
316/*
317 * The dev_info variable is the "key" that is used to match up this
318 * device driver with appropriate cards, through the card configuration
319 * database.
320 */
321
322static dev_info_t dev_info = "xirc2ps_cs";
323
324/**************** 313/****************
325 * A linked list of "instances" of the device. Each actual 314 * A linked list of "instances" of the device. Each actual
326 * PCMCIA card corresponds to one device instance, and is described 315 * PCMCIA card corresponds to one device instance, and is described
@@ -563,21 +552,19 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len)
563 * card insertion event. 552 * card insertion event.
564 */ 553 */
565 554
566static dev_link_t * 555static int
567xirc2ps_attach(void) 556xirc2ps_attach(struct pcmcia_device *p_dev)
568{ 557{
569 client_reg_t client_reg;
570 dev_link_t *link; 558 dev_link_t *link;
571 struct net_device *dev; 559 struct net_device *dev;
572 local_info_t *local; 560 local_info_t *local;
573 int err;
574 561
575 DEBUG(0, "attach()\n"); 562 DEBUG(0, "attach()\n");
576 563
577 /* Allocate the device structure */ 564 /* Allocate the device structure */
578 dev = alloc_etherdev(sizeof(local_info_t)); 565 dev = alloc_etherdev(sizeof(local_info_t));
579 if (!dev) 566 if (!dev)
580 return NULL; 567 return -ENOMEM;
581 local = netdev_priv(dev); 568 local = netdev_priv(dev);
582 link = &local->link; 569 link = &local->link;
583 link->priv = dev; 570 link->priv = dev;
@@ -606,18 +593,13 @@ xirc2ps_attach(void)
606 dev->watchdog_timeo = TX_TIMEOUT; 593 dev->watchdog_timeo = TX_TIMEOUT;
607#endif 594#endif
608 595
609 /* Register with Card Services */ 596 link->handle = p_dev;
610 link->next = NULL; 597 p_dev->instance = link;
611 client_reg.dev_info = &dev_info; 598
612 client_reg.Version = 0x0210; 599 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
613 client_reg.event_callback_args.client_data = link; 600 xirc2ps_config(link);
614 if ((err = pcmcia_register_client(&link->handle, &client_reg))) {
615 cs_error(link->handle, RegisterClient, err);
616 xirc2ps_detach(link->handle);
617 return NULL;
618 }
619 601
620 return link; 602 return 0;
621} /* xirc2ps_attach */ 603} /* xirc2ps_attach */
622 604
623/**************** 605/****************
@@ -1162,34 +1144,6 @@ static int xirc2ps_resume(struct pcmcia_device *p_dev)
1162 return 0; 1144 return 0;
1163} 1145}
1164 1146
1165/****************
1166 * The card status event handler. Mostly, this schedules other
1167 * stuff to run after an event is received. A CARD_REMOVAL event
1168 * also sets some flags to discourage the net drivers from trying
1169 * to talk to the card any more.
1170 *
1171 * When a CARD_REMOVAL event is received, we immediately set a flag
1172 * to block future accesses to this device. All the functions that
1173 * actually access the device should check this flag to make sure
1174 * the card is still present.
1175 */
1176
1177static int
1178xirc2ps_event(event_t event, int priority,
1179 event_callback_args_t * args)
1180{
1181 dev_link_t *link = args->client_data;
1182
1183 DEBUG(0, "event(%d)\n", (int)event);
1184
1185 switch (event) {
1186 case CS_EVENT_CARD_INSERTION:
1187 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1188 xirc2ps_config(link);
1189 break;
1190 }
1191 return 0;
1192} /* xirc2ps_event */
1193 1147
1194/*====================================================================*/ 1148/*====================================================================*/
1195 1149
@@ -1981,8 +1935,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = {
1981 .drv = { 1935 .drv = {
1982 .name = "xirc2ps_cs", 1936 .name = "xirc2ps_cs",
1983 }, 1937 },
1984 .attach = xirc2ps_attach, 1938 .probe = xirc2ps_attach,
1985 .event = xirc2ps_event,
1986 .remove = xirc2ps_detach, 1939 .remove = xirc2ps_detach,
1987 .id_table = xirc2ps_ids, 1940 .id_table = xirc2ps_ids,
1988 .suspend = xirc2ps_suspend, 1941 .suspend = xirc2ps_suspend,
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 88805a4c29f1..a496460ce224 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -82,8 +82,6 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
82 82
83static void airo_config(dev_link_t *link); 83static void airo_config(dev_link_t *link);
84static void airo_release(dev_link_t *link); 84static void airo_release(dev_link_t *link);
85static int airo_event(event_t event, int priority,
86 event_callback_args_t *args);
87 85
88/* 86/*
89 The attach() and detach() entry points are used to create and destroy 87 The attach() and detach() entry points are used to create and destroy
@@ -91,7 +89,6 @@ static int airo_event(event_t event, int priority,
91 needed to manage one actual PCMCIA card. 89 needed to manage one actual PCMCIA card.
92*/ 90*/
93 91
94static dev_link_t *airo_attach(void);
95static void airo_detach(struct pcmcia_device *p_dev); 92static void airo_detach(struct pcmcia_device *p_dev);
96 93
97/* 94/*
@@ -102,14 +99,6 @@ static void airo_detach(struct pcmcia_device *p_dev);
102*/ 99*/
103 100
104/* 101/*
105 The dev_info variable is the "key" that is used to match up this
106 device driver with appropriate cards, through the card configuration
107 database.
108*/
109
110static dev_info_t dev_info = "airo_cs";
111
112/*
113 A linked list of "instances" of the aironet device. Each actual 102 A linked list of "instances" of the aironet device. Each actual
114 PCMCIA card corresponds to one device instance, and is described 103 PCMCIA card corresponds to one device instance, and is described
115 by one dev_link_t structure (defined in ds.h). 104 by one dev_link_t structure (defined in ds.h).
@@ -152,20 +141,18 @@ typedef struct local_info_t {
152 141
153 ======================================================================*/ 142 ======================================================================*/
154 143
155static dev_link_t *airo_attach(void) 144static int airo_attach(struct pcmcia_device *p_dev)
156{ 145{
157 client_reg_t client_reg;
158 dev_link_t *link; 146 dev_link_t *link;
159 local_info_t *local; 147 local_info_t *local;
160 int ret; 148
161
162 DEBUG(0, "airo_attach()\n"); 149 DEBUG(0, "airo_attach()\n");
163 150
164 /* Initialize the dev_link_t structure */ 151 /* Initialize the dev_link_t structure */
165 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 152 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
166 if (!link) { 153 if (!link) {
167 printk(KERN_ERR "airo_cs: no memory for new device\n"); 154 printk(KERN_ERR "airo_cs: no memory for new device\n");
168 return NULL; 155 return -ENOMEM;
169 } 156 }
170 157
171 /* Interrupt setup */ 158 /* Interrupt setup */
@@ -189,23 +176,17 @@ static dev_link_t *airo_attach(void)
189 if (!local) { 176 if (!local) {
190 printk(KERN_ERR "airo_cs: no memory for new device\n"); 177 printk(KERN_ERR "airo_cs: no memory for new device\n");
191 kfree (link); 178 kfree (link);
192 return NULL; 179 return -ENOMEM;
193 } 180 }
194 link->priv = local; 181 link->priv = local;
195 182
196 /* Register with Card Services */ 183 link->handle = p_dev;
197 link->next = NULL; 184 p_dev->instance = link;
198 client_reg.dev_info = &dev_info; 185
199 client_reg.Version = 0x0210; 186 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
200 client_reg.event_callback_args.client_data = link; 187 airo_config(link);
201 ret = pcmcia_register_client(&link->handle, &client_reg); 188
202 if (ret != 0) { 189 return 0;
203 cs_error(link->handle, RegisterClient, ret);
204 airo_detach(link->handle);
205 return NULL;
206 }
207
208 return link;
209} /* airo_attach */ 190} /* airo_attach */
210 191
211/*====================================================================== 192/*======================================================================
@@ -497,34 +478,6 @@ static int airo_resume(struct pcmcia_device *p_dev)
497 return 0; 478 return 0;
498} 479}
499 480
500/*======================================================================
501
502 The card status event handler. Mostly, this schedules other
503 stuff to run after an event is received.
504
505 When a CARD_REMOVAL event is received, we immediately set a
506 private flag to block future accesses to this device. All the
507 functions that actually access the device should check this flag
508 to make sure the card is still present.
509
510 ======================================================================*/
511
512static int airo_event(event_t event, int priority,
513 event_callback_args_t *args)
514{
515 dev_link_t *link = args->client_data;
516
517 DEBUG(1, "airo_event(0x%06x)\n", event);
518
519 switch (event) {
520 case CS_EVENT_CARD_INSERTION:
521 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
522 airo_config(link);
523 break;
524 }
525 return 0;
526} /* airo_event */
527
528static struct pcmcia_device_id airo_ids[] = { 481static struct pcmcia_device_id airo_ids[] = {
529 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), 482 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a),
530 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005), 483 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005),
@@ -539,8 +492,7 @@ static struct pcmcia_driver airo_driver = {
539 .drv = { 492 .drv = {
540 .name = "airo_cs", 493 .name = "airo_cs",
541 }, 494 },
542 .attach = airo_attach, 495 .probe = airo_attach,
543 .event = airo_event,
544 .remove = airo_detach, 496 .remove = airo_detach,
545 .id_table = airo_ids, 497 .id_table = airo_ids,
546 .suspend = airo_suspend, 498 .suspend = airo_suspend,
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 32f009709355..d6f4a5a3e55a 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -93,8 +93,6 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
93 93
94static void atmel_config(dev_link_t *link); 94static void atmel_config(dev_link_t *link);
95static void atmel_release(dev_link_t *link); 95static void atmel_release(dev_link_t *link);
96static int atmel_event(event_t event, int priority,
97 event_callback_args_t *args);
98 96
99/* 97/*
100 The attach() and detach() entry points are used to create and destroy 98 The attach() and detach() entry points are used to create and destroy
@@ -102,7 +100,6 @@ static int atmel_event(event_t event, int priority,
102 needed to manage one actual PCMCIA card. 100 needed to manage one actual PCMCIA card.
103*/ 101*/
104 102
105static dev_link_t *atmel_attach(void);
106static void atmel_detach(struct pcmcia_device *p_dev); 103static void atmel_detach(struct pcmcia_device *p_dev);
107 104
108/* 105/*
@@ -113,14 +110,6 @@ static void atmel_detach(struct pcmcia_device *p_dev);
113*/ 110*/
114 111
115/* 112/*
116 The dev_info variable is the "key" that is used to match up this
117 device driver with appropriate cards, through the card configuration
118 database.
119*/
120
121static dev_info_t dev_info = "atmel_cs";
122
123/*
124 A linked list of "instances" of the atmelnet device. Each actual 113 A linked list of "instances" of the atmelnet device. Each actual
125 PCMCIA card corresponds to one device instance, and is described 114 PCMCIA card corresponds to one device instance, and is described
126 by one dev_link_t structure (defined in ds.h). 115 by one dev_link_t structure (defined in ds.h).
@@ -163,27 +152,25 @@ typedef struct local_info_t {
163 152
164 ======================================================================*/ 153 ======================================================================*/
165 154
166static dev_link_t *atmel_attach(void) 155static int atmel_attach(struct pcmcia_device *p_dev)
167{ 156{
168 client_reg_t client_reg;
169 dev_link_t *link; 157 dev_link_t *link;
170 local_info_t *local; 158 local_info_t *local;
171 int ret; 159
172
173 DEBUG(0, "atmel_attach()\n"); 160 DEBUG(0, "atmel_attach()\n");
174 161
175 /* Initialize the dev_link_t structure */ 162 /* Initialize the dev_link_t structure */
176 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 163 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
177 if (!link) { 164 if (!link) {
178 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 165 printk(KERN_ERR "atmel_cs: no memory for new device\n");
179 return NULL; 166 return -ENOMEM;
180 } 167 }
181 168
182 /* Interrupt setup */ 169 /* Interrupt setup */
183 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 170 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
184 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 171 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
185 link->irq.Handler = NULL; 172 link->irq.Handler = NULL;
186 173
187 /* 174 /*
188 General socket configuration defaults can go here. In this 175 General socket configuration defaults can go here. In this
189 client, we assume very little, and rely on the CIS for almost 176 client, we assume very little, and rely on the CIS for almost
@@ -194,29 +181,23 @@ static dev_link_t *atmel_attach(void)
194 link->conf.Attributes = 0; 181 link->conf.Attributes = 0;
195 link->conf.Vcc = 50; 182 link->conf.Vcc = 50;
196 link->conf.IntType = INT_MEMORY_AND_IO; 183 link->conf.IntType = INT_MEMORY_AND_IO;
197 184
198 /* Allocate space for private device-specific data */ 185 /* Allocate space for private device-specific data */
199 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 186 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
200 if (!local) { 187 if (!local) {
201 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 188 printk(KERN_ERR "atmel_cs: no memory for new device\n");
202 kfree (link); 189 kfree (link);
203 return NULL; 190 return -ENOMEM;
204 } 191 }
205 link->priv = local; 192 link->priv = local;
206 193
207 /* Register with Card Services */ 194 link->handle = p_dev;
208 link->next = NULL; 195 p_dev->instance = link;
209 client_reg.dev_info = &dev_info; 196
210 client_reg.Version = 0x0210; 197 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
211 client_reg.event_callback_args.client_data = link; 198 atmel_config(link);
212 ret = pcmcia_register_client(&link->handle, &client_reg); 199
213 if (ret != 0) { 200 return 0;
214 cs_error(link->handle, RegisterClient, ret);
215 atmel_detach(link->handle);
216 return NULL;
217 }
218
219 return link;
220} /* atmel_attach */ 201} /* atmel_attach */
221 202
222/*====================================================================== 203/*======================================================================
@@ -485,34 +466,6 @@ static int atmel_resume(struct pcmcia_device *dev)
485 return 0; 466 return 0;
486} 467}
487 468
488/*======================================================================
489
490 The card status event handler. Mostly, this schedules other
491 stuff to run after an event is received.
492
493 When a CARD_REMOVAL event is received, we immediately set a
494 private flag to block future accesses to this device. All the
495 functions that actually access the device should check this flag
496 to make sure the card is still present.
497
498 ======================================================================*/
499
500static int atmel_event(event_t event, int priority,
501 event_callback_args_t *args)
502{
503 dev_link_t *link = args->client_data;
504
505 DEBUG(1, "atmel_event(0x%06x)\n", event);
506
507 switch (event) {
508 case CS_EVENT_CARD_INSERTION:
509 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
510 atmel_config(link);
511 break;
512 }
513 return 0;
514} /* atmel_event */
515
516/*====================================================================*/ 469/*====================================================================*/
517/* We use the driver_info field to store the correct firmware type for a card. */ 470/* We use the driver_info field to store the correct firmware type for a card. */
518 471
@@ -562,8 +515,7 @@ static struct pcmcia_driver atmel_driver = {
562 .drv = { 515 .drv = {
563 .name = "atmel_cs", 516 .name = "atmel_cs",
564 }, 517 },
565 .attach = atmel_attach, 518 .probe = atmel_attach,
566 .event = atmel_event,
567 .remove = atmel_detach, 519 .remove = atmel_detach,
568 .id_table = atmel_ids, 520 .id_table = atmel_ids,
569 .suspend = atmel_suspend, 521 .suspend = atmel_suspend,
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 195a5bf3d725..8bc0b528548f 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -204,8 +204,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
204 204
205static void prism2_detach(struct pcmcia_device *p_dev); 205static void prism2_detach(struct pcmcia_device *p_dev);
206static void prism2_release(u_long arg); 206static void prism2_release(u_long arg);
207static int prism2_event(event_t event, int priority, 207static int prism2_config(dev_link_t *link);
208 event_callback_args_t *args);
209 208
210 209
211static int prism2_pccard_card_present(local_info_t *local) 210static int prism2_pccard_card_present(local_info_t *local)
@@ -502,15 +501,13 @@ static struct prism2_helper_functions prism2_pccard_funcs =
502 501
503/* allocate local data and register with CardServices 502/* allocate local data and register with CardServices
504 * initialize dev_link structure, but do not configure the card yet */ 503 * initialize dev_link structure, but do not configure the card yet */
505static dev_link_t *prism2_attach(void) 504static int prism2_attach(struct pcmcia_device *p_dev)
506{ 505{
507 dev_link_t *link; 506 dev_link_t *link;
508 client_reg_t client_reg;
509 int ret;
510 507
511 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); 508 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
512 if (link == NULL) 509 if (link == NULL)
513 return NULL; 510 return -ENOMEM;
514 511
515 memset(link, 0, sizeof(dev_link_t)); 512 memset(link, 0, sizeof(dev_link_t));
516 513
@@ -518,18 +515,14 @@ static dev_link_t *prism2_attach(void)
518 link->conf.Vcc = 33; 515 link->conf.Vcc = 33;
519 link->conf.IntType = INT_MEMORY_AND_IO; 516 link->conf.IntType = INT_MEMORY_AND_IO;
520 517
521 /* register with CardServices */ 518 link->handle = p_dev;
522 link->next = NULL; 519 p_dev->instance = link;
523 client_reg.dev_info = &dev_info; 520
524 client_reg.Version = 0x0210; 521 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
525 client_reg.event_callback_args.client_data = link; 522 if (prism2_config(link))
526 ret = pcmcia_register_client(&link->handle, &client_reg); 523 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
527 if (ret != CS_SUCCESS) { 524
528 cs_error(link->handle, RegisterClient, ret); 525 return 0;
529 prism2_detach(link->handle);
530 return NULL;
531 }
532 return link;
533} 526}
534 527
535 528
@@ -878,29 +871,6 @@ static int hostap_cs_resume(struct pcmcia_device *p_dev)
878 return 0; 871 return 0;
879} 872}
880 873
881static int prism2_event(event_t event, int priority,
882 event_callback_args_t *args)
883{
884 dev_link_t *link = args->client_data;
885
886 switch (event) {
887 case CS_EVENT_CARD_INSERTION:
888 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info);
889 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
890 if (prism2_config(link)) {
891 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
892 }
893 break;
894
895 default:
896 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n",
897 dev_info, event);
898 break;
899 }
900 return 0;
901}
902
903
904static struct pcmcia_device_id hostap_cs_ids[] = { 874static struct pcmcia_device_id hostap_cs_ids[] = {
905 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), 875 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
906 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), 876 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
@@ -959,10 +929,9 @@ static struct pcmcia_driver hostap_driver = {
959 .drv = { 929 .drv = {
960 .name = "hostap_cs", 930 .name = "hostap_cs",
961 }, 931 },
962 .attach = prism2_attach, 932 .probe = prism2_attach,
963 .remove = prism2_detach, 933 .remove = prism2_detach,
964 .owner = THIS_MODULE, 934 .owner = THIS_MODULE,
965 .event = prism2_event,
966 .id_table = hostap_cs_ids, 935 .id_table = hostap_cs_ids,
967 .suspend = hostap_cs_suspend, 936 .suspend = hostap_cs_suspend,
968 .resume = hostap_cs_resume, 937 .resume = hostap_cs_resume,
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index af9a32d8d22d..bf6271ee387a 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -166,8 +166,6 @@ static char *version =
166#define DEBUG(n, args...) 166#define DEBUG(n, args...)
167#endif 167#endif
168 168
169static dev_info_t dev_info = "netwave_cs";
170
171/*====================================================================*/ 169/*====================================================================*/
172 170
173/* Parameters that can be set with 'insmod' */ 171/* Parameters that can be set with 'insmod' */
@@ -195,11 +193,8 @@ module_param(mem_speed, int, 0);
195 193
196/* PCMCIA (Card Services) related functions */ 194/* PCMCIA (Card Services) related functions */
197static void netwave_release(dev_link_t *link); /* Card removal */ 195static void netwave_release(dev_link_t *link); /* Card removal */
198static int netwave_event(event_t event, int priority,
199 event_callback_args_t *args);
200static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card 196static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card
201 insertion */ 197 insertion */
202static dev_link_t *netwave_attach(void); /* Create instance */
203static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ 198static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
204 199
205/* Hardware configuration */ 200/* Hardware configuration */
@@ -383,20 +378,18 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
383 * configure the card at this point -- we wait until we receive a 378 * configure the card at this point -- we wait until we receive a
384 * card insertion event. 379 * card insertion event.
385 */ 380 */
386static dev_link_t *netwave_attach(void) 381static int netwave_attach(struct pcmcia_device *p_dev)
387{ 382{
388 client_reg_t client_reg;
389 dev_link_t *link; 383 dev_link_t *link;
390 struct net_device *dev; 384 struct net_device *dev;
391 netwave_private *priv; 385 netwave_private *priv;
392 int ret; 386
393
394 DEBUG(0, "netwave_attach()\n"); 387 DEBUG(0, "netwave_attach()\n");
395 388
396 /* Initialize the dev_link_t structure */ 389 /* Initialize the dev_link_t structure */
397 dev = alloc_etherdev(sizeof(netwave_private)); 390 dev = alloc_etherdev(sizeof(netwave_private));
398 if (!dev) 391 if (!dev)
399 return NULL; 392 return -ENOMEM;
400 priv = netdev_priv(dev); 393 priv = netdev_priv(dev);
401 link = &priv->link; 394 link = &priv->link;
402 link->priv = dev; 395 link->priv = dev;
@@ -438,20 +431,14 @@ static dev_link_t *netwave_attach(void)
438 dev->open = &netwave_open; 431 dev->open = &netwave_open;
439 dev->stop = &netwave_close; 432 dev->stop = &netwave_close;
440 link->irq.Instance = dev; 433 link->irq.Instance = dev;
441
442 /* Register with Card Services */
443 link->next = NULL;
444 client_reg.dev_info = &dev_info;
445 client_reg.Version = 0x0210;
446 client_reg.event_callback_args.client_data = link;
447 ret = pcmcia_register_client(&link->handle, &client_reg);
448 if (ret != 0) {
449 cs_error(link->handle, RegisterClient, ret);
450 netwave_detach(link->handle);
451 return NULL;
452 }
453 434
454 return link; 435 link->handle = p_dev;
436 p_dev->instance = link;
437
438 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
439 netwave_pcmcia_config( link);
440
441 return 0;
455} /* netwave_attach */ 442} /* netwave_attach */
456 443
457/* 444/*
@@ -935,36 +922,6 @@ static int netwave_resume(struct pcmcia_device *p_dev)
935 922
936 923
937/* 924/*
938 * Function netwave_event (event, priority, args)
939 *
940 * The card status event handler. Mostly, this schedules other
941 * stuff to run after an event is received. A CARD_REMOVAL event
942 * also sets some flags to discourage the net drivers from trying
943 * to talk to the card any more.
944 *
945 * When a CARD_REMOVAL event is received, we immediately set a flag
946 * to block future accesses to this device. All the functions that
947 * actually access the device should check this flag to make sure
948 * the card is still present.
949 *
950 */
951static int netwave_event(event_t event, int priority,
952 event_callback_args_t *args)
953{
954 dev_link_t *link = args->client_data;
955
956 DEBUG(1, "netwave_event(0x%06x)\n", event);
957
958 switch (event) {
959 case CS_EVENT_CARD_INSERTION:
960 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
961 netwave_pcmcia_config( link);
962 break;
963 }
964 return 0;
965} /* netwave_event */
966
967/*
968 * Function netwave_doreset (ioBase, ramBase) 925 * Function netwave_doreset (ioBase, ramBase)
969 * 926 *
970 * Proper hardware reset of the card. 927 * Proper hardware reset of the card.
@@ -1456,8 +1413,7 @@ static struct pcmcia_driver netwave_driver = {
1456 .drv = { 1413 .drv = {
1457 .name = "netwave_cs", 1414 .name = "netwave_cs",
1458 }, 1415 },
1459 .attach = netwave_attach, 1416 .probe = netwave_attach,
1460 .event = netwave_event,
1461 .remove = netwave_detach, 1417 .remove = netwave_detach,
1462 .id_table = netwave_ids, 1418 .id_table = netwave_ids,
1463 .suspend = netwave_suspend, 1419 .suspend = netwave_suspend,
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index bfeeef49f0b3..b664708481cc 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -43,17 +43,6 @@ module_param(ignore_cis_vcc, int, 0);
43MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); 43MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
44 44
45/********************************************************************/ 45/********************************************************************/
46/* Magic constants */
47/********************************************************************/
48
49/*
50 * The dev_info variable is the "key" that is used to match up this
51 * device driver with appropriate cards, through the card
52 * configuration database.
53 */
54static dev_info_t dev_info = DRIVER_NAME;
55
56/********************************************************************/
57/* Data structures */ 46/* Data structures */
58/********************************************************************/ 47/********************************************************************/
59 48
@@ -74,6 +63,7 @@ struct orinoco_pccard {
74/* Function prototypes */ 63/* Function prototypes */
75/********************************************************************/ 64/********************************************************************/
76 65
66static void orinoco_cs_config(dev_link_t *link);
77static void orinoco_cs_release(dev_link_t *link); 67static void orinoco_cs_release(dev_link_t *link);
78static void orinoco_cs_detach(struct pcmcia_device *p_dev); 68static void orinoco_cs_detach(struct pcmcia_device *p_dev);
79 69
@@ -113,19 +103,17 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
113 * The dev_link structure is initialized, but we don't actually 103 * The dev_link structure is initialized, but we don't actually
114 * configure the card at this point -- we wait until we receive a card 104 * configure the card at this point -- we wait until we receive a card
115 * insertion event. */ 105 * insertion event. */
116static dev_link_t * 106static int
117orinoco_cs_attach(void) 107orinoco_cs_attach(struct pcmcia_device *p_dev)
118{ 108{
119 struct net_device *dev; 109 struct net_device *dev;
120 struct orinoco_private *priv; 110 struct orinoco_private *priv;
121 struct orinoco_pccard *card; 111 struct orinoco_pccard *card;
122 dev_link_t *link; 112 dev_link_t *link;
123 client_reg_t client_reg;
124 int ret;
125 113
126 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); 114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset);
127 if (! dev) 115 if (! dev)
128 return NULL; 116 return -ENOMEM;
129 priv = netdev_priv(dev); 117 priv = netdev_priv(dev);
130 card = priv->card; 118 card = priv->card;
131 119
@@ -150,18 +138,13 @@ orinoco_cs_attach(void)
150 /* Register with Card Services */ 138 /* Register with Card Services */
151 link->next = NULL; 139 link->next = NULL;
152 140
153 client_reg.dev_info = &dev_info; 141 link->handle = p_dev;
154 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 142 p_dev->instance = link;
155 client_reg.event_callback_args.client_data = link;
156 143
157 ret = pcmcia_register_client(&link->handle, &client_reg); 144 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
158 if (ret != CS_SUCCESS) { 145 orinoco_cs_config(link);
159 cs_error(link->handle, RegisterClient, ret);
160 orinoco_cs_detach(link->handle);
161 return NULL;
162 }
163 146
164 return link; 147 return 0;
165} /* orinoco_cs_attach */ 148} /* orinoco_cs_attach */
166 149
167/* 150/*
@@ -521,26 +504,6 @@ static int orinoco_cs_resume(struct pcmcia_device *p_dev)
521} 504}
522 505
523 506
524/*
525 * The card status event handler. Mostly, this schedules other stuff
526 * to run after an event is received.
527 */
528static int
529orinoco_cs_event(event_t event, int priority,
530 event_callback_args_t * args)
531{
532 dev_link_t *link = args->client_data;
533
534 switch (event) {
535 case CS_EVENT_CARD_INSERTION:
536 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
537 orinoco_cs_config(link);
538 break;
539 }
540
541 return 0;
542} /* orinoco_cs_event */
543
544/********************************************************************/ 507/********************************************************************/
545/* Module initialization */ 508/* Module initialization */
546/********************************************************************/ 509/********************************************************************/
@@ -640,9 +603,8 @@ static struct pcmcia_driver orinoco_driver = {
640 .drv = { 603 .drv = {
641 .name = DRIVER_NAME, 604 .name = DRIVER_NAME,
642 }, 605 },
643 .attach = orinoco_cs_attach, 606 .probe = orinoco_cs_attach,
644 .remove = orinoco_cs_detach, 607 .remove = orinoco_cs_detach,
645 .event = orinoco_cs_event,
646 .id_table = orinoco_cs_ids, 608 .id_table = orinoco_cs_ids,
647 .suspend = orinoco_cs_suspend, 609 .suspend = orinoco_cs_suspend,
648 .resume = orinoco_cs_resume, 610 .resume = orinoco_cs_resume,
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 33a89e292126..319180ca7e71 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -92,8 +92,6 @@ module_param(pc_debug, int, 0);
92/** Prototypes based on PCMCIA skeleton driver *******************************/ 92/** Prototypes based on PCMCIA skeleton driver *******************************/
93static void ray_config(dev_link_t *link); 93static void ray_config(dev_link_t *link);
94static void ray_release(dev_link_t *link); 94static void ray_release(dev_link_t *link);
95static int ray_event(event_t event, int priority, event_callback_args_t *args);
96static dev_link_t *ray_attach(void);
97static void ray_detach(struct pcmcia_device *p_dev); 95static void ray_detach(struct pcmcia_device *p_dev);
98 96
99/***** Prototypes indicated by device structure ******************************/ 97/***** Prototypes indicated by device structure ******************************/
@@ -192,12 +190,6 @@ static int bc;
192static char *phy_addr = NULL; 190static char *phy_addr = NULL;
193 191
194 192
195/* The dev_info variable is the "key" that is used to match up this
196 device driver with appropriate cards, through the card configuration
197 database.
198*/
199static dev_info_t dev_info = "ray_cs";
200
201/* A linked list of "instances" of the ray device. Each actual 193/* A linked list of "instances" of the ray device. Each actual
202 PCMCIA card corresponds to one device instance, and is described 194 PCMCIA card corresponds to one device instance, and is described
203 by one dev_link_t structure (defined in ds.h). 195 by one dev_link_t structure (defined in ds.h).
@@ -314,12 +306,10 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
314 configure the card at this point -- we wait until we receive a 306 configure the card at this point -- we wait until we receive a
315 card insertion event. 307 card insertion event.
316=============================================================================*/ 308=============================================================================*/
317static dev_link_t *ray_attach(void) 309static int ray_attach(struct pcmcia_device *p_dev)
318{ 310{
319 client_reg_t client_reg;
320 dev_link_t *link; 311 dev_link_t *link;
321 ray_dev_t *local; 312 ray_dev_t *local;
322 int ret;
323 struct net_device *dev; 313 struct net_device *dev;
324 314
325 DEBUG(1, "ray_attach()\n"); 315 DEBUG(1, "ray_attach()\n");
@@ -328,7 +318,7 @@ static dev_link_t *ray_attach(void)
328 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 318 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
329 319
330 if (!link) 320 if (!link)
331 return NULL; 321 return -ENOMEM;
332 322
333 /* Allocate space for private device-specific data */ 323 /* Allocate space for private device-specific data */
334 dev = alloc_etherdev(sizeof(ray_dev_t)); 324 dev = alloc_etherdev(sizeof(ray_dev_t));
@@ -387,30 +377,19 @@ static dev_link_t *ray_attach(void)
387 dev->stop = &ray_dev_close; 377 dev->stop = &ray_dev_close;
388 netif_stop_queue(dev); 378 netif_stop_queue(dev);
389 379
390 /* Register with Card Services */ 380 init_timer(&local->timer);
391 link->next = dev_list;
392 dev_list = link;
393 client_reg.dev_info = &dev_info;
394 client_reg.Version = 0x0210;
395 client_reg.event_callback_args.client_data = link;
396 381
397 DEBUG(2,"ray_cs ray_attach calling pcmcia_register_client(...)\n"); 382 link->handle = p_dev;
383 p_dev->instance = link;
398 384
399 init_timer(&local->timer); 385 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
386 ray_config(link);
400 387
401 ret = pcmcia_register_client(&link->handle, &client_reg); 388 return 0;
402 if (ret != 0) {
403 printk("ray_cs ray_attach RegisterClient unhappy - detaching\n");
404 cs_error(link->handle, RegisterClient, ret);
405 ray_detach(link->handle);
406 return NULL;
407 }
408 DEBUG(2,"ray_cs ray_attach ending\n");
409 return link;
410 389
411fail_alloc_dev: 390fail_alloc_dev:
412 kfree(link); 391 kfree(link);
413 return NULL; 392 return -ENOMEM;
414} /* ray_attach */ 393} /* ray_attach */
415/*============================================================================= 394/*=============================================================================
416 This deletes a driver "instance". The device is de-registered 395 This deletes a driver "instance". The device is de-registered
@@ -924,32 +903,6 @@ static int ray_resume(struct pcmcia_device *p_dev)
924 return 0; 903 return 0;
925} 904}
926 905
927/*=============================================================================
928 The card status event handler. Mostly, this schedules other
929 stuff to run after an event is received. A CARD_REMOVAL event
930 also sets some flags to discourage the net drivers from trying
931 to talk to the card any more.
932
933 When a CARD_REMOVAL event is received, we immediately set a flag
934 to block future accesses to this device. All the functions that
935 actually access the device should check this flag to make sure
936 the card is still present.
937=============================================================================*/
938static int ray_event(event_t event, int priority,
939 event_callback_args_t *args)
940{
941 dev_link_t *link = args->client_data;
942 DEBUG(1, "ray_event(0x%06x)\n", event);
943
944 switch (event) {
945 case CS_EVENT_CARD_INSERTION:
946 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
947 ray_config(link);
948 break;
949 }
950 return 0;
951 DEBUG(2,"ray_event ending\n");
952} /* ray_event */
953/*===========================================================================*/ 906/*===========================================================================*/
954int ray_dev_init(struct net_device *dev) 907int ray_dev_init(struct net_device *dev)
955{ 908{
@@ -2945,8 +2898,7 @@ static struct pcmcia_driver ray_driver = {
2945 .drv = { 2898 .drv = {
2946 .name = "ray_cs", 2899 .name = "ray_cs",
2947 }, 2900 },
2948 .attach = ray_attach, 2901 .probe = ray_attach,
2949 .event = ray_event,
2950 .remove = ray_detach, 2902 .remove = ray_detach,
2951 .id_table = ray_ids, 2903 .id_table = ray_ids,
2952 .suspend = ray_suspend, 2904 .suspend = ray_suspend,
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 1933250dad1a..fee4be1ce810 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -57,17 +57,6 @@ module_param(ignore_cis_vcc, int, 0);
57MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); 57MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
58 58
59/********************************************************************/ 59/********************************************************************/
60/* Magic constants */
61/********************************************************************/
62
63/*
64 * The dev_info variable is the "key" that is used to match up this
65 * device driver with appropriate cards, through the card
66 * configuration database.
67 */
68static dev_info_t dev_info = DRIVER_NAME;
69
70/********************************************************************/
71/* Data structures */ 60/* Data structures */
72/********************************************************************/ 61/********************************************************************/
73 62
@@ -82,8 +71,8 @@ struct orinoco_pccard {
82/* Function prototypes */ 71/* Function prototypes */
83/********************************************************************/ 72/********************************************************************/
84 73
74static void spectrum_cs_config(dev_link_t *link);
85static void spectrum_cs_release(dev_link_t *link); 75static void spectrum_cs_release(dev_link_t *link);
86static void spectrum_cs_detach(struct pcmcia_device *p_dev);
87 76
88/********************************************************************/ 77/********************************************************************/
89/* Firmware downloader */ 78/* Firmware downloader */
@@ -594,19 +583,17 @@ spectrum_cs_hard_reset(struct orinoco_private *priv)
594 * The dev_link structure is initialized, but we don't actually 583 * The dev_link structure is initialized, but we don't actually
595 * configure the card at this point -- we wait until we receive a card 584 * configure the card at this point -- we wait until we receive a card
596 * insertion event. */ 585 * insertion event. */
597static dev_link_t * 586static int
598spectrum_cs_attach(void) 587spectrum_cs_attach(struct pcmcia_device *p_dev)
599{ 588{
600 struct net_device *dev; 589 struct net_device *dev;
601 struct orinoco_private *priv; 590 struct orinoco_private *priv;
602 struct orinoco_pccard *card; 591 struct orinoco_pccard *card;
603 dev_link_t *link; 592 dev_link_t *link;
604 client_reg_t client_reg;
605 int ret;
606 593
607 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); 594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
608 if (! dev) 595 if (! dev)
609 return NULL; 596 return -ENOMEM;
610 priv = netdev_priv(dev); 597 priv = netdev_priv(dev);
611 card = priv->card; 598 card = priv->card;
612 599
@@ -628,22 +615,13 @@ spectrum_cs_attach(void)
628 link->conf.Attributes = 0; 615 link->conf.Attributes = 0;
629 link->conf.IntType = INT_MEMORY_AND_IO; 616 link->conf.IntType = INT_MEMORY_AND_IO;
630 617
631 /* Register with Card Services */ 618 link->handle = p_dev;
632 /* FIXME: need a lock? */ 619 p_dev->instance = link;
633 link->next = NULL; /* not needed */
634 620
635 client_reg.dev_info = &dev_info; 621 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
636 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 622 spectrum_cs_config(link);
637 client_reg.event_callback_args.client_data = link;
638 623
639 ret = pcmcia_register_client(&link->handle, &client_reg); 624 return 0;
640 if (ret != CS_SUCCESS) {
641 cs_error(link->handle, RegisterClient, ret);
642 spectrum_cs_detach(link->handle);
643 return NULL;
644 }
645
646 return link;
647} /* spectrum_cs_attach */ 625} /* spectrum_cs_attach */
648 626
649/* 627/*
@@ -977,26 +955,6 @@ spectrum_cs_resume(struct pcmcia_device *p_dev)
977 return 0; 955 return 0;
978} 956}
979 957
980/*
981 * The card status event handler. Mostly, this schedules other stuff
982 * to run after an event is received.
983 */
984static int
985spectrum_cs_event(event_t event, int priority,
986 event_callback_args_t * args)
987{
988 dev_link_t *link = args->client_data;
989
990 switch (event) {
991 case CS_EVENT_CARD_INSERTION:
992 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
993 spectrum_cs_config(link);
994 break;
995
996 }
997
998 return 0;
999} /* spectrum_cs_event */
1000 958
1001/********************************************************************/ 959/********************************************************************/
1002/* Module initialization */ 960/* Module initialization */
@@ -1021,11 +979,10 @@ static struct pcmcia_driver orinoco_driver = {
1021 .drv = { 979 .drv = {
1022 .name = DRIVER_NAME, 980 .name = DRIVER_NAME,
1023 }, 981 },
1024 .attach = spectrum_cs_attach, 982 .probe = spectrum_cs_attach,
1025 .remove = spectrum_cs_detach, 983 .remove = spectrum_cs_detach,
1026 .suspend = spectrum_cs_suspend, 984 .suspend = spectrum_cs_suspend,
1027 .resume = spectrum_cs_resume, 985 .resume = spectrum_cs_resume,
1028 .event = spectrum_cs_event,
1029 .id_table = spectrum_cs_ids, 986 .id_table = spectrum_cs_ids,
1030}; 987};
1031 988
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index 196e827fc846..7e2039f52c49 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4594,14 +4594,12 @@ wavelan_close(struct net_device * dev)
4594 * configure the card at this point -- we wait until we receive a 4594 * configure the card at this point -- we wait until we receive a
4595 * card insertion event. 4595 * card insertion event.
4596 */ 4596 */
4597static dev_link_t * 4597static int
4598wavelan_attach(void) 4598wavelan_attach(struct pcmcia_device *p_dev)
4599{ 4599{
4600 client_reg_t client_reg; /* Register with cardmgr */
4601 dev_link_t * link; /* Info for cardmgr */ 4600 dev_link_t * link; /* Info for cardmgr */
4602 struct net_device * dev; /* Interface generic data */ 4601 struct net_device * dev; /* Interface generic data */
4603 net_local * lp; /* Interface specific data */ 4602 net_local * lp; /* Interface specific data */
4604 int ret;
4605 4603
4606#ifdef DEBUG_CALLBACK_TRACE 4604#ifdef DEBUG_CALLBACK_TRACE
4607 printk(KERN_DEBUG "-> wavelan_attach()\n"); 4605 printk(KERN_DEBUG "-> wavelan_attach()\n");
@@ -4609,7 +4607,7 @@ wavelan_attach(void)
4609 4607
4610 /* Initialize the dev_link_t structure */ 4608 /* Initialize the dev_link_t structure */
4611 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 4609 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
4612 if (!link) return NULL; 4610 if (!link) return -ENOMEM;
4613 4611
4614 /* The io structure describes IO port mapping */ 4612 /* The io structure describes IO port mapping */
4615 link->io.NumPorts1 = 8; 4613 link->io.NumPorts1 = 8;
@@ -4633,7 +4631,7 @@ wavelan_attach(void)
4633 dev = alloc_etherdev(sizeof(net_local)); 4631 dev = alloc_etherdev(sizeof(net_local));
4634 if (!dev) { 4632 if (!dev) {
4635 kfree(link); 4633 kfree(link);
4636 return NULL; 4634 return -ENOMEM;
4637 } 4635 }
4638 link->priv = link->irq.Instance = dev; 4636 link->priv = link->irq.Instance = dev;
4639 4637
@@ -4678,28 +4676,21 @@ wavelan_attach(void)
4678 /* Other specific data */ 4676 /* Other specific data */
4679 dev->mtu = WAVELAN_MTU; 4677 dev->mtu = WAVELAN_MTU;
4680 4678
4681 /* Register with Card Services */ 4679 link->handle = p_dev;
4682 client_reg.dev_info = &dev_info; 4680 p_dev->instance = link;
4683 client_reg.Version = 0x0210;
4684 client_reg.event_callback_args.client_data = link;
4685
4686#ifdef DEBUG_CONFIG_INFO
4687 printk(KERN_DEBUG "wavelan_attach(): almost done, calling pcmcia_register_client\n");
4688#endif
4689 4681
4690 ret = pcmcia_register_client(&link->handle, &client_reg); 4682 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4691 if(ret != 0) 4683 if(wv_pcmcia_config(link) &&
4692 { 4684 wv_hw_config(dev))
4693 cs_error(link->handle, RegisterClient, ret); 4685 wv_init_info(dev);
4694 wavelan_detach(link->handle); 4686 else
4695 return NULL; 4687 dev->irq = 0;
4696 }
4697 4688
4698#ifdef DEBUG_CALLBACK_TRACE 4689#ifdef DEBUG_CALLBACK_TRACE
4699 printk(KERN_DEBUG "<- wavelan_attach()\n"); 4690 printk(KERN_DEBUG "<- wavelan_attach()\n");
4700#endif 4691#endif
4701 4692
4702 return link; 4693 return 0;
4703} 4694}
4704 4695
4705/*------------------------------------------------------------------*/ 4696/*------------------------------------------------------------------*/
@@ -4801,52 +4792,6 @@ static int wavelan_resume(struct pcmcia_device *p_dev)
4801} 4792}
4802 4793
4803 4794
4804/*------------------------------------------------------------------*/
4805/*
4806 * The card status event handler. Mostly, this schedules other stuff
4807 * to run after an event is received. A CARD_REMOVAL event also sets
4808 * some flags to discourage the net drivers from trying to talk to the
4809 * card any more.
4810 */
4811static int
4812wavelan_event(event_t event, /* The event received */
4813 int priority,
4814 event_callback_args_t * args)
4815{
4816 dev_link_t * link = (dev_link_t *) args->client_data;
4817 struct net_device * dev = (struct net_device *) link->priv;
4818
4819#ifdef DEBUG_CALLBACK_TRACE
4820 printk(KERN_DEBUG "->wavelan_event(): %s\n",
4821 ((event == CS_EVENT_REGISTRATION_COMPLETE)?"registration complete" :
4822 ((event == CS_EVENT_CARD_REMOVAL) ? "card removal" :
4823 ((event == CS_EVENT_CARD_INSERTION) ? "card insertion" :
4824 ((event == CS_EVENT_PM_SUSPEND) ? "pm suspend" :
4825 ((event == CS_EVENT_RESET_PHYSICAL) ? "physical reset" :
4826 ((event == CS_EVENT_PM_RESUME) ? "pm resume" :
4827 ((event == CS_EVENT_CARD_RESET) ? "card reset" :
4828 "unknown"))))))));
4829#endif
4830
4831 switch(event)
4832 {
4833 case CS_EVENT_CARD_INSERTION:
4834 /* Reset and configure the card */
4835 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4836 if(wv_pcmcia_config(link) &&
4837 wv_hw_config(dev))
4838 wv_init_info(dev);
4839 else
4840 dev->irq = 0;
4841 break;
4842 }
4843
4844#ifdef DEBUG_CALLBACK_TRACE
4845 printk(KERN_DEBUG "<-wavelan_event()\n");
4846#endif
4847 return 0;
4848}
4849
4850static struct pcmcia_device_id wavelan_ids[] = { 4795static struct pcmcia_device_id wavelan_ids[] = {
4851 PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), 4796 PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975),
4852 PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), 4797 PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06),
@@ -4861,8 +4806,7 @@ static struct pcmcia_driver wavelan_driver = {
4861 .drv = { 4806 .drv = {
4862 .name = "wavelan_cs", 4807 .name = "wavelan_cs",
4863 }, 4808 },
4864 .attach = wavelan_attach, 4809 .probe = wavelan_attach,
4865 .event = wavelan_event,
4866 .remove = wavelan_detach, 4810 .remove = wavelan_detach,
4867 .id_table = wavelan_ids, 4811 .id_table = wavelan_ids,
4868 .suspend = wavelan_suspend, 4812 .suspend = wavelan_suspend,
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index a1a19177c5cd..f2d597568151 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -754,19 +754,11 @@ static void
754static int 754static int
755 wavelan_open(struct net_device *), /* Open the device */ 755 wavelan_open(struct net_device *), /* Open the device */
756 wavelan_close(struct net_device *); /* Close the device */ 756 wavelan_close(struct net_device *); /* Close the device */
757static dev_link_t *
758 wavelan_attach(void); /* Create a new device */
759static void 757static void
760 wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */ 758 wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */
761static int
762 wavelan_event(event_t, /* Manage pcmcia events */
763 int,
764 event_callback_args_t *);
765 759
766/**************************** VARIABLES ****************************/ 760/**************************** VARIABLES ****************************/
767 761
768static dev_info_t dev_info = "wavelan_cs";
769
770/* 762/*
771 * Parameters that can be set with 'insmod' 763 * Parameters that can be set with 'insmod'
772 * The exact syntax is 'insmod wavelan_cs.o <var>=<value>' 764 * The exact syntax is 'insmod wavelan_cs.o <var>=<value>'
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 21e498fe7b14..48e10b0c7e74 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -105,7 +105,6 @@ module_param(pc_debug, int, 0);
105 */ 105 */
106static void wl3501_config(dev_link_t *link); 106static void wl3501_config(dev_link_t *link);
107static void wl3501_release(dev_link_t *link); 107static void wl3501_release(dev_link_t *link);
108static int wl3501_event(event_t event, int pri, event_callback_args_t *args);
109 108
110/* 109/*
111 * The dev_info variable is the "key" that is used to match up this 110 * The dev_info variable is the "key" that is used to match up this
@@ -1954,18 +1953,16 @@ static const struct iw_handler_def wl3501_handler_def = {
1954 * The dev_link structure is initialized, but we don't actually configure the 1953 * The dev_link structure is initialized, but we don't actually configure the
1955 * card at this point -- we wait until we receive a card insertion event. 1954 * card at this point -- we wait until we receive a card insertion event.
1956 */ 1955 */
1957static dev_link_t *wl3501_attach(void) 1956static int wl3501_attach(struct pcmcia_device *p_dev)
1958{ 1957{
1959 client_reg_t client_reg;
1960 dev_link_t *link; 1958 dev_link_t *link;
1961 struct net_device *dev; 1959 struct net_device *dev;
1962 struct wl3501_card *this; 1960 struct wl3501_card *this;
1963 int ret;
1964 1961
1965 /* Initialize the dev_link_t structure */ 1962 /* Initialize the dev_link_t structure */
1966 link = kzalloc(sizeof(*link), GFP_KERNEL); 1963 link = kzalloc(sizeof(*link), GFP_KERNEL);
1967 if (!link) 1964 if (!link)
1968 goto out; 1965 return -ENOMEM;
1969 1966
1970 /* The io structure describes IO port mapping */ 1967 /* The io structure describes IO port mapping */
1971 link->io.NumPorts1 = 16; 1968 link->io.NumPorts1 = 16;
@@ -2001,24 +1998,17 @@ static dev_link_t *wl3501_attach(void)
2001 netif_stop_queue(dev); 1998 netif_stop_queue(dev);
2002 link->priv = link->irq.Instance = dev; 1999 link->priv = link->irq.Instance = dev;
2003 2000
2004 /* Register with Card Services */ 2001 link->handle = p_dev;
2005 link->next = wl3501_dev_list; 2002 p_dev->instance = link;
2006 wl3501_dev_list = link; 2003
2007 client_reg.dev_info = &wl3501_dev_info; 2004 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2008 client_reg.Version = 0x0210; 2005 wl3501_config(link);
2009 client_reg.event_callback_args.client_data = link; 2006
2010 ret = pcmcia_register_client(&link->handle, &client_reg); 2007 return 0;
2011 if (ret) {
2012 cs_error(link->handle, RegisterClient, ret);
2013 wl3501_detach(link->handle);
2014 link = NULL;
2015 }
2016out:
2017 return link;
2018out_link: 2008out_link:
2019 kfree(link); 2009 kfree(link);
2020 link = NULL; 2010 link = NULL;
2021 goto out; 2011 return -ENOMEM;
2022} 2012}
2023 2013
2024#define CS_CHECK(fn, ret) \ 2014#define CS_CHECK(fn, ret) \
@@ -2206,33 +2196,6 @@ static int wl3501_resume(struct pcmcia_device *p_dev)
2206} 2196}
2207 2197
2208 2198
2209/**
2210 * wl3501_event - The card status event handler
2211 * @event - event
2212 * @pri - priority
2213 * @args - arguments for this event
2214 *
2215 * The card status event handler. Mostly, this schedules other stuff to run
2216 * after an event is received. A CARD_REMOVAL event also sets some flags to
2217 * discourage the net drivers from trying to talk to the card any more.
2218 *
2219 * When a CARD_REMOVAL event is received, we immediately set a flag to block
2220 * future accesses to this device. All the functions that actually access the
2221 * device should check this flag to make sure the card is still present.
2222 */
2223static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2224{
2225 dev_link_t *link = args->client_data;
2226
2227 switch (event) {
2228 case CS_EVENT_CARD_INSERTION:
2229 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2230 wl3501_config(link);
2231 break;
2232 }
2233 return 0;
2234}
2235
2236static struct pcmcia_device_id wl3501_ids[] = { 2199static struct pcmcia_device_id wl3501_ids[] = {
2237 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001), 2200 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2238 PCMCIA_DEVICE_NULL 2201 PCMCIA_DEVICE_NULL
@@ -2244,8 +2207,7 @@ static struct pcmcia_driver wl3501_driver = {
2244 .drv = { 2207 .drv = {
2245 .name = "wl3501_cs", 2208 .name = "wl3501_cs",
2246 }, 2209 },
2247 .attach = wl3501_attach, 2210 .probe = wl3501_attach,
2248 .event = wl3501_event,
2249 .remove = wl3501_detach, 2211 .remove = wl3501_detach,
2250 .id_table = wl3501_ids, 2212 .id_table = wl3501_ids,
2251 .suspend = wl3501_suspend, 2213 .suspend = wl3501_suspend,
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 763f91a79085..158d92563259 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -87,14 +87,9 @@ typedef struct parport_info_t {
87 struct parport *port; 87 struct parport *port;
88} parport_info_t; 88} parport_info_t;
89 89
90static dev_link_t *parport_attach(void);
91static void parport_detach(struct pcmcia_device *p_dev); 90static void parport_detach(struct pcmcia_device *p_dev);
92static void parport_config(dev_link_t *link); 91static void parport_config(dev_link_t *link);
93static void parport_cs_release(dev_link_t *); 92static void parport_cs_release(dev_link_t *);
94static int parport_event(event_t event, int priority,
95 event_callback_args_t *args);
96
97static dev_info_t dev_info = "parport_cs";
98 93
99/*====================================================================== 94/*======================================================================
100 95
@@ -104,18 +99,16 @@ static dev_info_t dev_info = "parport_cs";
104 99
105======================================================================*/ 100======================================================================*/
106 101
107static dev_link_t *parport_attach(void) 102static int parport_attach(struct pcmcia_device *p_dev)
108{ 103{
109 parport_info_t *info; 104 parport_info_t *info;
110 dev_link_t *link; 105 dev_link_t *link;
111 client_reg_t client_reg; 106
112 int ret;
113
114 DEBUG(0, "parport_attach()\n"); 107 DEBUG(0, "parport_attach()\n");
115 108
116 /* Create new parport device */ 109 /* Create new parport device */
117 info = kmalloc(sizeof(*info), GFP_KERNEL); 110 info = kmalloc(sizeof(*info), GFP_KERNEL);
118 if (!info) return NULL; 111 if (!info) return -ENOMEM;
119 memset(info, 0, sizeof(*info)); 112 memset(info, 0, sizeof(*info));
120 link = &info->link; link->priv = info; 113 link = &info->link; link->priv = info;
121 114
@@ -126,20 +119,14 @@ static dev_link_t *parport_attach(void)
126 link->conf.Attributes = CONF_ENABLE_IRQ; 119 link->conf.Attributes = CONF_ENABLE_IRQ;
127 link->conf.Vcc = 50; 120 link->conf.Vcc = 50;
128 link->conf.IntType = INT_MEMORY_AND_IO; 121 link->conf.IntType = INT_MEMORY_AND_IO;
129 122
130 /* Register with Card Services */ 123 link->handle = p_dev;
131 link->next = NULL; 124 p_dev->instance = link;
132 client_reg.dev_info = &dev_info; 125
133 client_reg.Version = 0x0210; 126 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
134 client_reg.event_callback_args.client_data = link; 127 parport_config(link);
135 ret = pcmcia_register_client(&link->handle, &client_reg); 128
136 if (ret != CS_SUCCESS) { 129 return 0;
137 cs_error(link->handle, RegisterClient, ret);
138 parport_detach(link->handle);
139 return NULL;
140 }
141
142 return link;
143} /* parport_attach */ 130} /* parport_attach */
144 131
145/*====================================================================== 132/*======================================================================
@@ -329,29 +316,6 @@ static int parport_resume(struct pcmcia_device *dev)
329 return 0; 316 return 0;
330} 317}
331 318
332/*======================================================================
333
334 The card status event handler. Mostly, this schedules other
335 stuff to run after an event is received.
336
337======================================================================*/
338
339int parport_event(event_t event, int priority,
340 event_callback_args_t *args)
341{
342 dev_link_t *link = args->client_data;
343
344 DEBUG(1, "parport_event(0x%06x)\n", event);
345
346 switch (event) {
347 case CS_EVENT_CARD_INSERTION:
348 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
349 parport_config(link);
350 break;
351 }
352 return 0;
353} /* parport_event */
354
355static struct pcmcia_device_id parport_ids[] = { 319static struct pcmcia_device_id parport_ids[] = {
356 PCMCIA_DEVICE_FUNC_ID(3), 320 PCMCIA_DEVICE_FUNC_ID(3),
357 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), 321 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003),
@@ -364,8 +328,7 @@ static struct pcmcia_driver parport_cs_driver = {
364 .drv = { 328 .drv = {
365 .name = "parport_cs", 329 .name = "parport_cs",
366 }, 330 },
367 .attach = parport_attach, 331 .probe = parport_attach,
368 .event = parport_event,
369 .remove = parport_detach, 332 .remove = parport_detach,
370 .id_table = parport_ids, 333 .id_table = parport_ids,
371 .suspend = parport_suspend, 334 .suspend = parport_suspend,
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 8eff55b6c9e9..0fc61dd1d4d0 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -203,7 +203,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
203 unsigned int i; 203 unsigned int i;
204 u32 hash; 204 u32 hash;
205 205
206 if (!p_drv->attach || !p_drv->event || !p_drv->remove) 206 if (!p_drv->probe || !p_drv->remove)
207 printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback " 207 printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback "
208 "function\n", p_drv->drv.name); 208 "function\n", p_drv->drv.name);
209 209
@@ -361,6 +361,7 @@ static int pcmcia_device_probe(struct device * dev)
361{ 361{
362 struct pcmcia_device *p_dev; 362 struct pcmcia_device *p_dev;
363 struct pcmcia_driver *p_drv; 363 struct pcmcia_driver *p_drv;
364 struct pcmcia_socket *s;
364 int ret = 0; 365 int ret = 0;
365 366
366 dev = get_device(dev); 367 dev = get_device(dev);
@@ -369,25 +370,39 @@ static int pcmcia_device_probe(struct device * dev)
369 370
370 p_dev = to_pcmcia_dev(dev); 371 p_dev = to_pcmcia_dev(dev);
371 p_drv = to_pcmcia_drv(dev->driver); 372 p_drv = to_pcmcia_drv(dev->driver);
373 s = p_dev->socket;
372 374
373 if (!try_module_get(p_drv->owner)) { 375 if ((!p_drv->probe) || (!try_module_get(p_drv->owner))) {
374 ret = -EINVAL; 376 ret = -EINVAL;
375 goto put_dev; 377 goto put_dev;
376 } 378 }
377 379
378 if (p_drv->attach) { 380 p_dev->state &= ~CLIENT_UNBOUND;
379 p_dev->instance = p_drv->attach(); 381
380 if ((!p_dev->instance) || (p_dev->state & CLIENT_UNBOUND)) { 382 /* set up the device configuration, if it hasn't been done before */
381 printk(KERN_NOTICE "ds: unable to create instance " 383 if (!s->functions) {
382 "of '%s'!\n", p_drv->drv.name); 384 cistpl_longlink_mfc_t mfc;
383 ret = -EINVAL; 385 if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC,
386 &mfc) == CS_SUCCESS)
387 s->functions = mfc.nfn;
388 else
389 s->functions = 1;
390 s->config = kmalloc(sizeof(config_t) * s->functions,
391 GFP_KERNEL);
392 if (!s->config) {
393 ret = -ENOMEM;
394 goto put_module;
384 } 395 }
396 memset(s->config, 0, sizeof(config_t) * s->functions);
385 } 397 }
386 398
399 ret = p_drv->probe(p_dev);
400
401 put_module:
387 if (ret) 402 if (ret)
388 module_put(p_drv->owner); 403 module_put(p_drv->owner);
389 put_dev: 404 put_dev:
390 if ((ret) || !(p_drv->attach)) 405 if (ret)
391 put_device(dev); 406 put_device(dev);
392 return (ret); 407 return (ret);
393} 408}
@@ -418,11 +433,8 @@ static int pcmcia_device_remove(struct device * dev)
418 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", 433 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n",
419 p_drv->drv.name); 434 p_drv->drv.name);
420 435
421 /* undo pcmcia_register_client */
422 p_dev->state = CLIENT_UNBOUND;
423 pcmcia_put_dev(p_dev);
424
425 /* references from pcmcia_probe_device */ 436 /* references from pcmcia_probe_device */
437 p_dev->state = CLIENT_UNBOUND;
426 pcmcia_put_dev(p_dev); 438 pcmcia_put_dev(p_dev);
427 module_put(p_drv->owner); 439 module_put(p_drv->owner);
428 440
@@ -1042,49 +1054,6 @@ static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1042 1054
1043======================================================================*/ 1055======================================================================*/
1044 1056
1045struct send_event_data {
1046 struct pcmcia_socket *skt;
1047 event_t event;
1048 int priority;
1049};
1050
1051static int send_event_callback(struct device *dev, void * _data)
1052{
1053 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1054 struct pcmcia_driver *p_drv;
1055 struct send_event_data *data = _data;
1056
1057 /* we get called for all sockets, but may only pass the event
1058 * for drivers _on the affected socket_ */
1059 if (p_dev->socket != data->skt)
1060 return 0;
1061
1062 p_drv = to_pcmcia_drv(p_dev->dev.driver);
1063 if (!p_drv)
1064 return 0;
1065
1066 if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE))
1067 return 0;
1068
1069 if (p_drv->event)
1070 return p_drv->event(data->event, data->priority,
1071 &p_dev->event_callback_args);
1072
1073 return 0;
1074}
1075
1076static int send_event(struct pcmcia_socket *s, event_t event, int priority)
1077{
1078 struct send_event_data private;
1079
1080 private.skt = s;
1081 private.event = event;
1082 private.priority = priority;
1083
1084 return bus_for_each_dev(&pcmcia_bus_type, NULL, &private, send_event_callback);
1085} /* send_event */
1086
1087
1088/* Normally, the event is passed to individual drivers after 1057/* Normally, the event is passed to individual drivers after
1089 * informing userspace. Only for CS_EVENT_CARD_REMOVAL this 1058 * informing userspace. Only for CS_EVENT_CARD_REMOVAL this
1090 * is inversed to maintain historic compatibility. 1059 * is inversed to maintain historic compatibility.
@@ -1093,20 +1062,17 @@ static int send_event(struct pcmcia_socket *s, event_t event, int priority)
1093static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) 1062static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1094{ 1063{
1095 struct pcmcia_socket *s = pcmcia_get_socket(skt); 1064 struct pcmcia_socket *s = pcmcia_get_socket(skt);
1096 int ret = 0;
1097 1065
1098 ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", 1066 ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n",
1099 event, priority, skt); 1067 event, priority, skt);
1100
1101 switch (event) {
1102 1068
1069 switch (event) {
1103 case CS_EVENT_CARD_REMOVAL: 1070 case CS_EVENT_CARD_REMOVAL:
1104 s->pcmcia_state.present = 0; 1071 s->pcmcia_state.present = 0;
1105 send_event(skt, event, priority);
1106 pcmcia_card_remove(skt); 1072 pcmcia_card_remove(skt);
1107 handle_event(skt, event); 1073 handle_event(skt, event);
1108 break; 1074 break;
1109 1075
1110 case CS_EVENT_CARD_INSERTION: 1076 case CS_EVENT_CARD_INSERTION:
1111 s->pcmcia_state.present = 1; 1077 s->pcmcia_state.present = 1;
1112 pcmcia_card_add(skt); 1078 pcmcia_card_add(skt);
@@ -1114,19 +1080,14 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1114 break; 1080 break;
1115 1081
1116 case CS_EVENT_EJECTION_REQUEST: 1082 case CS_EVENT_EJECTION_REQUEST:
1117 ret = send_event(skt, event, priority);
1118 break; 1083 break;
1119 1084
1120 case CS_EVENT_PM_SUSPEND: 1085 case CS_EVENT_PM_SUSPEND:
1121 case CS_EVENT_PM_RESUME: 1086 case CS_EVENT_PM_RESUME:
1122 case CS_EVENT_RESET_PHYSICAL: 1087 case CS_EVENT_RESET_PHYSICAL:
1123 case CS_EVENT_CARD_RESET: 1088 case CS_EVENT_CARD_RESET:
1124 handle_event(skt, event);
1125 break;
1126
1127 default: 1089 default:
1128 handle_event(skt, event); 1090 handle_event(skt, event);
1129 send_event(skt, event, priority);
1130 break; 1091 break;
1131 } 1092 }
1132 1093
@@ -1136,90 +1097,6 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1136} /* ds_event */ 1097} /* ds_event */
1137 1098
1138 1099
1139
1140int pcmcia_register_client(struct pcmcia_device **handle, client_reg_t *req)
1141{
1142 struct pcmcia_socket *s = NULL;
1143 struct pcmcia_device *p_dev = NULL;
1144 struct pcmcia_driver *p_drv = NULL;
1145
1146 /* Look for unbound client with matching dev_info */
1147 down_read(&pcmcia_socket_list_rwsem);
1148 list_for_each_entry(s, &pcmcia_socket_list, socket_list) {
1149 unsigned long flags;
1150
1151 if (s->state & SOCKET_CARDBUS)
1152 continue;
1153
1154 s = pcmcia_get_socket(s);
1155 if (!s)
1156 continue;
1157 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
1158 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
1159 p_dev = pcmcia_get_dev(p_dev);
1160 if (!p_dev)
1161 continue;
1162 if (!(p_dev->state & CLIENT_UNBOUND) ||
1163 (!p_dev->dev.driver)) {
1164 pcmcia_put_dev(p_dev);
1165 continue;
1166 }
1167 p_drv = to_pcmcia_drv(p_dev->dev.driver);
1168 if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) {
1169 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1170 goto found;
1171 }
1172 pcmcia_put_dev(p_dev);
1173 }
1174 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1175 pcmcia_put_socket(s);
1176 }
1177 found:
1178 up_read(&pcmcia_socket_list_rwsem);
1179 if (!p_dev)
1180 return -ENODEV;
1181
1182 pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */
1183
1184 *handle = p_dev;
1185 p_dev->state &= ~CLIENT_UNBOUND;
1186 p_dev->event_callback_args = req->event_callback_args;
1187 p_dev->event_callback_args.client_handle = p_dev;
1188
1189
1190 if (!s->functions) {
1191 cistpl_longlink_mfc_t mfc;
1192 if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC, &mfc)
1193 == CS_SUCCESS)
1194 s->functions = mfc.nfn;
1195 else
1196 s->functions = 1;
1197 s->config = kmalloc(sizeof(config_t) * s->functions,
1198 GFP_KERNEL);
1199 if (!s->config)
1200 goto out_no_resource;
1201 memset(s->config, 0, sizeof(config_t) * s->functions);
1202 }
1203
1204 ds_dbg(1, "register_client(): client 0x%p, dev %s\n",
1205 p_dev, p_dev->dev.bus_id);
1206
1207 if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) {
1208 if (p_drv->event)
1209 p_drv->event(CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW,
1210 &p_dev->event_callback_args);
1211
1212 }
1213
1214 return CS_SUCCESS;
1215
1216 out_no_resource:
1217 pcmcia_put_dev(p_dev);
1218 return CS_OUT_OF_RESOURCE;
1219} /* register_client */
1220EXPORT_SYMBOL(pcmcia_register_client);
1221
1222
1223static struct pcmcia_callback pcmcia_bus_callback = { 1100static struct pcmcia_callback pcmcia_bus_callback = {
1224 .owner = THIS_MODULE, 1101 .owner = THIS_MODULE,
1225 .event = ds_event, 1102 .event = ds_event,
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 3128ba8c57a9..0c9edb7051f4 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -95,27 +95,21 @@ typedef struct scsi_info_t {
95} scsi_info_t; 95} scsi_info_t;
96 96
97static void aha152x_release_cs(dev_link_t *link); 97static void aha152x_release_cs(dev_link_t *link);
98static int aha152x_event(event_t event, int priority,
99 event_callback_args_t *args);
100
101static dev_link_t *aha152x_attach(void);
102static void aha152x_detach(struct pcmcia_device *p_dev); 98static void aha152x_detach(struct pcmcia_device *p_dev);
99static void aha152x_config_cs(dev_link_t *link);
103 100
104static dev_link_t *dev_list; 101static dev_link_t *dev_list;
105static dev_info_t dev_info = "aha152x_cs";
106 102
107static dev_link_t *aha152x_attach(void) 103static int aha152x_attach(struct pcmcia_device *p_dev)
108{ 104{
109 scsi_info_t *info; 105 scsi_info_t *info;
110 client_reg_t client_reg;
111 dev_link_t *link; 106 dev_link_t *link;
112 int ret;
113 107
114 DEBUG(0, "aha152x_attach()\n"); 108 DEBUG(0, "aha152x_attach()\n");
115 109
116 /* Create new SCSI device */ 110 /* Create new SCSI device */
117 info = kmalloc(sizeof(*info), GFP_KERNEL); 111 info = kmalloc(sizeof(*info), GFP_KERNEL);
118 if (!info) return NULL; 112 if (!info) return -ENOMEM;
119 memset(info, 0, sizeof(*info)); 113 memset(info, 0, sizeof(*info));
120 link = &info->link; link->priv = info; 114 link = &info->link; link->priv = info;
121 115
@@ -129,20 +123,13 @@ static dev_link_t *aha152x_attach(void)
129 link->conf.IntType = INT_MEMORY_AND_IO; 123 link->conf.IntType = INT_MEMORY_AND_IO;
130 link->conf.Present = PRESENT_OPTION; 124 link->conf.Present = PRESENT_OPTION;
131 125
132 /* Register with Card Services */ 126 link->handle = p_dev;
133 link->next = dev_list; 127 p_dev->instance = link;
134 dev_list = link; 128
135 client_reg.dev_info = &dev_info; 129 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
136 client_reg.Version = 0x0210; 130 aha152x_config_cs(link);
137 client_reg.event_callback_args.client_data = link; 131
138 ret = pcmcia_register_client(&link->handle, &client_reg); 132 return 0;
139 if (ret != 0) {
140 cs_error(link->handle, RegisterClient, ret);
141 aha152x_detach(link->handle);
142 return NULL;
143 }
144
145 return link;
146} /* aha152x_attach */ 133} /* aha152x_attach */
147 134
148/*====================================================================*/ 135/*====================================================================*/
@@ -297,22 +284,6 @@ static int aha152x_resume(struct pcmcia_device *dev)
297 return 0; 284 return 0;
298} 285}
299 286
300static int aha152x_event(event_t event, int priority,
301 event_callback_args_t *args)
302{
303 dev_link_t *link = args->client_data;
304
305 DEBUG(0, "aha152x_event(0x%06x)\n", event);
306
307 switch (event) {
308 case CS_EVENT_CARD_INSERTION:
309 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
310 aha152x_config_cs(link);
311 break;
312 }
313 return 0;
314}
315
316static struct pcmcia_device_id aha152x_ids[] = { 287static struct pcmcia_device_id aha152x_ids[] = {
317 PCMCIA_DEVICE_PROD_ID123("New Media", "SCSI", "Bus Toaster", 0xcdf7e4cc, 0x35f26476, 0xa8851d6e), 288 PCMCIA_DEVICE_PROD_ID123("New Media", "SCSI", "Bus Toaster", 0xcdf7e4cc, 0x35f26476, 0xa8851d6e),
318 PCMCIA_DEVICE_PROD_ID123("NOTEWORTHY", "SCSI", "Bus Toaster", 0xad89c6e8, 0x35f26476, 0xa8851d6e), 289 PCMCIA_DEVICE_PROD_ID123("NOTEWORTHY", "SCSI", "Bus Toaster", 0xad89c6e8, 0x35f26476, 0xa8851d6e),
@@ -328,8 +299,7 @@ static struct pcmcia_driver aha152x_cs_driver = {
328 .drv = { 299 .drv = {
329 .name = "aha152x_cs", 300 .name = "aha152x_cs",
330 }, 301 },
331 .attach = aha152x_attach, 302 .probe = aha152x_attach,
332 .event = aha152x_event,
333 .remove = aha152x_detach, 303 .remove = aha152x_detach,
334 .id_table = aha152x_ids, 304 .id_table = aha152x_ids,
335 .suspend = aha152x_suspend, 305 .suspend = aha152x_suspend,
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 538fedb97924..788c58d805f3 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -80,27 +80,19 @@ typedef struct scsi_info_t {
80 80
81 81
82static void fdomain_release(dev_link_t *link); 82static void fdomain_release(dev_link_t *link);
83static int fdomain_event(event_t event, int priority,
84 event_callback_args_t *args);
85
86static dev_link_t *fdomain_attach(void);
87static void fdomain_detach(struct pcmcia_device *p_dev); 83static void fdomain_detach(struct pcmcia_device *p_dev);
84static void fdomain_config(dev_link_t *link);
88 85
89 86static int fdomain_attach(struct pcmcia_device *p_dev)
90static dev_info_t dev_info = "fdomain_cs";
91
92static dev_link_t *fdomain_attach(void)
93{ 87{
94 scsi_info_t *info; 88 scsi_info_t *info;
95 client_reg_t client_reg;
96 dev_link_t *link; 89 dev_link_t *link;
97 int ret; 90
98
99 DEBUG(0, "fdomain_attach()\n"); 91 DEBUG(0, "fdomain_attach()\n");
100 92
101 /* Create new SCSI device */ 93 /* Create new SCSI device */
102 info = kmalloc(sizeof(*info), GFP_KERNEL); 94 info = kmalloc(sizeof(*info), GFP_KERNEL);
103 if (!info) return NULL; 95 if (!info) return -ENOMEM;
104 memset(info, 0, sizeof(*info)); 96 memset(info, 0, sizeof(*info));
105 link = &info->link; link->priv = info; 97 link = &info->link; link->priv = info;
106 link->io.NumPorts1 = 0x10; 98 link->io.NumPorts1 = 0x10;
@@ -113,19 +105,13 @@ static dev_link_t *fdomain_attach(void)
113 link->conf.IntType = INT_MEMORY_AND_IO; 105 link->conf.IntType = INT_MEMORY_AND_IO;
114 link->conf.Present = PRESENT_OPTION; 106 link->conf.Present = PRESENT_OPTION;
115 107
116 /* Register with Card Services */ 108 link->handle = p_dev;
117 link->next = NULL; 109 p_dev->instance = link;
118 client_reg.dev_info = &dev_info; 110
119 client_reg.Version = 0x0210; 111 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
120 client_reg.event_callback_args.client_data = link; 112 fdomain_config(link);
121 ret = pcmcia_register_client(&link->handle, &client_reg); 113
122 if (ret != 0) { 114 return 0;
123 cs_error(link->handle, RegisterClient, ret);
124 fdomain_detach(link->handle);
125 return NULL;
126 }
127
128 return link;
129} /* fdomain_attach */ 115} /* fdomain_attach */
130 116
131/*====================================================================*/ 117/*====================================================================*/
@@ -265,23 +251,6 @@ static int fdomain_resume(struct pcmcia_device *dev)
265 return 0; 251 return 0;
266} 252}
267 253
268static int fdomain_event(event_t event, int priority,
269 event_callback_args_t *args)
270{
271 dev_link_t *link = args->client_data;
272
273 DEBUG(1, "fdomain_event(0x%06x)\n", event);
274
275 switch (event) {
276 case CS_EVENT_CARD_INSERTION:
277 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
278 fdomain_config(link);
279 break;
280 }
281 return 0;
282} /* fdomain_event */
283
284
285static struct pcmcia_device_id fdomain_ids[] = { 254static struct pcmcia_device_id fdomain_ids[] = {
286 PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20), 255 PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20),
287 PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e), 256 PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e),
@@ -295,8 +264,7 @@ static struct pcmcia_driver fdomain_cs_driver = {
295 .drv = { 264 .drv = {
296 .name = "fdomain_cs", 265 .name = "fdomain_cs",
297 }, 266 },
298 .attach = fdomain_attach, 267 .probe = fdomain_attach,
299 .event = fdomain_event,
300 .remove = fdomain_detach, 268 .remove = fdomain_detach,
301 .id_table = fdomain_ids, 269 .id_table = fdomain_ids,
302 .suspend = fdomain_suspend, 270 .suspend = fdomain_suspend,
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index e48e9fb3c58c..9e3ab3fd5355 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -104,8 +104,6 @@ static struct scsi_host_template nsp_driver_template = {
104#endif 104#endif
105}; 105};
106 106
107static dev_info_t dev_info = {"nsp_cs"};
108
109static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ 107static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
110 108
111 109
@@ -1595,19 +1593,17 @@ static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt)
1595 configure the card at this point -- we wait until we receive a 1593 configure the card at this point -- we wait until we receive a
1596 card insertion event. 1594 card insertion event.
1597======================================================================*/ 1595======================================================================*/
1598static dev_link_t *nsp_cs_attach(void) 1596static int nsp_cs_attach(struct pcmcia_device *p_dev)
1599{ 1597{
1600 scsi_info_t *info; 1598 scsi_info_t *info;
1601 client_reg_t client_reg;
1602 dev_link_t *link; 1599 dev_link_t *link;
1603 int ret;
1604 nsp_hw_data *data = &nsp_data_base; 1600 nsp_hw_data *data = &nsp_data_base;
1605 1601
1606 nsp_dbg(NSP_DEBUG_INIT, "in"); 1602 nsp_dbg(NSP_DEBUG_INIT, "in");
1607 1603
1608 /* Create new SCSI device */ 1604 /* Create new SCSI device */
1609 info = kmalloc(sizeof(*info), GFP_KERNEL); 1605 info = kmalloc(sizeof(*info), GFP_KERNEL);
1610 if (info == NULL) { return NULL; } 1606 if (info == NULL) { return -ENOMEM; }
1611 memset(info, 0, sizeof(*info)); 1607 memset(info, 0, sizeof(*info));
1612 link = &info->link; 1608 link = &info->link;
1613 link->priv = info; 1609 link->priv = info;
@@ -1635,22 +1631,14 @@ static dev_link_t *nsp_cs_attach(void)
1635 link->conf.IntType = INT_MEMORY_AND_IO; 1631 link->conf.IntType = INT_MEMORY_AND_IO;
1636 link->conf.Present = PRESENT_OPTION; 1632 link->conf.Present = PRESENT_OPTION;
1637 1633
1634 link->handle = p_dev;
1635 p_dev->instance = link;
1638 1636
1639 /* Register with Card Services */ 1637 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1640 link->next = NULL; 1638 nsp_cs_config(link);
1641 client_reg.dev_info = &dev_info;
1642 client_reg.Version = 0x0210;
1643 client_reg.event_callback_args.client_data = link;
1644 ret = pcmcia_register_client(&link->handle, &client_reg);
1645 if (ret != CS_SUCCESS) {
1646 cs_error(link->handle, RegisterClient, ret);
1647 nsp_cs_detach(link->handle);
1648 return NULL;
1649 }
1650
1651 1639
1652 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); 1640 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link);
1653 return link; 1641 return 0;
1654} /* nsp_cs_attach */ 1642} /* nsp_cs_attach */
1655 1643
1656 1644
@@ -2056,44 +2044,6 @@ static int nsp_cs_resume(struct pcmcia_device *dev)
2056 return 0; 2044 return 0;
2057} 2045}
2058 2046
2059/*======================================================================
2060
2061 The card status event handler. Mostly, this schedules other
2062 stuff to run after an event is received. A CARD_REMOVAL event
2063 also sets some flags to discourage the net drivers from trying
2064 to talk to the card any more.
2065
2066 When a CARD_REMOVAL event is received, we immediately set a flag
2067 to block future accesses to this device. All the functions that
2068 actually access the device should check this flag to make sure
2069 the card is still present.
2070
2071======================================================================*/
2072static int nsp_cs_event(event_t event,
2073 int priority,
2074 event_callback_args_t *args)
2075{
2076 dev_link_t *link = args->client_data;
2077
2078 nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event);
2079
2080 switch (event) {
2081 case CS_EVENT_CARD_INSERTION:
2082 nsp_dbg(NSP_DEBUG_INIT, "event: insert");
2083 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2084#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68))
2085 info->bus = args->bus;
2086#endif
2087 nsp_cs_config(link);
2088 break;
2089 default:
2090 nsp_dbg(NSP_DEBUG_INIT, "event: unknown");
2091 break;
2092 }
2093 nsp_dbg(NSP_DEBUG_INIT, "end");
2094 return 0;
2095} /* nsp_cs_event */
2096
2097/*======================================================================* 2047/*======================================================================*
2098 * module entry point 2048 * module entry point
2099 *====================================================================*/ 2049 *====================================================================*/
@@ -2115,8 +2065,7 @@ static struct pcmcia_driver nsp_driver = {
2115 .drv = { 2065 .drv = {
2116 .name = "nsp_cs", 2066 .name = "nsp_cs",
2117 }, 2067 },
2118 .attach = nsp_cs_attach, 2068 .probe = nsp_cs_attach,
2119 .event = nsp_cs_event,
2120 .remove = nsp_cs_detach, 2069 .remove = nsp_cs_detach,
2121 .id_table = nsp_cs_ids, 2070 .id_table = nsp_cs_ids,
2122 .suspend = nsp_cs_suspend, 2071 .suspend = nsp_cs_suspend,
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index d276c469edf1..b66b140a745e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -296,11 +296,9 @@ typedef struct _nsp_hw_data {
296 */ 296 */
297 297
298/* Card service functions */ 298/* Card service functions */
299static dev_link_t *nsp_cs_attach (void);
300static void nsp_cs_detach (struct pcmcia_device *p_dev); 299static void nsp_cs_detach (struct pcmcia_device *p_dev);
301static void nsp_cs_release(dev_link_t *link); 300static void nsp_cs_release(dev_link_t *link);
302static void nsp_cs_config (dev_link_t *link); 301static void nsp_cs_config (dev_link_t *link);
303static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args);
304 302
305/* Linux SCSI subsystem specific functions */ 303/* Linux SCSI subsystem specific functions */
306static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); 304static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht);
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index e10281a6e5f9..dce7e687fd4a 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -98,13 +98,8 @@ typedef struct scsi_info_t {
98} scsi_info_t; 98} scsi_info_t;
99 99
100static void qlogic_release(dev_link_t *link); 100static void qlogic_release(dev_link_t *link);
101static int qlogic_event(event_t event, int priority, event_callback_args_t * args);
102
103static dev_link_t *qlogic_attach(void);
104static void qlogic_detach(struct pcmcia_device *p_dev); 101static void qlogic_detach(struct pcmcia_device *p_dev);
105 102static void qlogic_config(dev_link_t * link);
106
107static dev_info_t dev_info = "qlogic_cs";
108 103
109static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, 104static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
110 dev_link_t *link, int qbase, int qlirq) 105 dev_link_t *link, int qbase, int qlirq)
@@ -161,19 +156,17 @@ free_scsi_host:
161err: 156err:
162 return NULL; 157 return NULL;
163} 158}
164static dev_link_t *qlogic_attach(void) 159static int qlogic_attach(struct pcmcia_device *p_dev)
165{ 160{
166 scsi_info_t *info; 161 scsi_info_t *info;
167 client_reg_t client_reg;
168 dev_link_t *link; 162 dev_link_t *link;
169 int ret;
170 163
171 DEBUG(0, "qlogic_attach()\n"); 164 DEBUG(0, "qlogic_attach()\n");
172 165
173 /* Create new SCSI device */ 166 /* Create new SCSI device */
174 info = kmalloc(sizeof(*info), GFP_KERNEL); 167 info = kmalloc(sizeof(*info), GFP_KERNEL);
175 if (!info) 168 if (!info)
176 return NULL; 169 return -ENOMEM;
177 memset(info, 0, sizeof(*info)); 170 memset(info, 0, sizeof(*info));
178 link = &info->link; 171 link = &info->link;
179 link->priv = info; 172 link->priv = info;
@@ -187,19 +180,13 @@ static dev_link_t *qlogic_attach(void)
187 link->conf.IntType = INT_MEMORY_AND_IO; 180 link->conf.IntType = INT_MEMORY_AND_IO;
188 link->conf.Present = PRESENT_OPTION; 181 link->conf.Present = PRESENT_OPTION;
189 182
190 /* Register with Card Services */ 183 link->handle = p_dev;
191 link->next = NULL; 184 p_dev->instance = link;
192 client_reg.dev_info = &dev_info; 185
193 client_reg.Version = 0x0210; 186 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
194 client_reg.event_callback_args.client_data = link; 187 qlogic_config(link);
195 ret = pcmcia_register_client(&link->handle, &client_reg);
196 if (ret != 0) {
197 cs_error(link->handle, RegisterClient, ret);
198 qlogic_detach(link->handle);
199 return NULL;
200 }
201 188
202 return link; 189 return 0;
203} /* qlogic_attach */ 190} /* qlogic_attach */
204 191
205/*====================================================================*/ 192/*====================================================================*/
@@ -368,21 +355,6 @@ static int qlogic_resume(struct pcmcia_device *dev)
368 return 0; 355 return 0;
369} 356}
370 357
371static int qlogic_event(event_t event, int priority, event_callback_args_t * args)
372{
373 dev_link_t *link = args->client_data;
374
375 DEBUG(1, "qlogic_event(0x%06x)\n", event);
376
377 switch (event) {
378 case CS_EVENT_CARD_INSERTION:
379 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
380 qlogic_config(link);
381 break;
382 }
383 return 0;
384} /* qlogic_event */
385
386static struct pcmcia_device_id qlogic_ids[] = { 358static struct pcmcia_device_id qlogic_ids[] = {
387 PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6), 359 PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6),
388 PCMCIA_DEVICE_PROD_ID12("EPSON", "SCSI-2 PC Card SC200", 0xd361772f, 0x299d1751), 360 PCMCIA_DEVICE_PROD_ID12("EPSON", "SCSI-2 PC Card SC200", 0xd361772f, 0x299d1751),
@@ -410,8 +382,7 @@ static struct pcmcia_driver qlogic_cs_driver = {
410 .drv = { 382 .drv = {
411 .name = "qlogic_cs", 383 .name = "qlogic_cs",
412 }, 384 },
413 .attach = qlogic_attach, 385 .probe = qlogic_attach,
414 .event = qlogic_event,
415 .remove = qlogic_detach, 386 .remove = qlogic_detach,
416 .id_table = qlogic_ids, 387 .id_table = qlogic_ids,
417 .suspend = qlogic_suspend, 388 .suspend = qlogic_suspend,
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 87d50b33475e..3a4dd6f5b81f 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -228,14 +228,6 @@ enum Phase {
228 228
229/* ================================================================== */ 229/* ================================================================== */
230 230
231/*
232* Global (within this module) variables other than
233* sym53c500_driver_template (the scsi_host_template).
234*/
235static dev_info_t dev_info = "sym53c500_cs";
236
237/* ================================================================== */
238
239static void 231static void
240chip_init(int io_port) 232chip_init(int io_port)
241{ 233{
@@ -909,22 +901,6 @@ static int sym53c500_resume(struct pcmcia_device *dev)
909 return 0; 901 return 0;
910} 902}
911 903
912static int
913SYM53C500_event(event_t event, int priority, event_callback_args_t *args)
914{
915 dev_link_t *link = args->client_data;
916
917 DEBUG(1, "SYM53C500_event(0x%06x)\n", event);
918
919 switch (event) {
920 case CS_EVENT_CARD_INSERTION:
921 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
922 SYM53C500_config(link);
923 break;
924 }
925 return 0;
926} /* SYM53C500_event */
927
928static void 904static void
929SYM53C500_detach(struct pcmcia_device *p_dev) 905SYM53C500_detach(struct pcmcia_device *p_dev)
930{ 906{
@@ -939,20 +915,18 @@ SYM53C500_detach(struct pcmcia_device *p_dev)
939 link->priv = NULL; 915 link->priv = NULL;
940} /* SYM53C500_detach */ 916} /* SYM53C500_detach */
941 917
942static dev_link_t * 918static int
943SYM53C500_attach(void) 919SYM53C500_attach(struct pcmcia_device *p_dev)
944{ 920{
945 struct scsi_info_t *info; 921 struct scsi_info_t *info;
946 client_reg_t client_reg;
947 dev_link_t *link; 922 dev_link_t *link;
948 int ret;
949 923
950 DEBUG(0, "SYM53C500_attach()\n"); 924 DEBUG(0, "SYM53C500_attach()\n");
951 925
952 /* Create new SCSI device */ 926 /* Create new SCSI device */
953 info = kmalloc(sizeof(*info), GFP_KERNEL); 927 info = kmalloc(sizeof(*info), GFP_KERNEL);
954 if (!info) 928 if (!info)
955 return NULL; 929 return -ENOMEM;
956 memset(info, 0, sizeof(*info)); 930 memset(info, 0, sizeof(*info));
957 link = &info->link; 931 link = &info->link;
958 link->priv = info; 932 link->priv = info;
@@ -966,19 +940,13 @@ SYM53C500_attach(void)
966 link->conf.IntType = INT_MEMORY_AND_IO; 940 link->conf.IntType = INT_MEMORY_AND_IO;
967 link->conf.Present = PRESENT_OPTION; 941 link->conf.Present = PRESENT_OPTION;
968 942
969 /* Register with Card Services */ 943 link->handle = p_dev;
970 link->next = NULL; 944 p_dev->instance = link;
971 client_reg.dev_info = &dev_info;
972 client_reg.Version = 0x0210;
973 client_reg.event_callback_args.client_data = link;
974 ret = pcmcia_register_client(&link->handle, &client_reg);
975 if (ret != 0) {
976 cs_error(link->handle, RegisterClient, ret);
977 SYM53C500_detach(link->handle);
978 return NULL;
979 }
980 945
981 return link; 946 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
947 SYM53C500_config(link);
948
949 return 0;
982} /* SYM53C500_attach */ 950} /* SYM53C500_attach */
983 951
984MODULE_AUTHOR("Bob Tracy <rct@frus.com>"); 952MODULE_AUTHOR("Bob Tracy <rct@frus.com>");
@@ -998,8 +966,7 @@ static struct pcmcia_driver sym53c500_cs_driver = {
998 .drv = { 966 .drv = {
999 .name = "sym53c500_cs", 967 .name = "sym53c500_cs",
1000 }, 968 },
1001 .attach = SYM53C500_attach, 969 .probe = SYM53C500_attach,
1002 .event = SYM53C500_event,
1003 .remove = SYM53C500_detach, 970 .remove = SYM53C500_detach,
1004 .id_table = sym53c500_ids, 971 .id_table = sym53c500_ids,
1005 .suspend = sym53c500_suspend, 972 .suspend = sym53c500_suspend,
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 6e7a1a0ae015..96969cb960a9 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -114,13 +114,7 @@ struct serial_cfg_mem {
114 114
115 115
116static void serial_config(dev_link_t * link); 116static void serial_config(dev_link_t * link);
117static int serial_event(event_t event, int priority,
118 event_callback_args_t * args);
119 117
120static dev_info_t dev_info = "serial_cs";
121
122static dev_link_t *serial_attach(void);
123static void serial_detach(struct pcmcia_device *p_dev);
124 118
125/*====================================================================== 119/*======================================================================
126 120
@@ -203,19 +197,17 @@ static int serial_resume(struct pcmcia_device *dev)
203 197
204======================================================================*/ 198======================================================================*/
205 199
206static dev_link_t *serial_attach(void) 200static int serial_probe(struct pcmcia_device *p_dev)
207{ 201{
208 struct serial_info *info; 202 struct serial_info *info;
209 client_reg_t client_reg;
210 dev_link_t *link; 203 dev_link_t *link;
211 int ret;
212 204
213 DEBUG(0, "serial_attach()\n"); 205 DEBUG(0, "serial_attach()\n");
214 206
215 /* Create new serial device */ 207 /* Create new serial device */
216 info = kmalloc(sizeof (*info), GFP_KERNEL); 208 info = kmalloc(sizeof (*info), GFP_KERNEL);
217 if (!info) 209 if (!info)
218 return NULL; 210 return -ENOMEM;
219 memset(info, 0, sizeof (*info)); 211 memset(info, 0, sizeof (*info));
220 link = &info->link; 212 link = &info->link;
221 link->priv = info; 213 link->priv = info;
@@ -231,19 +223,12 @@ static dev_link_t *serial_attach(void)
231 } 223 }
232 link->conf.IntType = INT_MEMORY_AND_IO; 224 link->conf.IntType = INT_MEMORY_AND_IO;
233 225
234 /* Register with Card Services */ 226 link->handle = p_dev;
235 link->next = NULL; /* not needed */ 227 p_dev->instance = link;
236 client_reg.dev_info = &dev_info; 228 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
237 client_reg.Version = 0x0210; 229 serial_config(link);
238 client_reg.event_callback_args.client_data = link;
239 ret = pcmcia_register_client(&link->handle, &client_reg);
240 if (ret != CS_SUCCESS) {
241 cs_error(link->handle, RegisterClient, ret);
242 serial_detach(link->handle);
243 return NULL;
244 }
245 230
246 return link; 231 return 0;
247} 232}
248 233
249/*====================================================================== 234/*======================================================================
@@ -706,32 +691,6 @@ void serial_config(dev_link_t * link)
706 kfree(cfg_mem); 691 kfree(cfg_mem);
707} 692}
708 693
709/*======================================================================
710
711 The card status event handler. Mostly, this schedules other
712 stuff to run after an event is received. A CARD_REMOVAL event
713 also sets some flags to discourage the serial drivers from
714 talking to the ports.
715
716======================================================================*/
717
718static int
719serial_event(event_t event, int priority, event_callback_args_t * args)
720{
721 dev_link_t *link = args->client_data;
722
723 DEBUG(1, "serial_event(0x%06x)\n", event);
724
725 switch (event) {
726
727 case CS_EVENT_CARD_INSERTION:
728 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
729 serial_config(link);
730 break;
731 }
732 return 0;
733}
734
735static struct pcmcia_device_id serial_ids[] = { 694static struct pcmcia_device_id serial_ids[] = {
736 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), 695 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021),
737 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), 696 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a),
@@ -843,8 +802,7 @@ static struct pcmcia_driver serial_cs_driver = {
843 .drv = { 802 .drv = {
844 .name = "serial_cs", 803 .name = "serial_cs",
845 }, 804 },
846 .attach = serial_attach, 805 .probe = serial_probe,
847 .event = serial_event,
848 .remove = serial_detach, 806 .remove = serial_detach,
849 .id_table = serial_ids, 807 .id_table = serial_ids,
850 .suspend = serial_suspend, 808 .suspend = serial_suspend,
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index 6b992985d782..d3a7b0c3d38b 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -34,23 +34,19 @@ typedef struct ixj_info_t {
34 struct ixj *port; 34 struct ixj *port;
35} ixj_info_t; 35} ixj_info_t;
36 36
37static dev_link_t *ixj_attach(void);
38static void ixj_detach(struct pcmcia_device *p_dev); 37static void ixj_detach(struct pcmcia_device *p_dev);
39static void ixj_config(dev_link_t * link); 38static void ixj_config(dev_link_t * link);
40static void ixj_cs_release(dev_link_t * link); 39static void ixj_cs_release(dev_link_t * link);
41static int ixj_event(event_t event, int priority, event_callback_args_t * args);
42static dev_info_t dev_info = "ixj_cs";
43 40
44static dev_link_t *ixj_attach(void) 41static int ixj_attach(struct pcmcia_device *p_dev)
45{ 42{
46 client_reg_t client_reg;
47 dev_link_t *link; 43 dev_link_t *link;
48 int ret; 44
49 DEBUG(0, "ixj_attach()\n"); 45 DEBUG(0, "ixj_attach()\n");
50 /* Create new ixj device */ 46 /* Create new ixj device */
51 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 47 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
52 if (!link) 48 if (!link)
53 return NULL; 49 return -ENOMEM;
54 memset(link, 0, sizeof(struct dev_link_t)); 50 memset(link, 0, sizeof(struct dev_link_t));
55 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 51 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
56 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 52 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
@@ -60,21 +56,17 @@ static dev_link_t *ixj_attach(void)
60 link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL); 56 link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
61 if (!link->priv) { 57 if (!link->priv) {
62 kfree(link); 58 kfree(link);
63 return NULL; 59 return -ENOMEM;
64 } 60 }
65 memset(link->priv, 0, sizeof(struct ixj_info_t)); 61 memset(link->priv, 0, sizeof(struct ixj_info_t));
66 /* Register with Card Services */ 62
67 link->next = NULL; 63 link->handle = p_dev;
68 client_reg.dev_info = &dev_info; 64 p_dev->instance = link;
69 client_reg.Version = 0x0210; 65
70 client_reg.event_callback_args.client_data = link; 66 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
71 ret = pcmcia_register_client(&link->handle, &client_reg); 67 ixj_config(link);
72 if (ret != CS_SUCCESS) { 68
73 cs_error(link->handle, RegisterClient, ret); 69 return 0;
74 ixj_detach(link->handle);
75 return NULL;
76 }
77 return link;
78} 70}
79 71
80static void ixj_detach(struct pcmcia_device *p_dev) 72static void ixj_detach(struct pcmcia_device *p_dev)
@@ -265,19 +257,6 @@ static int ixj_resume(struct pcmcia_device *dev)
265 return 0; 257 return 0;
266} 258}
267 259
268static int ixj_event(event_t event, int priority, event_callback_args_t * args)
269{
270 dev_link_t *link = args->client_data;
271 DEBUG(1, "ixj_event(0x%06x)\n", event);
272 switch (event) {
273 case CS_EVENT_CARD_INSERTION:
274 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
275 ixj_config(link);
276 break;
277 }
278 return 0;
279}
280
281static struct pcmcia_device_id ixj_ids[] = { 260static struct pcmcia_device_id ixj_ids[] = {
282 PCMCIA_DEVICE_MANF_CARD(0x0257, 0x0600), 261 PCMCIA_DEVICE_MANF_CARD(0x0257, 0x0600),
283 PCMCIA_DEVICE_NULL 262 PCMCIA_DEVICE_NULL
@@ -289,8 +268,7 @@ static struct pcmcia_driver ixj_driver = {
289 .drv = { 268 .drv = {
290 .name = "ixj_cs", 269 .name = "ixj_cs",
291 }, 270 },
292 .attach = ixj_attach, 271 .probe = ixj_attach,
293 .event = ixj_event,
294 .remove = ixj_detach, 272 .remove = ixj_detach,
295 .id_table = ixj_ids, 273 .id_table = ixj_ids,
296 .suspend = ixj_suspend, 274 .suspend = ixj_suspend,
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 439709670d0b..466384d7c79f 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -325,32 +325,14 @@ static int sl811_resume(struct pcmcia_device *dev)
325 return 0; 325 return 0;
326} 326}
327 327
328static int 328static int sl811_cs_attach(struct pcmcia_device *p_dev)
329sl811_cs_event(event_t event, int priority, event_callback_args_t *args)
330{
331 dev_link_t *link = args->client_data;
332
333 DBG(1, "sl811_cs_event(0x%06x)\n", event);
334
335 switch (event) {
336 case CS_EVENT_CARD_INSERTION:
337 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
338 sl811_cs_config(link);
339 break;
340 }
341 return 0;
342}
343
344static dev_link_t *sl811_cs_attach(void)
345{ 329{
346 local_info_t *local; 330 local_info_t *local;
347 dev_link_t *link; 331 dev_link_t *link;
348 client_reg_t client_reg;
349 int ret;
350 332
351 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 333 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
352 if (!local) 334 if (!local)
353 return NULL; 335 return -ENOMEM;
354 memset(local, 0, sizeof(local_info_t)); 336 memset(local, 0, sizeof(local_info_t));
355 link = &local->link; 337 link = &local->link;
356 link->priv = local; 338 link->priv = local;
@@ -364,20 +346,13 @@ static dev_link_t *sl811_cs_attach(void)
364 link->conf.Vcc = 33; 346 link->conf.Vcc = 33;
365 link->conf.IntType = INT_MEMORY_AND_IO; 347 link->conf.IntType = INT_MEMORY_AND_IO;
366 348
367 /* Register with Card Services */ 349 link->handle = p_dev;
368 link->next = NULL; 350 p_dev->instance = link;
369 client_reg.dev_info = (dev_info_t *) &driver_name;
370 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
371 client_reg.Version = 0x0210;
372 client_reg.event_callback_args.client_data = link;
373 ret = pcmcia_register_client(&link->handle, &client_reg);
374 if (ret != CS_SUCCESS) {
375 cs_error(link->handle, RegisterClient, ret);
376 sl811_cs_detach(link->handle);
377 return NULL;
378 }
379 351
380 return link; 352 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
353 sl811_cs_config(link);
354
355 return 0;
381} 356}
382 357
383static struct pcmcia_device_id sl811_ids[] = { 358static struct pcmcia_device_id sl811_ids[] = {
@@ -391,8 +366,7 @@ static struct pcmcia_driver sl811_cs_driver = {
391 .drv = { 366 .drv = {
392 .name = (char *)driver_name, 367 .name = (char *)driver_name,
393 }, 368 },
394 .attach = sl811_cs_attach, 369 .probe = sl811_cs_attach,
395 .event = sl811_cs_event,
396 .remove = sl811_cs_detach, 370 .remove = sl811_cs_detach,
397 .id_table = sl811_ids, 371 .id_table = sl811_ids,
398 .suspend = sl811_suspend, 372 .suspend = sl811_suspend,
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index a751251efdc8..52660f32663d 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -389,7 +389,6 @@ int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status);
389int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); 389int pcmcia_get_mem_page(window_handle_t win, memreq_t *req);
390int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); 390int pcmcia_map_mem_page(window_handle_t win, memreq_t *req);
391int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 391int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod);
392int pcmcia_register_client(client_handle_t *handle, client_reg_t *req);
393int pcmcia_release_configuration(struct pcmcia_device *p_dev); 392int pcmcia_release_configuration(struct pcmcia_device *p_dev);
394int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req); 393int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req);
395int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req); 394int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req);
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index c53a0604e441..8e2a96396478 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -133,10 +133,7 @@ typedef struct dev_link_t {
133struct pcmcia_socket; 133struct pcmcia_socket;
134 134
135struct pcmcia_driver { 135struct pcmcia_driver {
136 dev_link_t *(*attach)(void); 136 int (*probe) (struct pcmcia_device *dev);
137 int (*event) (event_t event, int priority,
138 event_callback_args_t *);
139
140 void (*remove) (struct pcmcia_device *dev); 137 void (*remove) (struct pcmcia_device *dev);
141 138
142 int (*suspend) (struct pcmcia_device *dev); 139 int (*suspend) (struct pcmcia_device *dev);
@@ -169,7 +166,6 @@ struct pcmcia_device {
169 /* deprecated, a cleaned up version will be moved into this 166 /* deprecated, a cleaned up version will be moved into this
170 struct soon */ 167 struct soon */
171 dev_link_t *instance; 168 dev_link_t *instance;
172 event_callback_args_t event_callback_args;
173 u_int state; 169 u_int state;
174 170
175 /* information about this device */ 171 /* information about this device */