]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/isdn/gigaset/ev-layer.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6.git] / drivers / isdn / gigaset / ev-layer.c
index 44f02dbd1111c7b26602828b6fb15c5faa3238f1..ddeb0456d20285cda06e205b76a515630fb2eecf 100644 (file)
@@ -40,8 +40,8 @@
 
 /* Possible ASCII responses */
 #define RSP_OK         0
-//#define RSP_BUSY     1
-//#define RSP_CONNECT  2
+#define RSP_BUSY       1
+#define RSP_CONNECT    2
 #define RSP_ZGCI       3
 #define RSP_RING       4
 #define RSP_ZAOC       5
@@ -68,7 +68,6 @@
 #define RSP_ZHLC       (RSP_STR + STR_ZHLC)
 #define RSP_ERROR      -1      /* ERROR              */
 #define RSP_WRONG_CID  -2      /* unknown cid in cmd */
-//#define RSP_EMPTY    -3
 #define RSP_UNKNOWN    -4      /* unknown response   */
 #define RSP_FAIL       -5      /* internal error     */
 #define RSP_INVAL      -6      /* invalid response   */
@@ -76,9 +75,9 @@
 #define RSP_NONE       -19
 #define RSP_STRING     -20
 #define RSP_NULL       -21
-//#define RSP_RETRYFAIL        -22
-//#define RSP_RETRY    -23
-//#define RSP_SKIP     -24
+#define RSP_RETRYFAIL  -22
+#define RSP_RETRY      -23
+#define RSP_SKIP       -24
 #define RSP_INIT       -27
 #define RSP_ANY                -26
 #define RSP_LAST       -28
 #define ACT_NOTIFY_BC_UP       39
 #define ACT_DIAL               40
 #define ACT_ACCEPT             41
-#define ACT_PROTO_L2           42
 #define ACT_HUP                        43
 #define ACT_IF_LOCK            44
 #define ACT_START              45
 #define SEQ_UMMODE     11
 
 
