diff options
Diffstat (limited to 'drivers/bluetooth/bluecard_cs.c')
-rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 119 |
1 files changed, 35 insertions, 84 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) |