diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-07-17 17:14:23 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-17 17:14:23 -0400 |
commit | 881ebdc9f4fb6466a6198ef7943b8637e0a48232 (patch) | |
tree | 6de8c9efb81dcbc89112dc0edaf86f4351eb4af1 /drivers | |
parent | 82bcda95969dc9852f5cc64001c078ec7d3d95ef (diff) |
[ISDN] HiSax: move card state alloc/setup code into separate functions
Just code movement. No code changes or cleanups besides that which
is required to call the new functions from the old code site.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/isdn/hisax/config.c | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index 6bc49e6b61be..5f7907e57090 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c | |||
@@ -1016,12 +1016,14 @@ static int hisax_cs_setup_card(struct IsdnCard *card) | |||
1016 | return ret; | 1016 | return ret; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner) | 1019 | static int hisax_cs_new(int cardnr, char *id, struct IsdnCard *card, |
1020 | struct IsdnCardState **cs_out, int *busy_flag, | ||
1021 | struct module *lockowner) | ||
1020 | { | 1022 | { |
1021 | int ret = 0; | ||
1022 | struct IsdnCard *card = cards + cardnr; | ||
1023 | struct IsdnCardState *cs; | 1023 | struct IsdnCardState *cs; |
1024 | 1024 | ||
1025 | *cs_out = NULL; | ||
1026 | |||
1025 | cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC); | 1027 | cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC); |
1026 | if (!cs) { | 1028 | if (!cs) { |
1027 | printk(KERN_WARNING | 1029 | printk(KERN_WARNING |
@@ -1098,19 +1100,23 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow | |||
1098 | cs->iif.readstat = HiSax_readstatus; | 1100 | cs->iif.readstat = HiSax_readstatus; |
1099 | register_isdn(&cs->iif); | 1101 | register_isdn(&cs->iif); |
1100 | cs->myid = cs->iif.channels; | 1102 | 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 | 1103 | ||
1109 | ret = hisax_cs_setup_card(card); | 1104 | *cs_out = cs; |
1110 | if (!ret) { | 1105 | return 1; /* success */ |
1111 | ll_unload(cs); | 1106 | |
1112 | goto outf_cs; | 1107 | outf_dlog: |
1113 | } | 1108 | kfree(cs->dlog); |
1109 | outf_cs: | ||
1110 | kfree(cs); | ||
1111 | card->cs = NULL; | ||
1112 | out: | ||
1113 | return 0; /* error */ | ||
1114 | } | ||
1115 | |||
1116 | static int hisax_cs_setup(int cardnr, struct IsdnCard *card, | ||
1117 | struct IsdnCardState *cs) | ||
1118 | { | ||
1119 | int ret; | ||
1114 | 1120 | ||
1115 | if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) { | 1121 | if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) { |
1116 | printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n"); | 1122 | printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n"); |
@@ -1154,11 +1160,41 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow | |||
1154 | if (!test_bit(HW_ISAR, &cs->HW_Flags)) | 1160 | if (!test_bit(HW_ISAR, &cs->HW_Flags)) |
1155 | ll_run(cs, 0); | 1161 | ll_run(cs, 0); |
1156 | 1162 | ||
1157 | ret = 1; | 1163 | return 1; |
1164 | |||
1165 | outf_cs: | ||
1166 | kfree(cs); | ||
1167 | card->cs = NULL; | ||
1168 | return ret; | ||
1169 | } | ||
1170 | |||
1171 | static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner) | ||
1172 | { | ||
1173 | int ret; | ||
1174 | struct IsdnCard *card = cards + cardnr; | ||
1175 | struct IsdnCardState *cs; | ||
1176 | |||
1177 | ret = hisax_cs_new(cardnr, id, card, &cs, busy_flag, lockowner); | ||
1178 | if (!ret) | ||
1179 | return 0; | ||
1180 | |||
1181 | printk(KERN_INFO | ||
1182 | "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1, | ||
1183 | (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" : | ||
1184 | (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" : | ||
1185 | (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" : | ||
1186 | (card->protocol == ISDN_PTYPE_NI1) ? "NI1" : | ||
1187 | "NONE", cs->iif.id, cs->myid); | ||
1188 | |||
1189 | ret = hisax_cs_setup_card(card); | ||
1190 | if (!ret) { | ||
1191 | ll_unload(cs); | ||
1192 | goto outf_cs; | ||
1193 | } | ||
1194 | |||
1195 | ret = hisax_cs_setup(cardnr, card, cs); | ||
1158 | goto out; | 1196 | goto out; |
1159 | 1197 | ||
1160 | outf_dlog: | ||
1161 | kfree(cs->dlog); | ||
1162 | outf_cs: | 1198 | outf_cs: |
1163 | kfree(cs); | 1199 | kfree(cs); |
1164 | card->cs = NULL; | 1200 | card->cs = NULL; |