-// 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid), 400: hup, 500: reset, 600: dial, 700: ring
-struct reply_t gigaset_tab_nocid_m10x[]= /* with dle mode */
+/* 100: init, 200: dle0, 250:dle1, 300: get cid (dial), 350: "hup" (no cid),
+ * 400: hup, 500: reset, 600: dial, 700: ring */
+struct reply_t gigaset_tab_nocid[] =
 {
-       /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
-
-       /* initialize device, set cid mode if possible */
-       //{RSP_INIT,     -1, -1,100,                900, 0, {ACT_TEST}},
-       //{RSP_ERROR,   900,900, -1,                  0, 0, {ACT_FAILINIT}},
-       //{RSP_OK,      900,900, -1,                100, INIT_TIMEOUT,
-       //                                                  {ACT_TIMEOUT}},
-
-       {RSP_INIT,     -1, -1,SEQ_INIT,           100, INIT_TIMEOUT,
-                                                         {ACT_TIMEOUT}},                /* wait until device is ready */
-
-       {EV_TIMEOUT,  100,100, -1,                101, 3, {0},             "Z\r"},       /* device in transparent mode? try to initialize it. */
-       {RSP_OK,      101,103, -1,                120, 5, {ACT_GETSTRING}, "+GMR\r"},    /* get version */
-
-       {EV_TIMEOUT,  101,101, -1,                102, 5, {0},             "Z\r"},       /* timeout => try once again. */
-       {RSP_ERROR,   101,101, -1,                102, 5, {0},             "Z\r"},       /* error => try once again. */
-
-       {EV_TIMEOUT,  102,102, -1,                108, 5, {ACT_SETDLE1},   "^SDLE=0\r"}, /* timeout => try again in DLE mode. */
-       {RSP_OK,      108,108, -1,                104,-1},
-       {RSP_ZDLE,    104,104,  0,                103, 5, {0},             "Z\r"},
-       {EV_TIMEOUT,  104,104, -1,                  0, 0, {ACT_FAILINIT}},
-       {RSP_ERROR,   108,108, -1,                  0, 0, {ACT_FAILINIT}},
-
-       {EV_TIMEOUT,  108,108, -1,                105, 2, {ACT_SETDLE0,
-                                                          ACT_HUPMODEM,
-                                                          ACT_TIMEOUT}},                /* still timeout => connection in unimodem mode? */
-       {EV_TIMEOUT,  105,105, -1,                103, 5, {0},             "Z\r"},
-
-       {RSP_ERROR,   102,102, -1,                107, 5, {0},             "^GETPRE\r"}, /* ERROR on ATZ => maybe in config mode? */
-       {RSP_OK,      107,107, -1,                  0, 0, {ACT_CONFIGMODE}},
-       {RSP_ERROR,   107,107, -1,                  0, 0, {ACT_FAILINIT}},
-       {EV_TIMEOUT,  107,107, -1,                  0, 0, {ACT_FAILINIT}},
-
-       {RSP_ERROR,   103,103, -1,                  0, 0, {ACT_FAILINIT}},
-       {EV_TIMEOUT,  103,103, -1,                  0, 0, {ACT_FAILINIT}},
-
-       {RSP_STRING,  120,120, -1,                121,-1, {ACT_SETVER}},
-
-       {EV_TIMEOUT,  120,121, -1,                  0, 0, {ACT_FAILVER, ACT_INIT}},
-       {RSP_ERROR,   120,121, -1,                  0, 0, {ACT_FAILVER, ACT_INIT}},
-       {RSP_OK,      121,121, -1,                  0, 0, {ACT_GOTVER,  ACT_INIT}},
-#if 0
-       {EV_TIMEOUT,  120,121, -1,                130, 5, {ACT_FAILVER},   "^SGCI=1\r"},
-       {RSP_ERROR,   120,121, -1,                130, 5, {ACT_FAILVER},   "^SGCI=1\r"},
-       {RSP_OK,      121,121, -1,                130, 5, {ACT_GOTVER},    "^SGCI=1\r"},
-
-       {RSP_OK,      130,130, -1,                  0, 0, {ACT_INIT}},
-       {RSP_ERROR,   130,130, -1,                  0, 0, {ACT_FAILINIT}},
-       {EV_TIMEOUT,  130,130, -1,                  0, 0, {ACT_FAILINIT}},
-#endif
-
-       /* leave dle mode */
-       {RSP_INIT,      0,  0,SEQ_DLE0,           201, 5, {0},             "^SDLE=0\r"},
-       {RSP_OK,      201,201, -1,                202,-1},
-       //{RSP_ZDLE,    202,202,  0,                202, 0, {ACT_ERROR}},//DELETE
-       {RSP_ZDLE,    202,202,  0,                  0, 0, {ACT_DLE0}},
-       {RSP_NODEV,   200,249, -1,                  0, 0, {ACT_FAKEDLE0}},
-       {RSP_ERROR,   200,249, -1,                  0, 0, {ACT_FAILDLE0}},
-       {EV_TIMEOUT,  200,249, -1,                  0, 0, {ACT_FAILDLE0}},
-
-       /* enter dle mode */
-       {RSP_INIT,      0,  0,SEQ_DLE1,           251, 5, {0},             "^SDLE=1\r"},
-       {RSP_OK,      251,251, -1,                252,-1},
-       {RSP_ZDLE,    252,252,  1,                  0, 0, {ACT_DLE1}},
-       {RSP_ERROR,   250,299, -1,                  0, 0, {ACT_FAILDLE1}},
-       {EV_TIMEOUT,  250,299, -1,                  0, 0, {ACT_FAILDLE1}},
-
-       /* incoming call */
-       {RSP_RING,     -1, -1, -1,                 -1,-1, {ACT_RING}},
-
-       /* get cid */
-       //{RSP_INIT,      0,  0,300,                901, 0, {ACT_TEST}},
-       //{RSP_ERROR,   901,901, -1,                  0, 0, {ACT_FAILCID}},
-       //{RSP_OK,      901,901, -1,                301, 5, {0},             "^SGCI?\r"},
-
-       {RSP_INIT,      0,  0,SEQ_CID,            301, 5, {0},             "^SGCI?\r"},
-       {RSP_OK,      301,301, -1,                302,-1},
-       {RSP_ZGCI,    302,302, -1,                  0, 0, {ACT_CID}},
-       {RSP_ERROR,   301,349, -1,                  0, 0, {ACT_FAILCID}},
-       {EV_TIMEOUT,  301,349, -1,                  0, 0, {ACT_FAILCID}},
-
-       /* enter cid mode */
-       {RSP_INIT,      0,  0,SEQ_CIDMODE,        150, 5, {0},             "^SGCI=1\r"},
-       {RSP_OK,      150,150, -1,                  0, 0, {ACT_CMODESET}},
-       {RSP_ERROR,   150,150, -1,                  0, 0, {ACT_FAILCMODE}},
-       {EV_TIMEOUT,  150,150, -1,                  0, 0, {ACT_FAILCMODE}},
-
-       /* leave cid mode */
-       //{RSP_INIT,      0,  0,SEQ_UMMODE,         160, 5, {0},             "^SGCI=0\r"},
-       {RSP_INIT,      0,  0,SEQ_UMMODE,         160, 5, {0},             "Z\r"},
-       {RSP_OK,      160,160, -1,                  0, 0, {ACT_UMODESET}},
-       {RSP_ERROR,   160,160, -1,                  0, 0, {ACT_FAILUMODE}},
-       {EV_TIMEOUT,  160,160, -1,                  0, 0, {ACT_FAILUMODE}},
-
-       /* abort getting cid */
-       {RSP_INIT,      0,  0,SEQ_NOCID,            0, 0, {ACT_ABORTCID}},
-
-       /* reset */
-#if 0
-       {RSP_INIT,      0,  0,SEQ_SHUTDOWN,       503, 5, {0},             "^SGCI=0\r"},
-       {RSP_OK,      503,503, -1,                504, 5, {0},             "Z\r"},
-#endif
-       {RSP_INIT,      0,  0,SEQ_SHUTDOWN,       504, 5, {0},             "Z\r"},
-       {RSP_OK,      504,504, -1,                  0, 0, {ACT_SDOWN}},
-       {RSP_ERROR,   501,599, -1,                  0, 0, {ACT_FAILSDOWN}},
-       {EV_TIMEOUT,  501,599, -1,                  0, 0, {ACT_FAILSDOWN}},
-       {RSP_NODEV,   501,599, -1,                  0, 0, {ACT_FAKESDOWN}},
-
-       {EV_PROC_CIDMODE,-1, -1, -1,               -1,-1, {ACT_PROC_CIDMODE}}, //FIXME
-       {EV_IF_LOCK,   -1, -1, -1,                 -1,-1, {ACT_IF_LOCK}}, //FIXME
-       {EV_IF_VER,    -1, -1, -1,                 -1,-1, {ACT_IF_VER}}, //FIXME
-       {EV_START,     -1, -1, -1,                 -1,-1, {ACT_START}}, //FIXME
-       {EV_STOP,      -1, -1, -1,                 -1,-1, {ACT_STOP}}, //FIXME
-       {EV_SHUTDOWN,  -1, -1, -1,                 -1,-1, {ACT_SHUTDOWN}}, //FIXME
-
-       /* misc. */
-       {RSP_EMPTY,    -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZCFGT,    -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZCFG,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZLOG,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZMWI,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZABINFO,  -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZSMLSTCHG,-1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-
-       {RSP_ZCAU,     -1, -1, -1,                 -1,-1, {ACT_ZCAU}},
-       {RSP_NONE,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ANY,      -1, -1, -1,                 -1,-1, {ACT_WARN}},
-       {RSP_LAST}
-};
-
-// 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring, 400: hup, 750: accepted icall
-struct reply_t gigaset_tab_cid_m10x[] = /* for M10x */
-{
-       /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
-
-       /* dial */
-       {EV_DIAL,      -1, -1, -1,                 -1,-1, {ACT_DIAL}}, //FIXME
-       {RSP_INIT,      0,  0,SEQ_DIAL,           601, 5, {ACT_CMD+AT_BC}},
-       {RSP_OK,      601,601, -1,                602, 5, {ACT_CMD+AT_HLC}},
-       {RSP_NULL,    602,602, -1,                603, 5, {ACT_CMD+AT_PROTO}},
-       {RSP_OK,      602,602, -1,                603, 5, {ACT_CMD+AT_PROTO}},
-       {RSP_OK,      603,603, -1,                604, 5, {ACT_CMD+AT_TYPE}},
-       {RSP_OK,      604,604, -1,                605, 5, {ACT_CMD+AT_MSN}},
-       {RSP_OK,      605,605, -1,                606, 5, {ACT_CMD+AT_ISO}},
-       {RSP_NULL,    605,605, -1,                606, 5, {ACT_CMD+AT_ISO}},
-       {RSP_OK,      606,606, -1,                607, 5, {0},             "+VLS=17\r"}, /* set "Endgeraetemodus" */
-       {RSP_OK,      607,607, -1,                608,-1},
-       //{RSP_ZSAU,    608,608,ZSAU_PROCEEDING,    608, 0, {ACT_ERROR}},//DELETE
-       {RSP_ZSAU,    608,608,ZSAU_PROCEEDING,    609, 5, {ACT_CMD+AT_DIAL}},
-       {RSP_OK,      609,609, -1,                650, 0, {ACT_DIALING}},
-
-       {RSP_ZVLS,    608,608, 17,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ZCTP,    609,609, -1,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ZCPN,    609,609, -1,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ERROR,   601,609, -1,                  0, 0, {ACT_ABORTDIAL}},
-       {EV_TIMEOUT,  601,609, -1,                  0, 0, {ACT_ABORTDIAL}},
-
-       /* dialing */
-       {RSP_ZCTP,    650,650, -1,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ZCPN,    650,650, -1,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ZSAU,    650,650,ZSAU_CALL_DELIVERED, -1,-1, {ACT_DEBUG}}, /* some devices don't send this */
-
-       /* connection established  */
-       {RSP_ZSAU,    650,650,ZSAU_ACTIVE,        800,-1, {ACT_CONNECT}}, //FIXME -> DLE1
-       {RSP_ZSAU,    750,750,ZSAU_ACTIVE,        800,-1, {ACT_CONNECT}}, //FIXME -> DLE1
-
-       {EV_BC_OPEN,  800,800, -1,                800,-1, {ACT_NOTIFY_BC_UP}}, //FIXME new constate + timeout
-
-       /* remote hangup */
-       {RSP_ZSAU,    650,650,ZSAU_DISCONNECT_IND,  0, 0, {ACT_REMOTEREJECT}},
-       {RSP_ZSAU,    750,750,ZSAU_DISCONNECT_IND,  0, 0, {ACT_REMOTEHUP}},
-       {RSP_ZSAU,    800,800,ZSAU_DISCONNECT_IND,  0, 0, {ACT_REMOTEHUP}},
-
-       /* hangup */
-       {EV_HUP,       -1, -1, -1,                 -1,-1, {ACT_HUP}}, //FIXME
-       {RSP_INIT,     -1, -1,SEQ_HUP,            401, 5, {0},             "+VLS=0\r"}, /* hang up */ //-1,-1?
-       {RSP_OK,      401,401, -1,                402, 5},
-       {RSP_ZVLS,    402,402,  0,                403, 5},
-       {RSP_ZSAU,    403,403,ZSAU_DISCONNECT_REQ, -1,-1, {ACT_DEBUG}}, /* if not remote hup */
-       //{RSP_ZSAU,    403,403,ZSAU_NULL,          401, 0, {ACT_ERROR}}, //DELETE//FIXME -> DLE0 // should we do this _before_ hanging up for base driver?
-       {RSP_ZSAU,    403,403,ZSAU_NULL,            0, 0, {ACT_DISCONNECT}}, //FIXME -> DLE0 // should we do this _before_ hanging up for base driver?
-       {RSP_NODEV,   401,403, -1,                  0, 0, {ACT_FAKEHUP}}, //FIXME -> DLE0 // should we do this _before_ hanging up for base driver?
-       {RSP_ERROR,   401,401, -1,                  0, 0, {ACT_ABORTHUP}},
-       {EV_TIMEOUT,  401,403, -1,                  0, 0, {ACT_ABORTHUP}},
-
-       {EV_BC_CLOSED,  0,  0, -1,                  0,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME new constate + timeout
-
-       /* ring */
-       {RSP_ZBC,     700,700, -1,                 -1,-1, {0}},
-       {RSP_ZHLC,    700,700, -1,                 -1,-1, {0}},
-       {RSP_NMBR,    700,700, -1,                 -1,-1, {0}},
-       {RSP_ZCPN,    700,700, -1,                 -1,-1, {0}},
-       {RSP_ZCTP,    700,700, -1,                 -1,-1, {0}},
-       {EV_TIMEOUT,  700,700, -1,               720,720, {ACT_ICALL}},
-       {EV_BC_CLOSED,720,720, -1,                  0,-1, {ACT_NOTIFY_BC_DOWN}},
-
-       /*accept icall*/
-       {EV_ACCEPT,    -1, -1, -1,                 -1,-1, {ACT_ACCEPT}}, //FIXME
-       {RSP_INIT,    720,720,SEQ_ACCEPT,         721, 5, {ACT_CMD+AT_PROTO}},
-       {RSP_OK,      721,721, -1,                722, 5, {ACT_CMD+AT_ISO}},
-       {RSP_OK,      722,722, -1,                723, 5, {0},             "+VLS=17\r"}, /* set "Endgeraetemodus" */
-       {RSP_OK,      723,723, -1,                724, 5, {0}},
-       {RSP_ZVLS,    724,724, 17,                750,50, {ACT_ACCEPTED}},
-       {RSP_ERROR,   721,729, -1,                  0, 0, {ACT_ABORTACCEPT}},
-       {EV_TIMEOUT,  721,729, -1,                  0, 0, {ACT_ABORTACCEPT}},
-       {RSP_ZSAU,    700,729,ZSAU_NULL,            0, 0, {ACT_ABORTACCEPT}},
-       {RSP_ZSAU,    700,729,ZSAU_ACTIVE,          0, 0, {ACT_ABORTACCEPT}},
-       {RSP_ZSAU,    700,729,ZSAU_DISCONNECT_IND,  0, 0, {ACT_ABORTACCEPT}},
-
-       {EV_TIMEOUT,  750,750, -1,                  0, 0, {ACT_CONNTIMEOUT}},
-
-       /* B channel closed (general case) */
-       {EV_BC_CLOSED, -1, -1, -1,                 -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME
-
-       /* misc. */
-       {EV_PROTO_L2,  -1, -1, -1,                 -1,-1, {ACT_PROTO_L2}}, //FIXME
-
-       {RSP_ZCON,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZCCR,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZAOC,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-       {RSP_ZCSTR,    -1, -1, -1,                 -1,-1, {ACT_DEBUG}}, //FIXME
-
-       {RSP_ZCAU,     -1, -1, -1,                 -1,-1, {ACT_ZCAU}},
-       {RSP_NONE,     -1, -1, -1,                 -1,-1, {ACT_DEBUG}},
-       {RSP_ANY,      -1, -1, -1,                 -1,-1, {ACT_WARN}},
-       {RSP_LAST}
+/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout,
+ * action, command */
+
+/* initialize device, set cid mode if possible */
+{RSP_INIT,      -1,  -1, SEQ_INIT,             100,  1, {ACT_TIMEOUT} },
+
+{EV_TIMEOUT,   100, 100, -1,                   101,  3, {0},   "Z\r"},
+{RSP_OK,       101, 103, -1,                   120,  5, {ACT_GETSTRING},
+                                                               "+GMR\r"},
+
+{EV_TIMEOUT,   101, 101, -1,                   102,  5, {0},   "Z\r"},
+{RSP_ERROR,    101, 101, -1,                   102,  5, {0},   "Z\r"},
+
+{EV_TIMEOUT,   102, 102, -1,                   108,  5, {ACT_SETDLE1},
+                                                               "^SDLE=0\r"},
+{RSP_OK,       108, 108, -1,                   104, -1},
+{RSP_ZDLE,     104, 104,  0,                   103,  5, {0},   "Z\r"},
+{EV_TIMEOUT,   104, 104, -1,                     0,  0, {ACT_FAILINIT} },
+{RSP_ERROR,    108, 108, -1,                     0,  0, {ACT_FAILINIT} },
+
+{EV_TIMEOUT,   108, 108, -1,                   105,  2, {ACT_SETDLE0,
+                                                         ACT_HUPMODEM,
+                                                         ACT_TIMEOUT} },
+{EV_TIMEOUT,   105, 105, -1,                   103,  5, {0},   "Z\r"},
+
+{RSP_ERROR,    102, 102, -1,                   107,  5, {0},   "^GETPRE\r"},
+{RSP_OK,       107, 107, -1,                     0,  0, {ACT_CONFIGMODE} },
+{RSP_ERROR,    107, 107, -1,                     0,  0, {ACT_FAILINIT} },
+{EV_TIMEOUT,   107, 107, -1,                     0,  0, {ACT_FAILINIT} },
+
+{RSP_ERROR,    103, 103, -1,                     0,  0, {ACT_FAILINIT} },
+{EV_TIMEOUT,   103, 103, -1,                     0,  0, {ACT_FAILINIT} },
+
+{RSP_STRING,   120, 120, -1,                   121, -1, {ACT_SETVER} },
+
+{EV_TIMEOUT,   120, 121, -1,                     0,  0, {ACT_FAILVER,
+                                                         ACT_INIT} },
+{RSP_ERROR,    120, 121, -1,                     0,  0, {ACT_FAILVER,
+                                                         ACT_INIT} },
+{RSP_OK,       121, 121, -1,                     0,  0, {ACT_GOTVER,
+                                                         ACT_INIT} },
+
+/* leave dle mode */
+{RSP_INIT,       0,   0, SEQ_DLE0,             201,  5, {0},   "^SDLE=0\r"},
+{RSP_OK,       201, 201, -1,                   202, -1},
+{RSP_ZDLE,     202, 202,  0,                     0,  0, {ACT_DLE0} },
+{RSP_NODEV,    200, 249, -1,                     0,  0, {ACT_FAKEDLE0} },
+{RSP_ERROR,    200, 249, -1,                     0,  0, {ACT_FAILDLE0} },
+{EV_TIMEOUT,   200, 249, -1,                     0,  0, {ACT_FAILDLE0} },
+
+/* enter dle mode */
+{RSP_INIT,       0,   0, SEQ_DLE1,             251,  5, {0},   "^SDLE=1\r"},
+{RSP_OK,       251, 251, -1,                   252, -1},
+{RSP_ZDLE,     252, 252,  1,                     0,  0, {ACT_DLE1} },
+{RSP_ERROR,    250, 299, -1,                     0,  0, {ACT_FAILDLE1} },
+{EV_TIMEOUT,   250, 299, -1,                     0,  0, {ACT_FAILDLE1} },
+
+/* incoming call */
+{RSP_RING,      -1,  -1, -1,                    -1, -1, {ACT_RING} },
+
+/* get cid */
+{RSP_INIT,       0,   0, SEQ_CID,              301,  5, {0},   "^SGCI?\r"},
+{RSP_OK,       301, 301, -1,                   302, -1},
+{RSP_ZGCI,     302, 302, -1,                     0,  0, {ACT_CID} },
+{RSP_ERROR,    301, 349, -1,                     0,  0, {ACT_FAILCID} },
+{EV_TIMEOUT,   301, 349, -1,                     0,  0, {ACT_FAILCID} },
+
+/* enter cid mode */
+{RSP_INIT,       0,   0, SEQ_CIDMODE,          150,  5, {0},   "^SGCI=1\r"},
+{RSP_OK,       150, 150, -1,                     0,  0, {ACT_CMODESET} },
+{RSP_ERROR,    150, 150, -1,                     0,  0, {ACT_FAILCMODE} },
+{EV_TIMEOUT,   150, 150, -1,                     0,  0, {ACT_FAILCMODE} },
+
+/* leave cid mode */
+{RSP_INIT,       0,   0, SEQ_UMMODE,           160,  5, {0},   "Z\r"},
+{RSP_OK,       160, 160, -1,                     0,  0, {ACT_UMODESET} },
+{RSP_ERROR,    160, 160, -1,                     0,  0, {ACT_FAILUMODE} },
+{EV_TIMEOUT,   160, 160, -1,                     0,  0, {ACT_FAILUMODE} },
+
+/* abort getting cid */
+{RSP_INIT,       0,   0, SEQ_NOCID,              0,  0, {ACT_ABORTCID} },
+
+/* reset */
+{RSP_INIT,       0,   0, SEQ_SHUTDOWN,         504,  5, {0},   "Z\r"},
+{RSP_OK,       504, 504, -1,                     0,  0, {ACT_SDOWN} },
+{RSP_ERROR,    501, 599, -1,                     0,  0, {ACT_FAILSDOWN} },
+{EV_TIMEOUT,   501, 599, -1,                     0,  0, {ACT_FAILSDOWN} },
+{RSP_NODEV,    501, 599, -1,                     0,  0, {ACT_FAKESDOWN} },
+
+{EV_PROC_CIDMODE, -1, -1, -1,                   -1, -1, {ACT_PROC_CIDMODE} },
+{EV_IF_LOCK,    -1,  -1, -1,                    -1, -1, {ACT_IF_LOCK} },
+{EV_IF_VER,     -1,  -1, -1,                    -1, -1, {ACT_IF_VER} },
+{EV_START,      -1,  -1, -1,                    -1, -1, {ACT_START} },
+{EV_STOP,       -1,  -1, -1,                    -1, -1, {ACT_STOP} },
+{EV_SHUTDOWN,   -1,  -1, -1,                    -1, -1, {ACT_SHUTDOWN} },
+
+/* misc. */
+{RSP_ERROR,     -1,  -1, -1,                    -1, -1, {ACT_ERROR} },
+{RSP_ZCFGT,     -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZCFG,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZLOG,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZMWI,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZABINFO,   -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZSMLSTCHG,         -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+
+{RSP_ZCAU,      -1,  -1, -1,                    -1, -1, {ACT_ZCAU} },
+{RSP_NONE,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ANY,       -1,  -1, -1,                    -1, -1, {ACT_WARN} },
+{RSP_LAST}
 };
 
-
-#if 0
-static struct reply_t tab_nocid[]= /* no dle mode */ //FIXME
+/* 600: start dialing, 650: dial in progress, 800: connection is up, 700: ring,
+ * 400: hup, 750: accepted icall */
+struct reply_t gigaset_tab_cid[] =
 {
-       /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
-
-       {RSP_ANY,      -1, -1, -1,                 -1,-1, ACT_WARN,         NULL},
-       {RSP_LAST,0,0,0,0,0,0}
+/* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout,
+ * action, command */
+
+/* dial */
+{EV_DIAL,       -1,  -1, -1,                    -1, -1, {ACT_DIAL} },
+{RSP_INIT,       0,   0, SEQ_DIAL,             601,  5, {ACT_CMD+AT_BC} },
+{RSP_OK,       601, 601, -1,                   602,  5, {ACT_CMD+AT_HLC} },
+{RSP_NULL,     602, 602, -1,                   603,  5, {ACT_CMD+AT_PROTO} },
+{RSP_OK,       602, 602, -1,                   603,  5, {ACT_CMD+AT_PROTO} },
+{RSP_OK,       603, 603, -1,                   604,  5, {ACT_CMD+AT_TYPE} },
+{RSP_OK,       604, 604, -1,                   605,  5, {ACT_CMD+AT_MSN} },
+{RSP_NULL,     605, 605, -1,                   606,  5, {ACT_CMD+AT_CLIP} },
+{RSP_OK,       605, 605, -1,                   606,  5, {ACT_CMD+AT_CLIP} },
+{RSP_NULL,     606, 606, -1,                   607,  5, {ACT_CMD+AT_ISO} },
+{RSP_OK,       606, 606, -1,                   607,  5, {ACT_CMD+AT_ISO} },
+{RSP_OK,       607, 607, -1,                   608,  5, {0},   "+VLS=17\r"},
+{RSP_OK,       608, 608, -1,                   609, -1},
+{RSP_ZSAU,     609, 609, ZSAU_PROCEEDING,      610,  5, {ACT_CMD+AT_DIAL} },
+{RSP_OK,       610, 610, -1,                   650,  0, {ACT_DIALING} },
+
+{RSP_ERROR,    601, 610, -1,                     0,  0, {ACT_ABORTDIAL} },
+{EV_TIMEOUT,   601, 610, -1,                     0,  0, {ACT_ABORTDIAL} },
+
+/* optional dialing responses */
+{EV_BC_OPEN,   650, 650, -1,                   651, -1},
+{RSP_ZVLS,     609, 651, 17,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZCTP,     610, 651, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZCPN,     610, 651, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZSAU,     650, 651, ZSAU_CALL_DELIVERED,   -1, -1, {ACT_DEBUG} },
+
+/* connect */
+{RSP_ZSAU,     650, 650, ZSAU_ACTIVE,          800, -1, {ACT_CONNECT} },
+{RSP_ZSAU,     651, 651, ZSAU_ACTIVE,          800, -1, {ACT_CONNECT,
+                                                         ACT_NOTIFY_BC_UP} },
+{RSP_ZSAU,     750, 750, ZSAU_ACTIVE,          800, -1, {ACT_CONNECT} },
+{RSP_ZSAU,     751, 751, ZSAU_ACTIVE,          800, -1, {ACT_CONNECT,
+                                                         ACT_NOTIFY_BC_UP} },
+{EV_BC_OPEN,   800, 800, -1,                   800, -1, {ACT_NOTIFY_BC_UP} },
+
+/* remote hangup */
+{RSP_ZSAU,     650, 651, ZSAU_DISCONNECT_IND,    0,  0, {ACT_REMOTEREJECT} },
+{RSP_ZSAU,     750, 751, ZSAU_DISCONNECT_IND,    0,  0, {ACT_REMOTEHUP} },
+{RSP_ZSAU,     800, 800, ZSAU_DISCONNECT_IND,    0,  0, {ACT_REMOTEHUP} },
+
+/* hangup */
+{EV_HUP,        -1,  -1, -1,                    -1, -1, {ACT_HUP} },
+{RSP_INIT,      -1,  -1, SEQ_HUP,              401,  5, {0},   "+VLS=0\r"},
+{RSP_OK,       401, 401, -1,                   402,  5},
+{RSP_ZVLS,     402, 402,  0,                   403,  5},
+{RSP_ZSAU,     403, 403, ZSAU_DISCONNECT_REQ,   -1, -1, {ACT_DEBUG} },
+{RSP_ZSAU,     403, 403, ZSAU_NULL,              0,  0, {ACT_DISCONNECT} },
+{RSP_NODEV,    401, 403, -1,                     0,  0, {ACT_FAKEHUP} },
+{RSP_ERROR,    401, 401, -1,                     0,  0, {ACT_ABORTHUP} },
+{EV_TIMEOUT,   401, 403, -1,                     0,  0, {ACT_ABORTHUP} },
+
+{EV_BC_CLOSED,   0,   0, -1,                     0, -1, {ACT_NOTIFY_BC_DOWN} },
+
+/* ring */
+{RSP_ZBC,      700, 700, -1,                    -1, -1, {0} },
+{RSP_ZHLC,     700, 700, -1,                    -1, -1, {0} },
+{RSP_NMBR,     700, 700, -1,                    -1, -1, {0} },
+{RSP_ZCPN,     700, 700, -1,                    -1, -1, {0} },
+{RSP_ZCTP,     700, 700, -1,                    -1, -1, {0} },
+{EV_TIMEOUT,   700, 700, -1,                   720, 720, {ACT_ICALL} },
+{EV_BC_CLOSED, 720, 720, -1,                     0, -1, {ACT_NOTIFY_BC_DOWN} },
+
+/*accept icall*/
+{EV_ACCEPT,     -1,  -1, -1,                    -1, -1, {ACT_ACCEPT} },
+{RSP_INIT,     720, 720, SEQ_ACCEPT,           721,  5, {ACT_CMD+AT_PROTO} },
+{RSP_OK,       721, 721, -1,                   722,  5, {ACT_CMD+AT_ISO} },
+{RSP_OK,       722, 722, -1,                   723,  5, {0},   "+VLS=17\r"},
+{RSP_OK,       723, 723, -1,                   724,  5, {0} },
+{RSP_ZVLS,     724, 724, 17,                   750, 50, {ACT_ACCEPTED} },
+{RSP_ERROR,    721, 729, -1,                     0,  0, {ACT_ABORTACCEPT} },
+{EV_TIMEOUT,   721, 729, -1,                     0,  0, {ACT_ABORTACCEPT} },
+{RSP_ZSAU,     700, 729, ZSAU_NULL,              0,  0, {ACT_ABORTACCEPT} },
+{RSP_ZSAU,     700, 729, ZSAU_ACTIVE,            0,  0, {ACT_ABORTACCEPT} },
+{RSP_ZSAU,     700, 729, ZSAU_DISCONNECT_IND,    0,  0, {ACT_ABORTACCEPT} },
+
+{EV_BC_OPEN,   750, 750, -1,                   751, -1},
+{EV_TIMEOUT,   750, 751, -1,                     0,  0, {ACT_CONNTIMEOUT} },
+
+/* B channel closed (general case) */
+{EV_BC_CLOSED,  -1,  -1, -1,                    -1, -1, {ACT_NOTIFY_BC_DOWN} },
+
+/* misc. */
+{RSP_ZCON,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZCCR,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZAOC,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ZCSTR,     -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+
+{RSP_ZCAU,      -1,  -1, -1,                    -1, -1, {ACT_ZCAU} },
+{RSP_NONE,      -1,  -1, -1,                    -1, -1, {ACT_DEBUG} },
+{RSP_ANY,       -1,  -1, -1,                    -1, -1, {ACT_WARN} },
+{RSP_LAST}
 };
 
-static struct reply_t tab_cid[] = /* no dle mode */ //FIXME
-{
-       /* resp_code, min_ConState, max_ConState, parameter, new_ConState, timeout, action, command */
-
-       {RSP_ANY,      -1, -1, -1,                 -1,-1, ACT_WARN,         NULL},
-       {RSP_LAST,0,0,0,0,0,0}
-};
-#endif
 
-static struct resp_type_t resp_type[]=
+static const struct resp_type_t {
+       unsigned char   *response;
+       int             resp_code;
+       int             type;
+} resp_type[] =
 {
-       /*{"",          RSP_EMPTY,      RT_NOTHING},*/
        {"OK",          RSP_OK,         RT_NOTHING},
        {"ERROR",       RSP_ERROR,      RT_NOTHING},
        {"ZSAU",        RSP_ZSAU,       RT_ZSAU},
@@ -435,7 +403,21 @@ static struct resp_type_t resp_type[]=
        {"ZLOG",        RSP_ZLOG,       RT_NOTHING},
        {"ZABINFO",     RSP_ZABINFO,    RT_NOTHING},
        {"ZSMLSTCHG",   RSP_ZSMLSTCHG,  RT_NOTHING},
-       {NULL,0,0}
+       {NULL,          0,              0}
+};
+
+static const struct zsau_resp_t {
+       unsigned char   *str;
+       int             code;
+} zsau_resp[] =
+{
+       {"OUTGOING_CALL_PROCEEDING",    ZSAU_OUTGOING_CALL_PROCEEDING},
+       {"CALL_DELIVERED",              ZSAU_CALL_DELIVERED},
+       {"ACTIVE",                      ZSAU_ACTIVE},
+       {"DISCONNECT_IND",              ZSAU_DISCONNECT_IND},
+       {"NULL",                        ZSAU_NULL},
+       {"DISCONNECT_REQ",              ZSAU_DISCONNECT_REQ},
+       {NULL,                          ZSAU_UNKNOWN}
 };
 
 /*
@@ -500,18 +482,23 @@ static int cid_of_response(char *s)
        if (cid < 1 || cid > 65535)
                return -1;      /* CID out of range */
        return cid;
-       //FIXME is ;<digit>+ at end of non-CID response really impossible?
 }
 
-/* This function will be called via task queue from the callback handler.
- * We received a modem response and have to handle it..
+/**
+ * gigaset_handle_modem_response() - process received modem response
+ * @cs:                device descriptor structure.
+ *
+ * Called by asyncdata/isocdata if a block of data received from the
+ * device must be processed as a modem command response. The data is
+ * already in the cs structure.
  */
 void gigaset_handle_modem_response(struct cardstate *cs)
 {
        unsigned char *argv[MAX_REC_PARAMS + 1];
        int params;
        int i, j;
-       struct resp_type_t *rt;
+       const struct resp_type_t *rt;
+       const struct zsau_resp_t *zr;
        int curarg;
        unsigned long flags;
        unsigned next, tail, head;
@@ -638,24 +625,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
                                event->parameter = ZSAU_NONE;
                                break;
                        }
-                       if (!strcmp(argv[curarg], "OUTGOING_CALL_PROCEEDING"))
-                               event->parameter = ZSAU_OUTGOING_CALL_PROCEEDING;
-                       else if (!strcmp(argv[curarg], "CALL_DELIVERED"))
-                               event->parameter = ZSAU_CALL_DELIVERED;
-                       else if (!strcmp(argv[curarg], "ACTIVE"))
-                               event->parameter = ZSAU_ACTIVE;
-                       else if (!strcmp(argv[curarg], "DISCONNECT_IND"))
-                               event->parameter = ZSAU_DISCONNECT_IND;
-                       else if (!strcmp(argv[curarg], "NULL"))
-                               event->parameter = ZSAU_NULL;
-                       else if (!strcmp(argv[curarg], "DISCONNECT_REQ"))
-                               event->parameter = ZSAU_DISCONNECT_REQ;
-                       else {
-                               event->parameter = ZSAU_UNKNOWN;
+                       for (zr = zsau_resp; zr->str; ++zr)
+                               if (!strcmp(argv[curarg], zr->str))
+                                       break;
+                       event->parameter = zr->code;
+                       if (!zr->str)
                                dev_warn(cs->dev,
                                        "%s: unknown parameter %s after ZSAU\n",
                                         __func__, argv[curarg]);
-                       }
                        ++curarg;
                        break;
                case RT_STRING:
@@ -665,13 +642,8 @@ void gigaset_handle_modem_response(struct cardstate *cs)
                                        dev_err(cs->dev, "out of memory\n");
                                ++curarg;
                        }
-#ifdef CONFIG_GIGASET_DEBUG
-                       if (!event->ptr)
-                               gig_dbg(DEBUG_CMD, "string==NULL");
-                       else
-                               gig_dbg(DEBUG_CMD, "string==%s",
-                                       (char *) event->ptr);
-#endif
+                       gig_dbg(DEBUG_CMD, "string==%s",
+                               event->ptr ? (char *) event->ptr : "NULL");
                        break;
                case RT_ZCAU:
                        event->parameter = -1;
@@ -697,9 +669,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
                                ++curarg;
                        } else
                                event->parameter = -1;
-#ifdef CONFIG_GIGASET_DEBUG
                        gig_dbg(DEBUG_CMD, "parameter==%d", event->parameter);
-#endif
                        break;
                }
 
@@ -735,7 +705,7 @@ static void disconnect(struct at_state_t **at_state_p)
        /* revert to selected idle mode */
        if (!cs->cidmode) {
                cs->at_state.pending_commands |= PC_UMMODE;
-               atomic_set(&cs->commands_pending, 1); //FIXME
+               cs->commands_pending = 1;
                gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
        }
        spin_unlock_irqrestore(&cs->lock, flags);
@@ -743,6 +713,11 @@ static void disconnect(struct at_state_t **at_state_p)
        if (bcs) {
                /* B channel assigned: invoke hardware specific handler */
                cs->ops->close_bchannel(bcs);
+               /* notify LL */
+               if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
+                       bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
+                       gigaset_isdn_hupD(bcs);
+               }
        } else {
                /* no B channel assigned: just deallocate */
                spin_lock_irqsave(&cs->lock, flags);
@@ -793,15 +768,15 @@ static void init_failed(struct cardstate *cs, int mode)
        struct at_state_t *at_state;
 
        cs->at_state.pending_commands &= ~PC_INIT;
-       atomic_set(&cs->mode, mode);
-       atomic_set(&cs->mstate, MS_UNINITIALIZED);
+       cs->mode = mode;
+       cs->mstate = MS_UNINITIALIZED;
        gigaset_free_channels(cs);
        for (i = 0; i < cs->channels; ++i) {
                at_state = &cs->bcs[i].at_state;
                if (at_state->pending_commands & PC_CID) {
                        at_state->pending_commands &= ~PC_CID;
                        at_state->pending_commands |= PC_NOCID;
-                       atomic_set(&cs->commands_pending, 1);
+                       cs->commands_pending = 1;
                }
        }
 }
@@ -812,11 +787,11 @@ static void schedule_init(struct cardstate *cs, int state)
                gig_dbg(DEBUG_CMD, "not scheduling PC_INIT again");
                return;
        }
