21 #include <linux/string.h>
32 static unsigned int debugifc_count_whitespace(
const char *
buf,
38 for (scnt = 0; scnt <
count; scnt++) {
40 if (ch ==
' ')
continue;
41 if (ch ==
'\t')
continue;
42 if (ch ==
'\n')
continue;
49 static unsigned int debugifc_count_nonwhitespace(
const char *
buf,
55 for (scnt = 0; scnt <
count; scnt++) {
58 if (ch ==
'\t')
break;
59 if (ch ==
'\n')
break;
65 static unsigned int debugifc_isolate_word(
const char *buf,
unsigned int count,
67 unsigned int *wlenPtr)
70 unsigned int consume_cnt = 0;
76 scnt = debugifc_count_whitespace(buf,count);
78 if (!count)
goto done;
80 scnt = debugifc_count_nonwhitespace(buf,count);
93 static int debugifc_parse_unsigned_number(
const char *buf,
unsigned int count,
98 if ((count >= 2) && (buf[0] ==
'0') &&
99 ((buf[1] ==
'x') || (buf[1] ==
'X'))) {
103 }
else if ((count >= 1) && (buf[0] ==
'0')) {
109 if (val < 0 || val >= radix)
119 static int debugifc_match_keyword(
const char *buf,
unsigned int count,
123 if (!keyword)
return 0;
125 if (kl != count)
return 0;
126 return !
memcmp(buf,keyword,kl);
134 ccnt =
scnprintf(buf, acnt,
"Driver hardware description: %s\n",
136 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
137 ccnt =
scnprintf(buf,acnt,
"Driver state info:\n");
138 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
140 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
147 char *buf,
unsigned int acnt)
152 u32 gpio_dir,gpio_in,gpio_out;
157 ccnt =
scnprintf(buf,acnt,
"USB link speed: %s\n",
158 (ret < 0 ?
"FAIL" : (ret ?
"high" :
"full")));
159 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
161 gpio_dir = 0; gpio_in = 0; gpio_out = 0;
165 ccnt =
scnprintf(buf,acnt,
"GPIO state: dir=0x%x in=0x%x out=0x%x\n",
166 gpio_dir,gpio_in,gpio_out);
167 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
169 ccnt =
scnprintf(buf,acnt,
"Streaming is %s\n",
171 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
180 " URBs: queued=%u idle=%u ready=%u"
181 " processed=%u failed=%u\n",
188 bcnt += ccnt; acnt -= ccnt; buf += ccnt;
195 static int pvr2_debugifc_do1cmd(
struct pvr2_hdw *hdw,
const char *buf,
202 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
208 if (debugifc_match_keyword(wptr,wlen,
"reset")) {
209 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
210 if (!scnt)
return -
EINVAL;
212 if (!wptr)
return -
EINVAL;
213 if (debugifc_match_keyword(wptr,wlen,
"cpu")) {
217 }
else if (debugifc_match_keyword(wptr,wlen,
"bus")) {
219 }
else if (debugifc_match_keyword(wptr,wlen,
"soft")) {
221 }
else if (debugifc_match_keyword(wptr,wlen,
"deep")) {
223 }
else if (debugifc_match_keyword(wptr,wlen,
"firmware")) {
225 }
else if (debugifc_match_keyword(wptr,wlen,
"decoder")) {
227 }
else if (debugifc_match_keyword(wptr,wlen,
"worker")) {
229 }
else if (debugifc_match_keyword(wptr,wlen,
"usbstats")) {
235 }
else if (debugifc_match_keyword(wptr,wlen,
"cpufw")) {
236 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
237 if (!scnt)
return -
EINVAL;
239 if (!wptr)
return -
EINVAL;
240 if (debugifc_match_keyword(wptr,wlen,
"fetch")) {
241 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
244 if (debugifc_match_keyword(wptr, wlen,
247 }
else if (debugifc_match_keyword(wptr, wlen,
250 }
else if (debugifc_match_keyword(wptr, wlen,
259 }
else if (debugifc_match_keyword(wptr,wlen,
"done")) {
265 }
else if (debugifc_match_keyword(wptr,wlen,
"gpio")) {
269 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
270 if (!scnt)
return -
EINVAL;
272 if (!wptr)
return -
EINVAL;
273 if (debugifc_match_keyword(wptr,wlen,
"dir")) {
275 }
else if (!debugifc_match_keyword(wptr,wlen,
"out")) {
278 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
279 if (!scnt)
return -
EINVAL;
281 if (!wptr)
return -
EINVAL;
282 ret = debugifc_parse_unsigned_number(wptr,wlen,&msk);
284 scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
286 ret = debugifc_parse_unsigned_number(wptr,wlen,&val);
300 "debugifc failed to recognize cmd: \"%.*s\"",wlen,wptr);
308 unsigned int bcnt = 0;
312 for (bcnt = 0; bcnt <
count; bcnt++) {
313 if (buf[bcnt] ==
'\n')
break;
316 ret = pvr2_debugifc_do1cmd(hdw,buf,bcnt);
317 if (ret < 0)
return ret;
318 if (bcnt < count) bcnt++;