Commit 881ebdc9 authored by Jeff Garzik's avatar Jeff Garzik

[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: default avatarJeff Garzik <jeff@garzik.org>
parent 82bcda95
...@@ -1016,12 +1016,14 @@ static int hisax_cs_setup_card(struct IsdnCard *card) ...@@ -1016,12 +1016,14 @@ static int hisax_cs_setup_card(struct IsdnCard *card)
return ret; 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; struct IsdnCardState *cs;
*cs_out = NULL;
cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC); cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
if (!cs) { if (!cs) {
printk(KERN_WARNING printk(KERN_WARNING
...@@ -1098,19 +1100,23 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow ...@@ -1098,19 +1100,23 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
cs->iif.readstat = HiSax_readstatus; cs->iif.readstat = HiSax_readstatus;
register_isdn(&cs->iif); register_isdn(&cs->iif);
cs->myid = cs->iif.channels; 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); *cs_out = cs;
if (!ret) { return 1; /* success */
ll_unload(cs);
goto outf_cs; 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))) { if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n"); 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,11 +1160,41 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
if (!test_bit(HW_ISAR, &cs->HW_Flags)) if (!test_bit(HW_ISAR, &cs->HW_Flags))
ll_run(cs, 0); 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; goto out;
outf_dlog:
kfree(cs->dlog);
outf_cs: outf_cs:
kfree(cs); kfree(cs);
card->cs = NULL; card->cs = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment