nusb/lib: use fmtprint for the entire dump to be printed out
This commit is contained in:
parent
603d9812a7
commit
0505f8fb3a
1 changed files with 20 additions and 26 deletions
|
@ -48,26 +48,26 @@ hexstr(void *a, int n)
|
||||||
return dbuff;
|
return dbuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static void
|
||||||
seprintiface(char *s, char *e, Iface *i)
|
fmtprintiface(Fmt *f, Iface *i)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
Altc *a;
|
Altc *a;
|
||||||
Ep *ep;
|
Ep *ep;
|
||||||
char *eds, *ets;
|
char *eds, *ets;
|
||||||
|
|
||||||
s = seprint(s, e, "\t\tiface csp %s.%uld.%uld\n",
|
fmtprint(f, "\t\tiface csp %s.%uld.%uld\n",
|
||||||
classname(Class(i->csp)), Subclass(i->csp), Proto(i->csp));
|
classname(Class(i->csp)), Subclass(i->csp), Proto(i->csp));
|
||||||
for(j = 0; j < Naltc; j++){
|
for(j = 0; j < Naltc; j++){
|
||||||
a=i->altc[j];
|
a=i->altc[j];
|
||||||
if(a == nil)
|
if(a == nil)
|
||||||
break;
|
break;
|
||||||
s = seprint(s, e, "\t\t alt %d attr %d ival %d",
|
fmtprint(f, "\t\t alt %d attr %d ival %d",
|
||||||
j, a->attrib, a->interval);
|
j, a->attrib, a->interval);
|
||||||
if(a->aux != nil)
|
if(a->aux != nil)
|
||||||
s = seprint(s, e, " devspec %p\n", a->aux);
|
fmtprint(f, " devspec %p\n", a->aux);
|
||||||
else
|
else
|
||||||
s = seprint(s, e, "\n");
|
fmtprint(f, "\n");
|
||||||
}
|
}
|
||||||
for(j = 0; j < Nep; j++){
|
for(j = 0; j < Nep; j++){
|
||||||
ep = i->ep[j];
|
ep = i->ep[j];
|
||||||
|
@ -78,41 +78,39 @@ seprintiface(char *s, char *e, Iface *i)
|
||||||
eds = edir[ep->dir];
|
eds = edir[ep->dir];
|
||||||
if(ep->type <= nelem(etype))
|
if(ep->type <= nelem(etype))
|
||||||
ets = etype[ep->type];
|
ets = etype[ep->type];
|
||||||
s = seprint(s, e, "\t\t ep id %d addr %d dir %s type %s"
|
fmtprint(f, "\t\t ep id %d addr %d dir %s type %s"
|
||||||
" itype %d maxpkt %d ntds %d\n",
|
" itype %d maxpkt %d ntds %d\n",
|
||||||
ep->id, ep->addr, eds, ets, ep->isotype,
|
ep->id, ep->addr, eds, ets, ep->isotype,
|
||||||
ep->maxpkt, ep->ntds);
|
ep->maxpkt, ep->ntds);
|
||||||
}
|
}
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
static void
|
||||||
seprintconf(char *s, char *e, Usbdev *d, int ci)
|
fmtprintconf(Fmt *f, Usbdev *d, int ci)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Conf *c;
|
Conf *c;
|
||||||
char *hd;
|
char *hd;
|
||||||
|
|
||||||
c = d->conf[ci];
|
c = d->conf[ci];
|
||||||
s = seprint(s, e, "\tconf: cval %d attrib %x %d mA\n",
|
fmtprint(f, "\tconf: cval %d attrib %x %d mA\n",
|
||||||
c->cval, c->attrib, c->milliamps);
|
c->cval, c->attrib, c->milliamps);
|
||||||
for(i = 0; i < Niface; i++)
|
for(i = 0; i < Niface; i++)
|
||||||
if(c->iface[i] == nil)
|
if(c->iface[i] == nil)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
s = seprintiface(s, e, c->iface[i]);
|
fmtprintiface(f, c->iface[i]);
|
||||||
for(i = 0; i < Nddesc; i++)
|
for(i = 0; i < Nddesc; i++)
|
||||||
if(d->ddesc[i] == nil)
|
if(d->ddesc[i] == nil)
|
||||||
break;
|
break;
|
||||||
else if(d->ddesc[i]->conf == c){
|
else if(d->ddesc[i]->conf == c){
|
||||||
hd = hexstr((uchar*)&d->ddesc[i]->data,
|
hd = hexstr((uchar*)&d->ddesc[i]->data,
|
||||||
d->ddesc[i]->data.bLength);
|
d->ddesc[i]->data.bLength);
|
||||||
s = seprint(s, e, "\t\tdev desc %x[%d]: %s\n",
|
fmtprint(f, "\t\tdev desc %x[%d]: %s\n",
|
||||||
d->ddesc[i]->data.bDescriptorType,
|
d->ddesc[i]->data.bDescriptorType,
|
||||||
d->ddesc[i]->data.bLength, hd);
|
d->ddesc[i]->data.bLength, hd);
|
||||||
free(hd);
|
free(hd);
|
||||||
}
|
}
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -121,30 +119,26 @@ Ufmt(Fmt *f)
|
||||||
int i;
|
int i;
|
||||||
Dev *d;
|
Dev *d;
|
||||||
Usbdev *ud;
|
Usbdev *ud;
|
||||||
char buf[1024];
|
|
||||||
char *s, *e;
|
|
||||||
|
|
||||||
s = buf;
|
|
||||||
e = buf+sizeof(buf);
|
|
||||||
d = va_arg(f->args, Dev*);
|
d = va_arg(f->args, Dev*);
|
||||||
if(d == nil)
|
if(d == nil)
|
||||||
return fmtprint(f, "<nildev>\n");
|
return fmtprint(f, "<nildev>\n");
|
||||||
s = seprint(s, e, "%s", d->dir);
|
fmtprint(f, "%s", d->dir);
|
||||||
ud = d->usb;
|
ud = d->usb;
|
||||||
if(ud == nil)
|
if(ud == nil)
|
||||||
return fmtprint(f, "%s %ld refs\n", buf, d->ref);
|
return fmtprint(f, " %ld refs\n", d->ref);
|
||||||
s = seprint(s, e, " csp %s.%uld.%uld",
|
fmtprint(f, " csp %s.%uld.%uld",
|
||||||
classname(Class(ud->csp)), Subclass(ud->csp), Proto(ud->csp));
|
classname(Class(ud->csp)), Subclass(ud->csp), Proto(ud->csp));
|
||||||
s = seprint(s, e, " vid %#ux did %#ux", ud->vid, ud->did);
|
fmtprint(f, " vid %#ux did %#ux", ud->vid, ud->did);
|
||||||
s = seprint(s, e, " refs %ld\n", d->ref);
|
fmtprint(f, " refs %ld\n", d->ref);
|
||||||
s = seprint(s, e, "\t%s %s %s\n", ud->vendor, ud->product, ud->serial);
|
fmtprint(f, "\t%s %s %s\n", ud->vendor, ud->product, ud->serial);
|
||||||
for(i = 0; i < Nconf; i++){
|
for(i = 0; i < Nconf; i++){
|
||||||
if(ud->conf[i] == nil)
|
if(ud->conf[i] == nil)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
s = seprintconf(s, e, ud, i);
|
fmtprintconf(f, ud, i);
|
||||||
}
|
}
|
||||||
return fmtprint(f, "%s", buf);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
|
|
Loading…
Reference in a new issue