replace ulong with more appropriate types Reference: /n/atom/patch/applied/nixusbclean Date: Sun Jan 12 04:14:34 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/k10/usbehci.h Sun Jan 12 04:14:06 2014 +++ /sys/src/nix/k10/usbehci.h Sun Jan 12 04:14:06 2014 @@ -41,7 +41,7 @@ Eopio* opio; /* Operational i/o regs */ int nframes; /* 1024, 512, or 256 frames in the list */ - ulong* frames; /* periodic frame list (hw) */ + u32int* frames; /* periodic frame list (hw) */ Qh* qhs; /* async Qh circular list for bulk/ctl */ Qtree* tree; /* tree of Qhs for the periodic list */ int ntree; /* number of dummy qhs in tree */ --- /sys/src/nix/k10/usbohci.c Sun Jan 12 04:14:10 2014 +++ /sys/src/nix/k10/usbohci.c Sun Jan 12 04:14:12 2014 @@ -196,7 +196,7 @@ Ed* ed; /* to place Tds on it */ int sched; /* queue number (intr/iso) */ int toggle; /* Tddata0/Tddata1 */ - ulong usbid; /* device/endpoint address */ + u32int usbid; /* device/endpoint address */ int tok; /* Tdsetup, Tdtokin, Tdtokout */ long iotime; /* last I/O time; to hold interrupt polls */ int debug; /* for the endpoint */ @@ -240,7 +240,7 @@ Ep* ep; /* using this Td for I/O */ Qio* io; /* using this Td for I/O */ Block* bp; /* data for this Td */ - ulong nbytes; /* bytes in this Td */ + u32int nbytes; /* bytes in this Td */ u32int cbp0; /* initial value for cbp */ int last; /* true for last Td in Qio */ }; @@ -395,7 +395,7 @@ { if(pa == 0) return nil; - else if(pa > 0xffffffff) + else if(sizeof(pa) > 4 && pa > 0xffffffff) panic("usb: ohci: highmem pa %#P", pa); return KADDR(pa); } @@ -408,7 +408,7 @@ if(p == nil) return 0; pa = PADDR(p); - if(pa > 0xffffffff) + if(sizeof(pa) > 4 && pa > 0xffffffff) panic("usb: ohci: highmemptr %#p", p); return pa; } @@ -524,9 +524,9 @@ } static void -edsetaddr(Ed *ed, ulong addr) +edsetaddr(Ed *ed, u32int addr) { - ulong ctrl; + u32int ctrl; ctrl = ed->ctrl & ~((Epmax<<7)|Devmax); ctrl |= (addr & ((Epmax<<7)|Devmax)); @@ -563,7 +563,7 @@ static void edsetmaxpkt(Ed *ed, int m) { - ulong c; + u32int c; c = ed->ctrl & ~(Edmpsmask << Edmpsshift); ed->ctrl = c | ((m&Edmpsmask) << Edmpsshift); @@ -587,7 +587,7 @@ void *va; va = mallocalign(sz, align, 0, 0); - if(PADDR(va) > 0xffffffff) + if(sizeof(uintptr) >= 8 && (uintmem)PADDR(va) > 0xffffffffull) panic("usb: ohci: lomallocalign: mallocalign gives high mem %#p", va); return va; } @@ -857,7 +857,7 @@ } s = seprint(s, e, " cbp0 %#.8ux cbp %#.8ux next %#.8ux be %#.8ux %s", td->cbp0, td->cbp, td->nexttd, td->be, td->last ? "last" : ""); - s = seprint(s, e, "\n\t\t%ld bytes", td->nbytes); + s = seprint(s, e, "\n\t\t%d bytes", td->nbytes); if((bp = td->bp) != nil){ s = seprint(s, e, " rp %#p wp %#p ", bp->rp, bp->wp); if(BLEN(bp) > 0) @@ -944,7 +944,7 @@ seprintio(char *s, char *e, Qio *io, char *pref) { s = seprint(s, e, "%s qio %#p ed %#p", pref, io, io->ed); - s = seprint(s, e, " tog %d iot %ld err %s id %#ulx", + s = seprint(s, e, " tog %d iot %ld err %s id %#ux", io->toggle, io->iotime, io->err, io->usbid); s = seprinttdtok(s, e, io->tok); s = seprint(s, e, " %s\n", iosname[io->state]); @@ -987,7 +987,7 @@ } static char* -seprintctl(char *s, char *se, ulong ctl) +seprintctl(char *s, char *se, u32int ctl) { s = seprint(s, se, "en="); if((ctl&Cple) != 0) @@ -1065,7 +1065,7 @@ isodtdinit(Ep *ep, Isoio *iso, Td *td) { Block *bp; - long size; + u32int size; int i; bp = td->bp; @@ -1076,7 +1076,7 @@ if(size > ep->maxpkt){ print("ohci: ep%d.%d: size > maxpkt\n", ep->dev->nb, ep->nb); - print("size = %uld max = %ld\n", size, ep->maxpkt); + print("size = %ud max = %ld\n", size, ep->maxpkt); size = ep->maxpkt; } td->nbytes = size; @@ -1777,7 +1777,7 @@ putsamples(Ctlr *ctlr, Ep *ep, Isoio *iso, uchar *b, long count) { Td *td; - ulong n; + uint n; td = pa2ptr(iso->ed->tail); n = count; --- /sys/src/nix/k10/usbuhci.c Sun Jan 12 04:14:16 2014 +++ /sys/src/nix/k10/usbuhci.c Sun Jan 12 04:14:18 2014 @@ -244,7 +244,7 @@ Qh* next; /* in active or free list */ Td* tds; /* Td list in this Qh (initially, elink) */ char* tag; /* debug and align, mostly */ - ulong align; + u32int align; }; /* @@ -279,15 +279,14 @@ #define OUTS(x, v) outs(ctlr->port+(x), (v)) #define OUTL(x, v) outl(ctlr->port+(x), (v)) #define TRUNC(x, sz) ((x) & ((sz)-1)) -#define PTR(q) ((void*)KADDR((ulong)(q) & ~ (0xF|PCIWINDOW))) +#define PTR(q) ((void*)KADDR((uintmem)(q) & ~(uintmem)(0xf|PCIWINDOW))) #define QPTR(q) ((Qh*)PTR(q)) #define TPTR(q) ((Td*)PTR(q)) #define PORT(p) (Portsc0 + 2*(p)) -#define diprint if(debug || iso->debug)print -#define ddiprint if(debug>1 || iso->debug>1)print -#define dqprint if(debug || (qh->io && qh->io->debug))print -#define ddqprint if(debug>1 || (qh->io && qh->io->debug>1))print - +#define diprint(...) do{if(debug || iso->debug)print(__VA_ARGS__);}while(0) +#define ddiprint(...) do{if(debug>1 || iso->debug>1)print(__VA_ARGS__);}while(0) +#define dqprint(...) do{if(debug || (qh->io && qh->io->debug))print(__VA_ARGS__);}while(0) +#define ddqprint(...) do{if(debug>1 || (qh->io && qh->io->debug>1))print(__VA_ARGS__);}while(0) static Ctlr* ctlrs[Nhcis]; static Tdpool tdpool; @@ -446,7 +445,7 @@ } static int -sameptr(void *p, ulong l) +sameptr(void *p, uintmem l) { if(l & QHterm) return p == nil; @@ -482,7 +481,7 @@ char buf[256]; char *s; char *se; - ulong td; + u32int td; int i; s = buf; @@ -513,7 +512,7 @@ print("\thw tds:"); i = 0; for(td = qh->elink; (td & Tdterm) == 0; td = TPTR(td)->link){ - print(" %#ulx", td); + print(" %#ux", td); if(td == TPTR(td)->link) /* BWS Td */ break; if(i++ > 40){ @@ -2153,7 +2152,7 @@ if(0) qh->link = PCIWADDR(ctlr->qhs); - frsize = Nframes*sizeof(ulong); + frsize = Nframes*sizeof(u32int); ctlr->frames = mallocalign(frsize, frsize, 0, 0); if(ctlr->frames == nil) panic("uhci reset: no memory");