diff options
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 119 | ||||
-rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 130 | ||||
-rw-r--r-- | drivers/bluetooth/btuart_cs.c | 130 | ||||
-rw-r--r-- | drivers/bluetooth/dtl1_cs.c | 120 |
4 files changed, 150 insertions, 349 deletions
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 9888bc151755..473a13b22b29 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -65,7 +65,7 @@ MODULE_LICENSE("GPL"); | |||
65 | 65 | ||
66 | 66 | ||
67 | typedef struct bluecard_info_t { | 67 | typedef struct bluecard_info_t { |
68 | dev_link_t link; | 68 | struct pcmcia_device *p_dev; |
69 | dev_node_t node; | 69 | dev_node_t node; |
70 | 70 | ||
71 | struct hci_dev *hdev; | 71 | struct hci_dev *hdev; |
@@ -85,8 +85,8 @@ typedef struct bluecard_info_t { | |||
85 | } bluecard_info_t; | 85 | } bluecard_info_t; |
86 | 86 | ||
87 | 87 | ||
88 | static void bluecard_config(dev_link_t *link); | 88 | static int bluecard_config(struct pcmcia_device *link); |
89 | static void bluecard_release(dev_link_t *link); | 89 | static void bluecard_release(struct pcmcia_device *link); |
90 | 90 | ||
91 | static void bluecard_detach(struct pcmcia_device *p_dev); | 91 | static void bluecard_detach(struct pcmcia_device *p_dev); |
92 | 92 | ||
@@ -162,7 +162,7 @@ static void bluecard_detach(struct pcmcia_device *p_dev); | |||
162 | static void bluecard_activity_led_timeout(u_long arg) | 162 | static void bluecard_activity_led_timeout(u_long arg) |
163 | { | 163 | { |
164 | bluecard_info_t *info = (bluecard_info_t *)arg; | 164 | bluecard_info_t *info = (bluecard_info_t *)arg; |
165 | unsigned int iobase = info->link.io.BasePort1; | 165 | unsigned int iobase = info->p_dev->io.BasePort1; |
166 | 166 | ||
167 | if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) | 167 | if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) |
168 | return; | 168 | return; |
@@ -179,7 +179,7 @@ static void bluecard_activity_led_timeout(u_long arg) | |||
179 | 179 | ||
180 | static void bluecard_enable_activity_led(bluecard_info_t *info) | 180 | static void bluecard_enable_activity_led(bluecard_info_t *info) |
181 | { | 181 | { |
182 | unsigned int iobase = info->link.io.BasePort1; | 182 | unsigned int iobase = info->p_dev->io.BasePort1; |
183 | 183 | ||
184 | if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) | 184 | if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) |
185 | return; | 185 | return; |
@@ -235,7 +235,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info) | |||
235 | } | 235 | } |
236 | 236 | ||
237 | do { | 237 | do { |
238 | register unsigned int iobase = info->link.io.BasePort1; | 238 | register unsigned int iobase = info->p_dev->io.BasePort1; |
239 | register unsigned int offset; | 239 | register unsigned int offset; |
240 | register unsigned char command; | 240 | register unsigned char command; |
241 | register unsigned long ready_bit; | 241 | register unsigned long ready_bit; |
@@ -244,7 +244,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info) | |||
244 | 244 | ||
245 | clear_bit(XMIT_WAKEUP, &(info->tx_state)); | 245 | clear_bit(XMIT_WAKEUP, &(info->tx_state)); |
246 | 246 | ||
247 | if (!(info->link.state & DEV_PRESENT)) | 247 | if (!pcmcia_dev_present(info->p_dev)) |
248 | return; | 248 | return; |
249 | 249 | ||
250 | if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) { | 250 | if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) { |
@@ -382,7 +382,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset) | |||
382 | return; | 382 | return; |
383 | } | 383 | } |
384 | 384 | ||
385 | iobase = info->link.io.BasePort1; | 385 | iobase = info->p_dev->io.BasePort1; |
386 | 386 | ||
387 | if (test_bit(XMIT_SENDING_READY, &(info->tx_state))) | 387 | if (test_bit(XMIT_SENDING_READY, &(info->tx_state))) |
388 | bluecard_enable_activity_led(info); | 388 | bluecard_enable_activity_led(info); |
@@ -512,7 +512,7 @@ static irqreturn_t bluecard_interrupt(int irq, void *dev_inst, struct pt_regs *r | |||
512 | if (!test_bit(CARD_READY, &(info->hw_state))) | 512 | if (!test_bit(CARD_READY, &(info->hw_state))) |
513 | return IRQ_HANDLED; | 513 | return IRQ_HANDLED; |
514 | 514 | ||
515 | iobase = info->link.io.BasePort1; | 515 | iobase = info->p_dev->io.BasePort1; |
516 | 516 | ||
517 | spin_lock(&(info->lock)); | 517 | spin_lock(&(info->lock)); |
518 | 518 | ||
@@ -626,7 +626,7 @@ static int bluecard_hci_flush(struct hci_dev *hdev) | |||
626 | static int bluecard_hci_open(struct hci_dev *hdev) | 626 | static int bluecard_hci_open(struct hci_dev *hdev) |
627 | { | 627 | { |
628 | bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); | 628 | bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); |
629 | unsigned int iobase = info->link.io.BasePort1; | 629 | unsigned int iobase = info->p_dev->io.BasePort1; |
630 | 630 | ||
631 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) | 631 | if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) |
632 | bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); | 632 | bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); |
@@ -646,7 +646,7 @@ static int bluecard_hci_open(struct hci_dev *hdev) | |||
646 | static int bluecard_hci_close(struct hci_dev *hdev) | 646 | static int bluecard_hci_close(struct hci_dev *hdev) |
647 | { | 647 | { |
648 | bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); | 648 | bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); |
649 | unsigned int iobase = info->link.io.BasePort1; | 649 | unsigned int iobase = info->p_dev->io.BasePort1; |
650 | 650 | ||
651 | if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) | 651 | if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) |
652 | return 0; | 652 | return 0; |
@@ -713,7 +713,7 @@ static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned l | |||
713 | 713 | ||
714 | static int bluecard_open(bluecard_info_t *info) | 714 | static int bluecard_open(bluecard_info_t *info) |
715 | { | 715 | { |
716 | unsigned int iobase = info->link.io.BasePort1; | 716 | unsigned int iobase = info->p_dev->io.BasePort1; |
717 | struct hci_dev *hdev; | 717 | struct hci_dev *hdev; |
718 | unsigned char id; | 718 | unsigned char id; |
719 | 719 | ||
@@ -831,7 +831,7 @@ static int bluecard_open(bluecard_info_t *info) | |||
831 | 831 | ||
832 | static int bluecard_close(bluecard_info_t *info) | 832 | static int bluecard_close(bluecard_info_t *info) |
833 | { | 833 | { |
834 | unsigned int iobase = info->link.io.BasePort1; | 834 | unsigned int iobase = info->p_dev->io.BasePort1; |
835 | struct hci_dev *hdev = info->hdev; | 835 | struct hci_dev *hdev = info->hdev; |
836 | 836 | ||
837 | if (!hdev) | 837 | if (!hdev) |
@@ -856,17 +856,16 @@ static int bluecard_close(bluecard_info_t *info) | |||
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | 858 | ||
859 | static int bluecard_attach(struct pcmcia_device *p_dev) | 859 | static int bluecard_probe(struct pcmcia_device *link) |
860 | { | 860 | { |
861 | bluecard_info_t *info; | 861 | bluecard_info_t *info; |
862 | dev_link_t *link; | ||
863 | 862 | ||
864 | /* Create new info device */ | 863 | /* Create new info device */ |
865 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 864 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
866 | if (!info) | 865 | if (!info) |
867 | return -ENOMEM; | 866 | return -ENOMEM; |
868 | 867 | ||
869 | link = &info->link; | 868 | info->p_dev = link; |
870 | link->priv = info; | 869 | link->priv = info; |
871 | 870 | ||
872 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 871 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
@@ -878,32 +877,22 @@ static int bluecard_attach(struct pcmcia_device *p_dev) | |||
878 | link->irq.Instance = info; | 877 | link->irq.Instance = info; |
879 | 878 | ||
880 | link->conf.Attributes = CONF_ENABLE_IRQ; | 879 | link->conf.Attributes = CONF_ENABLE_IRQ; |
881 | link->conf.Vcc = 50; | ||
882 | link->conf.IntType = INT_MEMORY_AND_IO; | 880 | link->conf.IntType = INT_MEMORY_AND_IO; |
883 | 881 | ||
884 | link->handle = p_dev; | 882 | return bluecard_config(link); |
885 | p_dev->instance = link; | ||
886 | |||
887 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
888 | bluecard_config(link); | ||
889 | |||
890 | return 0; | ||
891 | } | 883 | } |
892 | 884 | ||
893 | 885 | ||
894 | static void bluecard_detach(struct pcmcia_device *p_dev) | 886 | static void bluecard_detach(struct pcmcia_device *link) |
895 | { | 887 | { |
896 | dev_link_t *link = dev_to_instance(p_dev); | ||
897 | bluecard_info_t *info = link->priv; | 888 | bluecard_info_t *info = link->priv; |
898 | 889 | ||
899 | if (link->state & DEV_CONFIG) | 890 | bluecard_release(link); |
900 | bluecard_release(link); | ||
901 | |||
902 | kfree(info); | 891 | kfree(info); |
903 | } | 892 | } |
904 | 893 | ||
905 | 894 | ||
906 | static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 895 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
907 | { | 896 | { |
908 | int i; | 897 | int i; |
909 | 898 | ||
@@ -918,14 +907,12 @@ static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse | |||
918 | return pcmcia_parse_tuple(handle, tuple, parse); | 907 | return pcmcia_parse_tuple(handle, tuple, parse); |
919 | } | 908 | } |
920 | 909 | ||
921 | static void bluecard_config(dev_link_t *link) | 910 | static int bluecard_config(struct pcmcia_device *link) |
922 | { | 911 | { |
923 | client_handle_t handle = link->handle; | ||
924 | bluecard_info_t *info = link->priv; | 912 | bluecard_info_t *info = link->priv; |
925 | tuple_t tuple; | 913 | tuple_t tuple; |
926 | u_short buf[256]; | 914 | u_short buf[256]; |
927 | cisparse_t parse; | 915 | cisparse_t parse; |
928 | config_info_t config; | ||
929 | int i, n, last_ret, last_fn; | 916 | int i, n, last_ret, last_fn; |
930 | 917 | ||
931 | tuple.TupleData = (cisdata_t *)buf; | 918 | tuple.TupleData = (cisdata_t *)buf; |
@@ -935,7 +922,7 @@ static void bluecard_config(dev_link_t *link) | |||
935 | 922 | ||
936 | /* Get configuration register information */ | 923 | /* Get configuration register information */ |
937 | tuple.DesiredTuple = CISTPL_CONFIG; | 924 | tuple.DesiredTuple = CISTPL_CONFIG; |
938 | last_ret = first_tuple(handle, &tuple, &parse); | 925 | last_ret = first_tuple(link, &tuple, &parse); |
939 | if (last_ret != CS_SUCCESS) { | 926 | if (last_ret != CS_SUCCESS) { |
940 | last_fn = ParseTuple; | 927 | last_fn = ParseTuple; |
941 | goto cs_failed; | 928 | goto cs_failed; |
@@ -943,36 +930,31 @@ static void bluecard_config(dev_link_t *link) | |||
943 | link->conf.ConfigBase = parse.config.base; | 930 | link->conf.ConfigBase = parse.config.base; |
944 | link->conf.Present = parse.config.rmask[0]; | 931 | link->conf.Present = parse.config.rmask[0]; |
945 | 932 | ||
946 | /* Configure card */ | ||
947 | link->state |= DEV_CONFIG; | ||
948 | i = pcmcia_get_configuration_info(handle, &config); | ||
949 | link->conf.Vcc = config.Vcc; | ||
950 | |||
951 | link->conf.ConfigIndex = 0x20; | 933 | link->conf.ConfigIndex = 0x20; |
952 | link->io.NumPorts1 = 64; | 934 | link->io.NumPorts1 = 64; |
953 | link->io.IOAddrLines = 6; | 935 | link->io.IOAddrLines = 6; |
954 | 936 | ||
955 | for (n = 0; n < 0x400; n += 0x40) { | 937 | for (n = 0; n < 0x400; n += 0x40) { |
956 | link->io.BasePort1 = n ^ 0x300; | 938 | link->io.BasePort1 = n ^ 0x300; |
957 | i = pcmcia_request_io(link->handle, &link->io); | 939 | i = pcmcia_request_io(link, &link->io); |
958 | if (i == CS_SUCCESS) | 940 | if (i == CS_SUCCESS) |
959 | break; | 941 | break; |
960 | } | 942 | } |
961 | 943 | ||
962 | if (i != CS_SUCCESS) { | 944 | if (i != CS_SUCCESS) { |
963 | cs_error(link->handle, RequestIO, i); | 945 | cs_error(link, RequestIO, i); |
964 | goto failed; | 946 | goto failed; |
965 | } | 947 | } |
966 | 948 | ||
967 | i = pcmcia_request_irq(link->handle, &link->irq); | 949 | i = pcmcia_request_irq(link, &link->irq); |
968 | if (i != CS_SUCCESS) { | 950 | if (i != CS_SUCCESS) { |
969 | cs_error(link->handle, RequestIRQ, i); | 951 | cs_error(link, RequestIRQ, i); |
970 | link->irq.AssignedIRQ = 0; | 952 | link->irq.AssignedIRQ = 0; |
971 | } | 953 | } |
972 | 954 | ||
973 | i = pcmcia_request_configuration(link->handle, &link->conf); | 955 | i = pcmcia_request_configuration(link, &link->conf); |
974 | if (i != CS_SUCCESS) { | 956 | if (i != CS_SUCCESS) { |
975 | cs_error(link->handle, RequestConfiguration, i); | 957 | cs_error(link, RequestConfiguration, i); |
976 | goto failed; | 958 | goto failed; |
977 | } | 959 | } |
978 | 960 | ||
@@ -980,57 +962,28 @@ static void bluecard_config(dev_link_t *link) | |||
980 | goto failed; | 962 | goto failed; |
981 | 963 | ||
982 | strcpy(info->node.dev_name, info->hdev->name); | 964 | strcpy(info->node.dev_name, info->hdev->name); |
983 | link->dev = &info->node; | 965 | link->dev_node = &info->node; |
984 | link->state &= ~DEV_CONFIG_PENDING; | ||
985 | 966 | ||
986 | return; | 967 | return 0; |
987 | 968 | ||
988 | cs_failed: | 969 | cs_failed: |
989 | cs_error(link->handle, last_fn, last_ret); | 970 | cs_error(link, last_fn, last_ret); |
990 | 971 | ||
991 | failed: | 972 | failed: |
992 | bluecard_release(link); | 973 | bluecard_release(link); |
974 | return -ENODEV; | ||
993 | } | 975 | } |
994 | 976 | ||
995 | 977 | ||
996 | static void bluecard_release(dev_link_t *link) | 978 | static void bluecard_release(struct pcmcia_device *link) |
997 | { | 979 | { |
998 | bluecard_info_t *info = link->priv; | 980 | bluecard_info_t *info = link->priv; |
999 | 981 | ||
1000 | if (link->state & DEV_PRESENT) | 982 | bluecard_close(info); |
1001 | bluecard_close(info); | ||
1002 | 983 | ||
1003 | del_timer(&(info->timer)); | 984 | del_timer(&(info->timer)); |
1004 | 985 | ||
1005 | link->dev = NULL; | 986 | pcmcia_disable_device(link); |
1006 | |||
1007 | pcmcia_release_configuration(link->handle); | ||
1008 | pcmcia_release_io(link->handle, &link->io); | ||
1009 | pcmcia_release_irq(link->handle, &link->irq); | ||
1010 | |||
1011 | link->state &= ~DEV_CONFIG; | ||
1012 | } | ||
1013 | |||
1014 | static int bluecard_suspend(struct pcmcia_device *dev) | ||
1015 | { | ||
1016 | dev_link_t *link = dev_to_instance(dev); | ||
1017 | |||
1018 | link->state |= DEV_SUSPEND; | ||
1019 | if (link->state & DEV_CONFIG) | ||
1020 | pcmcia_release_configuration(link->handle); | ||
1021 | |||
1022 | return 0; | ||
1023 | } | ||
1024 | |||
1025 | static int bluecard_resume(struct pcmcia_device *dev) | ||
1026 | { | ||
1027 | dev_link_t *link = dev_to_instance(dev); | ||
1028 | |||
1029 | link->state &= ~DEV_SUSPEND; | ||
1030 | if (DEV_OK(link)) | ||
1031 | pcmcia_request_configuration(link->handle, &link->conf); | ||
1032 | |||
1033 | return 0; | ||
1034 | } | 987 | } |
1035 | 988 | ||
1036 | static struct pcmcia_device_id bluecard_ids[] = { | 989 | static struct pcmcia_device_id bluecard_ids[] = { |
@@ -1046,11 +999,9 @@ static struct pcmcia_driver bluecard_driver = { | |||
1046 | .drv = { | 999 | .drv = { |
1047 | .name = "bluecard_cs", | 1000 | .name = "bluecard_cs", |
1048 | }, | 1001 | }, |
1049 | .probe = bluecard_attach, | 1002 | .probe = bluecard_probe, |
1050 | .remove = bluecard_detach, | 1003 | .remove = bluecard_detach, |
1051 | .id_table = bluecard_ids, | 1004 | .id_table = bluecard_ids, |
1052 | .suspend = bluecard_suspend, | ||
1053 | .resume = bluecard_resume, | ||
1054 | }; | 1005 | }; |
1055 | 1006 | ||
1056 | static int __init init_bluecard_cs(void) | 1007 | static int __init init_bluecard_cs(void) |
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 7e21b1ff27c4..b94ac2f9f7ba 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -72,7 +72,7 @@ MODULE_LICENSE("GPL"); | |||
72 | 72 | ||
73 | 73 | ||
74 | typedef struct bt3c_info_t { | 74 | typedef struct bt3c_info_t { |
75 | dev_link_t link; | 75 | struct pcmcia_device *p_dev; |
76 | dev_node_t node; | 76 | dev_node_t node; |
77 | 77 | ||
78 | struct hci_dev *hdev; | 78 | struct hci_dev *hdev; |
@@ -88,8 +88,8 @@ typedef struct bt3c_info_t { | |||
88 | } bt3c_info_t; | 88 | } bt3c_info_t; |
89 | 89 | ||
90 | 90 | ||
91 | static void bt3c_config(dev_link_t *link); | 91 | static int bt3c_config(struct pcmcia_device *link); |
92 | static void bt3c_release(dev_link_t *link); | 92 | static void bt3c_release(struct pcmcia_device *link); |
93 | 93 | ||
94 | static void bt3c_detach(struct pcmcia_device *p_dev); | 94 | static void bt3c_detach(struct pcmcia_device *p_dev); |
95 | 95 | ||
@@ -191,11 +191,11 @@ static void bt3c_write_wakeup(bt3c_info_t *info) | |||
191 | return; | 191 | return; |
192 | 192 | ||
193 | do { | 193 | do { |
194 | register unsigned int iobase = info->link.io.BasePort1; | 194 | register unsigned int iobase = info->p_dev->io.BasePort1; |
195 | register struct sk_buff *skb; | 195 | register struct sk_buff *skb; |
196 | register int len; | 196 | register int len; |
197 | 197 | ||
198 | if (!(info->link.state & DEV_PRESENT)) | 198 | if (!pcmcia_dev_present(info->p_dev)) |
199 | break; | 199 | break; |
200 | 200 | ||
201 | 201 | ||
@@ -229,7 +229,7 @@ static void bt3c_receive(bt3c_info_t *info) | |||
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | 231 | ||
232 | iobase = info->link.io.BasePort1; | 232 | iobase = info->p_dev->io.BasePort1; |
233 | 233 | ||
234 | avail = bt3c_read(iobase, 0x7006); | 234 | avail = bt3c_read(iobase, 0x7006); |
235 | //printk("bt3c_cs: receiving %d bytes\n", avail); | 235 | //printk("bt3c_cs: receiving %d bytes\n", avail); |
@@ -350,7 +350,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst, struct pt_regs *regs) | |||
350 | return IRQ_NONE; | 350 | return IRQ_NONE; |
351 | } | 351 | } |
352 | 352 | ||
353 | iobase = info->link.io.BasePort1; | 353 | iobase = info->p_dev->io.BasePort1; |
354 | 354 | ||
355 | spin_lock(&(info->lock)); | 355 | spin_lock(&(info->lock)); |
356 | 356 | ||
@@ -481,7 +481,7 @@ static int bt3c_load_firmware(bt3c_info_t *info, unsigned char *firmware, int co | |||
481 | unsigned int iobase, size, addr, fcs, tmp; | 481 | unsigned int iobase, size, addr, fcs, tmp; |
482 | int i, err = 0; | 482 | int i, err = 0; |
483 | 483 | ||
484 | iobase = info->link.io.BasePort1; | 484 | iobase = info->p_dev->io.BasePort1; |
485 | 485 | ||
486 | /* Reset */ | 486 | /* Reset */ |
487 | bt3c_io_write(iobase, 0x8040, 0x0404); | 487 | bt3c_io_write(iobase, 0x8040, 0x0404); |
@@ -562,7 +562,6 @@ static int bt3c_open(bt3c_info_t *info) | |||
562 | { | 562 | { |
563 | const struct firmware *firmware; | 563 | const struct firmware *firmware; |
564 | struct hci_dev *hdev; | 564 | struct hci_dev *hdev; |
565 | client_handle_t handle; | ||
566 | int err; | 565 | int err; |
567 | 566 | ||
568 | spin_lock_init(&(info->lock)); | 567 | spin_lock_init(&(info->lock)); |
@@ -594,10 +593,8 @@ static int bt3c_open(bt3c_info_t *info) | |||
594 | 593 | ||
595 | hdev->owner = THIS_MODULE; | 594 | hdev->owner = THIS_MODULE; |
596 | 595 | ||
597 | handle = info->link.handle; | ||
598 | |||
599 | /* Load firmware */ | 596 | /* Load firmware */ |
600 | err = request_firmware(&firmware, "BT3CPCC.bin", &handle_to_dev(handle)); | 597 | err = request_firmware(&firmware, "BT3CPCC.bin", &info->p_dev->dev); |
601 | if (err < 0) { | 598 | if (err < 0) { |
602 | BT_ERR("Firmware request failed"); | 599 | BT_ERR("Firmware request failed"); |
603 | goto error; | 600 | goto error; |
@@ -648,17 +645,16 @@ static int bt3c_close(bt3c_info_t *info) | |||
648 | return 0; | 645 | return 0; |
649 | } | 646 | } |
650 | 647 | ||
651 | static int bt3c_attach(struct pcmcia_device *p_dev) | 648 | static int bt3c_probe(struct pcmcia_device *link) |
652 | { | 649 | { |
653 | bt3c_info_t *info; | 650 | bt3c_info_t *info; |
654 | dev_link_t *link; | ||
655 | 651 | ||
656 | /* Create new info device */ | 652 | /* Create new info device */ |
657 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 653 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
658 | if (!info) | 654 | if (!info) |
659 | return -ENOMEM; | 655 | return -ENOMEM; |
660 | 656 | ||
661 | link = &info->link; | 657 | info->p_dev = link; |
662 | link->priv = info; | 658 | link->priv = info; |
663 | 659 | ||
664 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 660 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
@@ -670,31 +666,21 @@ static int bt3c_attach(struct pcmcia_device *p_dev) | |||
670 | link->irq.Instance = info; | 666 | link->irq.Instance = info; |
671 | 667 | ||
672 | link->conf.Attributes = CONF_ENABLE_IRQ; | 668 | link->conf.Attributes = CONF_ENABLE_IRQ; |
673 | link->conf.Vcc = 50; | ||
674 | link->conf.IntType = INT_MEMORY_AND_IO; | 669 | link->conf.IntType = INT_MEMORY_AND_IO; |
675 | 670 | ||
676 | link->handle = p_dev; | 671 | return bt3c_config(link); |
677 | p_dev->instance = link; | ||
678 | |||
679 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
680 | bt3c_config(link); | ||
681 | |||
682 | return 0; | ||
683 | } | 672 | } |
684 | 673 | ||
685 | 674 | ||
686 | static void bt3c_detach(struct pcmcia_device *p_dev) | 675 | static void bt3c_detach(struct pcmcia_device *link) |
687 | { | 676 | { |
688 | dev_link_t *link = dev_to_instance(p_dev); | ||
689 | bt3c_info_t *info = link->priv; | 677 | bt3c_info_t *info = link->priv; |
690 | 678 | ||
691 | if (link->state & DEV_CONFIG) | 679 | bt3c_release(link); |
692 | bt3c_release(link); | ||
693 | |||
694 | kfree(info); | 680 | kfree(info); |
695 | } | 681 | } |
696 | 682 | ||
697 | static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 683 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
698 | { | 684 | { |
699 | int i; | 685 | int i; |
700 | 686 | ||
@@ -705,30 +691,28 @@ static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | |||
705 | return pcmcia_parse_tuple(handle, tuple, parse); | 691 | return pcmcia_parse_tuple(handle, tuple, parse); |
706 | } | 692 | } |
707 | 693 | ||
708 | static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 694 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
709 | { | 695 | { |
710 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) | 696 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) |
711 | return CS_NO_MORE_ITEMS; | 697 | return CS_NO_MORE_ITEMS; |
712 | return get_tuple(handle, tuple, parse); | 698 | return get_tuple(handle, tuple, parse); |
713 | } | 699 | } |
714 | 700 | ||
715 | static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 701 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
716 | { | 702 | { |
717 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) | 703 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) |
718 | return CS_NO_MORE_ITEMS; | 704 | return CS_NO_MORE_ITEMS; |
719 | return get_tuple(handle, tuple, parse); | 705 | return get_tuple(handle, tuple, parse); |
720 | } | 706 | } |
721 | 707 | ||
722 | static void bt3c_config(dev_link_t *link) | 708 | static int bt3c_config(struct pcmcia_device *link) |
723 | { | 709 | { |
724 | static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; | 710 | static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; |
725 | client_handle_t handle = link->handle; | ||
726 | bt3c_info_t *info = link->priv; | 711 | bt3c_info_t *info = link->priv; |
727 | tuple_t tuple; | 712 | tuple_t tuple; |
728 | u_short buf[256]; | 713 | u_short buf[256]; |
729 | cisparse_t parse; | 714 | cisparse_t parse; |
730 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | 715 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; |
731 | config_info_t config; | ||
732 | int i, j, try, last_ret, last_fn; | 716 | int i, j, try, last_ret, last_fn; |
733 | 717 | ||
734 | tuple.TupleData = (cisdata_t *)buf; | 718 | tuple.TupleData = (cisdata_t *)buf; |
@@ -738,7 +722,7 @@ static void bt3c_config(dev_link_t *link) | |||
738 | 722 | ||
739 | /* Get configuration register information */ | 723 | /* Get configuration register information */ |
740 | tuple.DesiredTuple = CISTPL_CONFIG; | 724 | tuple.DesiredTuple = CISTPL_CONFIG; |
741 | last_ret = first_tuple(handle, &tuple, &parse); | 725 | last_ret = first_tuple(link, &tuple, &parse); |
742 | if (last_ret != CS_SUCCESS) { | 726 | if (last_ret != CS_SUCCESS) { |
743 | last_fn = ParseTuple; | 727 | last_fn = ParseTuple; |
744 | goto cs_failed; | 728 | goto cs_failed; |
@@ -746,11 +730,6 @@ static void bt3c_config(dev_link_t *link) | |||
746 | link->conf.ConfigBase = parse.config.base; | 730 | link->conf.ConfigBase = parse.config.base; |
747 | link->conf.Present = parse.config.rmask[0]; | 731 | link->conf.Present = parse.config.rmask[0]; |
748 | 732 | ||
749 | /* Configure card */ | ||
750 | link->state |= DEV_CONFIG; | ||
751 | i = pcmcia_get_configuration_info(handle, &config); | ||
752 | link->conf.Vcc = config.Vcc; | ||
753 | |||
754 | /* First pass: look for a config entry that looks normal. */ | 733 | /* First pass: look for a config entry that looks normal. */ |
755 | tuple.TupleData = (cisdata_t *)buf; | 734 | tuple.TupleData = (cisdata_t *)buf; |
756 | tuple.TupleOffset = 0; | 735 | tuple.TupleOffset = 0; |
@@ -759,59 +738,59 @@ static void bt3c_config(dev_link_t *link) | |||
759 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 738 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
760 | /* Two tries: without IO aliases, then with aliases */ | 739 | /* Two tries: without IO aliases, then with aliases */ |
761 | for (try = 0; try < 2; try++) { | 740 | for (try = 0; try < 2; try++) { |
762 | i = first_tuple(handle, &tuple, &parse); | 741 | i = first_tuple(link, &tuple, &parse); |
763 | while (i != CS_NO_MORE_ITEMS) { | 742 | while (i != CS_NO_MORE_ITEMS) { |
764 | if (i != CS_SUCCESS) | 743 | if (i != CS_SUCCESS) |
765 | goto next_entry; | 744 | goto next_entry; |
766 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 745 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
767 | link->conf.Vpp1 = link->conf.Vpp2 = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 746 | link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
768 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { | 747 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { |
769 | link->conf.ConfigIndex = cf->index; | 748 | link->conf.ConfigIndex = cf->index; |
770 | link->io.BasePort1 = cf->io.win[0].base; | 749 | link->io.BasePort1 = cf->io.win[0].base; |
771 | link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; | 750 | link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; |
772 | i = pcmcia_request_io(link->handle, &link->io); | 751 | i = pcmcia_request_io(link, &link->io); |
773 | if (i == CS_SUCCESS) | 752 | if (i == CS_SUCCESS) |
774 | goto found_port; | 753 | goto found_port; |
775 | } | 754 | } |
776 | next_entry: | 755 | next_entry: |
777 | i = next_tuple(handle, &tuple, &parse); | 756 | i = next_tuple(link, &tuple, &parse); |
778 | } | 757 | } |
779 | } | 758 | } |
780 | 759 | ||
781 | /* Second pass: try to find an entry that isn't picky about | 760 | /* Second pass: try to find an entry that isn't picky about |
782 | its base address, then try to grab any standard serial port | 761 | its base address, then try to grab any standard serial port |
783 | address, and finally try to get any free port. */ | 762 | address, and finally try to get any free port. */ |
784 | i = first_tuple(handle, &tuple, &parse); | 763 | i = first_tuple(link, &tuple, &parse); |
785 | while (i != CS_NO_MORE_ITEMS) { | 764 | while (i != CS_NO_MORE_ITEMS) { |
786 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | 765 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { |
787 | link->conf.ConfigIndex = cf->index; | 766 | link->conf.ConfigIndex = cf->index; |
788 | for (j = 0; j < 5; j++) { | 767 | for (j = 0; j < 5; j++) { |
789 | link->io.BasePort1 = base[j]; | 768 | link->io.BasePort1 = base[j]; |
790 | link->io.IOAddrLines = base[j] ? 16 : 3; | 769 | link->io.IOAddrLines = base[j] ? 16 : 3; |
791 | i = pcmcia_request_io(link->handle, &link->io); | 770 | i = pcmcia_request_io(link, &link->io); |
792 | if (i == CS_SUCCESS) | 771 | if (i == CS_SUCCESS) |
793 | goto found_port; | 772 | goto found_port; |
794 | } | 773 | } |
795 | } | 774 | } |
796 | i = next_tuple(handle, &tuple, &parse); | 775 | i = next_tuple(link, &tuple, &parse); |
797 | } | 776 | } |
798 | 777 | ||
799 | found_port: | 778 | found_port: |
800 | if (i != CS_SUCCESS) { | 779 | if (i != CS_SUCCESS) { |
801 | BT_ERR("No usable port range found"); | 780 | BT_ERR("No usable port range found"); |
802 | cs_error(link->handle, RequestIO, i); | 781 | cs_error(link, RequestIO, i); |
803 | goto failed; | 782 | goto failed; |
804 | } | 783 | } |
805 | 784 | ||
806 | i = pcmcia_request_irq(link->handle, &link->irq); | 785 | i = pcmcia_request_irq(link, &link->irq); |
807 | if (i != CS_SUCCESS) { | 786 | if (i != CS_SUCCESS) { |
808 | cs_error(link->handle, RequestIRQ, i); | 787 | cs_error(link, RequestIRQ, i); |
809 | link->irq.AssignedIRQ = 0; | 788 | link->irq.AssignedIRQ = 0; |
810 | } | 789 | } |
811 | 790 | ||
812 | i = pcmcia_request_configuration(link->handle, &link->conf); | 791 | i = pcmcia_request_configuration(link, &link->conf); |
813 | if (i != CS_SUCCESS) { | 792 | if (i != CS_SUCCESS) { |
814 | cs_error(link->handle, RequestConfiguration, i); | 793 | cs_error(link, RequestConfiguration, i); |
815 | goto failed; | 794 | goto failed; |
816 | } | 795 | } |
817 | 796 | ||
@@ -819,55 +798,26 @@ found_port: | |||
819 | goto failed; | 798 | goto failed; |
820 | 799 | ||
821 | strcpy(info->node.dev_name, info->hdev->name); | 800 | strcpy(info->node.dev_name, info->hdev->name); |
822 | link->dev = &info->node; | 801 | link->dev_node = &info->node; |
823 | link->state &= ~DEV_CONFIG_PENDING; | ||
824 | 802 | ||
825 | return; | 803 | return 0; |
826 | 804 | ||
827 | cs_failed: | 805 | cs_failed: |
828 | cs_error(link->handle, last_fn, last_ret); | 806 | cs_error(link, last_fn, last_ret); |
829 | 807 | ||
830 | failed: | 808 | failed: |
831 | bt3c_release(link); | 809 | bt3c_release(link); |
810 | return -ENODEV; | ||
832 | } | 811 | } |
833 | 812 | ||
834 | 813 | ||
835 | static void bt3c_release(dev_link_t *link) | 814 | static void bt3c_release(struct pcmcia_device *link) |
836 | { | 815 | { |
837 | bt3c_info_t *info = link->priv; | 816 | bt3c_info_t *info = link->priv; |
838 | 817 | ||
839 | if (link->state & DEV_PRESENT) | 818 | bt3c_close(info); |
840 | bt3c_close(info); | ||
841 | |||
842 | link->dev = NULL; | ||
843 | |||
844 | pcmcia_release_configuration(link->handle); | ||
845 | pcmcia_release_io(link->handle, &link->io); | ||
846 | pcmcia_release_irq(link->handle, &link->irq); | ||
847 | |||
848 | link->state &= ~DEV_CONFIG; | ||
849 | } | ||
850 | |||
851 | static int bt3c_suspend(struct pcmcia_device *dev) | ||
852 | { | ||
853 | dev_link_t *link = dev_to_instance(dev); | ||
854 | 819 | ||
855 | link->state |= DEV_SUSPEND; | 820 | pcmcia_disable_device(link); |
856 | if (link->state & DEV_CONFIG) | ||
857 | pcmcia_release_configuration(link->handle); | ||
858 | |||
859 | return 0; | ||
860 | } | ||
861 | |||
862 | static int bt3c_resume(struct pcmcia_device *dev) | ||
863 | { | ||
864 | dev_link_t *link = dev_to_instance(dev); | ||
865 | |||
866 | link->state &= ~DEV_SUSPEND; | ||
867 | if (DEV_OK(link)) | ||
868 | pcmcia_request_configuration(link->handle, &link->conf); | ||
869 | |||
870 | return 0; | ||
871 | } | 821 | } |
872 | 822 | ||
873 | 823 | ||
@@ -882,11 +832,9 @@ static struct pcmcia_driver bt3c_driver = { | |||
882 | .drv = { | 832 | .drv = { |
883 | .name = "bt3c_cs", | 833 | .name = "bt3c_cs", |
884 | }, | 834 | }, |
885 | .probe = bt3c_attach, | 835 | .probe = bt3c_probe, |
886 | .remove = bt3c_detach, | 836 | .remove = bt3c_detach, |
887 | .id_table = bt3c_ids, | 837 | .id_table = bt3c_ids, |
888 | .suspend = bt3c_suspend, | ||
889 | .resume = bt3c_resume, | ||
890 | }; | 838 | }; |
891 | 839 | ||
892 | static int __init init_bt3c_cs(void) | 840 | static int __init init_bt3c_cs(void) |
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 7b4bff4cfa2d..9ce4c93467e5 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -68,7 +68,7 @@ MODULE_LICENSE("GPL"); | |||
68 | 68 | ||
69 | 69 | ||
70 | typedef struct btuart_info_t { | 70 | typedef struct btuart_info_t { |
71 | dev_link_t link; | 71 | struct pcmcia_device *p_dev; |
72 | dev_node_t node; | 72 | dev_node_t node; |
73 | 73 | ||
74 | struct hci_dev *hdev; | 74 | struct hci_dev *hdev; |
@@ -84,8 +84,8 @@ typedef struct btuart_info_t { | |||
84 | } btuart_info_t; | 84 | } btuart_info_t; |
85 | 85 | ||
86 | 86 | ||
87 | static void btuart_config(dev_link_t *link); | 87 | static int btuart_config(struct pcmcia_device *link); |
88 | static void btuart_release(dev_link_t *link); | 88 | static void btuart_release(struct pcmcia_device *link); |
89 | 89 | ||
90 | static void btuart_detach(struct pcmcia_device *p_dev); | 90 | static void btuart_detach(struct pcmcia_device *p_dev); |
91 | 91 | ||
@@ -146,13 +146,13 @@ static void btuart_write_wakeup(btuart_info_t *info) | |||
146 | } | 146 | } |
147 | 147 | ||
148 | do { | 148 | do { |
149 | register unsigned int iobase = info->link.io.BasePort1; | 149 | register unsigned int iobase = info->p_dev->io.BasePort1; |
150 | register struct sk_buff *skb; | 150 | register struct sk_buff *skb; |
151 | register int len; | 151 | register int len; |
152 | 152 | ||
153 | clear_bit(XMIT_WAKEUP, &(info->tx_state)); | 153 | clear_bit(XMIT_WAKEUP, &(info->tx_state)); |
154 | 154 | ||
155 | if (!(info->link.state & DEV_PRESENT)) | 155 | if (!pcmcia_dev_present(info->p_dev)) |
156 | return; | 156 | return; |
157 | 157 | ||
158 | if (!(skb = skb_dequeue(&(info->txq)))) | 158 | if (!(skb = skb_dequeue(&(info->txq)))) |
@@ -187,7 +187,7 @@ static void btuart_receive(btuart_info_t *info) | |||
187 | return; | 187 | return; |
188 | } | 188 | } |
189 | 189 | ||
190 | iobase = info->link.io.BasePort1; | 190 | iobase = info->p_dev->io.BasePort1; |
191 | 191 | ||
192 | do { | 192 | do { |
193 | info->hdev->stat.byte_rx++; | 193 | info->hdev->stat.byte_rx++; |
@@ -301,7 +301,7 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst, struct pt_regs *reg | |||
301 | return IRQ_NONE; | 301 | return IRQ_NONE; |
302 | } | 302 | } |
303 | 303 | ||
304 | iobase = info->link.io.BasePort1; | 304 | iobase = info->p_dev->io.BasePort1; |
305 | 305 | ||
306 | spin_lock(&(info->lock)); | 306 | spin_lock(&(info->lock)); |
307 | 307 | ||
@@ -357,7 +357,7 @@ static void btuart_change_speed(btuart_info_t *info, unsigned int speed) | |||
357 | return; | 357 | return; |
358 | } | 358 | } |
359 | 359 | ||
360 | iobase = info->link.io.BasePort1; | 360 | iobase = info->p_dev->io.BasePort1; |
361 | 361 | ||
362 | spin_lock_irqsave(&(info->lock), flags); | 362 | spin_lock_irqsave(&(info->lock), flags); |
363 | 363 | ||
@@ -481,7 +481,7 @@ static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned lon | |||
481 | static int btuart_open(btuart_info_t *info) | 481 | static int btuart_open(btuart_info_t *info) |
482 | { | 482 | { |
483 | unsigned long flags; | 483 | unsigned long flags; |
484 | unsigned int iobase = info->link.io.BasePort1; | 484 | unsigned int iobase = info->p_dev->io.BasePort1; |
485 | struct hci_dev *hdev; | 485 | struct hci_dev *hdev; |
486 | 486 | ||
487 | spin_lock_init(&(info->lock)); | 487 | spin_lock_init(&(info->lock)); |
@@ -550,7 +550,7 @@ static int btuart_open(btuart_info_t *info) | |||
550 | static int btuart_close(btuart_info_t *info) | 550 | static int btuart_close(btuart_info_t *info) |
551 | { | 551 | { |
552 | unsigned long flags; | 552 | unsigned long flags; |
553 | unsigned int iobase = info->link.io.BasePort1; | 553 | unsigned int iobase = info->p_dev->io.BasePort1; |
554 | struct hci_dev *hdev = info->hdev; | 554 | struct hci_dev *hdev = info->hdev; |
555 | 555 | ||
556 | if (!hdev) | 556 | if (!hdev) |
@@ -576,17 +576,16 @@ static int btuart_close(btuart_info_t *info) | |||
576 | return 0; | 576 | return 0; |
577 | } | 577 | } |
578 | 578 | ||
579 | static int btuart_attach(struct pcmcia_device *p_dev) | 579 | static int btuart_probe(struct pcmcia_device *link) |
580 | { | 580 | { |
581 | btuart_info_t *info; | 581 | btuart_info_t *info; |
582 | dev_link_t *link; | ||
583 | 582 | ||
584 | /* Create new info device */ | 583 | /* Create new info device */ |
585 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 584 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
586 | if (!info) | 585 | if (!info) |
587 | return -ENOMEM; | 586 | return -ENOMEM; |
588 | 587 | ||
589 | link = &info->link; | 588 | info->p_dev = link; |
590 | link->priv = info; | 589 | link->priv = info; |
591 | 590 | ||
592 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 591 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
@@ -598,31 +597,21 @@ static int btuart_attach(struct pcmcia_device *p_dev) | |||
598 | link->irq.Instance = info; | 597 | link->irq.Instance = info; |
599 | 598 | ||
600 | link->conf.Attributes = CONF_ENABLE_IRQ; | 599 | link->conf.Attributes = CONF_ENABLE_IRQ; |
601 | link->conf.Vcc = 50; | ||
602 | link->conf.IntType = INT_MEMORY_AND_IO; | 600 | link->conf.IntType = INT_MEMORY_AND_IO; |
603 | 601 | ||
604 | link->handle = p_dev; | 602 | return btuart_config(link); |
605 | p_dev->instance = link; | ||
606 | |||
607 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
608 | btuart_config(link); | ||
609 | |||
610 | return 0; | ||
611 | } | 603 | } |
612 | 604 | ||
613 | 605 | ||
614 | static void btuart_detach(struct pcmcia_device *p_dev) | 606 | static void btuart_detach(struct pcmcia_device *link) |
615 | { | 607 | { |
616 | dev_link_t *link = dev_to_instance(p_dev); | ||
617 | btuart_info_t *info = link->priv; | 608 | btuart_info_t *info = link->priv; |
618 | 609 | ||
619 | if (link->state & DEV_CONFIG) | 610 | btuart_release(link); |
620 | btuart_release(link); | ||
621 | |||
622 | kfree(info); | 611 | kfree(info); |
623 | } | 612 | } |
624 | 613 | ||
625 | static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 614 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
626 | { | 615 | { |
627 | int i; | 616 | int i; |
628 | 617 | ||
@@ -633,30 +622,28 @@ static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | |||
633 | return pcmcia_parse_tuple(handle, tuple, parse); | 622 | return pcmcia_parse_tuple(handle, tuple, parse); |
634 | } | 623 | } |
635 | 624 | ||
636 | static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 625 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
637 | { | 626 | { |
638 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) | 627 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) |
639 | return CS_NO_MORE_ITEMS; | 628 | return CS_NO_MORE_ITEMS; |
640 | return get_tuple(handle, tuple, parse); | 629 | return get_tuple(handle, tuple, parse); |
641 | } | 630 | } |
642 | 631 | ||
643 | static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 632 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
644 | { | 633 | { |
645 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) | 634 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) |
646 | return CS_NO_MORE_ITEMS; | 635 | return CS_NO_MORE_ITEMS; |
647 | return get_tuple(handle, tuple, parse); | 636 | return get_tuple(handle, tuple, parse); |
648 | } | 637 | } |
649 | 638 | ||
650 | static void btuart_config(dev_link_t *link) | 639 | static int btuart_config(struct pcmcia_device *link) |
651 | { | 640 | { |
652 | static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; | 641 | static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; |
653 | client_handle_t handle = link->handle; | ||
654 | btuart_info_t *info = link->priv; | 642 | btuart_info_t *info = link->priv; |
655 | tuple_t tuple; | 643 | tuple_t tuple; |
656 | u_short buf[256]; | 644 | u_short buf[256]; |
657 | cisparse_t parse; | 645 | cisparse_t parse; |
658 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | 646 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; |
659 | config_info_t config; | ||
660 | int i, j, try, last_ret, last_fn; | 647 | int i, j, try, last_ret, last_fn; |
661 | 648 | ||
662 | tuple.TupleData = (cisdata_t *)buf; | 649 | tuple.TupleData = (cisdata_t *)buf; |
@@ -666,7 +653,7 @@ static void btuart_config(dev_link_t *link) | |||
666 | 653 | ||
667 | /* Get configuration register information */ | 654 | /* Get configuration register information */ |
668 | tuple.DesiredTuple = CISTPL_CONFIG; | 655 | tuple.DesiredTuple = CISTPL_CONFIG; |
669 | last_ret = first_tuple(handle, &tuple, &parse); | 656 | last_ret = first_tuple(link, &tuple, &parse); |
670 | if (last_ret != CS_SUCCESS) { | 657 | if (last_ret != CS_SUCCESS) { |
671 | last_fn = ParseTuple; | 658 | last_fn = ParseTuple; |
672 | goto cs_failed; | 659 | goto cs_failed; |
@@ -674,11 +661,6 @@ static void btuart_config(dev_link_t *link) | |||
674 | link->conf.ConfigBase = parse.config.base; | 661 | link->conf.ConfigBase = parse.config.base; |
675 | link->conf.Present = parse.config.rmask[0]; | 662 | link->conf.Present = parse.config.rmask[0]; |
676 | 663 | ||
677 | /* Configure card */ | ||
678 | link->state |= DEV_CONFIG; | ||
679 | i = pcmcia_get_configuration_info(handle, &config); | ||
680 | link->conf.Vcc = config.Vcc; | ||
681 | |||
682 | /* First pass: look for a config entry that looks normal. */ | 664 | /* First pass: look for a config entry that looks normal. */ |
683 | tuple.TupleData = (cisdata_t *) buf; | 665 | tuple.TupleData = (cisdata_t *) buf; |
684 | tuple.TupleOffset = 0; | 666 | tuple.TupleOffset = 0; |
@@ -687,29 +669,29 @@ static void btuart_config(dev_link_t *link) | |||
687 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 669 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
688 | /* Two tries: without IO aliases, then with aliases */ | 670 | /* Two tries: without IO aliases, then with aliases */ |
689 | for (try = 0; try < 2; try++) { | 671 | for (try = 0; try < 2; try++) { |
690 | i = first_tuple(handle, &tuple, &parse); | 672 | i = first_tuple(link, &tuple, &parse); |
691 | while (i != CS_NO_MORE_ITEMS) { | 673 | while (i != CS_NO_MORE_ITEMS) { |
692 | if (i != CS_SUCCESS) | 674 | if (i != CS_SUCCESS) |
693 | goto next_entry; | 675 | goto next_entry; |
694 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) | 676 | if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) |
695 | link->conf.Vpp1 = link->conf.Vpp2 = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; | 677 | link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; |
696 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { | 678 | if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { |
697 | link->conf.ConfigIndex = cf->index; | 679 | link->conf.ConfigIndex = cf->index; |
698 | link->io.BasePort1 = cf->io.win[0].base; | 680 | link->io.BasePort1 = cf->io.win[0].base; |
699 | link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; | 681 | link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; |
700 | i = pcmcia_request_io(link->handle, &link->io); | 682 | i = pcmcia_request_io(link, &link->io); |
701 | if (i == CS_SUCCESS) | 683 | if (i == CS_SUCCESS) |
702 | goto found_port; | 684 | goto found_port; |
703 | } | 685 | } |
704 | next_entry: | 686 | next_entry: |
705 | i = next_tuple(handle, &tuple, &parse); | 687 | i = next_tuple(link, &tuple, &parse); |
706 | } | 688 | } |
707 | } | 689 | } |
708 | 690 | ||
709 | /* Second pass: try to find an entry that isn't picky about | 691 | /* Second pass: try to find an entry that isn't picky about |
710 | its base address, then try to grab any standard serial port | 692 | its base address, then try to grab any standard serial port |
711 | address, and finally try to get any free port. */ | 693 | address, and finally try to get any free port. */ |
712 | i = first_tuple(handle, &tuple, &parse); | 694 | i = first_tuple(link, &tuple, &parse); |
713 | while (i != CS_NO_MORE_ITEMS) { | 695 | while (i != CS_NO_MORE_ITEMS) { |
714 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) | 696 | if ((i == CS_SUCCESS) && (cf->io.nwin > 0) |
715 | && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { | 697 | && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { |
@@ -717,30 +699,30 @@ next_entry: | |||
717 | for (j = 0; j < 5; j++) { | 699 | for (j = 0; j < 5; j++) { |
718 | link->io.BasePort1 = base[j]; | 700 | link->io.BasePort1 = base[j]; |
719 | link->io.IOAddrLines = base[j] ? 16 : 3; | 701 | link->io.IOAddrLines = base[j] ? 16 : 3; |
720 | i = pcmcia_request_io(link->handle, &link->io); | 702 | i = pcmcia_request_io(link, &link->io); |
721 | if (i == CS_SUCCESS) | 703 | if (i == CS_SUCCESS) |
722 | goto found_port; | 704 | goto found_port; |
723 | } | 705 | } |
724 | } | 706 | } |
725 | i = next_tuple(handle, &tuple, &parse); | 707 | i = next_tuple(link, &tuple, &parse); |
726 | } | 708 | } |
727 | 709 | ||
728 | found_port: | 710 | found_port: |
729 | if (i != CS_SUCCESS) { | 711 | if (i != CS_SUCCESS) { |
730 | BT_ERR("No usable port range found"); | 712 | BT_ERR("No usable port range found"); |
731 | cs_error(link->handle, RequestIO, i); | 713 | cs_error(link, RequestIO, i); |
732 | goto failed; | 714 | goto failed; |
733 | } | 715 | } |
734 | 716 | ||
735 | i = pcmcia_request_irq(link->handle, &link->irq); | 717 | i = pcmcia_request_irq(link, &link->irq); |
736 | if (i != CS_SUCCESS) { | 718 | if (i != CS_SUCCESS) { |
737 | cs_error(link->handle, RequestIRQ, i); | 719 | cs_error(link, RequestIRQ, i); |
738 | link->irq.AssignedIRQ = 0; | 720 | link->irq.AssignedIRQ = 0; |
739 | } | 721 | } |
740 | 722 | ||
741 | i = pcmcia_request_configuration(link->handle, &link->conf); | 723 | i = pcmcia_request_configuration(link, &link->conf); |
742 | if (i != CS_SUCCESS) { | 724 | if (i != CS_SUCCESS) { |
743 | cs_error(link->handle, RequestConfiguration, i); | 725 | cs_error(link, RequestConfiguration, i); |
744 | goto failed; | 726 | goto failed; |
745 | } | 727 | } |
746 | 728 | ||
@@ -748,58 +730,28 @@ found_port: | |||
748 | goto failed; | 730 | goto failed; |
749 | 731 | ||
750 | strcpy(info->node.dev_name, info->hdev->name); | 732 | strcpy(info->node.dev_name, info->hdev->name); |
751 | link->dev = &info->node; | 733 | link->dev_node = &info->node; |
752 | link->state &= ~DEV_CONFIG_PENDING; | ||
753 | 734 | ||
754 | return; | 735 | return 0; |
755 | 736 | ||
756 | cs_failed: | 737 | cs_failed: |
757 | cs_error(link->handle, last_fn, last_ret); | 738 | cs_error(link, last_fn, last_ret); |
758 | 739 | ||
759 | failed: | 740 | failed: |
760 | btuart_release(link); | 741 | btuart_release(link); |
742 | return -ENODEV; | ||
761 | } | 743 | } |
762 | 744 | ||
763 | 745 | ||
764 | static void btuart_release(dev_link_t *link) | 746 | static void btuart_release(struct pcmcia_device *link) |
765 | { | 747 | { |
766 | btuart_info_t *info = link->priv; | 748 | btuart_info_t *info = link->priv; |
767 | 749 | ||
768 | if (link->state & DEV_PRESENT) | 750 | btuart_close(info); |
769 | btuart_close(info); | ||
770 | |||
771 | link->dev = NULL; | ||
772 | |||
773 | pcmcia_release_configuration(link->handle); | ||
774 | pcmcia_release_io(link->handle, &link->io); | ||
775 | pcmcia_release_irq(link->handle, &link->irq); | ||
776 | |||
777 | link->state &= ~DEV_CONFIG; | ||
778 | } | ||
779 | |||
780 | static int btuart_suspend(struct pcmcia_device *dev) | ||
781 | { | ||
782 | dev_link_t *link = dev_to_instance(dev); | ||
783 | |||
784 | link->state |= DEV_SUSPEND; | ||
785 | if (link->state & DEV_CONFIG) | ||
786 | pcmcia_release_configuration(link->handle); | ||
787 | 751 | ||
788 | return 0; | 752 | pcmcia_disable_device(link); |
789 | } | 753 | } |
790 | 754 | ||
791 | static int btuart_resume(struct pcmcia_device *dev) | ||
792 | { | ||
793 | dev_link_t *link = dev_to_instance(dev); | ||
794 | |||
795 | link->state &= ~DEV_SUSPEND; | ||
796 | if (DEV_OK(link)) | ||
797 | pcmcia_request_configuration(link->handle, &link->conf); | ||
798 | |||
799 | return 0; | ||
800 | } | ||
801 | |||
802 | |||
803 | static struct pcmcia_device_id btuart_ids[] = { | 755 | static struct pcmcia_device_id btuart_ids[] = { |
804 | /* don't use this driver. Use serial_cs + hci_uart instead */ | 756 | /* don't use this driver. Use serial_cs + hci_uart instead */ |
805 | PCMCIA_DEVICE_NULL | 757 | PCMCIA_DEVICE_NULL |
@@ -811,11 +763,9 @@ static struct pcmcia_driver btuart_driver = { | |||
811 | .drv = { | 763 | .drv = { |
812 | .name = "btuart_cs", | 764 | .name = "btuart_cs", |
813 | }, | 765 | }, |
814 | .probe = btuart_attach, | 766 | .probe = btuart_probe, |
815 | .remove = btuart_detach, | 767 | .remove = btuart_detach, |
816 | .id_table = btuart_ids, | 768 | .id_table = btuart_ids, |
817 | .suspend = btuart_suspend, | ||
818 | .resume = btuart_resume, | ||
819 | }; | 769 | }; |
820 | 770 | ||
821 | static int __init init_btuart_cs(void) | 771 | static int __init init_btuart_cs(void) |
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 0449bc45ae5e..a71a240611e0 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -68,7 +68,7 @@ MODULE_LICENSE("GPL"); | |||
68 | 68 | ||
69 | 69 | ||
70 | typedef struct dtl1_info_t { | 70 | typedef struct dtl1_info_t { |
71 | dev_link_t link; | 71 | struct pcmcia_device *p_dev; |
72 | dev_node_t node; | 72 | dev_node_t node; |
73 | 73 | ||
74 | struct hci_dev *hdev; | 74 | struct hci_dev *hdev; |
@@ -87,8 +87,8 @@ typedef struct dtl1_info_t { | |||
87 | } dtl1_info_t; | 87 | } dtl1_info_t; |
88 | 88 | ||
89 | 89 | ||
90 | static void dtl1_config(dev_link_t *link); | 90 | static int dtl1_config(struct pcmcia_device *link); |
91 | static void dtl1_release(dev_link_t *link); | 91 | static void dtl1_release(struct pcmcia_device *link); |
92 | 92 | ||
93 | static void dtl1_detach(struct pcmcia_device *p_dev); | 93 | static void dtl1_detach(struct pcmcia_device *p_dev); |
94 | 94 | ||
@@ -153,13 +153,13 @@ static void dtl1_write_wakeup(dtl1_info_t *info) | |||
153 | } | 153 | } |
154 | 154 | ||
155 | do { | 155 | do { |
156 | register unsigned int iobase = info->link.io.BasePort1; | 156 | register unsigned int iobase = info->p_dev->io.BasePort1; |
157 | register struct sk_buff *skb; | 157 | register struct sk_buff *skb; |
158 | register int len; | 158 | register int len; |
159 | 159 | ||
160 | clear_bit(XMIT_WAKEUP, &(info->tx_state)); | 160 | clear_bit(XMIT_WAKEUP, &(info->tx_state)); |
161 | 161 | ||
162 | if (!(info->link.state & DEV_PRESENT)) | 162 | if (!pcmcia_dev_present(info->p_dev)) |
163 | return; | 163 | return; |
164 | 164 | ||
165 | if (!(skb = skb_dequeue(&(info->txq)))) | 165 | if (!(skb = skb_dequeue(&(info->txq)))) |
@@ -218,7 +218,7 @@ static void dtl1_receive(dtl1_info_t *info) | |||
218 | return; | 218 | return; |
219 | } | 219 | } |
220 | 220 | ||
221 | iobase = info->link.io.BasePort1; | 221 | iobase = info->p_dev->io.BasePort1; |
222 | 222 | ||
223 | do { | 223 | do { |
224 | info->hdev->stat.byte_rx++; | 224 | info->hdev->stat.byte_rx++; |
@@ -305,7 +305,7 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs) | |||
305 | return IRQ_NONE; | 305 | return IRQ_NONE; |
306 | } | 306 | } |
307 | 307 | ||
308 | iobase = info->link.io.BasePort1; | 308 | iobase = info->p_dev->io.BasePort1; |
309 | 309 | ||
310 | spin_lock(&(info->lock)); | 310 | spin_lock(&(info->lock)); |
311 | 311 | ||
@@ -458,7 +458,7 @@ static int dtl1_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long | |||
458 | static int dtl1_open(dtl1_info_t *info) | 458 | static int dtl1_open(dtl1_info_t *info) |
459 | { | 459 | { |
460 | unsigned long flags; | 460 | unsigned long flags; |
461 | unsigned int iobase = info->link.io.BasePort1; | 461 | unsigned int iobase = info->p_dev->io.BasePort1; |
462 | struct hci_dev *hdev; | 462 | struct hci_dev *hdev; |
463 | 463 | ||
464 | spin_lock_init(&(info->lock)); | 464 | spin_lock_init(&(info->lock)); |
@@ -504,7 +504,7 @@ static int dtl1_open(dtl1_info_t *info) | |||
504 | outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */ | 504 | outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */ |
505 | outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR); | 505 | outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR); |
506 | 506 | ||
507 | info->ri_latch = inb(info->link.io.BasePort1 + UART_MSR) & UART_MSR_RI; | 507 | info->ri_latch = inb(info->p_dev->io.BasePort1 + UART_MSR) & UART_MSR_RI; |
508 | 508 | ||
509 | /* Turn on interrupts */ | 509 | /* Turn on interrupts */ |
510 | outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); | 510 | outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); |
@@ -529,7 +529,7 @@ static int dtl1_open(dtl1_info_t *info) | |||
529 | static int dtl1_close(dtl1_info_t *info) | 529 | static int dtl1_close(dtl1_info_t *info) |
530 | { | 530 | { |
531 | unsigned long flags; | 531 | unsigned long flags; |
532 | unsigned int iobase = info->link.io.BasePort1; | 532 | unsigned int iobase = info->p_dev->io.BasePort1; |
533 | struct hci_dev *hdev = info->hdev; | 533 | struct hci_dev *hdev = info->hdev; |
534 | 534 | ||
535 | if (!hdev) | 535 | if (!hdev) |
@@ -555,17 +555,16 @@ static int dtl1_close(dtl1_info_t *info) | |||
555 | return 0; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | static int dtl1_attach(struct pcmcia_device *p_dev) | 558 | static int dtl1_probe(struct pcmcia_device *link) |
559 | { | 559 | { |
560 | dtl1_info_t *info; | 560 | dtl1_info_t *info; |
561 | dev_link_t *link; | ||
562 | 561 | ||
563 | /* Create new info device */ | 562 | /* Create new info device */ |
564 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 563 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
565 | if (!info) | 564 | if (!info) |
566 | return -ENOMEM; | 565 | return -ENOMEM; |
567 | 566 | ||
568 | link = &info->link; | 567 | info->p_dev = link; |
569 | link->priv = info; | 568 | link->priv = info; |
570 | 569 | ||
571 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | 570 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
@@ -577,31 +576,22 @@ static int dtl1_attach(struct pcmcia_device *p_dev) | |||
577 | link->irq.Instance = info; | 576 | link->irq.Instance = info; |
578 | 577 | ||
579 | link->conf.Attributes = CONF_ENABLE_IRQ; | 578 | link->conf.Attributes = CONF_ENABLE_IRQ; |
580 | link->conf.Vcc = 50; | ||
581 | link->conf.IntType = INT_MEMORY_AND_IO; | 579 | link->conf.IntType = INT_MEMORY_AND_IO; |
582 | 580 | ||
583 | link->handle = p_dev; | 581 | return dtl1_config(link); |
584 | p_dev->instance = link; | ||
585 | |||
586 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
587 | dtl1_config(link); | ||
588 | |||
589 | return 0; | ||
590 | } | 582 | } |
591 | 583 | ||
592 | 584 | ||
593 | static void dtl1_detach(struct pcmcia_device *p_dev) | 585 | static void dtl1_detach(struct pcmcia_device *link) |
594 | { | 586 | { |
595 | dev_link_t *link = dev_to_instance(p_dev); | ||
596 | dtl1_info_t *info = link->priv; | 587 | dtl1_info_t *info = link->priv; |
597 | 588 | ||
598 | if (link->state & DEV_CONFIG) | 589 | dtl1_release(link); |
599 | dtl1_release(link); | ||
600 | 590 | ||
601 | kfree(info); | 591 | kfree(info); |
602 | } | 592 | } |
603 | 593 | ||
604 | static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 594 | static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
605 | { | 595 | { |
606 | int i; | 596 | int i; |
607 | 597 | ||
@@ -612,29 +602,27 @@ static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | |||
612 | return pcmcia_parse_tuple(handle, tuple, parse); | 602 | return pcmcia_parse_tuple(handle, tuple, parse); |
613 | } | 603 | } |
614 | 604 | ||
615 | static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 605 | static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
616 | { | 606 | { |
617 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) | 607 | if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) |
618 | return CS_NO_MORE_ITEMS; | 608 | return CS_NO_MORE_ITEMS; |
619 | return get_tuple(handle, tuple, parse); | 609 | return get_tuple(handle, tuple, parse); |
620 | } | 610 | } |
621 | 611 | ||
622 | static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 612 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
623 | { | 613 | { |
624 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) | 614 | if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) |
625 | return CS_NO_MORE_ITEMS; | 615 | return CS_NO_MORE_ITEMS; |
626 | return get_tuple(handle, tuple, parse); | 616 | return get_tuple(handle, tuple, parse); |
627 | } | 617 | } |
628 | 618 | ||
629 | static void dtl1_config(dev_link_t *link) | 619 | static int dtl1_config(struct pcmcia_device *link) |
630 | { | 620 | { |
631 | client_handle_t handle = link->handle; | ||
632 | dtl1_info_t *info = link->priv; | 621 | dtl1_info_t *info = link->priv; |
633 | tuple_t tuple; | 622 | tuple_t tuple; |
634 | u_short buf[256]; | 623 | u_short buf[256]; |
635 | cisparse_t parse; | 624 | cisparse_t parse; |
636 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | 625 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; |
637 | config_info_t config; | ||
638 | int i, last_ret, last_fn; | 626 | int i, last_ret, last_fn; |
639 | 627 | ||
640 | tuple.TupleData = (cisdata_t *)buf; | 628 | tuple.TupleData = (cisdata_t *)buf; |
@@ -644,7 +632,7 @@ static void dtl1_config(dev_link_t *link) | |||
644 | 632 | ||
645 | /* Get configuration register information */ | 633 | /* Get configuration register information */ |
646 | tuple.DesiredTuple = CISTPL_CONFIG; | 634 | tuple.DesiredTuple = CISTPL_CONFIG; |
647 | last_ret = first_tuple(handle, &tuple, &parse); | 635 | last_ret = first_tuple(link, &tuple, &parse); |
648 | if (last_ret != CS_SUCCESS) { | 636 | if (last_ret != CS_SUCCESS) { |
649 | last_fn = ParseTuple; | 637 | last_fn = ParseTuple; |
650 | goto cs_failed; | 638 | goto cs_failed; |
@@ -652,11 +640,6 @@ static void dtl1_config(dev_link_t *link) | |||
652 | link->conf.ConfigBase = parse.config.base; | 640 | link->conf.ConfigBase = parse.config.base; |
653 | link->conf.Present = parse.config.rmask[0]; | 641 | link->conf.Present = parse.config.rmask[0]; |
654 | 642 | ||
655 | /* Configure card */ | ||
656 | link->state |= DEV_CONFIG; | ||
657 | i = pcmcia_get_configuration_info(handle, &config); | ||
658 | link->conf.Vcc = config.Vcc; | ||
659 | |||
660 | tuple.TupleData = (cisdata_t *)buf; | 643 | tuple.TupleData = (cisdata_t *)buf; |
661 | tuple.TupleOffset = 0; | 644 | tuple.TupleOffset = 0; |
662 | tuple.TupleDataMax = 255; | 645 | tuple.TupleDataMax = 255; |
@@ -665,34 +648,34 @@ static void dtl1_config(dev_link_t *link) | |||
665 | 648 | ||
666 | /* Look for a generic full-sized window */ | 649 | /* Look for a generic full-sized window */ |
667 | link->io.NumPorts1 = 8; | 650 | link->io.NumPorts1 = 8; |
668 | i = first_tuple(handle, &tuple, &parse); | 651 | i = first_tuple(link, &tuple, &parse); |
669 | while (i != CS_NO_MORE_ITEMS) { | 652 | while (i != CS_NO_MORE_ITEMS) { |
670 | if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { | 653 | if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { |
671 | link->conf.ConfigIndex = cf->index; | 654 | link->conf.ConfigIndex = cf->index; |
672 | link->io.BasePort1 = cf->io.win[0].base; | 655 | link->io.BasePort1 = cf->io.win[0].base; |
673 | link->io.NumPorts1 = cf->io.win[0].len; /*yo */ | 656 | link->io.NumPorts1 = cf->io.win[0].len; /*yo */ |
674 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | 657 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; |
675 | i = pcmcia_request_io(link->handle, &link->io); | 658 | i = pcmcia_request_io(link, &link->io); |
676 | if (i == CS_SUCCESS) | 659 | if (i == CS_SUCCESS) |
677 | break; | 660 | break; |
678 | } | 661 | } |
679 | i = next_tuple(handle, &tuple, &parse); | 662 | i = next_tuple(link, &tuple, &parse); |
680 | } | 663 | } |
681 | 664 | ||
682 | if (i != CS_SUCCESS) { | 665 | if (i != CS_SUCCESS) { |
683 | cs_error(link->handle, RequestIO, i); | 666 | cs_error(link, RequestIO, i); |
684 | goto failed; | 667 | goto failed; |
685 | } | 668 | } |
686 | 669 | ||
687 | i = pcmcia_request_irq(link->handle, &link->irq); | 670 | i = pcmcia_request_irq(link, &link->irq); |
688 | if (i != CS_SUCCESS) { | 671 | if (i != CS_SUCCESS) { |
689 | cs_error(link->handle, RequestIRQ, i); | 672 | cs_error(link, RequestIRQ, i); |
690 | link->irq.AssignedIRQ = 0; | 673 | link->irq.AssignedIRQ = 0; |
691 | } | 674 | } |
692 | 675 | ||
693 | i = pcmcia_request_configuration(link->handle, &link->conf); | 676 | i = pcmcia_request_configuration(link, &link->conf); |
694 | if (i != CS_SUCCESS) { | 677 | if (i != CS_SUCCESS) { |
695 | cs_error(link->handle, RequestConfiguration, i); | 678 | cs_error(link, RequestConfiguration, i); |
696 | goto failed; | 679 | goto failed; |
697 | } | 680 | } |
698 | 681 | ||
@@ -700,55 +683,26 @@ static void dtl1_config(dev_link_t *link) | |||
700 | goto failed; | 683 | goto failed; |
701 | 684 | ||
702 | strcpy(info->node.dev_name, info->hdev->name); | 685 | strcpy(info->node.dev_name, info->hdev->name); |
703 | link->dev = &info->node; | 686 | link->dev_node = &info->node; |
704 | link->state &= ~DEV_CONFIG_PENDING; | ||
705 | 687 | ||
706 | return; | 688 | return 0; |
707 | 689 | ||
708 | cs_failed: | 690 | cs_failed: |
709 | cs_error(link->handle, last_fn, last_ret); | 691 | cs_error(link, last_fn, last_ret); |
710 | 692 | ||
711 | failed: | 693 | failed: |
712 | dtl1_release(link); | 694 | dtl1_release(link); |
695 | return -ENODEV; | ||
713 | } | 696 | } |
714 | 697 | ||
715 | 698 | ||
716 | static void dtl1_release(dev_link_t *link) | 699 | static void dtl1_release(struct pcmcia_device *link) |
717 | { | 700 | { |
718 | dtl1_info_t *info = link->priv; | 701 | dtl1_info_t *info = link->priv; |
719 | 702 | ||
720 | if (link->state & DEV_PRESENT) | 703 | dtl1_close(info); |
721 | dtl1_close(info); | ||
722 | |||
723 | link->dev = NULL; | ||
724 | |||
725 | pcmcia_release_configuration(link->handle); | ||
726 | pcmcia_release_io(link->handle, &link->io); | ||
727 | pcmcia_release_irq(link->handle, &link->irq); | ||
728 | |||
729 | link->state &= ~DEV_CONFIG; | ||
730 | } | ||
731 | |||
732 | static int dtl1_suspend(struct pcmcia_device *dev) | ||
733 | { | ||
734 | dev_link_t *link = dev_to_instance(dev); | ||
735 | |||
736 | link->state |= DEV_SUSPEND; | ||
737 | if (link->state & DEV_CONFIG) | ||
738 | pcmcia_release_configuration(link->handle); | ||
739 | |||
740 | return 0; | ||
741 | } | ||
742 | |||
743 | static int dtl1_resume(struct pcmcia_device *dev) | ||
744 | { | ||
745 | dev_link_t *link = dev_to_instance(dev); | ||
746 | 704 | ||
747 | link->state &= ~DEV_SUSPEND; | 705 | pcmcia_disable_device(link); |
748 | if (DEV_OK(link)) | ||
749 | pcmcia_request_configuration(link->handle, &link->conf); | ||
750 | |||
751 | return 0; | ||
752 | } | 706 | } |
753 | 707 | ||
754 | 708 | ||
@@ -765,11 +719,9 @@ static struct pcmcia_driver dtl1_driver = { | |||
765 | .drv = { | 719 | .drv = { |
766 | .name = "dtl1_cs", | 720 | .name = "dtl1_cs", |
767 | }, | 721 | }, |
768 | .probe = dtl1_attach, | 722 | .probe = dtl1_probe, |
769 | .remove = dtl1_detach, | 723 | .remove = dtl1_detach, |
770 | .id_table = dtl1_ids, | 724 | .id_table = dtl1_ids, |
771 | .suspend = dtl1_suspend, | ||
772 | .resume = dtl1_resume, | ||
773 | }; | 725 | }; |
774 | 726 | ||
775 | static int __init init_dtl1_cs(void) | 727 | static int __init init_dtl1_cs(void) |