-       atomic_set(&cs->mstate, state);
-       atomic_set(&cs->mode, M_UNKNOWN);
+       cs->mstate = state;
+       cs->mode = M_UNKNOWN;
        gigaset_block_channels(cs);
        cs->at_state.pending_commands |= PC_INIT;
-       atomic_set(&cs->commands_pending, 1);
+       cs->commands_pending = 1;
        gig_dbg(DEBUG_CMD, "Scheduling PC_INIT");
 }
 
@@ -899,12 +874,12 @@ static void bchannel_down(struct bc_state *bcs)
 {
        if (bcs->chstate & CHS_B_UP) {
                bcs->chstate &= ~CHS_B_UP;
-               gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BHUP);
+               gigaset_isdn_hupB(bcs);
        }
 
        if (bcs->chstate & (CHS_D_UP | CHS_NOTIFY_LL)) {
                bcs->chstate &= ~(CHS_D_UP | CHS_NOTIFY_LL);
-               gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DHUP);
+               gigaset_isdn_hupD(bcs);
        }
 
        gigaset_free_channel(bcs);
@@ -914,12 +889,6 @@ static void bchannel_down(struct bc_state *bcs)
 
 static void bchannel_up(struct bc_state *bcs)
 {
-       if (!(bcs->chstate & CHS_D_UP)) {
-               dev_notice(bcs->cs->dev, "%s: D channel not up\n", __func__);
-               bcs->chstate |= CHS_D_UP;
-               gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
-       }
-
        if (bcs->chstate & CHS_B_UP) {
                dev_notice(bcs->cs->dev, "%s: B channel already up\n",
                           __func__);
@@ -927,15 +896,17 @@ static void bchannel_up(struct bc_state *bcs)
        }
 
        bcs->chstate |= CHS_B_UP;
-       gigaset_i4l_channel_cmd(bcs, ISDN_STAT_BCONN);
+       gigaset_isdn_connB(bcs);
 }
 
