Commit 50e4fe91 authored by Tilman Schmidt's avatar Tilman Schmidt Committed by David S. Miller

gigaset: convert strcmp chain to table lookup

Replace the sequence of strcmp calls for interpreting ZSAU parameter
strings by a table of known strings and lookup loop to improve
readability.

Impact: readability improvement, no functional change
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c35a87ff
...@@ -374,7 +374,11 @@ struct reply_t gigaset_tab_cid[] = ...@@ -374,7 +374,11 @@ struct reply_t gigaset_tab_cid[] =
}; };
static const struct resp_type_t resp_type[] = static const struct resp_type_t {
unsigned char *response;
int resp_code;
int type;
} resp_type[] =
{ {
{"OK", RSP_OK, RT_NOTHING}, {"OK", RSP_OK, RT_NOTHING},
{"ERROR", RSP_ERROR, RT_NOTHING}, {"ERROR", RSP_ERROR, RT_NOTHING},
...@@ -402,6 +406,20 @@ static const struct resp_type_t resp_type[] = ...@@ -402,6 +406,20 @@ static const struct resp_type_t resp_type[] =
{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}
};
/* /*
* Get integer from char-pointer * Get integer from char-pointer
*/ */
...@@ -480,6 +498,7 @@ void gigaset_handle_modem_response(struct cardstate *cs) ...@@ -480,6 +498,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
int params; int params;
int i, j; int i, j;
const struct resp_type_t *rt; const struct resp_type_t *rt;
const struct zsau_resp_t *zr;
int curarg; int curarg;
unsigned long flags; unsigned long flags;
unsigned next, tail, head; unsigned next, tail, head;
...@@ -606,25 +625,14 @@ void gigaset_handle_modem_response(struct cardstate *cs) ...@@ -606,25 +625,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
event->parameter = ZSAU_NONE; event->parameter = ZSAU_NONE;
break; break;
} }
if (!strcmp(argv[curarg], "OUTGOING_CALL_PROCEEDING")) for (zr = zsau_resp; zr->str; ++zr)
event->parameter = if (!strcmp(argv[curarg], zr->str))
ZSAU_OUTGOING_CALL_PROCEEDING; break;
else if (!strcmp(argv[curarg], "CALL_DELIVERED")) event->parameter = zr->code;
event->parameter = ZSAU_CALL_DELIVERED; if (!zr->str)
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;
dev_warn(cs->dev, dev_warn(cs->dev,
"%s: unknown parameter %s after ZSAU\n", "%s: unknown parameter %s after ZSAU\n",
__func__, argv[curarg]); __func__, argv[curarg]);
}
++curarg; ++curarg;
break; break;
case RT_STRING: case RT_STRING:
......
...@@ -357,12 +357,6 @@ struct at_state_t { ...@@ -357,12 +357,6 @@ struct at_state_t {
struct bc_state *bcs; struct bc_state *bcs;
}; };
struct resp_type_t {
unsigned char *response;
int resp_code; /* RSP_XXXX */
int type; /* RT_XXXX */
};
struct event_t { struct event_t {
int type; int type;
void *ptr, *arg; void *ptr, *arg;
......
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