aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2009-10-25 05:30:07 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-29 04:37:10 -0400
commit2032e2c2309de02cd67b1d26aa701c2a57c4639f (patch)
treeee0f953f4afb7d98e3e27a32310d92bf0765b00b /drivers/isdn/gigaset/common.c
parent4dd8230acd20cb456cae02696b3da2986faad258 (diff)
usb_gigaset: code cleanup
Reorganize the code of the Gigaset M10x driver to make it more readable, less redundant, better aligned to the style of other parts of the driver, and cause fewer checkpatch.pl complaints. Impact: code reorganization, 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.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 1d2ae2e05e0b..690ac74c82a8 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -400,9 +400,9 @@ static void gigaset_freebcs(struct bc_state *bcs)
400 gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel); 400 gig_dbg(DEBUG_INIT, "clearing bcs[%d]->at_state", bcs->channel);
401 clear_at_state(&bcs->at_state); 401 clear_at_state(&bcs->at_state);
402 gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel); 402 gig_dbg(DEBUG_INIT, "freeing bcs[%d]->skb", bcs->channel);
403 dev_kfree_skb(bcs->skb);
404 bcs->skb = NULL;
403 405
404 if (bcs->skb)
405 dev_kfree_skb(bcs->skb);
406 for (i = 0; i < AT_NUM; ++i) { 406 for (i = 0; i < AT_NUM; ++i) {
407 kfree(bcs->commands[i]); 407 kfree(bcs->commands[i]);
408 bcs->commands[i] = NULL; 408 bcs->commands[i] = NULL;
@@ -560,16 +560,13 @@ void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
560} 560}
561 561
562 562
563static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct bc_state *bcs, 563static void gigaset_inbuf_init(struct inbuf_t *inbuf, struct cardstate *cs)
564 struct cardstate *cs, int inputstate)
565/* inbuf->read must be allocated before! */ 564/* inbuf->read must be allocated before! */
566{ 565{
567 inbuf->head = 0; 566 inbuf->head = 0;
568 inbuf->tail = 0; 567 inbuf->tail = 0;
569 inbuf->cs = cs; 568 inbuf->cs = cs;
570 inbuf->bcs = bcs; /*base driver: NULL*/ 569 inbuf->inputstate = INS_command;
571 inbuf->rcvbuf = NULL;
572 inbuf->inputstate = inputstate;
573} 570}
574 571
575/** 572/**
@@ -644,16 +641,13 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
644 bcs->fcs = PPP_INITFCS; 641 bcs->fcs = PPP_INITFCS;
645 bcs->inputstate = 0; 642 bcs->inputstate = 0;
646 if (cs->ignoreframes) { 643 if (cs->ignoreframes) {
647 bcs->inputstate |= INS_skip_frame;
648 bcs->skb = NULL; 644 bcs->skb = NULL;
649 } else { 645 } else {
650 bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len); 646 bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
651 if (bcs->skb != NULL) 647 if (bcs->skb != NULL)
652 skb_reserve(bcs->skb, cs->hw_hdr_len); 648 skb_reserve(bcs->skb, cs->hw_hdr_len);
653 else { 649 else
654 pr_err("out of memory\n"); 650 pr_err("out of memory\n");
655 bcs->inputstate |= INS_skip_frame;
656 }
657 } 651 }
658 652
659 bcs->channel = channel; 653 bcs->channel = channel;
@@ -674,8 +668,8 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
674 gig_dbg(DEBUG_INIT, " failed"); 668 gig_dbg(DEBUG_INIT, " failed");
675 669
676 gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel); 670 gig_dbg(DEBUG_INIT, " freeing bcs[%d]->skb", channel);
677 if (bcs->skb) 671 dev_kfree_skb(bcs->skb);
678 dev_kfree_skb(bcs->skb); 672 bcs->skb = NULL;
679 673
680 return NULL; 674 return NULL;
681} 675}
@@ -764,10 +758,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
764 cs->cbytes = 0; 758 cs->cbytes = 0;
765 759
766 gig_dbg(DEBUG_INIT, "setting up inbuf"); 760 gig_dbg(DEBUG_INIT, "setting up inbuf");
767 if (onechannel) { //FIXME distinction necessary? 761 gigaset_inbuf_init(cs->inbuf, cs);
768 gigaset_inbuf_init(cs->inbuf, cs->bcs, cs, INS_command);
769 } else
770 gigaset_inbuf_init(cs->inbuf, NULL, cs, INS_command);
771 762
772 cs->connected = 0; 763 cs->connected = 0;
773 cs->isdn_up = 0; 764 cs->isdn_up = 0;
@@ -854,9 +845,10 @@ void gigaset_bcs_reinit(struct bc_state *bcs)
854 bcs->chstate = 0; 845 bcs->chstate = 0;
855 846
856 bcs->ignore = cs->ignoreframes; 847 bcs->ignore = cs->ignoreframes;
857 if (bcs->ignore) 848 if (bcs->ignore) {
858 bcs->inputstate |= INS_skip_frame; 849 dev_kfree_skb(bcs->skb);
859 850 bcs->skb = NULL;
851 }
860 852
861 cs->ops->reinitbcshw(bcs); 853 cs->ops->reinitbcshw(bcs);
862} 854}
@@ -877,8 +869,6 @@ static void cleanup_cs(struct cardstate *cs)
877 free_strings(&cs->at_state); 869 free_strings(&cs->at_state);
878 gigaset_at_init(&cs->at_state, NULL, cs, 0); 870 gigaset_at_init(&cs->at_state, NULL, cs, 0);
879 871
880 kfree(cs->inbuf->rcvbuf);
881 cs->inbuf->rcvbuf = NULL;
882 cs->inbuf->inputstate = INS_command; 872 cs->inbuf->inputstate = INS_command;
883 cs->inbuf->head = 0; 873 cs->inbuf->head = 0;
884 cs->inbuf->tail = 0; 874 cs->inbuf->tail = 0;