aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/ev-layer.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2009-10-25 05:30:57 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-29 04:37:18 -0400
commit50e4fe91a5edbf680853b2ca37300a47ff860d63 (patch)
tree1b361226a74b6fd3f2d7819507fb3154c43a6107 /drivers/isdn/gigaset/ev-layer.c
parentc35a87ff6678f92b12437843e88f9c89437ed4a7 (diff)
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: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset/ev-layer.c')
-rw-r--r--drivers/isdn/gigaset/ev-layer.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c
index a9a397519bac..ddeb0456d202 100644
--- a/drivers/isdn/gigaset/ev-layer.c
+++ b/drivers/isdn/gigaset/ev-layer.c
@@ -374,7 +374,11 @@ struct reply_t gigaset_tab_cid[] =
374}; 374};
375 375
376 376
377static const struct resp_type_t resp_type[] = 377static const struct resp_type_t {
378 unsigned char *response;
379 int resp_code;
380 int type;
381} resp_type[] =
378{ 382{
379 {"OK", RSP_OK, RT_NOTHING}, 383 {"OK", RSP_OK, RT_NOTHING},
380 {"ERROR", RSP_ERROR, RT_NOTHING}, 384 {"ERROR", RSP_ERROR, RT_NOTHING},
@@ -402,6 +406,20 @@ static const struct resp_type_t resp_type[] =
402 {NULL, 0, 0} 406 {NULL, 0, 0}
403}; 407};
404 408
409static const struct zsau_resp_t {
410 unsigned char *str;
411 int code;
412} zsau_resp[] =
413{
414 {"OUTGOING_CALL_PROCEEDING", ZSAU_OUTGOING_CALL_PROCEEDING},
415 {"CALL_DELIVERED", ZSAU_CALL_DELIVERED},
416 {"ACTIVE", ZSAU_ACTIVE},
417 {"DISCONNECT_IND", ZSAU_DISCONNECT_IND},
418 {"NULL", ZSAU_NULL},
419 {"DISCONNECT_REQ", ZSAU_DISCONNECT_REQ},
420 {NULL, ZSAU_UNKNOWN}
421};
422
405/* 423/*
406 * Get integer from char-pointer 424 * Get integer from char-pointer
407 */ 425 */
@@ -480,6 +498,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
480 int params; 498 int params;
481 int i, j; 499 int i, j;
482 const struct resp_type_t *rt; 500 const struct resp_type_t *rt;
501 const struct zsau_resp_t *zr;
483 int curarg; 502 int curarg;
484 unsigned long flags; 503 unsigned long flags;
485 unsigned next, tail, head; 504 unsigned next, tail, head;
@@ -606,25 +625,14 @@ void gigaset_handle_modem_response(struct cardstate *cs)
606 event->parameter = ZSAU_NONE; 625 event->parameter = ZSAU_NONE;
607 break; 626 break;
608 } 627 }
609 if (!strcmp(argv[curarg], "OUTGOING_CALL_PROCEEDING")) 628 for (zr = zsau_resp; zr->str; ++zr)
610 event->parameter = 629 if (!strcmp(argv[curarg], zr->str))
611 ZSAU_OUTGOING_CALL_PROCEEDING; 630 break;
612 else if (!strcmp(argv[curarg], "CALL_DELIVERED")) 631 event->parameter = zr->code;
613 event->parameter = ZSAU_CALL_DELIVERED; 632 if (!zr->str)
614 else if (!strcmp(argv[curarg], "ACTIVE"))
615 event->parameter = ZSAU_ACTIVE;
616 else if (!strcmp(argv[curarg], "DISCONNECT_IND"))
617 event->parameter = ZSAU_DISCONNECT_IND;
618 else if (!strcmp(argv[curarg], "NULL"))
619 event->parameter = ZSAU_NULL;
620 else if (!strcmp(argv[curarg], "DISCONNECT_REQ"))
621 event->parameter = ZSAU_DISCONNECT_REQ;
622 else {
623 event->parameter = ZSAU_UNKNOWN;
624 dev_warn(cs->dev, 633 dev_warn(cs->dev,
625 "%s: unknown parameter %s after ZSAU\n", 634 "%s: unknown parameter %s after ZSAU\n",
626 __func__, argv[curarg]); 635 __func__, argv[curarg]);
627 }
628 ++curarg; 636 ++curarg;
629 break; 637 break;
630 case RT_STRING: 638 case RT_STRING: