1*2504ba9fSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
20c0d06caSMauro Carvalho Chehab /*
30c0d06caSMauro Carvalho Chehab *
40c0d06caSMauro Carvalho Chehab * Copyright (C) 2005 Mike Isely <isely@pobox.com>
50c0d06caSMauro Carvalho Chehab */
60c0d06caSMauro Carvalho Chehab
70c0d06caSMauro Carvalho Chehab #include <linux/string.h>
80c0d06caSMauro Carvalho Chehab #include "pvrusb2-debugifc.h"
90c0d06caSMauro Carvalho Chehab #include "pvrusb2-hdw.h"
100c0d06caSMauro Carvalho Chehab #include "pvrusb2-debug.h"
110c0d06caSMauro Carvalho Chehab
120c0d06caSMauro Carvalho Chehab struct debugifc_mask_item {
130c0d06caSMauro Carvalho Chehab const char *name;
140c0d06caSMauro Carvalho Chehab unsigned long msk;
150c0d06caSMauro Carvalho Chehab };
160c0d06caSMauro Carvalho Chehab
170c0d06caSMauro Carvalho Chehab
debugifc_count_whitespace(const char * buf,unsigned int count)180c0d06caSMauro Carvalho Chehab static unsigned int debugifc_count_whitespace(const char *buf,
190c0d06caSMauro Carvalho Chehab unsigned int count)
200c0d06caSMauro Carvalho Chehab {
210c0d06caSMauro Carvalho Chehab unsigned int scnt;
220c0d06caSMauro Carvalho Chehab char ch;
230c0d06caSMauro Carvalho Chehab
240c0d06caSMauro Carvalho Chehab for (scnt = 0; scnt < count; scnt++) {
250c0d06caSMauro Carvalho Chehab ch = buf[scnt];
260c0d06caSMauro Carvalho Chehab if (ch == ' ') continue;
270c0d06caSMauro Carvalho Chehab if (ch == '\t') continue;
280c0d06caSMauro Carvalho Chehab if (ch == '\n') continue;
290c0d06caSMauro Carvalho Chehab break;
300c0d06caSMauro Carvalho Chehab }
310c0d06caSMauro Carvalho Chehab return scnt;
320c0d06caSMauro Carvalho Chehab }
330c0d06caSMauro Carvalho Chehab
340c0d06caSMauro Carvalho Chehab
debugifc_count_nonwhitespace(const char * buf,unsigned int count)350c0d06caSMauro Carvalho Chehab static unsigned int debugifc_count_nonwhitespace(const char *buf,
360c0d06caSMauro Carvalho Chehab unsigned int count)
370c0d06caSMauro Carvalho Chehab {
380c0d06caSMauro Carvalho Chehab unsigned int scnt;
390c0d06caSMauro Carvalho Chehab char ch;
400c0d06caSMauro Carvalho Chehab
410c0d06caSMauro Carvalho Chehab for (scnt = 0; scnt < count; scnt++) {
420c0d06caSMauro Carvalho Chehab ch = buf[scnt];
430c0d06caSMauro Carvalho Chehab if (ch == ' ') break;
440c0d06caSMauro Carvalho Chehab if (ch == '\t') break;
450c0d06caSMauro Carvalho Chehab if (ch == '\n') break;
460c0d06caSMauro Carvalho Chehab }
470c0d06caSMauro Carvalho Chehab return scnt;
480c0d06caSMauro Carvalho Chehab }
490c0d06caSMauro Carvalho Chehab
500c0d06caSMauro Carvalho Chehab
debugifc_isolate_word(const char * buf,unsigned int count,const char ** wstrPtr,unsigned int * wlenPtr)510c0d06caSMauro Carvalho Chehab static unsigned int debugifc_isolate_word(const char *buf,unsigned int count,
520c0d06caSMauro Carvalho Chehab const char **wstrPtr,
530c0d06caSMauro Carvalho Chehab unsigned int *wlenPtr)
540c0d06caSMauro Carvalho Chehab {
550c0d06caSMauro Carvalho Chehab const char *wptr;
560c0d06caSMauro Carvalho Chehab unsigned int consume_cnt = 0;
570c0d06caSMauro Carvalho Chehab unsigned int wlen;
580c0d06caSMauro Carvalho Chehab unsigned int scnt;
590c0d06caSMauro Carvalho Chehab
600c0d06caSMauro Carvalho Chehab wptr = NULL;
610c0d06caSMauro Carvalho Chehab wlen = 0;
620c0d06caSMauro Carvalho Chehab scnt = debugifc_count_whitespace(buf,count);
630c0d06caSMauro Carvalho Chehab consume_cnt += scnt; count -= scnt; buf += scnt;
640c0d06caSMauro Carvalho Chehab if (!count) goto done;
650c0d06caSMauro Carvalho Chehab
660c0d06caSMauro Carvalho Chehab scnt = debugifc_count_nonwhitespace(buf,count);
670c0d06caSMauro Carvalho Chehab if (!scnt) goto done;
680c0d06caSMauro Carvalho Chehab wptr = buf;
690c0d06caSMauro Carvalho Chehab wlen = scnt;
700c0d06caSMauro Carvalho Chehab consume_cnt += scnt; count -= scnt; buf += scnt;
710c0d06caSMauro Carvalho Chehab
720c0d06caSMauro Carvalho Chehab done:
730c0d06caSMauro Carvalho Chehab *wstrPtr = wptr;
740c0d06caSMauro Carvalho Chehab *wlenPtr = wlen;
750c0d06caSMauro Carvalho Chehab return consume_cnt;
760c0d06caSMauro Carvalho Chehab }
770c0d06caSMauro Carvalho Chehab
780c0d06caSMauro Carvalho Chehab
debugifc_parse_unsigned_number(const char * buf,unsigned int count,u32 * num_ptr)790c0d06caSMauro Carvalho Chehab static int debugifc_parse_unsigned_number(const char *buf,unsigned int count,
800c0d06caSMauro Carvalho Chehab u32 *num_ptr)
810c0d06caSMauro Carvalho Chehab {
820c0d06caSMauro Carvalho Chehab u32 result = 0;
830c0d06caSMauro Carvalho Chehab int radix = 10;
840c0d06caSMauro Carvalho Chehab if ((count >= 2) && (buf[0] == '0') &&
850c0d06caSMauro Carvalho Chehab ((buf[1] == 'x') || (buf[1] == 'X'))) {
860c0d06caSMauro Carvalho Chehab radix = 16;
870c0d06caSMauro Carvalho Chehab count -= 2;
880c0d06caSMauro Carvalho Chehab buf += 2;
890c0d06caSMauro Carvalho Chehab } else if ((count >= 1) && (buf[0] == '0')) {
900c0d06caSMauro Carvalho Chehab radix = 8;
910c0d06caSMauro Carvalho Chehab }
920c0d06caSMauro Carvalho Chehab
930c0d06caSMauro Carvalho Chehab while (count--) {
940c0d06caSMauro Carvalho Chehab int val = hex_to_bin(*buf++);
950c0d06caSMauro Carvalho Chehab if (val < 0 || val >= radix)
960c0d06caSMauro Carvalho Chehab return -EINVAL;
970c0d06caSMauro Carvalho Chehab result *= radix;
980c0d06caSMauro Carvalho Chehab result += val;
990c0d06caSMauro Carvalho Chehab }
1000c0d06caSMauro Carvalho Chehab *num_ptr = result;
1010c0d06caSMauro Carvalho Chehab return 0;
1020c0d06caSMauro Carvalho Chehab }
1030c0d06caSMauro Carvalho Chehab
1040c0d06caSMauro Carvalho Chehab
debugifc_match_keyword(const char * buf,unsigned int count,const char * keyword)1050c0d06caSMauro Carvalho Chehab static int debugifc_match_keyword(const char *buf,unsigned int count,
1060c0d06caSMauro Carvalho Chehab const char *keyword)
1070c0d06caSMauro Carvalho Chehab {
1080c0d06caSMauro Carvalho Chehab unsigned int kl;
1090c0d06caSMauro Carvalho Chehab if (!keyword) return 0;
1100c0d06caSMauro Carvalho Chehab kl = strlen(keyword);
1110c0d06caSMauro Carvalho Chehab if (kl != count) return 0;
1120c0d06caSMauro Carvalho Chehab return !memcmp(buf,keyword,kl);
1130c0d06caSMauro Carvalho Chehab }
1140c0d06caSMauro Carvalho Chehab
1150c0d06caSMauro Carvalho Chehab
pvr2_debugifc_print_info(struct pvr2_hdw * hdw,char * buf,unsigned int acnt)1160c0d06caSMauro Carvalho Chehab int pvr2_debugifc_print_info(struct pvr2_hdw *hdw,char *buf,unsigned int acnt)
1170c0d06caSMauro Carvalho Chehab {
1180c0d06caSMauro Carvalho Chehab int bcnt = 0;
1190c0d06caSMauro Carvalho Chehab int ccnt;
1200c0d06caSMauro Carvalho Chehab ccnt = scnprintf(buf, acnt, "Driver hardware description: %s\n",
1210c0d06caSMauro Carvalho Chehab pvr2_hdw_get_desc(hdw));
1220c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1230c0d06caSMauro Carvalho Chehab ccnt = scnprintf(buf,acnt,"Driver state info:\n");
1240c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1250c0d06caSMauro Carvalho Chehab ccnt = pvr2_hdw_state_report(hdw,buf,acnt);
1260c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1270c0d06caSMauro Carvalho Chehab
1280c0d06caSMauro Carvalho Chehab return bcnt;
1290c0d06caSMauro Carvalho Chehab }
1300c0d06caSMauro Carvalho Chehab
1310c0d06caSMauro Carvalho Chehab
pvr2_debugifc_print_status(struct pvr2_hdw * hdw,char * buf,unsigned int acnt)1320c0d06caSMauro Carvalho Chehab int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
1330c0d06caSMauro Carvalho Chehab char *buf,unsigned int acnt)
1340c0d06caSMauro Carvalho Chehab {
1350c0d06caSMauro Carvalho Chehab int bcnt = 0;
1360c0d06caSMauro Carvalho Chehab int ccnt;
1370c0d06caSMauro Carvalho Chehab int ret;
1380c0d06caSMauro Carvalho Chehab u32 gpio_dir,gpio_in,gpio_out;
1390c0d06caSMauro Carvalho Chehab struct pvr2_stream_stats stats;
1400c0d06caSMauro Carvalho Chehab struct pvr2_stream *sp;
1410c0d06caSMauro Carvalho Chehab
1420c0d06caSMauro Carvalho Chehab ret = pvr2_hdw_is_hsm(hdw);
1430c0d06caSMauro Carvalho Chehab ccnt = scnprintf(buf,acnt,"USB link speed: %s\n",
1440c0d06caSMauro Carvalho Chehab (ret < 0 ? "FAIL" : (ret ? "high" : "full")));
1450c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1460c0d06caSMauro Carvalho Chehab
1470c0d06caSMauro Carvalho Chehab gpio_dir = 0; gpio_in = 0; gpio_out = 0;
1480c0d06caSMauro Carvalho Chehab pvr2_hdw_gpio_get_dir(hdw,&gpio_dir);
1490c0d06caSMauro Carvalho Chehab pvr2_hdw_gpio_get_out(hdw,&gpio_out);
1500c0d06caSMauro Carvalho Chehab pvr2_hdw_gpio_get_in(hdw,&gpio_in);
1510c0d06caSMauro Carvalho Chehab ccnt = scnprintf(buf,acnt,"GPIO state: dir=0x%x in=0x%x out=0x%x\n",
1520c0d06caSMauro Carvalho Chehab gpio_dir,gpio_in,gpio_out);
1530c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1540c0d06caSMauro Carvalho Chehab
1550c0d06caSMauro Carvalho Chehab ccnt = scnprintf(buf,acnt,"Streaming is %s\n",
1560c0d06caSMauro Carvalho Chehab pvr2_hdw_get_streaming(hdw) ? "on" : "off");
1570c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1580c0d06caSMauro Carvalho Chehab
1590c0d06caSMauro Carvalho Chehab
1600c0d06caSMauro Carvalho Chehab sp = pvr2_hdw_get_video_stream(hdw);
1610c0d06caSMauro Carvalho Chehab if (sp) {
1620c0d06caSMauro Carvalho Chehab pvr2_stream_get_stats(sp, &stats, 0);
1630c0d06caSMauro Carvalho Chehab ccnt = scnprintf(
1640c0d06caSMauro Carvalho Chehab buf,acnt,
16596292c89SMauro Carvalho Chehab "Bytes streamed=%u URBs: queued=%u idle=%u ready=%u processed=%u failed=%u\n",
1660c0d06caSMauro Carvalho Chehab stats.bytes_processed,
1670c0d06caSMauro Carvalho Chehab stats.buffers_in_queue,
1680c0d06caSMauro Carvalho Chehab stats.buffers_in_idle,
1690c0d06caSMauro Carvalho Chehab stats.buffers_in_ready,
1700c0d06caSMauro Carvalho Chehab stats.buffers_processed,
1710c0d06caSMauro Carvalho Chehab stats.buffers_failed);
1720c0d06caSMauro Carvalho Chehab bcnt += ccnt; acnt -= ccnt; buf += ccnt;
1730c0d06caSMauro Carvalho Chehab }
1740c0d06caSMauro Carvalho Chehab
1750c0d06caSMauro Carvalho Chehab return bcnt;
1760c0d06caSMauro Carvalho Chehab }
1770c0d06caSMauro Carvalho Chehab
1780c0d06caSMauro Carvalho Chehab
pvr2_debugifc_do1cmd(struct pvr2_hdw * hdw,const char * buf,unsigned int count)1790c0d06caSMauro Carvalho Chehab static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
1800c0d06caSMauro Carvalho Chehab unsigned int count)
1810c0d06caSMauro Carvalho Chehab {
1820c0d06caSMauro Carvalho Chehab const char *wptr;
1830c0d06caSMauro Carvalho Chehab unsigned int wlen;
1840c0d06caSMauro Carvalho Chehab unsigned int scnt;
1850c0d06caSMauro Carvalho Chehab
1860c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
1870c0d06caSMauro Carvalho Chehab if (!scnt) return 0;
1880c0d06caSMauro Carvalho Chehab count -= scnt; buf += scnt;
1890c0d06caSMauro Carvalho Chehab if (!wptr) return 0;
1900c0d06caSMauro Carvalho Chehab
1910c0d06caSMauro Carvalho Chehab pvr2_trace(PVR2_TRACE_DEBUGIFC,"debugifc cmd: \"%.*s\"",wlen,wptr);
1920c0d06caSMauro Carvalho Chehab if (debugifc_match_keyword(wptr,wlen,"reset")) {
1930c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
1940c0d06caSMauro Carvalho Chehab if (!scnt) return -EINVAL;
1950c0d06caSMauro Carvalho Chehab count -= scnt; buf += scnt;
1960c0d06caSMauro Carvalho Chehab if (!wptr) return -EINVAL;
1970c0d06caSMauro Carvalho Chehab if (debugifc_match_keyword(wptr,wlen,"cpu")) {
1980c0d06caSMauro Carvalho Chehab pvr2_hdw_cpureset_assert(hdw,!0);
1990c0d06caSMauro Carvalho Chehab pvr2_hdw_cpureset_assert(hdw,0);
2000c0d06caSMauro Carvalho Chehab return 0;
2010c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"bus")) {
2020c0d06caSMauro Carvalho Chehab pvr2_hdw_device_reset(hdw);
2030c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"soft")) {
2040c0d06caSMauro Carvalho Chehab return pvr2_hdw_cmd_powerup(hdw);
2050c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"deep")) {
2060c0d06caSMauro Carvalho Chehab return pvr2_hdw_cmd_deep_reset(hdw);
2070c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"firmware")) {
2080c0d06caSMauro Carvalho Chehab return pvr2_upload_firmware2(hdw);
2090c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"decoder")) {
2100c0d06caSMauro Carvalho Chehab return pvr2_hdw_cmd_decoder_reset(hdw);
2110c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"worker")) {
2120c0d06caSMauro Carvalho Chehab return pvr2_hdw_untrip(hdw);
2130c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"usbstats")) {
2140c0d06caSMauro Carvalho Chehab pvr2_stream_get_stats(pvr2_hdw_get_video_stream(hdw),
2150c0d06caSMauro Carvalho Chehab NULL, !0);
2160c0d06caSMauro Carvalho Chehab return 0;
2170c0d06caSMauro Carvalho Chehab }
2180c0d06caSMauro Carvalho Chehab return -EINVAL;
2190c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"cpufw")) {
2200c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
2210c0d06caSMauro Carvalho Chehab if (!scnt) return -EINVAL;
2220c0d06caSMauro Carvalho Chehab count -= scnt; buf += scnt;
2230c0d06caSMauro Carvalho Chehab if (!wptr) return -EINVAL;
2240c0d06caSMauro Carvalho Chehab if (debugifc_match_keyword(wptr,wlen,"fetch")) {
2250c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
2260c0d06caSMauro Carvalho Chehab if (scnt && wptr) {
2270c0d06caSMauro Carvalho Chehab count -= scnt; buf += scnt;
2280c0d06caSMauro Carvalho Chehab if (debugifc_match_keyword(wptr, wlen,
2290c0d06caSMauro Carvalho Chehab "prom")) {
2300c0d06caSMauro Carvalho Chehab pvr2_hdw_cpufw_set_enabled(hdw, 2, !0);
2310c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr, wlen,
2320c0d06caSMauro Carvalho Chehab "ram8k")) {
2330c0d06caSMauro Carvalho Chehab pvr2_hdw_cpufw_set_enabled(hdw, 0, !0);
2340c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr, wlen,
2350c0d06caSMauro Carvalho Chehab "ram16k")) {
2360c0d06caSMauro Carvalho Chehab pvr2_hdw_cpufw_set_enabled(hdw, 1, !0);
2370c0d06caSMauro Carvalho Chehab } else {
2380c0d06caSMauro Carvalho Chehab return -EINVAL;
2390c0d06caSMauro Carvalho Chehab }
2400c0d06caSMauro Carvalho Chehab }
2410c0d06caSMauro Carvalho Chehab pvr2_hdw_cpufw_set_enabled(hdw,0,!0);
2420c0d06caSMauro Carvalho Chehab return 0;
2430c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"done")) {
2440c0d06caSMauro Carvalho Chehab pvr2_hdw_cpufw_set_enabled(hdw,0,0);
2450c0d06caSMauro Carvalho Chehab return 0;
2460c0d06caSMauro Carvalho Chehab } else {
2470c0d06caSMauro Carvalho Chehab return -EINVAL;
2480c0d06caSMauro Carvalho Chehab }
2490c0d06caSMauro Carvalho Chehab } else if (debugifc_match_keyword(wptr,wlen,"gpio")) {
2500c0d06caSMauro Carvalho Chehab int dir_fl = 0;
2510c0d06caSMauro Carvalho Chehab int ret;
2520c0d06caSMauro Carvalho Chehab u32 msk,val;
2530c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
2540c0d06caSMauro Carvalho Chehab if (!scnt) return -EINVAL;
2550c0d06caSMauro Carvalho Chehab count -= scnt; buf += scnt;
2560c0d06caSMauro Carvalho Chehab if (!wptr) return -EINVAL;
2570c0d06caSMauro Carvalho Chehab if (debugifc_match_keyword(wptr,wlen,"dir")) {
2580c0d06caSMauro Carvalho Chehab dir_fl = !0;
2590c0d06caSMauro Carvalho Chehab } else if (!debugifc_match_keyword(wptr,wlen,"out")) {
2600c0d06caSMauro Carvalho Chehab return -EINVAL;
2610c0d06caSMauro Carvalho Chehab }
2620c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
2630c0d06caSMauro Carvalho Chehab if (!scnt) return -EINVAL;
2640c0d06caSMauro Carvalho Chehab count -= scnt; buf += scnt;
2650c0d06caSMauro Carvalho Chehab if (!wptr) return -EINVAL;
2660c0d06caSMauro Carvalho Chehab ret = debugifc_parse_unsigned_number(wptr,wlen,&msk);
2670c0d06caSMauro Carvalho Chehab if (ret) return ret;
2680c0d06caSMauro Carvalho Chehab scnt = debugifc_isolate_word(buf,count,&wptr,&wlen);
2690c0d06caSMauro Carvalho Chehab if (wptr) {
2700c0d06caSMauro Carvalho Chehab ret = debugifc_parse_unsigned_number(wptr,wlen,&val);
2710c0d06caSMauro Carvalho Chehab if (ret) return ret;
2720c0d06caSMauro Carvalho Chehab } else {
2730c0d06caSMauro Carvalho Chehab val = msk;
2740c0d06caSMauro Carvalho Chehab msk = 0xffffffff;
2750c0d06caSMauro Carvalho Chehab }
2760c0d06caSMauro Carvalho Chehab if (dir_fl) {
2770c0d06caSMauro Carvalho Chehab ret = pvr2_hdw_gpio_chg_dir(hdw,msk,val);
2780c0d06caSMauro Carvalho Chehab } else {
2790c0d06caSMauro Carvalho Chehab ret = pvr2_hdw_gpio_chg_out(hdw,msk,val);
2800c0d06caSMauro Carvalho Chehab }
2810c0d06caSMauro Carvalho Chehab return ret;
2820c0d06caSMauro Carvalho Chehab }
2830c0d06caSMauro Carvalho Chehab pvr2_trace(PVR2_TRACE_DEBUGIFC,
2840c0d06caSMauro Carvalho Chehab "debugifc failed to recognize cmd: \"%.*s\"",wlen,wptr);
2850c0d06caSMauro Carvalho Chehab return -EINVAL;
2860c0d06caSMauro Carvalho Chehab }
2870c0d06caSMauro Carvalho Chehab
2880c0d06caSMauro Carvalho Chehab
pvr2_debugifc_docmd(struct pvr2_hdw * hdw,const char * buf,unsigned int count)2890c0d06caSMauro Carvalho Chehab int pvr2_debugifc_docmd(struct pvr2_hdw *hdw,const char *buf,
2900c0d06caSMauro Carvalho Chehab unsigned int count)
2910c0d06caSMauro Carvalho Chehab {
2920c0d06caSMauro Carvalho Chehab unsigned int bcnt = 0;
2930c0d06caSMauro Carvalho Chehab int ret;
2940c0d06caSMauro Carvalho Chehab
2950c0d06caSMauro Carvalho Chehab while (count) {
2960c0d06caSMauro Carvalho Chehab for (bcnt = 0; bcnt < count; bcnt++) {
2970c0d06caSMauro Carvalho Chehab if (buf[bcnt] == '\n') break;
2980c0d06caSMauro Carvalho Chehab }
2990c0d06caSMauro Carvalho Chehab
3000c0d06caSMauro Carvalho Chehab ret = pvr2_debugifc_do1cmd(hdw,buf,bcnt);
3010c0d06caSMauro Carvalho Chehab if (ret < 0) return ret;
3020c0d06caSMauro Carvalho Chehab if (bcnt < count) bcnt++;
3030c0d06caSMauro Carvalho Chehab buf += bcnt;
3040c0d06caSMauro Carvalho Chehab count -= bcnt;
3050c0d06caSMauro Carvalho Chehab }
3060c0d06caSMauro Carvalho Chehab
3070c0d06caSMauro Carvalho Chehab return 0;
3080c0d06caSMauro Carvalho Chehab }
309