diff options
author | Tilman Schmidt <tilman@imap.cc> | 2013-01-21 06:57:21 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-21 17:36:25 -0500 |
commit | bc882b1880b94d3731b462d3a213885073b350ed (patch) | |
tree | 2f01a928952b27b672bb9dd1768289b184762f47 /drivers/isdn/gigaset | |
parent | cdc4827098d128423297720dcf33792d85079b78 (diff) |
isdn/gigaset: beautify common.c
Rearrange the gigaset_freecs() function to make it more readable,
and adapt gigaset_initcs() accordingly.
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset')
-rw-r--r-- | drivers/isdn/gigaset/common.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 6849a11a1b24..7c7814497e3e 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -467,11 +467,6 @@ void gigaset_freecs(struct cardstate *cs) | |||
467 | 467 | ||
468 | mutex_lock(&cs->mutex); | 468 | mutex_lock(&cs->mutex); |
469 | 469 | ||
470 | if (!cs->bcs) | ||
471 | goto f_cs; | ||
472 | if (!cs->inbuf) | ||
473 | goto f_bcs; | ||
474 | |||
475 | spin_lock_irqsave(&cs->lock, flags); | 470 | spin_lock_irqsave(&cs->lock, flags); |
476 | cs->running = 0; | 471 | cs->running = 0; |
477 | spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are | 472 | spin_unlock_irqrestore(&cs->lock, flags); /* event handler and timer are |
@@ -507,17 +502,16 @@ void gigaset_freecs(struct cardstate *cs) | |||
507 | gig_dbg(DEBUG_INIT, "clearing at_state"); | 502 | gig_dbg(DEBUG_INIT, "clearing at_state"); |
508 | clear_at_state(&cs->at_state); | 503 | clear_at_state(&cs->at_state); |
509 | dealloc_temp_at_states(cs); | 504 | dealloc_temp_at_states(cs); |
505 | clear_events(cs); | ||
510 | tty_port_destroy(&cs->port); | 506 | tty_port_destroy(&cs->port); |
511 | 507 | ||
512 | /* fall through */ | 508 | /* fall through */ |
513 | case 0: /* error in basic setup */ | 509 | case 0: /* error in basic setup */ |
514 | clear_events(cs); | ||
515 | gig_dbg(DEBUG_INIT, "freeing inbuf"); | 510 | gig_dbg(DEBUG_INIT, "freeing inbuf"); |
516 | kfree(cs->inbuf); | 511 | kfree(cs->inbuf); |
512 | kfree(cs->bcs); | ||
517 | } | 513 | } |
518 | f_bcs: gig_dbg(DEBUG_INIT, "freeing bcs[]"); | 514 | |
519 | kfree(cs->bcs); | ||
520 | f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); | ||
521 | mutex_unlock(&cs->mutex); | 515 | mutex_unlock(&cs->mutex); |
522 | free_cs(cs); | 516 | free_cs(cs); |
523 | } | 517 | } |
@@ -687,19 +681,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
687 | return NULL; | 681 | return NULL; |
688 | } | 682 | } |
689 | 683 | ||
690 | gig_dbg(DEBUG_INIT, "allocating bcs[0..%d]", channels - 1); | ||
691 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); | ||
692 | if (!cs->bcs) { | ||
693 | pr_err("out of memory\n"); | ||
694 | goto error; | ||
695 | } | ||
696 | gig_dbg(DEBUG_INIT, "allocating inbuf"); | ||
697 | cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); | ||
698 | if (!cs->inbuf) { | ||
699 | pr_err("out of memory\n"); | ||
700 | goto error; | ||
701 | } | ||
702 | |||
703 | cs->cs_init = 0; | 684 | cs->cs_init = 0; |
704 | cs->channels = channels; | 685 | cs->channels = channels; |
705 | cs->onechannel = onechannel; | 686 | cs->onechannel = onechannel; |
@@ -729,6 +710,12 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
729 | cs->mode = M_UNKNOWN; | 710 | cs->mode = M_UNKNOWN; |
730 | cs->mstate = MS_UNINITIALIZED; | 711 | cs->mstate = MS_UNINITIALIZED; |
731 | 712 | ||
713 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); | ||
714 | cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); | ||
715 | if (!cs->bcs || !cs->inbuf) { | ||
716 | pr_err("out of memory\n"); | ||
717 | goto error; | ||
718 | } | ||
732 | ++cs->cs_init; | 719 | ++cs->cs_init; |
733 | 720 | ||
734 | gig_dbg(DEBUG_INIT, "setting up at_state"); | 721 | gig_dbg(DEBUG_INIT, "setting up at_state"); |