-static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_index)
+static void start_dial(struct at_state_t *at_state, void *data,
+                       unsigned seq_index)
 {
        struct bc_state *bcs = at_state->bcs;
        struct cardstate *cs = at_state->cs;
-       int retval;
+       char **commands = data;
        unsigned long flags;
+       int i;
 
        bcs->chstate |= CHS_NOTIFY_LL;
 
@@ -946,53 +917,66 @@ static void start_dial(struct at_state_t *at_state, void *data, unsigned seq_ind
        }
        spin_unlock_irqrestore(&cs->lock, flags);
 
-       retval = gigaset_isdn_setup_dial(at_state, data);
-       if (retval != 0)
-               goto error;
-
+       for (i = 0; i < AT_NUM; ++i) {
+               kfree(bcs->commands[i]);
+               bcs->commands[i] = commands[i];
+       }
 
        at_state->pending_commands |= PC_CID;
        gig_dbg(DEBUG_CMD, "Scheduling PC_CID");
-       atomic_set(&cs->commands_pending, 1);
+       cs->commands_pending = 1;
        return;
 
 error:
+       for (i = 0; i < AT_NUM; ++i) {
+               kfree(commands[i]);
+               commands[i] = NULL;
+       }
        at_state->pending_commands |= PC_NOCID;
        gig_dbg(DEBUG_CMD, "Scheduling PC_NOCID");
-       atomic_set(&cs->commands_pending, 1);
+       cs->commands_pending = 1;
        return;
 }
 
 static void start_accept(struct at_state_t *at_state)
 {
        struct cardstate *cs = at_state->cs;
-       int retval;
+       struct bc_state *bcs = at_state->bcs;
+       int i;
 
-       retval = gigaset_isdn_setup_accept(at_state);
+       for (i = 0; i < AT_NUM; ++i) {
+               kfree(bcs->commands[i]);
+               bcs->commands[i] = NULL;
+       }
 
-       if (retval == 0) {
-               at_state->pending_commands |= PC_ACCEPT;
-               gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
-               atomic_set(&cs->commands_pending, 1);
-       } else {
-               //FIXME
+       bcs->commands[AT_PROTO] = kmalloc(9, GFP_ATOMIC);
+       bcs->commands[AT_ISO] = kmalloc(9, GFP_ATOMIC);
+       if (!bcs->commands[AT_PROTO] || !bcs->commands[AT_ISO]) {
+               dev_err(at_state->cs->dev, "out of memory\n");
+               /* error reset */
                at_state->pending_commands |= PC_HUP;
                gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
+               return;
        }
+
+       snprintf(bcs->commands[AT_PROTO], 9, "^SBPR=%u\r", bcs->proto2);
+       snprintf(bcs->commands[AT_ISO], 9, "^SISO=%u\r", bcs->channel + 1);
+
+       at_state->pending_commands |= PC_ACCEPT;
+       gig_dbg(DEBUG_CMD, "Scheduling PC_ACCEPT");
+       cs->commands_pending = 1;
 }
 
 static void do_start(struct cardstate *cs)
 {
        gigaset_free_channels(cs);
 
-       if (atomic_read(&cs->mstate) != MS_LOCKED)
+       if (cs->mstate != MS_LOCKED)
                schedule_init(cs, MS_INIT);
 
        cs->isdn_up = 1;
-       gigaset_i4l_cmd(cs, ISDN_STAT_RUN);
-                                       // FIXME: not in locked mode
-                                       // FIXME 2: only after init sequence
+       gigaset_isdn_start(cs);
 
        cs->waiting = 0;
        wake_up(&cs->waitqueue);
@@ -1000,32 +984,32 @@ static void do_start(struct cardstate *cs)
 
 static void finish_shutdown(struct cardstate *cs)
 {
-       if (atomic_read(&cs->mstate) != MS_LOCKED) {
-               atomic_set(&cs->mstate, MS_UNINITIALIZED);
-               atomic_set(&cs->mode, M_UNKNOWN);
+       if (cs->mstate != MS_LOCKED) {
+               cs->mstate = MS_UNINITIALIZED;
+               cs->mode = M_UNKNOWN;
        }
 
        /* Tell the LL that the device is not available .. */
        if (cs->isdn_up) {
                cs->isdn_up = 0;
-               gigaset_i4l_cmd(cs, ISDN_STAT_STOP);
+               gigaset_isdn_stop(cs);
        }
 
        /* The rest is done by cleanup_cs () in user mode. */
 
        cs->cmd_result = -ENODEV;
        cs->waiting = 0;
-       wake_up_interruptible(&cs->waitqueue);
+       wake_up(&cs->waitqueue);
 }
 
 static void do_shutdown(struct cardstate *cs)
 {
        gigaset_block_channels(cs);
 
-       if (atomic_read(&cs->mstate) == MS_READY) {
-               atomic_set(&cs->mstate, MS_SHUTDOWN);
+       if (cs->mstate == MS_READY) {
+               cs->mstate = MS_SHUTDOWN;
                cs->at_state.pending_commands |= PC_SHUTDOWN;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                gig_dbg(DEBUG_CMD, "Scheduling PC_SHUTDOWN");
        } else
                finish_shutdown(cs);
@@ -1120,7 +1104,7 @@ static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
                 * In fact it doesn't.
                 */
                at_state->pending_commands |= PC_HUP;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                break;
        }
 }
@@ -1130,7 +1114,7 @@ static int do_lock(struct cardstate *cs)
        int mode;
        int i;
 
-       switch (atomic_read(&cs->mstate)) {
+       switch (cs->mstate) {
        case MS_UNINITIALIZED:
        case MS_READY:
                if (cs->cur_at_seq || !list_empty(&cs->temp_at_states) ||
@@ -1146,26 +1130,25 @@ static int do_lock(struct cardstate *cs)
 
                break;
        case MS_LOCKED:
-               //retval = -EACCES;
                break;
        default:
                return -EBUSY;
        }
 
-       mode = atomic_read(&cs->mode);
-       atomic_set(&cs->mstate, MS_LOCKED);
-       atomic_set(&cs->mode, M_UNKNOWN);
+       mode = cs->mode;
+       cs->mstate = MS_LOCKED;
+       cs->mode = M_UNKNOWN;
 
        return mode;
 }
 
 static int do_unlock(struct cardstate *cs)
 {
-       if (atomic_read(&cs->mstate) != MS_LOCKED)
+       if (cs->mstate != MS_LOCKED)
                return -EINVAL;
 
-       atomic_set(&cs->mstate, MS_UNINITIALIZED);
-       atomic_set(&cs->mode, M_UNKNOWN);
+       cs->mstate = MS_UNINITIALIZED;
+       cs->mode = M_UNKNOWN;
        gigaset_free_channels(cs);
        if (cs->connected)
                schedule_init(cs, MS_INIT);
@@ -1198,17 +1181,17 @@ static void do_action(int action, struct cardstate *cs,
        case ACT_INIT:
                cs->at_state.pending_commands &= ~PC_INIT;
                cs->cur_at_seq = SEQ_NONE;
-               atomic_set(&cs->mode, M_UNIMODEM);
+               cs->mode = M_UNIMODEM;
                spin_lock_irqsave(&cs->lock, flags);
                if (!cs->cidmode) {
                        spin_unlock_irqrestore(&cs->lock, flags);
                        gigaset_free_channels(cs);
-                       atomic_set(&cs->mstate, MS_READY);
+                       cs->mstate = MS_READY;
                        break;
                }
                spin_unlock_irqrestore(&cs->lock, flags);
                cs->at_state.pending_commands |= PC_CIDMODE;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
                break;
        case ACT_FAILINIT:
@@ -1234,22 +1217,20 @@ static void do_action(int action, struct cardstate *cs,
                        | INS_command;
                break;
        case ACT_CMODESET:
-               if (atomic_read(&cs->mstate) == MS_INIT ||
-                   atomic_read(&cs->mstate) == MS_RECOVER) {
+               if (cs->mstate == MS_INIT || cs->mstate == MS_RECOVER) {
                        gigaset_free_channels(cs);
-                       atomic_set(&cs->mstate, MS_READY);
+                       cs->mstate = MS_READY;
                }
-               atomic_set(&cs->mode, M_CID);
+               cs->mode = M_CID;
                cs->cur_at_seq = SEQ_NONE;
                break;
        case ACT_UMODESET:
-               atomic_set(&cs->mode, M_UNIMODEM);
+               cs->mode = M_UNIMODEM;
                cs->cur_at_seq = SEQ_NONE;
                break;
        case ACT_FAILCMODE:
                cs->cur_at_seq = SEQ_NONE;
-               if (atomic_read(&cs->mstate) == MS_INIT ||
-                   atomic_read(&cs->mstate) == MS_RECOVER) {
+               if (cs->mstate == MS_INIT || cs->mstate == MS_RECOVER) {
                        init_failed(cs, M_UNKNOWN);
                        break;
                }
@@ -1307,11 +1288,11 @@ static void do_action(int action, struct cardstate *cs,
        case ACT_CONNECT:
                if (cs->onechannel) {
                        at_state->pending_commands |= PC_DLE1;
-                       atomic_set(&cs->commands_pending, 1);
+                       cs->commands_pending = 1;
                        break;
                }
                bcs->chstate |= CHS_D_UP;
-               gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
+               gigaset_isdn_connD(bcs);
                cs->ops->init_bchannel(bcs);
                break;
        case ACT_DLE1:
@@ -1319,7 +1300,7 @@ static void do_action(int action, struct cardstate *cs,
                bcs = cs->bcs + cs->curchannel;
 
                bcs->chstate |= CHS_D_UP;
-               gigaset_i4l_channel_cmd(bcs, ISDN_STAT_DCONN);
+               gigaset_isdn_connD(bcs);
                cs->ops->init_bchannel(bcs);
                break;
        case ACT_FAKEHUP:
@@ -1333,7 +1314,7 @@ static void do_action(int action, struct cardstate *cs,
                         * DLE only used for M10x with one B channel.
                         */
                        at_state->pending_commands |= PC_DLE0;
-                       atomic_set(&cs->commands_pending, 1);
+                       cs->commands_pending = 1;
                } else
                        disconnect(p_at_state);
                break;
@@ -1369,7 +1350,7 @@ static void do_action(int action, struct cardstate *cs,
                         "Could not enter DLE mode. Trying to hang up.\n");
                channel = cs->curchannel;
                cs->bcs[channel].at_state.pending_commands |= PC_HUP;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                break;
 
        case ACT_CID: /* got cid; start dialing */
@@ -1379,7 +1360,7 @@ static void do_action(int action, struct cardstate *cs,
                        cs->bcs[channel].at_state.cid = ev->parameter;
                        cs->bcs[channel].at_state.pending_commands |=
                                PC_DIAL;
-                       atomic_set(&cs->commands_pending, 1);
+                       cs->commands_pending = 1;
                        break;
                }
                /* fall through */
@@ -1404,21 +1385,21 @@ static void do_action(int action, struct cardstate *cs,
                cs->cur_at_seq = SEQ_NONE;
                break;
 
-       case ACT_ABORTACCEPT:   /* hangup/error/timeout during ICALL processing */
+       case ACT_ABORTACCEPT:   /* hangup/error/timeout during ICALL procssng */
                disconnect(p_at_state);
                break;
 
        case ACT_ABORTDIAL:     /* error/timeout during dial preparation */
                cs->cur_at_seq = SEQ_NONE;
                at_state->pending_commands |= PC_HUP;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                break;
 
        case ACT_REMOTEREJECT:  /* DISCONNECT_IND after dialling */
        case ACT_CONNTIMEOUT:   /* timeout waiting for ZSAU=ACTIVE */
        case ACT_REMOTEHUP:     /* DISCONNECT_IND with established connection */
                at_state->pending_commands |= PC_HUP;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                break;
        case ACT_GETSTRING: /* warning: RING, ZDLE, ...
                               are not handled properly anymore */
@@ -1473,21 +1454,11 @@ static void do_action(int action, struct cardstate *cs,
                cs->gotfwver = -1;
                dev_err(cs->dev, "could not read firmware version.\n");
                break;
-#ifdef CONFIG_GIGASET_DEBUG
        case ACT_ERROR:
-               *p_genresp = 1;
-               *p_resp_code = RSP_ERROR;
-               break;
-       case ACT_TEST:
-               {
-                       static int count = 3; //2; //1;
-                       *p_genresp = 1;
-                       *p_resp_code = count ? RSP_ERROR : RSP_OK;
-                       if (count > 0)
-                               --count;
-               }
+               gig_dbg(DEBUG_ANY, "%s: ERROR response in ConState %d",
+                       __func__, at_state->ConState);
+               cs->cur_at_seq = SEQ_NONE;
                break;
-#endif
        case ACT_DEBUG:
                gig_dbg(DEBUG_ANY, "%s: resp_code %d in ConState %d",
                        __func__, ev->type, at_state->ConState);
@@ -1508,14 +1479,9 @@ static void do_action(int action, struct cardstate *cs,
        case ACT_ACCEPT:
                start_accept(at_state);
                break;
-       case ACT_PROTO_L2:
-               gig_dbg(DEBUG_CMD, "set protocol to %u",
-                       (unsigned) ev->parameter);
-               at_state->bcs->proto2 = ev->parameter;
-               break;
        case ACT_HUP:
                at_state->pending_commands |= PC_HUP;
-               atomic_set(&cs->commands_pending, 1);
+               cs->commands_pending = 1;
                gig_dbg(DEBUG_CMD, "Scheduling PC_HUP");
                break;
 
@@ -1527,7 +1493,7 @@ static void do_action(int action, struct cardstate *cs,
                do_start(cs);
                break;
 
-       /* events from the interface */ // FIXME without ACT_xxxx?
+       /* events from the interface */
        case ACT_IF_LOCK:
                cs->cmd_result = ev->parameter ? do_lock(cs) : do_unlock(cs);
                cs->waiting = 0;
@@ -1546,7 +1512,7 @@ static void do_action(int action, struct cardstate *cs,
                wake_up(&cs->waitqueue);
                break;
 
-       /* events from the proc file system */ // FIXME without ACT_xxxx?
+       /* events from the proc file system */
        case ACT_PROC_CIDMODE:
                spin_lock_irqsave(&cs->lock, flags);
                if (ev->parameter != cs->cidmode) {
@@ -1558,7 +1524,7 @@ static void do_action(int action, struct cardstate *cs,
                                cs->at_state.pending_commands |= PC_UMMODE;
                                gig_dbg(DEBUG_CMD, "Scheduling PC_UMMODE");
                        }
-                       atomic_set(&cs->commands_pending, 1);
+                       cs->commands_pending = 1;
                }
                spin_unlock_irqrestore(&cs->lock, flags);
                cs->waiting = 0;
@@ -1683,7 +1649,8 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
        for (curact = 0; curact < MAXACT; ++curact) {
                /* The row tells us what we should do  ..
                 */
-               do_action(rep->action[curact], cs, bcs, &at_state, &p_command, &genresp, &resp_code, ev);
+               do_action(rep->action[curact], cs, bcs, &at_state, &p_command,
+                         &genresp, &resp_code, ev);
                if (!at_state)
                        break; /* may be freed after disconnect */
        }
@@ -1695,13 +1662,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
 
                if (genresp) {
                        spin_lock_irqsave(&cs->lock, flags);
-                       at_state->timer_expires = 0; //FIXME
-                       at_state->timer_active = 0; //FIXME
+                       at_state->timer_expires = 0;
+                       at_state->timer_active = 0;
                        spin_unlock_irqrestore(&cs->lock, flags);
-                       gigaset_add_event(cs, at_state, resp_code, NULL, 0, NULL);
+                       gigaset_add_event(cs, at_state, resp_code,
+                                         NULL, 0, NULL);
                } else {
                        /* Send command to modem if not NULL... */
-                       if (p_command/*rep->command*/) {
+                       if (p_command) {
                                if (cs->connected)
                                        send_command(cs, p_command,
                                                     sendcid, cs->dle,
@@ -1741,7 +1709,7 @@ static void process_command_flags(struct cardstate *cs)
        int sequence;
        unsigned long flags;
 
-       atomic_set(&cs->commands_pending, 0);
+       cs->commands_pending = 0;
 
        if (cs->cur_at_seq) {
                gig_dbg(DEBUG_CMD, "not searching scheduled commands: busy");
@@ -1779,7 +1747,7 @@ static void process_command_flags(struct cardstate *cs)
                                ~(PC_DLE1 | PC_ACCEPT | PC_DIAL);
                        if (at_state->cid > 0)
                                at_state->pending_commands |= PC_HUP;
-                       if (atomic_read(&cs->mstate) == MS_RECOVER) {
+                       if (cs->mstate == MS_RECOVER) {
                                if (at_state->pending_commands & PC_CID) {
                                        at_state->pending_commands |= PC_NOCID;
                                        at_state->pending_commands &= ~PC_CID;
@@ -1788,12 +1756,13 @@ static void process_command_flags(struct cardstate *cs)
                }
        }
 
-       /* only switch back to unimodem mode, if no commands are pending and no channels are up */
+       /* only switch back to unimodem mode if no commands are pending and
+        * no channels are up */
        spin_lock_irqsave(&cs->lock, flags);
        if (cs->at_state.pending_commands == PC_UMMODE
            && !cs->cidmode
            && list_empty(&cs->temp_at_states)
-           && atomic_read(&cs->mode) == M_CID) {
+           && cs->mode == M_CID) {
                sequence = SEQ_UMMODE;
                at_state = &cs->at_state;
                for (i = 0; i < cs->channels; ++i) {
@@ -1847,9 +1816,8 @@ static void process_command_flags(struct cardstate *cs)
 
        if (cs->at_state.pending_commands & PC_INIT) {
                cs->at_state.pending_commands &= ~PC_INIT;
-               cs->dle = 0; //FIXME
+               cs->dle = 0;
                cs->inbuf->inputstate = INS_command;
-               //FIXME reset card state (or -> LOCK0)?
                schedule_sequence(cs, &cs->at_state, SEQ_INIT);
                return;
        }
@@ -1860,7 +1828,7 @@ static void process_command_flags(struct cardstate *cs)
        }
        if (cs->at_state.pending_commands & PC_CIDMODE) {
                cs->at_state.pending_commands &= ~PC_CIDMODE;
-               if (atomic_read(&cs->mode) == M_UNIMODEM) {
+               if (cs->mode == M_UNIMODEM) {
                        cs->retry_count = 1;
                        schedule_sequence(cs, &cs->at_state, SEQ_CIDMODE);
                        return;
@@ -1886,11 +1854,11 @@ static void process_command_flags(struct cardstate *cs)
                        return;
                }
                if (bcs->at_state.pending_commands & PC_CID) {
-                       switch (atomic_read(&cs->mode)) {
+                       switch (cs->mode) {
                        case M_UNIMODEM:
                                cs->at_state.pending_commands |= PC_CIDMODE;
                                gig_dbg(DEBUG_CMD, "Scheduling PC_CIDMODE");
-                               atomic_set(&cs->commands_pending, 1);
+                               cs->commands_pending = 1;
                                return;
 #ifdef GIG_MAYINITONDIAL
                        case M_UNKNOWN:
@@ -1926,7 +1894,7 @@ static void process_events(struct cardstate *cs)
        for (i = 0; i < 2 * MAX_EVENTS; ++i) {
                tail = cs->ev_tail;
                if (tail == head) {
-                       if (!check_flags && !atomic_read(&cs->commands_pending))
+                       if (!check_flags && !cs->commands_pending)
                                break;
                        check_flags = 0;
                        spin_unlock_irqrestore(&cs->ev_lock, flags);
@@ -1934,7 +1902,7 @@ static void process_events(struct cardstate *cs)
                        spin_lock_irqsave(&cs->ev_lock, flags);
                        tail = cs->ev_tail;
                        if (tail == head) {
-                               if (!atomic_read(&cs->commands_pending))
+                               if (!cs->commands_pending)
                                        break;
                                continue;
                        }
@@ -1971,7 +1939,7 @@ void gigaset_handle_event(unsigned long data)
        struct cardstate *cs = (struct cardstate *) data;
 
        /* handle incoming data on control/common channel */
-       if (atomic_read(&cs->inbuf->head) != atomic_read(&cs->inbuf->tail)) {
+       if (cs->inbuf->head != cs->inbuf->tail) {
                gig_dbg(DEBUG_INTR, "processing new data");
                cs->ops->handle_input(cs->inbuf);
        }