[PATCH 01/10] ixj: Remove code duplication for processing codec names.

From: Richard A. Holden III
Date: Wed Oct 08 2008 - 15:41:18 EST


Signed-off-by: Richard A. Holden III <aciddeath@xxxxxxxxx>
---
drivers/telephony/ixj.c | 124 ++++++++++++++---------------------------------
1 files changed, 36 insertions(+), 88 deletions(-)

diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index ec7aeb5..1b2387e 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -7122,6 +7122,40 @@ IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)

EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */

+static int sprintf_codec_name(int len, char *buf, unsigned int codec)
+{
+ switch (codec) {
+ case G723_63:
+ return sprintf(buf + len, "G.723.1 6.3");
+ case G723_53:
+ return sprintf(buf + len, "G.723.1 5.3");
+ case TS85:
+ return sprintf(buf + len, "TrueSpeech 8.5");
+ case TS48:
+ return sprintf(buf + len, "TrueSpeech 4.8");
+ case TS41:
+ return sprintf(buf + len, "TrueSpeech 4.1");
+ case G728:
+ return sprintf(buf + len, "G.728");
+ case G729:
+ return sprintf(buf + len, "G.729");
+ case G729B:
+ return sprintf(buf + len, "G.729B");
+ case ULAW:
+ return sprintf(buf + len, "uLaw");
+ case ALAW:
+ return sprintf(buf + len, "aLaw");
+ case LINEAR16:
+ return sprintf(buf + len, "16 bit Linear");
+ case LINEAR8:
+ return sprintf(buf + len, "8 bit Linear");
+ case WSS:
+ return sprintf(buf + len, "Windows Sound System");
+ default:
+ return sprintf(buf + len, "NO CODEC CHOSEN");
+ }
+}
+
static int ixj_get_status_proc(char *buf)
{
int len;
@@ -7191,95 +7225,9 @@ static int ixj_get_status_proc(char *buf)
len += sprintf(buf + len, "\nCaller ID data not sent");

len += sprintf(buf + len, "\nPlay CODEC ");
- switch (j->play_codec) {
- case G723_63:
- len += sprintf(buf + len, "G.723.1 6.3");
- break;
- case G723_53:
- len += sprintf(buf + len, "G.723.1 5.3");
- break;
- case TS85:
- len += sprintf(buf + len, "TrueSpeech 8.5");
- break;
- case TS48:
- len += sprintf(buf + len, "TrueSpeech 4.8");
- break;
- case TS41:
- len += sprintf(buf + len, "TrueSpeech 4.1");
- break;
- case G728:
- len += sprintf(buf + len, "G.728");
- break;
- case G729:
- len += sprintf(buf + len, "G.729");
- break;
- case G729B:
- len += sprintf(buf + len, "G.729B");
- break;
- case ULAW:
- len += sprintf(buf + len, "uLaw");
- break;
- case ALAW:
- len += sprintf(buf + len, "aLaw");
- break;
- case LINEAR16:
- len += sprintf(buf + len, "16 bit Linear");
- break;
- case LINEAR8:
- len += sprintf(buf + len, "8 bit Linear");
- break;
- case WSS:
- len += sprintf(buf + len, "Windows Sound System");
- break;
- default:
- len += sprintf(buf + len, "NO CODEC CHOSEN");
- break;
- }
+ len += sprintf_codec_name(len, buf, j->play_codec);
len += sprintf(buf + len, "\nRecord CODEC ");
- switch (j->rec_codec) {
- case G723_63:
- len += sprintf(buf + len, "G.723.1 6.3");
- break;
- case G723_53:
- len += sprintf(buf + len, "G.723.1 5.3");
- break;
- case TS85:
- len += sprintf(buf + len, "TrueSpeech 8.5");
- break;
- case TS48:
- len += sprintf(buf + len, "TrueSpeech 4.8");
- break;
- case TS41:
- len += sprintf(buf + len, "TrueSpeech 4.1");
- break;
- case G728:
- len += sprintf(buf + len, "G.728");
- break;
- case G729:
- len += sprintf(buf + len, "G.729");
- break;
- case G729B:
- len += sprintf(buf + len, "G.729B");
- break;
- case ULAW:
- len += sprintf(buf + len, "uLaw");
- break;
- case ALAW:
- len += sprintf(buf + len, "aLaw");
- break;
- case LINEAR16:
- len += sprintf(buf + len, "16 bit Linear");
- break;
- case LINEAR8:
- len += sprintf(buf + len, "8 bit Linear");
- break;
- case WSS:
- len += sprintf(buf + len, "Windows Sound System");
- break;
- default:
- len += sprintf(buf + len, "NO CODEC CHOSEN");
- break;
- }
+ len += sprintf_codec_name(len, buf, j->rec_codec);
len += sprintf(buf + len, "\nAEC ");
switch (j->aec_level) {
case AEC_OFF:
--
1.5.6.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/