diff options
author | Tilman Schmidt <tilman@imap.cc> | 2009-10-06 08:19:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-07 01:43:50 -0400 |
commit | 088ec0cc96e2befd5f3c035123f95c17bdf26e64 (patch) | |
tree | 4d0fdcc26e6bfd9ee320cf716f56a695e38be8ae /drivers/isdn/gigaset/common.c | |
parent | 7ecc59c1b7fd5749667fc31f8683099cbef38977 (diff) |
gigaset: prepare for CAPI implementation
Reorganize the code of the Gigaset driver, moving all isdn4linux
dependencies to the source file i4l.c so that it can be replaced
by a file capi.c interfacing to Kernel CAPI instead.
Impact: refactoring, no functional change
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r-- | drivers/isdn/gigaset/common.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 33dcd8d72b7c..15dc0fc28a96 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -463,6 +463,12 @@ void gigaset_freecs(struct cardstate *cs) | |||
463 | 463 | ||
464 | switch (cs->cs_init) { | 464 | switch (cs->cs_init) { |
465 | default: | 465 | default: |
466 | /* clear B channel structures */ | ||
467 | for (i = 0; i < cs->channels; ++i) { | ||
468 | gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i); | ||
469 | gigaset_freebcs(cs->bcs + i); | ||
470 | } | ||
471 | |||
466 | /* clear device sysfs */ | 472 | /* clear device sysfs */ |
467 | gigaset_free_dev_sysfs(cs); | 473 | gigaset_free_dev_sysfs(cs); |
468 | 474 | ||
@@ -477,22 +483,16 @@ void gigaset_freecs(struct cardstate *cs) | |||
477 | case 2: /* error in initcshw */ | 483 | case 2: /* error in initcshw */ |
478 | /* Deregister from LL */ | 484 | /* Deregister from LL */ |
479 | make_invalid(cs, VALID_ID); | 485 | make_invalid(cs, VALID_ID); |
480 | gig_dbg(DEBUG_INIT, "clearing iif"); | 486 | gigaset_isdn_unregister(cs); |
481 | gigaset_i4l_cmd(cs, ISDN_STAT_UNLOAD); | ||
482 | 487 | ||
483 | /* fall through */ | 488 | /* fall through */ |
484 | case 1: /* error when regestering to LL */ | 489 | case 1: /* error when registering to LL */ |
485 | gig_dbg(DEBUG_INIT, "clearing at_state"); | 490 | gig_dbg(DEBUG_INIT, "clearing at_state"); |
486 | clear_at_state(&cs->at_state); | 491 | clear_at_state(&cs->at_state); |
487 | dealloc_at_states(cs); | 492 | dealloc_at_states(cs); |
488 | 493 | ||
489 | /* fall through */ | 494 | /* fall through */ |
490 | case 0: /* error in one call to initbcs */ | 495 | case 0: /* error in basic setup */ |
491 | for (i = 0; i < cs->channels; ++i) { | ||
492 | gig_dbg(DEBUG_INIT, "clearing bcs[%d]", i); | ||
493 | gigaset_freebcs(cs->bcs + i); | ||
494 | } | ||
495 | |||
496 | clear_events(cs); | 496 | clear_events(cs); |
497 | gig_dbg(DEBUG_INIT, "freeing inbuf"); | 497 | gig_dbg(DEBUG_INIT, "freeing inbuf"); |
498 | kfree(cs->inbuf); | 498 | kfree(cs->inbuf); |
@@ -620,11 +620,14 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs, | |||
620 | if (cs->ignoreframes) { | 620 | if (cs->ignoreframes) { |
621 | bcs->inputstate |= INS_skip_frame; | 621 | bcs->inputstate |= INS_skip_frame; |
622 | bcs->skb = NULL; | 622 | bcs->skb = NULL; |
623 | } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) | 623 | } else { |
624 | skb_reserve(bcs->skb, HW_HDR_LEN); | 624 | bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); |
625 | else { | 625 | if (bcs->skb != NULL) |
626 | pr_err("out of memory\n"); | 626 | skb_reserve(bcs->skb, cs->hw_hdr_len); |
627 | bcs->inputstate |= INS_skip_frame; | 627 | else { |
628 | pr_err("out of memory\n"); | ||
629 | bcs->inputstate |= INS_skip_frame; | ||
630 | } | ||
628 | } | 631 | } |
629 | 632 | ||
630 | bcs->channel = channel; | 633 | bcs->channel = channel; |
@@ -726,14 +729,6 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
726 | cs->mode = M_UNKNOWN; | 729 | cs->mode = M_UNKNOWN; |
727 | cs->mstate = MS_UNINITIALIZED; | 730 | cs->mstate = MS_UNINITIALIZED; |
728 | 731 | ||
729 | for (i = 0; i < channels; ++i) { | ||
730 | gig_dbg(DEBUG_INIT, "setting up bcs[%d].read", i); | ||
731 | if (!gigaset_initbcs(cs->bcs + i, cs, i)) { | ||
732 | pr_err("could not allocate channel %d data\n", i); | ||
733 | goto error; | ||
734 | } | ||
735 | } | ||
736 | |||
737 | ++cs->cs_init; | 732 | ++cs->cs_init; |
738 | 733 | ||
739 | gig_dbg(DEBUG_INIT, "setting up at_state"); | 734 | gig_dbg(DEBUG_INIT, "setting up at_state"); |
@@ -758,7 +753,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
758 | cs->cmdbytes = 0; | 753 | cs->cmdbytes = 0; |
759 | 754 | ||
760 | gig_dbg(DEBUG_INIT, "setting up iif"); | 755 | gig_dbg(DEBUG_INIT, "setting up iif"); |
761 | if (!gigaset_register_to_LL(cs, modulename)) { | 756 | if (!gigaset_isdn_register(cs, modulename)) { |
762 | pr_err("error registering ISDN device\n"); | 757 | pr_err("error registering ISDN device\n"); |
763 | goto error; | 758 | goto error; |
764 | } | 759 | } |
@@ -777,6 +772,15 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
777 | /* set up device sysfs */ | 772 | /* set up device sysfs */ |
778 | gigaset_init_dev_sysfs(cs); | 773 | gigaset_init_dev_sysfs(cs); |
779 | 774 | ||
775 | /* set up channel data structures */ | ||
776 | for (i = 0; i < channels; ++i) { | ||
777 | gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); | ||
778 | if (!gigaset_initbcs(cs->bcs + i, cs, i)) { | ||
779 | pr_err("could not allocate channel %d data\n", i); | ||
780 | goto error; | ||
781 | } | ||
782 | } | ||
783 | |||
780 | spin_lock_irqsave(&cs->lock, flags); | 784 | spin_lock_irqsave(&cs->lock, flags); |
781 | cs->running = 1; | 785 | cs->running = 1; |
782 | spin_unlock_irqrestore(&cs->lock, flags); | 786 | spin_unlock_irqrestore(&cs->lock, flags); |