summaryrefslogtreecommitdiff
path: root/drivers/isdn/hisax/config.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-07-17 17:14:23 -0400
committerJeff Garzik <jeff@garzik.org>2007-07-17 17:14:23 -0400
commit881ebdc9f4fb6466a6198ef7943b8637e0a48232 (patch)
tree6de8c9efb81dcbc89112dc0edaf86f4351eb4af1 /drivers/isdn/hisax/config.c
parent82bcda95969dc9852f5cc64001c078ec7d3d95ef (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/isdn/hisax/config.c')
-rw-r--r--drivers/isdn/hisax/config.c72
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)
return ret;
}
-static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
+static int hisax_cs_new(int cardnr, char *id, struct IsdnCard *card,
+ struct IsdnCardState **cs_out, int *busy_flag,
+ struct module *lockowner)
{
- int ret = 0;
- struct IsdnCard *card = cards + cardnr;
struct IsdnCardState *cs;
+ *cs_out = NULL;
+
cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
if (!cs) {
printk(KERN_WARNING
@@ -1098,19 +1100,23 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
cs->iif.readstat = HiSax_readstatus;
register_isdn(&cs->iif);
cs->myid = cs->iif.channels;
- printk(KERN_INFO
- "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
- (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
- (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
- (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
- (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
- "NONE", cs->iif.id, cs->myid);
- ret = hisax_cs_setup_card(card);
- if (!ret) {
- ll_unload(cs);
- goto outf_cs;
- }
+ *cs_out = cs;
+ return 1; /* success */
+
+outf_dlog:
+ kfree(cs->dlog);
+outf_cs:
+ kfree(cs);
+ card->cs = NULL;
+out:
+ return 0; /* error */
+}
+
+static int hisax_cs_setup(int cardnr, struct IsdnCard *card,
+ struct IsdnCardState *cs)
+{
+ int ret;
if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
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
if (!test_bit(HW_ISAR, &cs->HW_Flags))
ll_run(cs, 0);
- ret = 1;
+ return 1;
+
+outf_cs:
+ kfree(cs);
+ card->cs = NULL;
+ return ret;
+}
+
+static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
+{
+ int ret;
+ struct IsdnCard *card = cards + cardnr;
+ struct IsdnCardState *cs;
+
+ ret = hisax_cs_new(cardnr, id, card, &cs, busy_flag, lockowner);
+ if (!ret)
+ return 0;
+
+ printk(KERN_INFO
+ "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
+ (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
+ (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
+ (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
+ (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
+ "NONE", cs->iif.id, cs->myid);
+
+ ret = hisax_cs_setup_card(card);
+ if (!ret) {
+ ll_unload(cs);
+ goto outf_cs;
+ }
+
+ ret = hisax_cs_setup(cardnr, card, cs);
goto out;
- outf_dlog:
- kfree(cs->dlog);
outf_cs:
kfree(cs);
card->cs = NULL;