diff options
author | Tilman Schmidt <tilman@imap.cc> | 2014-10-11 07:46:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-14 15:05:34 -0400 |
commit | 854d23b77aa25b203c7af11de885c3b8b3834c20 (patch) | |
tree | 64c8d880677949a3171d631d7a60bedac085682e /drivers/isdn/capi | |
parent | 5362247a42e18ef74e698bb23575c272f8e35375 (diff) |
isdn/capi: refactor command/subcommand table accesses
Encapsulate accesses to the CAPI 2.0 command/subcommand name and
parameter tables in a single place in preparation for redesign.
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/capi')
-rw-r--r-- | drivers/isdn/capi/capiutil.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/isdn/capi/capiutil.c b/drivers/isdn/capi/capiutil.c index b501d76209f0..8e401eda2aa1 100644 --- a/drivers/isdn/capi/capiutil.c +++ b/drivers/isdn/capi/capiutil.c | |||
@@ -212,6 +212,19 @@ static unsigned command_2_index(unsigned c, unsigned sc) | |||
212 | return (sc & 3) * (0x9 + 0x9) + c; | 212 | return (sc & 3) * (0x9 + 0x9) + c; |
213 | } | 213 | } |
214 | 214 | ||
215 | /** | ||
216 | * capi_cmd2par() - find parameter string for CAPI 2.0 command/subcommand | ||
217 | * @cmd: command number | ||
218 | * @subcmd: subcommand number | ||
219 | * | ||
220 | * Return value: static string, NULL if command/subcommand unknown | ||
221 | */ | ||
222 | |||
223 | static unsigned char *capi_cmd2par(u8 cmd, u8 subcmd) | ||
224 | { | ||
225 | return cpars[command_2_index(cmd, subcmd)]; | ||
226 | } | ||
227 | |||
215 | /*-------------------------------------------------------*/ | 228 | /*-------------------------------------------------------*/ |
216 | #define TYP (cdef[cmsg->par[cmsg->p]].typ) | 229 | #define TYP (cdef[cmsg->par[cmsg->p]].typ) |
217 | #define OFF (((u8 *)cmsg) + cdef[cmsg->par[cmsg->p]].off) | 230 | #define OFF (((u8 *)cmsg) + cdef[cmsg->par[cmsg->p]].off) |
@@ -304,7 +317,7 @@ unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg) | |||
304 | cmsg->m = msg; | 317 | cmsg->m = msg; |
305 | cmsg->l = 8; | 318 | cmsg->l = 8; |
306 | cmsg->p = 0; | 319 | cmsg->p = 0; |
307 | cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)]; | 320 | cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); |
308 | 321 | ||
309 | pars_2_message(cmsg); | 322 | pars_2_message(cmsg); |
310 | 323 | ||
@@ -377,7 +390,7 @@ unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg) | |||
377 | cmsg->p = 0; | 390 | cmsg->p = 0; |
378 | byteTRcpy(cmsg->m + 4, &cmsg->Command); | 391 | byteTRcpy(cmsg->m + 4, &cmsg->Command); |
379 | byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); | 392 | byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); |
380 | cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)]; | 393 | cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); |
381 | 394 | ||
382 | message_2_pars(cmsg); | 395 | message_2_pars(cmsg); |
383 | 396 | ||
@@ -761,10 +774,10 @@ _cdebbuf *capi_message2str(u8 *msg) | |||
761 | cmsg->p = 0; | 774 | cmsg->p = 0; |
762 | byteTRcpy(cmsg->m + 4, &cmsg->Command); | 775 | byteTRcpy(cmsg->m + 4, &cmsg->Command); |
763 | byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); | 776 | byteTRcpy(cmsg->m + 5, &cmsg->Subcommand); |
764 | cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)]; | 777 | cmsg->par = capi_cmd2par(cmsg->Command, cmsg->Subcommand); |
765 | 778 | ||
766 | cdb = bufprint(cdb, "%-26s ID=%03d #0x%04x LEN=%04d\n", | 779 | cdb = bufprint(cdb, "%-26s ID=%03d #0x%04x LEN=%04d\n", |
767 | mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], | 780 | capi_cmd2str(cmsg->Command, cmsg->Subcommand), |
768 | ((unsigned short *) msg)[1], | 781 | ((unsigned short *) msg)[1], |
769 | ((unsigned short *) msg)[3], | 782 | ((unsigned short *) msg)[3], |
770 | ((unsigned short *) msg)[0]); | 783 | ((unsigned short *) msg)[0]); |
@@ -798,7 +811,7 @@ _cdebbuf *capi_cmsg2str(_cmsg *cmsg) | |||
798 | cmsg->l = 8; | 811 | cmsg->l = 8; |
799 | cmsg->p = 0; | 812 | cmsg->p = 0; |
800 | cdb = bufprint(cdb, "%s ID=%03d #0x%04x LEN=%04d\n", | 813 | cdb = bufprint(cdb, "%s ID=%03d #0x%04x LEN=%04d\n", |
801 | mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], | 814 | capi_cmd2str(cmsg->Command, cmsg->Subcommand), |
802 | ((u16 *) cmsg->m)[1], | 815 | ((u16 *) cmsg->m)[1], |
803 | ((u16 *) cmsg->m)[3], | 816 | ((u16 *) cmsg->m)[3], |
804 | ((u16 *) cmsg->m)[0]); | 817 | ((u16 *) cmsg->m)[0]); |