aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2013-01-21 06:57:21 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-21 17:36:26 -0500
commit63b203b43baeb1ba5fab0b7f3611e0f0a2a4a7ab (patch)
treec3edd64d1091dae7adab77391dad64796f7ab55b /drivers
parentbc882b1880b94d3731b462d3a213885073b350ed (diff)
isdn/gigaset: beautify ev-layer.c
Cosmetic changes to drivers/isdn/gigaset/ev-layer.c and drivers/isdn/gigaset/gigaset.h to improve readability. Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/isdn/gigaset/ev-layer.c119
-rw-r--r--drivers/isdn/gigaset/gigaset.h9
2 files changed, 64 insertions, 64 deletions
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index e2383ece8e2e..7459b127ddd5 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -351,10 +351,11 @@ struct reply_t gigaset_tab_cid[] =
351 351
352 352
353static const struct resp_type_t { 353static const struct resp_type_t {
354 unsigned char *response; 354 char *response;
355 int resp_code; 355 int resp_code;
356 int type; 356 int type;
357} resp_type[] = 357}
358resp_type[] =
358{ 359{
359 {"OK", RSP_OK, RT_NOTHING}, 360 {"OK", RSP_OK, RT_NOTHING},
360 {"ERROR", RSP_ERROR, RT_NOTHING}, 361 {"ERROR", RSP_ERROR, RT_NOTHING},
@@ -374,11 +375,12 @@ static const struct resp_type_t {
374}; 375};
375 376
376static const struct zsau_resp_t { 377static const struct zsau_resp_t {
377 unsigned char *str; 378 char *str;
378 int code; 379 int code;
379} zsau_resp[] = 380}
381zsau_resp[] =
380{ 382{
381 {"OUTGOING_CALL_PROCEEDING", ZSAU_OUTGOING_CALL_PROCEEDING}, 383 {"OUTGOING_CALL_PROCEEDING", ZSAU_PROCEEDING},
382 {"CALL_DELIVERED", ZSAU_CALL_DELIVERED}, 384 {"CALL_DELIVERED", ZSAU_CALL_DELIVERED},
383 {"ACTIVE", ZSAU_ACTIVE}, 385 {"ACTIVE", ZSAU_ACTIVE},
384 {"DISCONNECT_IND", ZSAU_DISCONNECT_IND}, 386 {"DISCONNECT_IND", ZSAU_DISCONNECT_IND},
@@ -434,7 +436,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
434 len = cs->cbytes; 436 len = cs->cbytes;
435 if (!len) { 437 if (!len) {
436 /* ignore additional LFs/CRs (M10x config mode or cx100) */ 438 /* ignore additional LFs/CRs (M10x config mode or cx100) */
437 gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]); 439 gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[0]);
438 return; 440 return;
439 } 441 }
440 cs->respdata[len] = 0; 442 cs->respdata[len] = 0;
@@ -707,27 +709,29 @@ static void schedule_init(struct cardstate *cs, int state)
707 cs->commands_pending = 1; 709 cs->commands_pending = 1;
708} 710}
709 711
710/* Add "AT" to a command, add the cid, dle encode it, send the result to the 712/* send an AT command
711 hardware. */ 713 * adding the "AT" prefix, cid and DLE encapsulation as appropriate
712static void send_command(struct cardstate *cs, const char *cmd, int cid, 714 */
713 int dle, gfp_t kmallocflags) 715static void send_command(struct cardstate *cs, const char *cmd,
716 struct at_state_t *at_state)
714{ 717{
718 int cid = at_state->cid;
715 struct cmdbuf_t *cb; 719 struct cmdbuf_t *cb;
716 size_t buflen; 720 size_t buflen;
717 721
718 buflen = strlen(cmd) + 12; /* DLE ( A T 1 2 3 4 5 <cmd> DLE ) \0 */ 722 buflen = strlen(cmd) + 12; /* DLE ( A T 1 2 3 4 5 <cmd> DLE ) \0 */
719 cb = kmalloc(sizeof(struct cmdbuf_t) + buflen, kmallocflags); 723 cb = kmalloc(sizeof(struct cmdbuf_t) + buflen, GFP_ATOMIC);
720 if (!cb) { 724 if (!cb) {
721 dev_err(cs->dev, "%s: out of memory\n", __func__); 725 dev_err(cs->dev, "%s: out of memory\n", __func__);
722 return; 726 return;
723 } 727 }
724 if (cid > 0 && cid <= 65535) 728 if (cid > 0 && cid <= 65535)
725 cb->len = snprintf(cb->buf, buflen, 729 cb->len = snprintf(cb->buf, buflen,
726 dle ? "\020(AT%d%s\020)" : "AT%d%s", 730 cs->dle ? "\020(AT%d%s\020)" : "AT%d%s",
727 cid, cmd); 731 cid, cmd);
728 else 732 else
729 cb->len = snprintf(cb->buf, buflen, 733 cb->len = snprintf(cb->buf, buflen,
730 dle ? "\020(AT%s\020)" : "AT%s", 734 cs->dle ? "\020(AT%s\020)" : "AT%s",
731 cmd); 735 cmd);
732 cb->offset = 0; 736 cb->offset = 0;
733 cb->next = NULL; 737 cb->next = NULL;
@@ -886,7 +890,7 @@ static void finish_shutdown(struct cardstate *cs)
886 gigaset_isdn_stop(cs); 890 gigaset_isdn_stop(cs);
887 } 891 }
888 892
889 /* The rest is done by cleanup_cs () in user mode. */ 893 /* The rest is done by cleanup_cs() in process context. */
890 894
891 cs->cmd_result = -ENODEV; 895 cs->cmd_result = -ENODEV;
892 cs->waiting = 0; 896 cs->waiting = 0;
@@ -976,10 +980,9 @@ exit:
976} 980}
977 981
978static void handle_icall(struct cardstate *cs, struct bc_state *bcs, 982static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
979 struct at_state_t **p_at_state) 983 struct at_state_t *at_state)
980{ 984{
981 int retval; 985 int retval;
982 struct at_state_t *at_state = *p_at_state;
983 986
984 retval = gigaset_isdn_icall(at_state); 987 retval = gigaset_isdn_icall(at_state);
985 switch (retval) { 988 switch (retval) {
@@ -1176,7 +1179,7 @@ static void do_action(int action, struct cardstate *cs,
1176 spin_unlock_irqrestore(&cs->lock, flags); 1179 spin_unlock_irqrestore(&cs->lock, flags);
1177 break; 1180 break;
1178 case ACT_ICALL: 1181 case ACT_ICALL:
1179 handle_icall(cs, bcs, p_at_state); 1182 handle_icall(cs, bcs, at_state);
1180 break; 1183 break;
1181 case ACT_FAILSDOWN: 1184 case ACT_FAILSDOWN:
1182 dev_warn(cs->dev, "Could not shut down the device.\n"); 1185 dev_warn(cs->dev, "Could not shut down the device.\n");
@@ -1264,7 +1267,7 @@ static void do_action(int action, struct cardstate *cs,
1264 cs->commands_pending = 1; 1267 cs->commands_pending = 1;
1265 break; 1268 break;
1266 } 1269 }
1267 /* fall through */ 1270 /* bad cid: fall through */
1268 case ACT_FAILCID: 1271 case ACT_FAILCID:
1269 cs->cur_at_seq = SEQ_NONE; 1272 cs->cur_at_seq = SEQ_NONE;
1270 channel = cs->curchannel; 1273 channel = cs->curchannel;
@@ -1339,7 +1342,6 @@ static void do_action(int action, struct cardstate *cs,
1339 *p_resp_code = RSP_ERROR; 1342 *p_resp_code = RSP_ERROR;
1340 break; 1343 break;
1341 } 1344 }
1342 /*at_state->getstring = 1;*/
1343 cs->gotfwver = 0; 1345 cs->gotfwver = 0;
1344 break; 1346 break;
1345 case ACT_GOTVER: 1347 case ACT_GOTVER:
@@ -1471,7 +1473,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1471 int rcode; 1473 int rcode;
1472 int genresp = 0; 1474 int genresp = 0;
1473 int resp_code = RSP_ERROR; 1475 int resp_code = RSP_ERROR;
1474 int sendcid;
1475 struct at_state_t *at_state; 1476 struct at_state_t *at_state;
1476 int index; 1477 int index;
1477 int curact; 1478 int curact;
@@ -1499,7 +1500,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1499 at_state->ConState, ev->type); 1500 at_state->ConState, ev->type);
1500 1501
1501 bcs = at_state->bcs; 1502 bcs = at_state->bcs;
1502 sendcid = at_state->cid;
1503 1503
1504 /* Setting the pointer to the dial array */ 1504 /* Setting the pointer to the dial array */
1505 rep = at_state->replystruct; 1505 rep = at_state->replystruct;
@@ -1510,10 +1510,12 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1510 || !at_state->timer_active) { 1510 || !at_state->timer_active) {
1511 ev->type = RSP_NONE; /* old timeout */ 1511 ev->type = RSP_NONE; /* old timeout */
1512 gig_dbg(DEBUG_EVENT, "old timeout"); 1512 gig_dbg(DEBUG_EVENT, "old timeout");
1513 } else if (!at_state->waiting) 1513 } else {
1514 gig_dbg(DEBUG_EVENT, "timeout occurred"); 1514 if (at_state->waiting)
1515 else 1515 gig_dbg(DEBUG_EVENT, "stopped waiting");
1516 gig_dbg(DEBUG_EVENT, "stopped waiting"); 1516 else
1517 gig_dbg(DEBUG_EVENT, "timeout occurred");
1518 }
1517 } 1519 }
1518 spin_unlock_irqrestore(&cs->lock, flags); 1520 spin_unlock_irqrestore(&cs->lock, flags);
1519 1521
@@ -1561,45 +1563,40 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
1561 do_action(rep->action[curact], cs, bcs, &at_state, &p_command, 1563 do_action(rep->action[curact], cs, bcs, &at_state, &p_command,
1562 &genresp, &resp_code, ev); 1564 &genresp, &resp_code, ev);
1563 if (!at_state) 1565 if (!at_state)
1564 break; /* may be freed after disconnect */ 1566 /* at_state destroyed by disconnect */
1567 return;
1565 } 1568 }
1566 1569
1567 if (at_state) { 1570 /* Jump to the next con-state regarding the array */
1568 /* Jump to the next con-state regarding the array */ 1571 if (rep->new_ConState >= 0)
1569 if (rep->new_ConState >= 0) 1572 at_state->ConState = rep->new_ConState;
1570 at_state->ConState = rep->new_ConState;
1571 1573
1572 if (genresp) { 1574 if (genresp) {
1573 spin_lock_irqsave(&cs->lock, flags); 1575 spin_lock_irqsave(&cs->lock, flags);
1576 at_state->timer_expires = 0;
1577 at_state->timer_active = 0;
1578 spin_unlock_irqrestore(&cs->lock, flags);
1579 gigaset_add_event(cs, at_state, resp_code, NULL, 0, NULL);
1580 } else {
1581 /* Send command to modem if not NULL... */
1582 if (p_command) {
1583 if (cs->connected)
1584 send_command(cs, p_command, at_state);
1585 else
1586 gigaset_add_event(cs, at_state, RSP_NODEV,
1587 NULL, 0, NULL);
1588 }
1589
1590 spin_lock_irqsave(&cs->lock, flags);
1591 if (!rep->timeout) {
1574 at_state->timer_expires = 0; 1592 at_state->timer_expires = 0;
1575 at_state->timer_active = 0; 1593 at_state->timer_active = 0;
1576 spin_unlock_irqrestore(&cs->lock, flags); 1594 } else if (rep->timeout > 0) { /* new timeout */
1577 gigaset_add_event(cs, at_state, resp_code, 1595 at_state->timer_expires = rep->timeout * 10;
1578 NULL, 0, NULL); 1596 at_state->timer_active = 1;
1579 } else { 1597 ++at_state->timer_index;
1580 /* Send command to modem if not NULL... */
1581 if (p_command) {
1582 if (cs->connected)
1583 send_command(cs, p_command,
1584 sendcid, cs->dle,
1585 GFP_ATOMIC);
1586 else
1587 gigaset_add_event(cs, at_state,
1588 RSP_NODEV,
1589 NULL, 0, NULL);
1590 }
1591
1592 spin_lock_irqsave(&cs->lock, flags);
1593 if (!rep->timeout) {
1594 at_state->timer_expires = 0;
1595 at_state->timer_active = 0;
1596 } else if (rep->timeout > 0) { /* new timeout */
1597 at_state->timer_expires = rep->timeout * 10;
1598 at_state->timer_active = 1;
1599 ++at_state->timer_index;
1600 }
1601 spin_unlock_irqrestore(&cs->lock, flags);
1602 } 1598 }
1599 spin_unlock_irqrestore(&cs->lock, flags);
1603 } 1600 }
1604} 1601}
1605 1602
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 8e2fc8f31d16..eb63a0f7a02a 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -111,11 +111,10 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
111 111
112/* connection state */ 112/* connection state */
113#define ZSAU_NONE 0 113#define ZSAU_NONE 0
114#define ZSAU_DISCONNECT_IND 4
115#define ZSAU_OUTGOING_CALL_PROCEEDING 1
116#define ZSAU_PROCEEDING 1 114#define ZSAU_PROCEEDING 1
117#define ZSAU_CALL_DELIVERED 2 115#define ZSAU_CALL_DELIVERED 2
118#define ZSAU_ACTIVE 3 116#define ZSAU_ACTIVE 3
117#define ZSAU_DISCONNECT_IND 4
119#define ZSAU_NULL 5 118#define ZSAU_NULL 5
120#define ZSAU_DISCONNECT_REQ 6 119#define ZSAU_DISCONNECT_REQ 6
121#define ZSAU_UNKNOWN -1 120#define ZSAU_UNKNOWN -1
@@ -183,18 +182,22 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
183#define AT_NUM 7 182#define AT_NUM 7
184 183
185/* variables in struct at_state_t */ 184/* variables in struct at_state_t */
185/* - numeric */
186#define VAR_ZSAU 0 186#define VAR_ZSAU 0
187#define VAR_ZDLE 1 187#define VAR_ZDLE 1
188#define VAR_ZCTP 2 188#define VAR_ZCTP 2
189/* total number */
189#define VAR_NUM 3 190#define VAR_NUM 3
190 191/* - string */
191#define STR_NMBR 0 192#define STR_NMBR 0
192#define STR_ZCPN 1 193#define STR_ZCPN 1
193#define STR_ZCON 2 194#define STR_ZCON 2
194#define STR_ZBC 3 195#define STR_ZBC 3
195#define STR_ZHLC 4 196#define STR_ZHLC 4
197/* total number */
196#define STR_NUM 5 198#define STR_NUM 5
197 199
200/* event types */
198#define EV_TIMEOUT -105 201#define EV_TIMEOUT -105
199#define EV_IF_VER -106 202#define EV_IF_VER -106
200#define EV_PROC_CIDMODE -107 203#define EV_PROC_CIDMODE -107