Commit 63b203b4 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

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: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bc882b18
...@@ -351,10 +351,11 @@ struct reply_t gigaset_tab_cid[] = ...@@ -351,10 +351,11 @@ struct reply_t gigaset_tab_cid[] =
static const struct resp_type_t { static const struct resp_type_t {
unsigned char *response; char *response;
int resp_code; int resp_code;
int type; int type;
} resp_type[] = }
resp_type[] =
{ {
{"OK", RSP_OK, RT_NOTHING}, {"OK", RSP_OK, RT_NOTHING},
{"ERROR", RSP_ERROR, RT_NOTHING}, {"ERROR", RSP_ERROR, RT_NOTHING},
...@@ -374,11 +375,12 @@ static const struct resp_type_t { ...@@ -374,11 +375,12 @@ static const struct resp_type_t {
}; };
static const struct zsau_resp_t { static const struct zsau_resp_t {
unsigned char *str; char *str;
int code; int code;
} zsau_resp[] = }
zsau_resp[] =
{ {
{"OUTGOING_CALL_PROCEEDING", ZSAU_OUTGOING_CALL_PROCEEDING}, {"OUTGOING_CALL_PROCEEDING", ZSAU_PROCEEDING},
{"CALL_DELIVERED", ZSAU_CALL_DELIVERED}, {"CALL_DELIVERED", ZSAU_CALL_DELIVERED},
{"ACTIVE", ZSAU_ACTIVE}, {"ACTIVE", ZSAU_ACTIVE},
{"DISCONNECT_IND", ZSAU_DISCONNECT_IND}, {"DISCONNECT_IND", ZSAU_DISCONNECT_IND},
...@@ -434,7 +436,7 @@ void gigaset_handle_modem_response(struct cardstate *cs) ...@@ -434,7 +436,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
len = cs->cbytes; len = cs->cbytes;
if (!len) { if (!len) {
/* ignore additional LFs/CRs (M10x config mode or cx100) */ /* ignore additional LFs/CRs (M10x config mode or cx100) */
gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[len]); gig_dbg(DEBUG_MCMD, "skipped EOL [%02X]", cs->respdata[0]);
return; return;
} }
cs->respdata[len] = 0; cs->respdata[len] = 0;
...@@ -707,27 +709,29 @@ static void schedule_init(struct cardstate *cs, int state) ...@@ -707,27 +709,29 @@ static void schedule_init(struct cardstate *cs, int state)
cs->commands_pending = 1; cs->commands_pending = 1;
} }
/* Add "AT" to a command, add the cid, dle encode it, send the result to the /* send an AT command
hardware. */ * adding the "AT" prefix, cid and DLE encapsulation as appropriate
static void send_command(struct cardstate *cs, const char *cmd, int cid, */
int dle, gfp_t kmallocflags) static void send_command(struct cardstate *cs, const char *cmd,
struct at_state_t *at_state)
{ {
int cid = at_state->cid;
struct cmdbuf_t *cb; struct cmdbuf_t *cb;
size_t buflen; size_t buflen;
buflen = strlen(cmd) + 12; /* DLE ( A T 1 2 3 4 5 <cmd> DLE ) \0 */ buflen = strlen(cmd) + 12; /* DLE ( A T 1 2 3 4 5 <cmd> DLE ) \0 */
cb = kmalloc(sizeof(struct cmdbuf_t) + buflen, kmallocflags); cb = kmalloc(sizeof(struct cmdbuf_t) + buflen, GFP_ATOMIC);
if (!cb) { if (!cb) {
dev_err(cs->dev, "%s: out of memory\n", __func__); dev_err(cs->dev, "%s: out of memory\n", __func__);
return; return;
} }
if (cid > 0 && cid <= 65535) if (cid > 0 && cid <= 65535)
cb->len = snprintf(cb->buf, buflen, cb->len = snprintf(cb->buf, buflen,
dle ? "\020(AT%d%s\020)" : "AT%d%s", cs->dle ? "\020(AT%d%s\020)" : "AT%d%s",
cid, cmd); cid, cmd);
else else
cb->len = snprintf(cb->buf, buflen, cb->len = snprintf(cb->buf, buflen,
dle ? "\020(AT%s\020)" : "AT%s", cs->dle ? "\020(AT%s\020)" : "AT%s",
cmd); cmd);
cb->offset = 0; cb->offset = 0;
cb->next = NULL; cb->next = NULL;
...@@ -886,7 +890,7 @@ static void finish_shutdown(struct cardstate *cs) ...@@ -886,7 +890,7 @@ static void finish_shutdown(struct cardstate *cs)
gigaset_isdn_stop(cs); gigaset_isdn_stop(cs);
} }
/* The rest is done by cleanup_cs () in user mode. */ /* The rest is done by cleanup_cs() in process context. */
cs->cmd_result = -ENODEV; cs->cmd_result = -ENODEV;
cs->waiting = 0; cs->waiting = 0;
...@@ -976,10 +980,9 @@ static int at_state_invalid(struct cardstate *cs, ...@@ -976,10 +980,9 @@ static int at_state_invalid(struct cardstate *cs,
} }
static void handle_icall(struct cardstate *cs, struct bc_state *bcs, static void handle_icall(struct cardstate *cs, struct bc_state *bcs,
struct at_state_t **p_at_state) struct at_state_t *at_state)
{ {
int retval; int retval;
struct at_state_t *at_state = *p_at_state;
retval = gigaset_isdn_icall(at_state); retval = gigaset_isdn_icall(at_state);
switch (retval) { switch (retval) {
...@@ -1176,7 +1179,7 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1176,7 +1179,7 @@ static void do_action(int action, struct cardstate *cs,
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
break; break;
case ACT_ICALL: case ACT_ICALL:
handle_icall(cs, bcs, p_at_state); handle_icall(cs, bcs, at_state);
break; break;
case ACT_FAILSDOWN: case ACT_FAILSDOWN:
dev_warn(cs->dev, "Could not shut down the device.\n"); 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,7 +1267,7 @@ static void do_action(int action, struct cardstate *cs,
cs->commands_pending = 1; cs->commands_pending = 1;
break; break;
} }
/* fall through */ /* bad cid: fall through */
case ACT_FAILCID: case ACT_FAILCID:
cs->cur_at_seq = SEQ_NONE; cs->cur_at_seq = SEQ_NONE;
channel = cs->curchannel; channel = cs->curchannel;
...@@ -1339,7 +1342,6 @@ static void do_action(int action, struct cardstate *cs, ...@@ -1339,7 +1342,6 @@ static void do_action(int action, struct cardstate *cs,
*p_resp_code = RSP_ERROR; *p_resp_code = RSP_ERROR;
break; break;
} }
/*at_state->getstring = 1;*/
cs->gotfwver = 0; cs->gotfwver = 0;
break; break;
case ACT_GOTVER: case ACT_GOTVER:
...@@ -1471,7 +1473,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev) ...@@ -1471,7 +1473,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
int rcode; int rcode;
int genresp = 0; int genresp = 0;
int resp_code = RSP_ERROR; int resp_code = RSP_ERROR;
int sendcid;
struct at_state_t *at_state; struct at_state_t *at_state;
int index; int index;
int curact; int curact;
...@@ -1499,7 +1500,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev) ...@@ -1499,7 +1500,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
at_state->ConState, ev->type); at_state->ConState, ev->type);
bcs = at_state->bcs; bcs = at_state->bcs;
sendcid = at_state->cid;
/* Setting the pointer to the dial array */ /* Setting the pointer to the dial array */
rep = at_state->replystruct; rep = at_state->replystruct;
...@@ -1510,10 +1510,12 @@ static void process_event(struct cardstate *cs, struct event_t *ev) ...@@ -1510,10 +1510,12 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
|| !at_state->timer_active) { || !at_state->timer_active) {
ev->type = RSP_NONE; /* old timeout */ ev->type = RSP_NONE; /* old timeout */
gig_dbg(DEBUG_EVENT, "old timeout"); gig_dbg(DEBUG_EVENT, "old timeout");
} else if (!at_state->waiting) } else {
gig_dbg(DEBUG_EVENT, "timeout occurred"); if (at_state->waiting)
else
gig_dbg(DEBUG_EVENT, "stopped waiting"); gig_dbg(DEBUG_EVENT, "stopped waiting");
else
gig_dbg(DEBUG_EVENT, "timeout occurred");
}
} }
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
...@@ -1561,10 +1563,10 @@ static void process_event(struct cardstate *cs, struct event_t *ev) ...@@ -1561,10 +1563,10 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
do_action(rep->action[curact], cs, bcs, &at_state, &p_command, do_action(rep->action[curact], cs, bcs, &at_state, &p_command,
&genresp, &resp_code, ev); &genresp, &resp_code, ev);
if (!at_state) if (!at_state)
break; /* may be freed after disconnect */ /* at_state destroyed by disconnect */
return;
} }
if (at_state) {
/* Jump to the next con-state regarding the array */ /* Jump to the next con-state regarding the array */
if (rep->new_ConState >= 0) if (rep->new_ConState >= 0)
at_state->ConState = rep->new_ConState; at_state->ConState = rep->new_ConState;
...@@ -1574,18 +1576,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev) ...@@ -1574,18 +1576,14 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
at_state->timer_expires = 0; at_state->timer_expires = 0;
at_state->timer_active = 0; at_state->timer_active = 0;
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
gigaset_add_event(cs, at_state, resp_code, gigaset_add_event(cs, at_state, resp_code, NULL, 0, NULL);
NULL, 0, NULL);
} else { } else {
/* Send command to modem if not NULL... */ /* Send command to modem if not NULL... */
if (p_command) { if (p_command) {
if (cs->connected) if (cs->connected)
send_command(cs, p_command, send_command(cs, p_command, at_state);
sendcid, cs->dle,
GFP_ATOMIC);
else else
gigaset_add_event(cs, at_state, gigaset_add_event(cs, at_state, RSP_NODEV,
RSP_NODEV,
NULL, 0, NULL); NULL, 0, NULL);
} }
...@@ -1600,7 +1598,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev) ...@@ -1600,7 +1598,6 @@ static void process_event(struct cardstate *cs, struct event_t *ev)
} }
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
} }
}
} }
static void schedule_sequence(struct cardstate *cs, static void schedule_sequence(struct cardstate *cs,
......
...@@ -111,11 +111,10 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, ...@@ -111,11 +111,10 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
/* connection state */ /* connection state */
#define ZSAU_NONE 0 #define ZSAU_NONE 0
#define ZSAU_DISCONNECT_IND 4
#define ZSAU_OUTGOING_CALL_PROCEEDING 1
#define ZSAU_PROCEEDING 1 #define ZSAU_PROCEEDING 1
#define ZSAU_CALL_DELIVERED 2 #define ZSAU_CALL_DELIVERED 2
#define ZSAU_ACTIVE 3 #define ZSAU_ACTIVE 3
#define ZSAU_DISCONNECT_IND 4
#define ZSAU_NULL 5 #define ZSAU_NULL 5
#define ZSAU_DISCONNECT_REQ 6 #define ZSAU_DISCONNECT_REQ 6
#define ZSAU_UNKNOWN -1 #define ZSAU_UNKNOWN -1
...@@ -183,18 +182,22 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, ...@@ -183,18 +182,22 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
#define AT_NUM 7 #define AT_NUM 7
/* variables in struct at_state_t */ /* variables in struct at_state_t */
/* - numeric */
#define VAR_ZSAU 0 #define VAR_ZSAU 0
#define VAR_ZDLE 1 #define VAR_ZDLE 1
#define VAR_ZCTP 2 #define VAR_ZCTP 2
/* total number */
#define VAR_NUM 3 #define VAR_NUM 3
/* - string */
#define STR_NMBR 0 #define STR_NMBR 0
#define STR_ZCPN 1 #define STR_ZCPN 1
#define STR_ZCON 2 #define STR_ZCON 2
#define STR_ZBC 3 #define STR_ZBC 3
#define STR_ZHLC 4 #define STR_ZHLC 4
/* total number */
#define STR_NUM 5 #define STR_NUM 5
/* event types */
#define EV_TIMEOUT -105 #define EV_TIMEOUT -105
#define EV_IF_VER -106 #define EV_IF_VER -106
#define EV_PROC_CIDMODE -107 #define EV_PROC_CIDMODE -107
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment