aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/common.c')
-rw-r--r--drivers/isdn/gigaset/common.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 5155c5b07a06..e9bfcfd9f116 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -79,50 +79,34 @@ __u8 gigaset_invtab[256] = {
79EXPORT_SYMBOL_GPL(gigaset_invtab); 79EXPORT_SYMBOL_GPL(gigaset_invtab);
80 80
81void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, 81void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
82 size_t len, const unsigned char *buf, int from_user) 82 size_t len, const unsigned char *buf)
83{ 83{
84 unsigned char outbuf[80]; 84 unsigned char outbuf[80];
85 unsigned char inbuf[80 - 1];
86 unsigned char c; 85 unsigned char c;
87 size_t numin;
88 const unsigned char *in;
89 size_t space = sizeof outbuf - 1; 86 size_t space = sizeof outbuf - 1;
90 unsigned char *out = outbuf; 87 unsigned char *out = outbuf;
88 size_t numin = len;
91 89
92 if (!from_user) { 90 while (numin--) {
93 in = buf;
94 numin = len;
95 } else {
96 numin = len < sizeof inbuf ? len : sizeof inbuf;
97 in = inbuf;
98 if (copy_from_user(inbuf, (const unsigned char __user *) buf,
99 numin)) {
100 gig_dbg(level, "%s (%u bytes) - copy_from_user failed",
101 msg, (unsigned) len);
102 return;
103 }
104 }
105
106 while (numin-- > 0) {
107 c = *buf++; 91 c = *buf++;
108 if (c == '~' || c == '^' || c == '\\') { 92 if (c == '~' || c == '^' || c == '\\') {
109 if (space-- <= 0) 93 if (!space--)
110 break; 94 break;
111 *out++ = '\\'; 95 *out++ = '\\';
112 } 96 }
113 if (c & 0x80) { 97 if (c & 0x80) {
114 if (space-- <= 0) 98 if (!space--)
115 break; 99 break;
116 *out++ = '~'; 100 *out++ = '~';
117 c ^= 0x80; 101 c ^= 0x80;
118 } 102 }
119 if (c < 0x20 || c == 0x7f) { 103 if (c < 0x20 || c == 0x7f) {
120 if (space-- <= 0) 104 if (!space--)
121 break; 105 break;
122 *out++ = '^'; 106 *out++ = '^';
123 c ^= 0x40; 107 c ^= 0x40;
124 } 108 }
125 if (space-- <= 0) 109 if (!space--)
126 break; 110 break;
127 *out++ = c; 111 *out++ = c;
128 } 112 }