Commit bc882b18 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

isdn/gigaset: beautify common.c

Rearrange the gigaset_freecs() function to make it more readable,
and adapt gigaset_initcs() accordingly.
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cdc48270
...@@ -467,11 +467,6 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -467,11 +467,6 @@ void gigaset_freecs(struct cardstate *cs)
mutex_lock(&cs->mutex); mutex_lock(&cs->mutex);
if (!cs->bcs)
goto f_cs;
if (!cs->inbuf)
goto f_bcs;
spin_lock_irqsave(&cs->lock, flags); spin_lock_irqsave(&cs->lock, flags);
cs->running = 0; cs->running = 0;
spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are
...@@ -507,17 +502,16 @@ void gigaset_freecs(struct cardstate *cs) ...@@ -507,17 +502,16 @@ void gigaset_freecs(struct cardstate *cs)
gig_dbg(DEBUG_INIT, "clearing at_state"); gig_dbg(DEBUG_INIT, "clearing at_state");
clear_at_state(&cs->at_state); clear_at_state(&cs->at_state);
dealloc_temp_at_states(cs); dealloc_temp_at_states(cs);
clear_events(cs);
tty_port_destroy(&cs->port); tty_port_destroy(&cs->port);
/* fall through */ /* fall through */
case 0: /* error in basic setup */ case 0: /* error in basic setup */
clear_events(cs);
gig_dbg(DEBUG_INIT, "freeing inbuf"); gig_dbg(DEBUG_INIT, "freeing inbuf");
kfree(cs->inbuf); kfree(cs->inbuf);
}
f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]");
kfree(cs->bcs); kfree(cs->bcs);
f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); }
mutex_unlock(&cs->mutex); mutex_unlock(&cs->mutex);
free_cs(cs); free_cs(cs);
} }
...@@ -687,19 +681,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -687,19 +681,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
return NULL; return NULL;
} }
gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1);
cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
if (!cs->bcs) {
pr_err("out of memory\n");
goto error;
}
gig_dbg(DEBUG_INIT, "allocating inbuf");
cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
if (!cs->inbuf) {
pr_err("out of memory\n");
goto error;
}
cs->cs_init = 0; cs->cs_init = 0;
cs->channels = channels; cs->channels = channels;
cs->onechannel = onechannel; cs->onechannel = onechannel;
...@@ -729,6 +710,12 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, ...@@ -729,6 +710,12 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
cs->mode = M_UNKNOWN; cs->mode = M_UNKNOWN;
cs->mstate = MS_UNINITIALIZED; cs->mstate = MS_UNINITIALIZED;
cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
if (!cs->bcs || !cs->inbuf) {
pr_err("out of memory\n");
goto error;
}
++cs->cs_init; ++cs->cs_init;
gig_dbg(DEBUG_INIT, "setting up at_state"); gig_dbg(DEBUG_INIT, "setting up at_state");
......
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