aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/ev-layer.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2006-04-11 01:55:04 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-11 09:18:49 -0400
commit784d5858aac58c06608def862d73ae9a32f5ee23 (patch)
tree992ba2e122df6fc90a935dcc1629186bc7e168ac /drivers/isdn/gigaset/ev-layer.c
parentec81b5e6294088dc4738d0e8c2316c0dc081215c (diff)
[PATCH] isdn4linux: Siemens Gigaset drivers: logging usage
With Hansjoerg Lipp <hjlipp@web.de> Improve error reporting of the Gigaset drivers, by using the dev_err/dev_warn/dev_info macros from device.h instead of err/warn/info from usb.h whereever possible. Also rename the private dbg macro to gig_dbg in order to avoid confusion with the macro of the same name in usb.h. Signed-off-by: Hansjoerg Lipp <hjlipp@web.de> Signed-off-by: Tilman Schmidt <tilman@imap.cc> Cc: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/isdn/gigaset/ev-layer.c')
-rw-r--r--drivers/isdn/gigaset/ev-layer.c265
1 files changed, 138 insertions, 127 deletions
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index 6c1000491231..53490430a2e1 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -171,7 +171,7 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
171 // {ACT_TIMEOUT}}, 171 // {ACT_TIMEOUT}},
172 172
173 {RSP_INIT, -1, -1,SEQ_INIT, 100, INIT_TIMEOUT, 173 {RSP_INIT, -1, -1,SEQ_INIT, 100, INIT_TIMEOUT,
174 {ACT_TIMEOUT}}, /* wait until device is ready */ 174 {ACT_TIMEOUT}}, /* wait until device is ready */
175 175
176 {EV_TIMEOUT, 100,100, -1, 101, 3, {0}, "Z\r"}, /* device in transparent mode? try to initialize it. */ 176 {EV_TIMEOUT, 100,100, -1, 101, 3, {0}, "Z\r"}, /* device in transparent mode? try to initialize it. */
177 {RSP_OK, 101,103, -1, 120, 5, {ACT_GETSTRING}, "+GMR\r"}, /* get version */ 177 {RSP_OK, 101,103, -1, 120, 5, {ACT_GETSTRING}, "+GMR\r"}, /* get version */
@@ -186,8 +186,8 @@ struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
186 {RSP_ERROR, 108,108, -1, 0, 0, {ACT_FAILINIT}}, 186 {RSP_ERROR, 108,108, -1, 0, 0, {ACT_FAILINIT}},
187 187
188 {EV_TIMEOUT, 108,108, -1, 105, 2, {ACT_SETDLE0, 188 {EV_TIMEOUT, 108,108, -1, 105, 2, {ACT_SETDLE0,
189 ACT_HUPMODEM, 189 ACT_HUPMODEM,
190 ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */ 190 ACT_TIMEOUT}}, /* still timeout => connection in unimodem mode? */
191 {EV_TIMEOUT, 105,105, -1, 103, 5, {0}, "Z\r"}, 191 {EV_TIMEOUT, 105,105, -1, 103, 5, {0}, "Z\r"},
192 192
193 {RSP_ERROR, 102,102, -1, 107, 5, {0}, "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */ 193 {RSP_ERROR, 102,102, -1, 107, 5, {0}, "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */
@@ -444,7 +444,7 @@ static int isdn_getnum(char *p)
444 444
445 IFNULLRETVAL(p, -1); 445 IFNULLRETVAL(p, -1);
446 446
447 dbg(DEBUG_TRANSCMD, "string: %s", p); 447 gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
448 448
449 while (*p >= '0' && *p <= '9') 449 while (*p >= '0' && *p <= '9')
450 v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0'); 450 v = ((v < 0) ? 0 : (v * 10)) + (int) ((*p++) - '0');
@@ -463,7 +463,7 @@ static int isdn_gethex(char *p)
463 463
464 IFNULLRETVAL(p, -1); 464 IFNULLRETVAL(p, -1);
465 465
466 dbg(DEBUG_TRANSCMD, "string: %s", p); 466 gig_dbg(DEBUG_TRANSCMD, "string: %s", p);
467 467
468 if (!*p) 468 if (!*p)
469 return -1; 469 return -1;
@@ -537,11 +537,11 @@ void gigaset_handle_modem_response(struct cardstate *cs)
537 len = cs->cbytes; 537 len = cs->cbytes;
538 if (!len) { 538 if (!len) {
539 /* ignore additional LFs/CRs (M10x config mode or cx100) */ 539 /* ignore additional LFs/CRs (M10x config mode or cx100) */
540 dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]); 540 gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]);
541 return; 541 return;
542 } 542 }
543 cs->respdata[len] = 0; 543 cs->respdata[len] = 0;
544 dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata); 544 gig_dbg(DEBUG_TRANSCMD, "raw string: '%s'", cs->respdata);
545 argv[0] = cs->respdata; 545 argv[0] = cs->respdata;
546 params = 1; 546 params = 1;
547 if (cs->at_state.getstring) { 547 if (cs->at_state.getstring) {
@@ -557,7 +557,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
557 case ',': 557 case ',':
558 case '=': 558 case '=':
559 if (params > MAX_REC_PARAMS) { 559 if (params > MAX_REC_PARAMS) {
560 warn("too many parameters in response"); 560 dev_warn(cs->dev,
561 "too many parameters in response\n");
561 /* need last parameter (might be CID) */ 562 /* need last parameter (might be CID) */
562 params--; 563 params--;
563 } 564 }
@@ -568,21 +569,21 @@ void gigaset_handle_modem_response(struct cardstate *cs)
568 cid = params > 1 ? cid_of_response(argv[params-1]) : 0; 569 cid = params > 1 ? cid_of_response(argv[params-1]) : 0;
569 if (cid < 0) { 570 if (cid < 0) {
570 gigaset_add_event(cs, &cs->at_state, RSP_INVAL, 571 gigaset_add_event(cs, &cs->at_state, RSP_INVAL,
571 NULL, 0, NULL); 572 NULL, 0, NULL);
572 return; 573 return;
573 } 574 }
574 575
575 for (j = 1; j < params; ++j) 576 for (j = 1; j < params; ++j)
576 argv[j][-1] = 0; 577 argv[j][-1] = 0;
577 578
578 dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]); 579 gig_dbg(DEBUG_TRANSCMD, "CMD received: %s", argv[0]);
579 if (cid) { 580 if (cid) {
580 --params; 581 --params;
581 dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]); 582 gig_dbg(DEBUG_TRANSCMD, "CID: %s", argv[params]);
582 } 583 }
583 dbg(DEBUG_TRANSCMD, "available params: %d", params - 1); 584 gig_dbg(DEBUG_TRANSCMD, "available params: %d", params - 1);
584 for (j = 1; j < params; j++) 585 for (j = 1; j < params; j++)
585 dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]); 586 gig_dbg(DEBUG_TRANSCMD, "param %d: %s", j, argv[j]);
586 } 587 }
587 588
588 spin_lock_irqsave(&cs->ev_lock, flags); 589 spin_lock_irqsave(&cs->ev_lock, flags);
@@ -594,7 +595,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
594 while (curarg < params) { 595 while (curarg < params) {
595 next = (tail + 1) % MAX_EVENTS; 596 next = (tail + 1) % MAX_EVENTS;
596 if (unlikely(next == head)) { 597 if (unlikely(next == head)) {
597 err("event queue full"); 598 dev_err(cs->dev, "event queue full\n");
598 break; 599 break;
599 } 600 }
600 601
@@ -615,8 +616,9 @@ void gigaset_handle_modem_response(struct cardstate *cs)
615 616
616 if (!rt->response) { 617 if (!rt->response) {
617 event->type = RSP_UNKNOWN; 618 event->type = RSP_UNKNOWN;
618 warn("unknown modem response: %s", 619 dev_warn(cs->dev,
619 argv[curarg]); 620 "unknown modem response: %s\n",
621 argv[curarg]);
620 break; 622 break;
621 } 623 }
622 624
@@ -632,7 +634,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
632 break; 634 break;
633 case RT_RING: 635 case RT_RING:
634 if (!cid) { 636 if (!cid) {
635 err("received RING without CID!"); 637 dev_err(cs->dev,
638 "received RING without CID!\n");
636 event->type = RSP_INVAL; 639 event->type = RSP_INVAL;
637 abort = 1; 640 abort = 1;
638 } else { 641 } else {
@@ -660,27 +663,25 @@ void gigaset_handle_modem_response(struct cardstate *cs)
660 event->parameter = ZSAU_DISCONNECT_REQ; 663 event->parameter = ZSAU_DISCONNECT_REQ;
661 else { 664 else {
662 event->parameter = ZSAU_UNKNOWN; 665 event->parameter = ZSAU_UNKNOWN;
663 warn("%s: unknown parameter %s after ZSAU", 666 dev_warn(cs->dev,
664 __func__, argv[curarg]); 667 "%s: unknown parameter %s after ZSAU\n",
668 __func__, argv[curarg]);
665 } 669 }
666 ++curarg; 670 ++curarg;
667 break; 671 break;
668 case RT_STRING: 672 case RT_STRING:
669 if (curarg < params) { 673 if (curarg < params) {
670 len = strlen(argv[curarg]) + 1; 674 event->ptr = kstrdup(argv[curarg], GFP_ATOMIC);
671 event->ptr = kmalloc(len, GFP_ATOMIC); 675 if (!event->ptr)
672 if (event->ptr) 676 dev_err(cs->dev, "out of memory\n");
673 memcpy(event->ptr, argv[curarg], len);
674 else
675 err("no memory for string!");
676 ++curarg; 677 ++curarg;
677 } 678 }
678#ifdef CONFIG_GIGASET_DEBUG 679#ifdef CONFIG_GIGASET_DEBUG
679 if (!event->ptr) 680 if (!event->ptr)
680 dbg(DEBUG_CMD, "string==NULL"); 681 gig_dbg(DEBUG_CMD, "string==NULL");
681 else 682 else
682 dbg(DEBUG_CMD, 683 gig_dbg(DEBUG_CMD, "string==%s",
683 "string==%s", (char *) event->ptr); 684 (char *) event->ptr);
684#endif 685#endif
685 break; 686 break;
686 case RT_ZCAU: 687 case RT_ZCAU:
@@ -690,7 +691,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
690 j = isdn_gethex(argv[curarg + 1]); 691 j = isdn_gethex(argv[curarg + 1]);
691 if (i >= 0 && i < 256 && j >= 0 && j < 256) 692 if (i >= 0 && i < 256 && j >= 0 && j < 256)
692 event->parameter = (unsigned) i << 8 693 event->parameter = (unsigned) i << 8
693 | j; 694 | j;
694 curarg += 2; 695 curarg += 2;
695 } else 696 } else
696 curarg = params - 1; 697 curarg = params - 1;
@@ -708,7 +709,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
708 } else 709 } else
709 event->parameter = -1; 710 event->parameter = -1;
710#ifdef CONFIG_GIGASET_DEBUG 711#ifdef CONFIG_GIGASET_DEBUG
711 dbg(DEBUG_CMD, "parameter==%d", event->parameter); 712 gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter);
712#endif 713#endif
713 break; 714 break;
714 } 715 }
@@ -724,8 +725,9 @@ void gigaset_handle_modem_response(struct cardstate *cs)
724 spin_unlock_irqrestore(&cs->ev_lock, flags); 725 spin_unlock_irqrestore(&cs->ev_lock, flags);
725 726
726 if (curarg != params) 727 if (curarg != params)
727 dbg(DEBUG_ANY, "invalid number of processed parameters: %d/%d", 728 gig_dbg(DEBUG_ANY,
728 curarg, params); 729 "invalid number of processed parameters: %d/%d",
730 curarg, params);
729} 731}
730EXPORT_SYMBOL_GPL(gigaset_handle_modem_response); 732EXPORT_SYMBOL_GPL(gigaset_handle_modem_response);
731 733
@@ -750,7 +752,7 @@ static void disconnect(struct at_state_t **at_state_p)
750 if (!atomic_read(&cs->cidmode)) { 752 if (!atomic_read(&cs->cidmode)) {
751 cs->at_state.pending_commands |= PC_UMMODE; 753 cs->at_state.pending_commands |= PC_UMMODE;
752 atomic_set(&cs->commands_pending, 1); //FIXME 754 atomic_set(&cs->commands_pending, 1); //FIXME
753 dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 755 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
754 } 756 }
755 757
756 if (bcs) { 758 if (bcs) {
@@ -773,7 +775,7 @@ static void disconnect(struct at_state_t **at_state_p)
773 * The structure should be freed by calling disconnect() after use. 775 * The structure should be freed by calling disconnect() after use.
774 */ 776 */
775static inline struct at_state_t *get_free_channel(struct cardstate *cs, 777static inline struct at_state_t *get_free_channel(struct cardstate *cs,
776 int cid) 778 int cid)
777/* cids: >0: siemens-cid 779/* cids: >0: siemens-cid
778 0: without cid 780 0: without cid
779 -1: no cid assigned yet 781 -1: no cid assigned yet
@@ -822,7 +824,7 @@ static void init_failed(struct cardstate *cs, int mode)
822static void schedule_init(struct cardstate *cs, int state) 824static void schedule_init(struct cardstate *cs, int state)
823{ 825{
824 if (cs->at_state.pending_commands & PC_INIT) { 826 if (cs->at_state.pending_commands & PC_INIT) {
825 dbg(DEBUG_CMD, "not scheduling PC_INIT again"); 827 gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again");
826 return; 828 return;
827 } 829 }
828 atomic_set(&cs->mstate, state); 830 atomic_set(&cs->mstate, state);
@@ -830,53 +832,56 @@ static void schedule_init(struct cardstate *cs, int state)
830 gigaset_block_channels(cs); 832 gigaset_block_channels(cs);
831 cs->at_state.pending_commands |= PC_INIT; 833 cs->at_state.pending_commands |= PC_INIT;
832 atomic_set(&cs->commands_pending, 1); 834 atomic_set(&cs->commands_pending, 1);
833 dbg(DEBUG_CMD, "Scheduling PC_INIT"); 835 gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
834} 836}
835 837
836/* Add "AT" to a command, add the cid, dle encode it, send the result to the 838/* Add "AT" to a command, add the cid, dle encode it, send the result to the
837 hardware. */ 839 hardware. */
838static void send_command(struct cardstate *cs, const char *cmd, int cid, 840static void send_command(struct cardstate *cs, const char *cmd, int cid,
839 int dle, gfp_t kmallocflags) 841 int dle, gfp_t kmallocflags)
840{ 842{
841 size_t cmdlen, buflen; 843 size_t cmdlen, buflen;
842 char *cmdpos, *cmdbuf, *cmdtail; 844 char *cmdpos, *cmdbuf, *cmdtail;
843 845
844 cmdlen = strlen(cmd); 846 cmdlen = strlen(cmd);
845 buflen = 11 + cmdlen; 847 buflen = 11 + cmdlen;
848 if (unlikely(buflen <= cmdlen)) {
849 dev_err(cs->dev, "integer overflow in buflen\n");
850 return;
851 }
846 852
847 if (likely(buflen > cmdlen)) { 853 cmdbuf = kmalloc(buflen, kmallocflags);
848 cmdbuf = kmalloc(buflen, kmallocflags); 854 if (unlikely(!cmdbuf)) {
849 if (likely(cmdbuf != NULL)) { 855 dev_err(cs->dev, "out of memory\n");
850 cmdpos = cmdbuf + 9; 856 return;
851 cmdtail = cmdpos + cmdlen; 857 }
852 memcpy(cmdpos, cmd, cmdlen);
853
854 if (cid > 0 && cid <= 65535) {
855 do {
856 *--cmdpos = '0' + cid % 10;
857 cid /= 10;
858 ++cmdlen;
859 } while (cid);
860 }
861 858
862 cmdlen += 2; 859 cmdpos = cmdbuf + 9;
863 *--cmdpos = 'T'; 860 cmdtail = cmdpos + cmdlen;
864 *--cmdpos = 'A'; 861 memcpy(cmdpos, cmd, cmdlen);
865 862
866 if (dle) { 863 if (cid > 0 && cid <= 65535) {
867 cmdlen += 4; 864 do {
868 *--cmdpos = '('; 865 *--cmdpos = '0' + cid % 10;
869 *--cmdpos = 0x10; 866 cid /= 10;
870 *cmdtail++ = 0x10; 867 ++cmdlen;
871 *cmdtail++ = ')'; 868 } while (cid);
872 } 869 }
873 870
874 cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL); 871 cmdlen += 2;
875 kfree(cmdbuf); 872 *--cmdpos = 'T';
876 } else 873 *--cmdpos = 'A';
877 err("no memory for command buffer"); 874
878 } else 875 if (dle) {
879 err("overflow in buflen"); 876 cmdlen += 4;
877 *--cmdpos = '(';
878 *--cmdpos = 0x10;
879 *cmdtail++ = 0x10;
880 *cmdtail++ = ')';
881 }
882
883 cs->ops->write_cmd(cs, cmdpos, cmdlen, NULL);
884 kfree(cmdbuf);
880} 885}
881 886
882static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid) 887static struct at_state_t *at_state_from_cid(struct cardstate *cs, int cid)
@@ -930,13 +935,14 @@ static void bchannel_up(struct bc_state *bcs)
930 IFNULLRET(bcs); 935 IFNULLRET(bcs);
931 936
932 if (!(bcs->chstate & CHS_D_UP)) { 937 if (!(bcs->chstate & CHS_D_UP)) {
933 notice("%s: D channel not up", __func__); 938 dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
934 bcs->chstate |= CHS_D_UP; 939 bcs->chstate |= CHS_D_UP;
935 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN); 940 gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
936 } 941 }
937 942
938 if (bcs->chstate & CHS_B_UP) { 943 if (bcs->chstate & CHS_B_UP) {
939 notice("%s: B channel already up", __func__); 944 dev_notice(bcs->cs->dev, "%s: B channel already up\n",
945 __func__);
940 return; 946 return;
941 } 947 }
942 948
@@ -962,13 +968,13 @@ static void start_dial(struct at_state_t *at_state, void *data, int seq_index)
962 968
963 969
964 at_state->pending_commands |= PC_CID; 970 at_state->pending_commands |= PC_CID;
965 dbg(DEBUG_CMD, "Scheduling PC_CID"); 971 gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
966 atomic_set(&cs->commands_pending, 1); 972 atomic_set(&cs->commands_pending, 1);
967 return; 973 return;
968 974
969error: 975error:
970 at_state->pending_commands |= PC_NOCID; 976 at_state->pending_commands |= PC_NOCID;
971 dbg(DEBUG_CMD, "Scheduling PC_NOCID"); 977 gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
972 atomic_set(&cs->commands_pending, 1); 978 atomic_set(&cs->commands_pending, 1);
973 return; 979 return;
974} 980}
@@ -982,12 +988,12 @@ static void start_accept(struct at_state_t *at_state)
982 988
983 if (retval == 0) { 989 if (retval == 0) {
984 at_state->pending_commands |= PC_ACCEPT; 990 at_state->pending_commands |= PC_ACCEPT;
985 dbg(DEBUG_CMD, "Scheduling PC_ACCEPT"); 991 gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
986 atomic_set(&cs->commands_pending, 1); 992 atomic_set(&cs->commands_pending, 1);
987 } else { 993 } else {
988 //FIXME 994 //FIXME
989 at_state->pending_commands |= PC_HUP; 995 at_state->pending_commands |= PC_HUP;
990 dbg(DEBUG_CMD, "Scheduling PC_HUP"); 996 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
991 atomic_set(&cs->commands_pending, 1); 997 atomic_set(&cs->commands_pending, 1);
992 } 998 }
993} 999}
@@ -1000,8 +1006,8 @@ static void do_start(struct cardstate *cs)
1000 schedule_init(cs, MS_INIT); 1006 schedule_init(cs, MS_INIT);
1001 1007
1002 gigaset_i4l_cmd(cs, ISDN_STAT_RUN); 1008 gigaset_i4l_cmd(cs, ISDN_STAT_RUN);
1003 // FIXME: not in locked mode 1009 // FIXME: not in locked mode
1004 // FIXME 2: only after init sequence 1010 // FIXME 2: only after init sequence
1005 1011
1006 cs->waiting = 0; 1012 cs->waiting = 0;
1007 wake_up(&cs->waitqueue); 1013 wake_up(&cs->waitqueue);
@@ -1029,7 +1035,7 @@ static void do_shutdown(struct cardstate *cs)
1029 atomic_set(&cs->mstate, MS_SHUTDOWN); 1035 atomic_set(&cs->mstate, MS_SHUTDOWN);
1030 cs->at_state.pending_commands |= PC_SHUTDOWN; 1036 cs->at_state.pending_commands |= PC_SHUTDOWN;
1031 atomic_set(&cs->commands_pending, 1); 1037 atomic_set(&cs->commands_pending, 1);
1032 dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN"); 1038 gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
1033 } else 1039 } else
1034 finish_shutdown(cs); 1040 finish_shutdown(cs);
1035} 1041}
@@ -1059,9 +1065,11 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
1059 return 0; 1065 return 0;
1060 1066
1061 if (channel < 0) 1067 if (channel < 0)
1062 warn("Could not enter cid mode. Reinit device and try again."); 1068 dev_warn(cs->dev,
1069 "Could not enter cid mode. Reinit device and try again.\n");
1063 else { 1070 else {
1064 warn("Could not get a call id. Reinit device and try again."); 1071 dev_warn(cs->dev,
1072 "Could not get a call id. Reinit device and try again.\n");
1065 cs->bcs[channel].at_state.pending_commands |= PC_CID; 1073 cs->bcs[channel].at_state.pending_commands |= PC_CID;
1066 } 1074 }
1067 schedule_init(cs, MS_INIT); 1075 schedule_init(cs, MS_INIT);
@@ -1069,7 +1077,7 @@ static int reinit_and_retry(struct cardstate *cs, int channel)
1069} 1077}
1070 1078
1071static int at_state_invalid(struct cardstate *cs, 1079static int at_state_invalid(struct cardstate *cs,
1072 struct at_state_t *test_ptr) 1080 struct at_state_t *test_ptr)
1073{ 1081{
1074 unsigned long flags; 1082 unsigned long flags;
1075 unsigned channel; 1083 unsigned channel;
@@ -1106,7 +1114,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
1106 case ICALL_ACCEPT: 1114 case ICALL_ACCEPT:
1107 break; 1115 break;
1108 default: 1116 default:
1109 err("internal error: disposition=%d", retval); 1117 dev_err(cs->dev, "internal error: disposition=%d\n", retval);
1110 /* --v-- fall through --v-- */ 1118 /* --v-- fall through --v-- */
1111 case ICALL_IGNORE: 1119 case ICALL_IGNORE:
1112 case ICALL_REJECT: 1120 case ICALL_REJECT:
@@ -1201,10 +1209,10 @@ static void do_action(int action, struct cardstate *cs,
1201 } 1209 }
1202 cs->at_state.pending_commands |= PC_CIDMODE; 1210 cs->at_state.pending_commands |= PC_CIDMODE;
1203 atomic_set(&cs->commands_pending, 1); 1211 atomic_set(&cs->commands_pending, 1);
1204 dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1212 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1205 break; 1213 break;
1206 case ACT_FAILINIT: 1214 case ACT_FAILINIT:
1207 warn("Could not initialize the device."); 1215 dev_warn(cs->dev, "Could not initialize the device.\n");
1208 cs->dle = 0; 1216 cs->dle = 0;
1209 init_failed(cs, M_UNKNOWN); 1217 init_failed(cs, M_UNKNOWN);
1210 cs->cur_at_seq = SEQ_NONE; 1218 cs->cur_at_seq = SEQ_NONE;
@@ -1260,8 +1268,8 @@ static void do_action(int action, struct cardstate *cs,
1260 /* get fresh AT state structure for new CID */ 1268 /* get fresh AT state structure for new CID */
1261 at_state2 = get_free_channel(cs, ev->parameter); 1269 at_state2 = get_free_channel(cs, ev->parameter);
1262 if (!at_state2) { 1270 if (!at_state2) {
1263 warn("RING ignored: " 1271 dev_warn(cs->dev,
1264 "could not allocate channel structure"); 1272 "RING ignored: could not allocate channel structure\n");
1265 break; 1273 break;
1266 } 1274 }
1267 1275
@@ -1289,7 +1297,7 @@ static void do_action(int action, struct cardstate *cs,
1289 at_state = *p_at_state; 1297 at_state = *p_at_state;
1290 break; 1298 break;
1291 case ACT_FAILSDOWN: 1299 case ACT_FAILSDOWN:
1292 warn("Could not shut down the device."); 1300 dev_warn(cs->dev, "Could not shut down the device.\n");
1293 /* fall through */ 1301 /* fall through */
1294 case ACT_FAKESDOWN: 1302 case ACT_FAKESDOWN:
1295 case ACT_SDOWN: 1303 case ACT_SDOWN:
@@ -1342,7 +1350,7 @@ static void do_action(int action, struct cardstate *cs,
1342 break; 1350 break;
1343 case ACT_ABORTHUP: 1351 case ACT_ABORTHUP:
1344 cs->cur_at_seq = SEQ_NONE; 1352 cs->cur_at_seq = SEQ_NONE;
1345 warn("Could not hang up."); 1353 dev_warn(cs->dev, "Could not hang up.\n");
1346 at_state->cid = -1; 1354 at_state->cid = -1;
1347 if (bcs && cs->onechannel) 1355 if (bcs && cs->onechannel)
1348 at_state->pending_commands |= PC_DLE0; 1356 at_state->pending_commands |= PC_DLE0;
@@ -1354,14 +1362,15 @@ static void do_action(int action, struct cardstate *cs,
1354 break; 1362 break;
1355 case ACT_FAILDLE0: 1363 case ACT_FAILDLE0:
1356 cs->cur_at_seq = SEQ_NONE; 1364 cs->cur_at_seq = SEQ_NONE;
1357 warn("Could not leave DLE mode."); 1365 dev_warn(cs->dev, "Could not leave DLE mode.\n");
1358 at_state2 = &cs->bcs[cs->curchannel].at_state; 1366 at_state2 = &cs->bcs[cs->curchannel].at_state;
1359 disconnect(&at_state2); 1367 disconnect(&at_state2);
1360 schedule_init(cs, MS_RECOVER); 1368 schedule_init(cs, MS_RECOVER);
1361 break; 1369 break;
1362 case ACT_FAILDLE1: 1370 case ACT_FAILDLE1:
1363 cs->cur_at_seq = SEQ_NONE; 1371 cs->cur_at_seq = SEQ_NONE;
1364 warn("Could not enter DLE mode. Try to hang up."); 1372 dev_warn(cs->dev,
1373 "Could not enter DLE mode. Trying to hang up.\n");
1365 channel = cs->curchannel; 1374 channel = cs->curchannel;
1366 cs->bcs[channel].at_state.pending_commands |= PC_HUP; 1375 cs->bcs[channel].at_state.pending_commands |= PC_HUP;
1367 atomic_set(&cs->commands_pending, 1); 1376 atomic_set(&cs->commands_pending, 1);
@@ -1382,7 +1391,8 @@ static void do_action(int action, struct cardstate *cs,
1382 cs->cur_at_seq = SEQ_NONE; 1391 cs->cur_at_seq = SEQ_NONE;
1383 channel = cs->curchannel; 1392 channel = cs->curchannel;
1384 if (!reinit_and_retry(cs, channel)) { 1393 if (!reinit_and_retry(cs, channel)) {
1385 warn("Could not get a call id. Dialing not possible"); 1394 dev_warn(cs->dev,
1395 "Could not get a call ID. Cannot dial.\n");
1386 at_state2 = &cs->bcs[channel].at_state; 1396 at_state2 = &cs->bcs[channel].at_state;
1387 disconnect(&at_state2); 1397 disconnect(&at_state2);
1388 } 1398 }
@@ -1416,7 +1426,7 @@ static void do_action(int action, struct cardstate *cs,
1416 atomic_set(&cs->commands_pending, 1); 1426 atomic_set(&cs->commands_pending, 1);
1417 break; 1427 break;
1418 case ACT_GETSTRING: /* warning: RING, ZDLE, ... 1428 case ACT_GETSTRING: /* warning: RING, ZDLE, ...
1419 are not handled properly any more */ 1429 are not handled properly anymore */
1420 at_state->getstring = 1; 1430 at_state->getstring = 1;
1421 break; 1431 break;
1422 case ACT_SETVER: 1432 case ACT_SETVER:
@@ -1457,16 +1467,16 @@ static void do_action(int action, struct cardstate *cs,
1457 case ACT_GOTVER: 1467 case ACT_GOTVER:
1458 if (cs->gotfwver == 0) { 1468 if (cs->gotfwver == 0) {
1459 cs->gotfwver = 1; 1469 cs->gotfwver = 1;
1460 dbg(DEBUG_ANY, 1470 gig_dbg(DEBUG_ANY,
1461 "firmware version %02d.%03d.%02d.%02d", 1471 "firmware version %02d.%03d.%02d.%02d",
1462 cs->fwver[0], cs->fwver[1], 1472 cs->fwver[0], cs->fwver[1],
1463 cs->fwver[2], cs->fwver[3]); 1473 cs->fwver[2], cs->fwver[3]);
1464 break; 1474 break;
1465 } 1475 }
1466 /* fall through */ 1476 /* fall through */
1467 case ACT_FAILVER: 1477 case ACT_FAILVER:
1468 cs->gotfwver = -1; 1478 cs->gotfwver = -1;
1469 err("could not read firmware version."); 1479 dev_err(cs->dev, "could not read firmware version.\n");
1470 break; 1480 break;
1471#ifdef CONFIG_GIGASET_DEBUG 1481#ifdef CONFIG_GIGASET_DEBUG
1472 case ACT_ERROR: 1482 case ACT_ERROR:
@@ -1484,16 +1494,16 @@ static void do_action(int action, struct cardstate *cs,
1484 break; 1494 break;
1485#endif 1495#endif
1486 case ACT_DEBUG: 1496 case ACT_DEBUG:
1487 dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d", 1497 gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
1488 __func__, ev->type, at_state->ConState); 1498 __func__, ev->type, at_state->ConState);
1489 break; 1499 break;
1490 case ACT_WARN: 1500 case ACT_WARN:
1491 warn("%s: resp_code %d in ConState %d!", 1501 dev_warn(cs->dev, "%s: resp_code %d in ConState %d!\n",
1492 __func__, ev->type, at_state->ConState); 1502 __func__, ev->type, at_state->ConState);
1493 break; 1503 break;
1494 case ACT_ZCAU: 1504 case ACT_ZCAU:
1495 warn("cause code %04x in connection state %d.", 1505 dev_warn(cs->dev, "cause code %04x in connection state %d.\n",
1496 ev->parameter, at_state->ConState); 1506 ev->parameter, at_state->ConState);
1497 break; 1507 break;
1498 1508
1499 /* events from the LL */ 1509 /* events from the LL */
@@ -1504,14 +1514,14 @@ static void do_action(int action, struct cardstate *cs,
1504 start_accept(at_state); 1514 start_accept(at_state);
1505 break; 1515 break;
1506 case ACT_PROTO_L2: 1516 case ACT_PROTO_L2:
1507 dbg(DEBUG_CMD, 1517 gig_dbg(DEBUG_CMD, "set protocol to %u",
1508 "set protocol to %u", (unsigned) ev->parameter); 1518 (unsigned) ev->parameter);
1509 at_state->bcs->proto2 = ev->parameter; 1519 at_state->bcs->proto2 = ev->parameter;
1510 break; 1520 break;
1511 case ACT_HUP: 1521 case ACT_HUP:
1512 at_state->pending_commands |= PC_HUP; 1522 at_state->pending_commands |= PC_HUP;
1513 atomic_set(&cs->commands_pending, 1); 1523 atomic_set(&cs->commands_pending, 1);
1514 dbg(DEBUG_CMD, "Scheduling PC_HUP"); 1524 gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
1515 break; 1525 break;
1516 1526
1517 /* hotplug events */ 1527 /* hotplug events */
@@ -1547,10 +1557,10 @@ static void do_action(int action, struct cardstate *cs,
1547 atomic_set(&cs->cidmode, ev->parameter); 1557 atomic_set(&cs->cidmode, ev->parameter);
1548 if (ev->parameter) { 1558 if (ev->parameter) {
1549 cs->at_state.pending_commands |= PC_CIDMODE; 1559 cs->at_state.pending_commands |= PC_CIDMODE;
1550 dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1560 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1551 } else { 1561 } else {
1552 cs->at_state.pending_commands |= PC_UMMODE; 1562 cs->at_state.pending_commands |= PC_UMMODE;
1553 dbg(DEBUG_CMD, "Scheduling PC_UMMODE"); 1563 gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
1554 } 1564 }
1555 atomic_set(&cs->commands_pending, 1); 1565 atomic_set(&cs->commands_pending, 1);
1556 } 1566 }
@@ -1578,7 +1588,7 @@ static void do_action(int action, struct cardstate *cs,
1578 *p_resp_code = RSP_NULL; 1588 *p_resp_code = RSP_NULL;
1579 } 1589 }
1580 } else 1590 } else
1581 err("%s: action==%d!", __func__, action); 1591 dev_err(cs->dev, "%s: action==%d!\n", __func__, action);
1582 } 1592 }
1583} 1593}
1584 1594
@@ -1604,20 +1614,20 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1604 at_state = at_state_from_cid(cs, ev->cid); 1614 at_state = at_state_from_cid(cs, ev->cid);
1605 if (!at_state) { 1615 if (!at_state) {
1606 gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID, 1616 gigaset_add_event(cs, &cs->at_state, RSP_WRONG_CID,
1607 NULL, 0, NULL); 1617 NULL, 0, NULL);
1608 return; 1618 return;
1609 } 1619 }
1610 } else { 1620 } else {
1611 at_state = ev->at_state; 1621 at_state = ev->at_state;
1612 if (at_state_invalid(cs, at_state)) { 1622 if (at_state_invalid(cs, at_state)) {
1613 dbg(DEBUG_ANY, 1623 gig_dbg(DEBUG_ANY, "event for invalid at_state %p",
1614 "event for invalid at_state %p", at_state); 1624 at_state);
1615 return; 1625 return;
1616 } 1626 }
1617 } 1627 }
1618 1628
1619 dbg(DEBUG_CMD, 1629 gig_dbg(DEBUG_CMD, "connection state %d, event %d",
1620 "connection state %d, event %d", at_state->ConState, ev->type); 1630 at_state->ConState, ev->type);
1621 1631
1622 bcs = at_state->bcs; 1632 bcs = at_state->bcs;
1623 sendcid = at_state->cid; 1633 sendcid = at_state->cid;
@@ -1630,11 +1640,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1630 if (ev->parameter != atomic_read(&at_state->timer_index) 1640 if (ev->parameter != atomic_read(&at_state->timer_index)
1631 || !at_state->timer_active) { 1641 || !at_state->timer_active) {
1632 ev->type = RSP_NONE; /* old timeout */ 1642 ev->type = RSP_NONE; /* old timeout */
1633 dbg(DEBUG_ANY, "old timeout"); 1643 gig_dbg(DEBUG_ANY, "old timeout");
1634 } else if (!at_state->waiting) 1644 } else if (!at_state->waiting)
1635 dbg(DEBUG_ANY, "timeout occured"); 1645 gig_dbg(DEBUG_ANY, "timeout occurred");
1636 else 1646 else
1637 dbg(DEBUG_ANY, "stopped waiting"); 1647 gig_dbg(DEBUG_ANY, "stopped waiting");
1638 } 1648 }
1639 1649
1640 /* if the response belongs to a variable in at_state->int_var[VAR_XXXX] 1650 /* if the response belongs to a variable in at_state->int_var[VAR_XXXX]
@@ -1657,11 +1667,11 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1657 constate */ 1667 constate */
1658 for (;; rep++) { 1668 for (;; rep++) {
1659 rcode = rep->resp_code; 1669 rcode = rep->resp_code;
1660 /* dbg (DEBUG_ANY, "rcode %d", rcode); */
1661 if (rcode == RSP_LAST) { 1670 if (rcode == RSP_LAST) {
1662 /* found nothing...*/ 1671 /* found nothing...*/
1663 warn("%s: rcode=RSP_LAST: resp_code %d in ConState %d!", 1672 dev_warn(cs->dev, "%s: rcode=RSP_LAST: "
1664 __func__, ev->type, at_state->ConState); 1673 "resp_code %d in ConState %d!\n",
1674 __func__, ev->type, at_state->ConState);
1665 return; 1675 return;
1666 } 1676 }
1667 if ((rcode == RSP_ANY || rcode == ev->type) 1677 if ((rcode == RSP_ANY || rcode == ev->type)
@@ -1699,12 +1709,12 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1699 if (p_command/*rep->command*/) { 1709 if (p_command/*rep->command*/) {
1700 if (atomic_read(&cs->connected)) 1710 if (atomic_read(&cs->connected))
1701 send_command(cs, p_command, 1711 send_command(cs, p_command,
1702 sendcid, cs->dle, 1712 sendcid, cs->dle,
1703 GFP_ATOMIC); 1713 GFP_ATOMIC);
1704 else 1714 else
1705 gigaset_add_event(cs, at_state, 1715 gigaset_add_event(cs, at_state,
1706 RSP_NODEV, 1716 RSP_NODEV,
1707 NULL, 0, NULL); 1717 NULL, 0, NULL);
1708 } 1718 }
1709 1719
1710 spin_lock_irqsave(&cs->lock, flags); 1720 spin_lock_irqsave(&cs->lock, flags);
@@ -1715,7 +1725,7 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1715 at_state->timer_expires = rep->timeout * 10; 1725 at_state->timer_expires = rep->timeout * 10;
1716 at_state->timer_active = 1; 1726 at_state->timer_active = 1;
1717 new_index(&at_state->timer_index, 1727 new_index(&at_state->timer_index,
1718 MAX_TIMER_INDEX); 1728 MAX_TIMER_INDEX);
1719 } 1729 }
1720 spin_unlock_irqrestore(&cs->lock, flags); 1730 spin_unlock_irqrestore(&cs->lock, flags);
1721 } 1731 }
@@ -1741,11 +1751,11 @@ static void process_command_flags(struct cardstate *cs)
1741 atomic_set(&cs->commands_pending, 0); 1751 atomic_set(&cs->commands_pending, 0);
1742 1752
1743 if (cs->cur_at_seq) { 1753 if (cs->cur_at_seq) {
1744 dbg(DEBUG_CMD, "not searching scheduled commands: busy"); 1754 gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
1745 return; 1755 return;
1746 } 1756 }
1747 1757
1748 dbg(DEBUG_CMD, "searching scheduled commands"); 1758 gig_dbg(DEBUG_CMD, "searching scheduled commands");
1749 1759
1750 sequence = SEQ_NONE; 1760 sequence = SEQ_NONE;
1751 1761
@@ -1884,7 +1894,7 @@ static void process_command_flags(struct cardstate *cs)
1884 switch (atomic_read(&cs->mode)) { 1894 switch (atomic_read(&cs->mode)) {
1885 case M_UNIMODEM: 1895 case M_UNIMODEM:
1886 cs->at_state.pending_commands |= PC_CIDMODE; 1896 cs->at_state.pending_commands |= PC_CIDMODE;
1887 dbg(DEBUG_CMD, "Scheduling PC_CIDMODE"); 1897 gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
1888 atomic_set(&cs->commands_pending, 1); 1898 atomic_set(&cs->commands_pending, 1);
1889 return; 1899 return;
1890#ifdef GIG_MAYINITONDIAL 1900#ifdef GIG_MAYINITONDIAL
@@ -1945,7 +1955,8 @@ static void process_events(struct cardstate *cs)
1945 } 1955 }
1946 1956
1947 if (i == 2 * MAX_EVENTS) { 1957 if (i == 2 * MAX_EVENTS) {
1948 err("infinite loop in process_events; aborting."); 1958 dev_err(cs->dev,
1959 "infinite loop in process_events; aborting.\n");
1949 } 1960 }
1950} 1961}
1951 1962
@@ -1962,7 +1973,7 @@ void gigaset_handle_event(unsigned long data)
1962 1973
1963 /* handle incoming data on control/common channel */ 1974 /* handle incoming data on control/common channel */
1964 if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) { 1975 if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) {
1965 dbg(DEBUG_INTR, "processing new data"); 1976 gig_dbg(DEBUG_INTR, "processing new data");
1966 cs->ops->handle_input(cs->inbuf); 1977 cs->ops->handle_input(cs->inbuf);
1967 } 1978 }
1968 1979