diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-07-14 21:58:34 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-17 17:00:32 -0400 |
commit | 82bcda95969dc9852f5cc64001c078ec7d3d95ef (patch) | |
tree | ff0e1fb239f4b342643a95b6ff5c56f12b95d162 /drivers/isdn/hisax/config.c | |
parent | 49c13b51a15f1ba9f6d47e26e4a3886c4f3931e2 (diff) |
[ISDN] HiSax: move card setup into separate function
No behavior changes, just code movement.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/isdn/hisax/config.c')
-rw-r--r-- | drivers/isdn/hisax/config.c | 187 |
1 files changed, 99 insertions, 88 deletions
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index a43162c2ef15..6bc49e6b61be 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c | |||
@@ -847,95 +847,10 @@ static int init_card(struct IsdnCardState *cs) | |||
847 | return 3; | 847 | return 3; |
848 | } | 848 | } |
849 | 849 | ||
850 | static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner) | 850 | static int hisax_cs_setup_card(struct IsdnCard *card) |
851 | { | 851 | { |
852 | int ret = 0; | 852 | int ret; |
853 | struct IsdnCard *card = cards + cardnr; | ||
854 | struct IsdnCardState *cs; | ||
855 | |||
856 | cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC); | ||
857 | if (!cs) { | ||
858 | printk(KERN_WARNING | ||
859 | "HiSax: No memory for IsdnCardState(card %d)\n", | ||
860 | cardnr + 1); | ||
861 | goto out; | ||
862 | } | ||
863 | card->cs = cs; | ||
864 | spin_lock_init(&cs->statlock); | ||
865 | spin_lock_init(&cs->lock); | ||
866 | cs->chanlimit = 2; /* maximum B-channel number */ | ||
867 | cs->logecho = 0; /* No echo logging */ | ||
868 | cs->cardnr = cardnr; | ||
869 | cs->debug = L1_DEB_WARN; | ||
870 | cs->HW_Flags = 0; | ||
871 | cs->busy_flag = busy_flag; | ||
872 | cs->irq_flags = I4L_IRQ_FLAG; | ||
873 | #if TEI_PER_CARD | ||
874 | if (card->protocol == ISDN_PTYPE_NI1) | ||
875 | test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags); | ||
876 | #else | ||
877 | test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags); | ||
878 | #endif | ||
879 | cs->protocol = card->protocol; | ||
880 | |||
881 | if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) { | ||
882 | printk(KERN_WARNING | ||
883 | "HiSax: Card Type %d out of range\n", card->typ); | ||
884 | goto outf_cs; | ||
885 | } | ||
886 | if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) { | ||
887 | printk(KERN_WARNING | ||
888 | "HiSax: No memory for dlog(card %d)\n", cardnr + 1); | ||
889 | goto outf_cs; | ||
890 | } | ||
891 | if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) { | ||
892 | printk(KERN_WARNING | ||
893 | "HiSax: No memory for status_buf(card %d)\n", | ||
894 | cardnr + 1); | ||
895 | goto outf_dlog; | ||
896 | } | ||
897 | cs->stlist = NULL; | ||
898 | cs->status_read = cs->status_buf; | ||
899 | cs->status_write = cs->status_buf; | ||
900 | cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1; | ||
901 | cs->typ = card->typ; | ||
902 | #ifdef MODULE | ||
903 | cs->iif.owner = lockowner; | ||
904 | #endif | ||
905 | strcpy(cs->iif.id, id); | ||
906 | cs->iif.channels = 2; | ||
907 | cs->iif.maxbufsize = MAX_DATA_SIZE; | ||
908 | cs->iif.hl_hdrlen = MAX_HEADER_LEN; | ||
909 | cs->iif.features = | ||
910 | ISDN_FEATURE_L2_X75I | | ||
911 | ISDN_FEATURE_L2_HDLC | | ||
912 | ISDN_FEATURE_L2_HDLC_56K | | ||
913 | ISDN_FEATURE_L2_TRANS | | ||
914 | ISDN_FEATURE_L3_TRANS | | ||
915 | #ifdef CONFIG_HISAX_1TR6 | ||
916 | ISDN_FEATURE_P_1TR6 | | ||
917 | #endif | ||
918 | #ifdef CONFIG_HISAX_EURO | ||
919 | ISDN_FEATURE_P_EURO | | ||
920 | #endif | ||
921 | #ifdef CONFIG_HISAX_NI1 | ||
922 | ISDN_FEATURE_P_NI1 | | ||
923 | #endif | ||
924 | 0; | ||
925 | 853 | ||
926 | cs->iif.command = HiSax_command; | ||
927 | cs->iif.writecmd = NULL; | ||
928 | cs->iif.writebuf_skb = HiSax_writebuf_skb; | ||
929 | cs->iif.readstat = HiSax_readstatus; | ||
930 | register_isdn(&cs->iif); | ||
931 | cs->myid = cs->iif.channels; | ||
932 | printk(KERN_INFO | ||
933 | "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1, | ||
934 | (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" : | ||
935 | (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" : | ||
936 | (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" : | ||
937 | (card->protocol == ISDN_PTYPE_NI1) ? "NI1" : | ||
938 | "NONE", cs->iif.id, cs->myid); | ||
939 | switch (card->typ) { | 854 | switch (card->typ) { |
940 | #if CARD_TELES0 | 855 | #if CARD_TELES0 |
941 | case ISDN_CTYPE_16_0: | 856 | case ISDN_CTYPE_16_0: |
@@ -1094,13 +1009,109 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow | |||
1094 | printk(KERN_WARNING | 1009 | printk(KERN_WARNING |
1095 | "HiSax: Support for %s Card not selected\n", | 1010 | "HiSax: Support for %s Card not selected\n", |
1096 | CardType[card->typ]); | 1011 | CardType[card->typ]); |
1097 | ll_unload(cs); | 1012 | ret = 0; |
1013 | break; | ||
1014 | } | ||
1015 | |||
1016 | return ret; | ||
1017 | } | ||
1018 | |||
1019 | static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner) | ||
1020 | { | ||
1021 | int ret = 0; | ||
1022 | struct IsdnCard *card = cards + cardnr; | ||
1023 | struct IsdnCardState *cs; | ||
1024 | |||
1025 | cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC); | ||
1026 | if (!cs) { | ||
1027 | printk(KERN_WARNING | ||
1028 | "HiSax: No memory for IsdnCardState(card %d)\n", | ||
1029 | cardnr + 1); | ||
1030 | goto out; | ||
1031 | } | ||
1032 | card->cs = cs; | ||
1033 | spin_lock_init(&cs->statlock); | ||
1034 | spin_lock_init(&cs->lock); | ||
1035 | cs->chanlimit = 2; /* maximum B-channel number */ | ||
1036 | cs->logecho = 0; /* No echo logging */ | ||
1037 | cs->cardnr = cardnr; | ||
1038 | cs->debug = L1_DEB_WARN; | ||
1039 | cs->HW_Flags = 0; | ||
1040 | cs->busy_flag = busy_flag; | ||
1041 | cs->irq_flags = I4L_IRQ_FLAG; | ||
1042 | #if TEI_PER_CARD | ||
1043 | if (card->protocol == ISDN_PTYPE_NI1) | ||
1044 | test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags); | ||
1045 | #else | ||
1046 | test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags); | ||
1047 | #endif | ||
1048 | cs->protocol = card->protocol; | ||
1049 | |||
1050 | if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) { | ||
1051 | printk(KERN_WARNING | ||
1052 | "HiSax: Card Type %d out of range\n", card->typ); | ||
1098 | goto outf_cs; | 1053 | goto outf_cs; |
1099 | } | 1054 | } |
1055 | if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) { | ||
1056 | printk(KERN_WARNING | ||
1057 | "HiSax: No memory for dlog(card %d)\n", cardnr + 1); | ||
1058 | goto outf_cs; | ||
1059 | } | ||
1060 | if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) { | ||
1061 | printk(KERN_WARNING | ||
1062 | "HiSax: No memory for status_buf(card %d)\n", | ||
1063 | cardnr + 1); | ||
1064 | goto outf_dlog; | ||
1065 | } | ||
1066 | cs->stlist = NULL; | ||
1067 | cs->status_read = cs->status_buf; | ||
1068 | cs->status_write = cs->status_buf; | ||
1069 | cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1; | ||
1070 | cs->typ = card->typ; | ||
1071 | #ifdef MODULE | ||
1072 | cs->iif.owner = lockowner; | ||
1073 | #endif | ||
1074 | strcpy(cs->iif.id, id); | ||
1075 | cs->iif.channels = 2; | ||
1076 | cs->iif.maxbufsize = MAX_DATA_SIZE; | ||
1077 | cs->iif.hl_hdrlen = MAX_HEADER_LEN; | ||
1078 | cs->iif.features = | ||
1079 | ISDN_FEATURE_L2_X75I | | ||
1080 | ISDN_FEATURE_L2_HDLC | | ||
1081 | ISDN_FEATURE_L2_HDLC_56K | | ||
1082 | ISDN_FEATURE_L2_TRANS | | ||
1083 | ISDN_FEATURE_L3_TRANS | | ||
1084 | #ifdef CONFIG_HISAX_1TR6 | ||
1085 | ISDN_FEATURE_P_1TR6 | | ||
1086 | #endif | ||
1087 | #ifdef CONFIG_HISAX_EURO | ||
1088 | ISDN_FEATURE_P_EURO | | ||
1089 | #endif | ||
1090 | #ifdef CONFIG_HISAX_NI1 | ||
1091 | ISDN_FEATURE_P_NI1 | | ||
1092 | #endif | ||
1093 | 0; | ||
1094 | |||
1095 | cs->iif.command = HiSax_command; | ||
1096 | cs->iif.writecmd = NULL; | ||
1097 | cs->iif.writebuf_skb = HiSax_writebuf_skb; | ||
1098 | cs->iif.readstat = HiSax_readstatus; | ||
1099 | register_isdn(&cs->iif); | ||
1100 | cs->myid = cs->iif.channels; | ||
1101 | printk(KERN_INFO | ||
1102 | "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1, | ||
1103 | (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" : | ||
1104 | (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" : | ||
1105 | (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" : | ||
1106 | (card->protocol == ISDN_PTYPE_NI1) ? "NI1" : | ||
1107 | "NONE", cs->iif.id, cs->myid); | ||
1108 | |||
1109 | ret = hisax_cs_setup_card(card); | ||
1100 | if (!ret) { | 1110 | if (!ret) { |
1101 | ll_unload(cs); | 1111 | ll_unload(cs); |
1102 | goto outf_cs; | 1112 | goto outf_cs; |
1103 | } | 1113 | } |
1114 | |||
1104 | if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) { | 1115 | if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) { |
1105 | printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n"); | 1116 | printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n"); |
1106 | ll_unload(cs); | 1117 | ll_unload(cs); |