diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2007-05-21 06:10:45 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2007-05-21 06:10:45 +0000 |
commit | 0ee94271e89f93fd778e45ae27e6cb9c3aca5e9d (patch) | |
tree | b9fb9ed59bf3748729e9792176b0f90a1d40b5d3 | |
parent | 1b539c3c7dd463c768cad0db562eab4a77af23c6 (diff) |
Remove le{16,32}toh macros
-rw-r--r-- | sys/dev/usb/ehci.c | 26 | ||||
-rw-r--r-- | sys/dev/usb/if_ral.c | 4 | ||||
-rw-r--r-- | sys/dev/usb/if_rum.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/if_ubt.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/ohci.c | 126 | ||||
-rw-r--r-- | sys/dev/usb/uhci.c | 62 | ||||
-rw-r--r-- | sys/dev/usb/usb_port.h | 12 |
7 files changed, 116 insertions, 126 deletions
diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index 8feb626a385..7dea456ec38 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.68 2007/05/20 00:52:25 jsg Exp $ */ +/* $OpenBSD: ehci.c,v 1.69 2007/05/21 06:10:43 jsg Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -716,10 +716,10 @@ ehci_check_intr(ehci_softc_t *sc, struct ehci_xfer *ex) * is a an error somewhere in the middle, or whether there was a * short packet (SPD and not ACTIVE). */ - if (le32toh(lsqtd->qtd.qtd_status) & EHCI_QTD_ACTIVE) { + if (letoh32(lsqtd->qtd.qtd_status) & EHCI_QTD_ACTIVE) { DPRINTFN(12, ("ehci_check_intr: active ex=%p\n", ex)); for (sqtd = ex->sqtdstart; sqtd != lsqtd; sqtd=sqtd->nextqtd) { - status = le32toh(sqtd->qtd.qtd_status); + status = letoh32(sqtd->qtd.qtd_status); /* If there's an active QTD the xfer isn't done. */ if (status & EHCI_QTD_ACTIVE) break; @@ -788,7 +788,7 @@ ehci_idone(struct ehci_xfer *ex) actlen = 0; for (sqtd = ex->sqtdstart; sqtd != lsqtd->nextqtd; sqtd = sqtd->nextqtd) { - nstatus = le32toh(sqtd->qtd.qtd_status); + nstatus = letoh32(sqtd->qtd.qtd_status); if (nstatus & EHCI_QTD_ACTIVE) break; @@ -1210,7 +1210,7 @@ ehci_dump() void ehci_dump_link(ehci_link_t link, int type) { - link = le32toh(link); + link = letoh32(link); printf("0x%08x", link); if (link & EHCI_LINK_TERMINATE) printf("<T>"); @@ -1259,7 +1259,7 @@ ehci_dump_qtd(ehci_qtd_t *qtd) printf(" next="); ehci_dump_link(qtd->qtd_next, 0); printf(" altnext="); ehci_dump_link(qtd->qtd_altnext, 0); printf("\n"); - s = le32toh(qtd->qtd_status); + s = letoh32(qtd->qtd_status); bitmask_snprintf(EHCI_QTD_GET_STATUS(s), "\20\10ACTIVE\7HALTED" "\6BUFERR\5BABBLE\4XACTERR\3MISSED\2SPLIT\1PING", sbuf, sizeof(sbuf)); @@ -1269,7 +1269,7 @@ ehci_dump_qtd(ehci_qtd_t *qtd) printf(" cerr=%d pid=%d stat=0x%s\n", EHCI_QTD_GET_CERR(s), EHCI_QTD_GET_PID(s), sbuf); for (s = 0; s < 5; s++) - printf(" buffer[%d]=0x%08x\n", s, le32toh(qtd->qtd_buffer[s])); + printf(" buffer[%d]=0x%08x\n", s, letoh32(qtd->qtd_buffer[s])); } void @@ -1280,7 +1280,7 @@ ehci_dump_sqh(ehci_soft_qh_t *sqh) printf("QH(%p) at 0x%08x:\n", sqh, sqh->physaddr); printf(" link="); ehci_dump_link(qh->qh_link, 1); printf("\n"); - endp = le32toh(qh->qh_endp); + endp = letoh32(qh->qh_endp); printf(" endp=0x%08x\n", endp); printf(" addr=0x%02x inact=%d endpt=%d eps=%d dtc=%d hrecl=%d\n", EHCI_QH_GET_ADDR(endp), EHCI_QH_GET_INACT(endp), @@ -1289,7 +1289,7 @@ ehci_dump_sqh(ehci_soft_qh_t *sqh) printf(" mpl=0x%x ctl=%d nrl=%d\n", EHCI_QH_GET_MPL(endp), EHCI_QH_GET_CTL(endp), EHCI_QH_GET_NRL(endp)); - endphub = le32toh(qh->qh_endphub); + endphub = letoh32(qh->qh_endphub); printf(" endphub=0x%08x\n", endphub); printf(" smask=0x%02x cmask=0x%02x huba=0x%02x port=%d mult=%d\n", EHCI_QH_GET_SMASK(endphub), EHCI_QH_GET_CMASK(endphub), @@ -2401,7 +2401,7 @@ ehci_close_pipe(usbd_pipe_handle pipe, ehci_soft_qh_t *head) ehci_rem_qh(sc, sqh, head); splx(s); pipe->endpoint->savedtoggle = - EHCI_QTD_GET_TOGGLE(le32toh(sqh->qh.qh_qtd.qtd_status)); + EHCI_QTD_GET_TOGGLE(letoh32(sqh->qh.qh_qtd.qtd_status)); ehci_free_sqh(sc, epipe->sqh); } @@ -2525,7 +2525,7 @@ ehci_abort_xfer(usbd_xfer_handle xfer, usbd_status status) * the aborting xfer. (If there is something past us). * Hardware and software. */ - cur = EHCI_LINK_ADDR(le32toh(sqh->qh.qh_curqtd)); + cur = EHCI_LINK_ADDR(letoh32(sqh->qh.qh_curqtd)); hit = 0; /* If they initially point here. */ @@ -2543,9 +2543,9 @@ ehci_abort_xfer(usbd_xfer_handle xfer, usbd_status status) sqtd = sqh->sqtd; while (sqtd && sqtd != exfer->sqtdstart) { hit |= (cur == sqtd->physaddr); - if (EHCI_LINK_ADDR(le32toh(sqtd->qtd.qtd_next)) == us) + if (EHCI_LINK_ADDR(letoh32(sqtd->qtd.qtd_next)) == us) sqtd->qtd.qtd_next = next; - if (EHCI_LINK_ADDR(le32toh(sqtd->qtd.qtd_altnext)) == us) + if (EHCI_LINK_ADDR(letoh32(sqtd->qtd.qtd_altnext)) == us) sqtd->qtd.qtd_altnext = next; psqtd = &sqtd->nextqtd; sqtd = sqtd->nextqtd; diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index dd023fc0078..40b7fd9dc42 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.90 2007/05/21 05:40:27 jsg Exp $ */ +/* $OpenBSD: if_ral.c,v 1.91 2007/05/21 06:10:43 jsg Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -1415,7 +1415,7 @@ ural_read(struct ural_softc *sc, uint16_t reg) USBDEVNAME(sc->sc_dev), usbd_errstr(error)); return 0; } - return le16toh(val); + return letoh16(val); } Static void diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index c20370b678a..c15595738f1 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rum.c,v 1.55 2007/05/21 05:40:27 jsg Exp $ */ +/* $OpenBSD: if_rum.c,v 1.56 2007/05/21 06:10:43 jsg Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> @@ -1857,7 +1857,7 @@ rum_read_eeprom(struct rum_softc *sc) DPRINTF(("RF revision=%d\n", sc->rf_rev)); rum_eeprom_read(sc, RT2573_EEPROM_CONFIG2, &val, 2); - val = le16toh(val); + val = letoh16(val); sc->ext_5ghz_lna = (val >> 6) & 0x1; sc->ext_2ghz_lna = (val >> 4) & 0x1; @@ -1878,7 +1878,7 @@ rum_read_eeprom(struct rum_softc *sc) sc->rssi_2ghz_corr, sc->rssi_5ghz_corr)); rum_eeprom_read(sc, RT2573_EEPROM_FREQ_OFFSET, &val, 2); - val = le16toh(val); + val = letoh16(val); if ((val & 0xff) != 0xff) sc->rffreq = val & 0xff; diff --git a/sys/dev/usb/if_ubt.c b/sys/dev/usb/if_ubt.c index a41eac0026f..e3acdf3ff84 100644 --- a/sys/dev/usb/if_ubt.c +++ b/sys/dev/usb/if_ubt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ubt.c,v 1.7 2007/04/26 17:00:28 miod Exp $ */ +/* $OpenBSD: if_ubt.c,v 1.8 2007/05/21 06:10:43 jsg Exp $ */ /* * ng_ubt.c @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: if_ubt.c,v 1.7 2007/04/26 17:00:28 miod Exp $ + * $Id: if_ubt.c,v 1.8 2007/05/21 06:10:43 jsg Exp $ * $FreeBSD: src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c,v 1.20 2004/10/12 23:33:46 emax Exp $ */ @@ -1131,7 +1131,7 @@ ubt_bulk_in_complete(usbd_xfer_handle h, usbd_private_handle p, usbd_status s) goto done; } - len = le16toh(hdr->length); + len = letoh16(hdr->length); if (len == m->m_pkthdr.len - sizeof(*hdr)) { NG_UBT_INFO( "%s: %s - Got complete ACL data frame, pktlen=%d, length=%d\n", diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index 51343cc4184..efce97685d7 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.77 2007/05/21 05:40:27 jsg Exp $ */ +/* $OpenBSD: ohci.c,v 1.78 2007/05/21 06:10:43 jsg Exp $ */ /* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -1072,8 +1072,8 @@ ohci_dumpregs(ohci_softc_t *sc) OREAD4(sc, OHCI_RH_PORT_STATUS(1)), OREAD4(sc, OHCI_RH_PORT_STATUS(2)))); DPRINTF((" HCCA: frame_number=0x%04x done_head=0x%08x\n", - le32toh(sc->sc_hcca->hcca_frame_number), - le32toh(sc->sc_hcca->hcca_done_head))); + letoh32(sc->sc_hcca->hcca_frame_number), + letoh32(sc->sc_hcca->hcca_done_head))); } #endif @@ -1119,7 +1119,7 @@ ohci_intr1(ohci_softc_t *sc) } intrs = 0; - done = le32toh(sc->sc_hcca->hcca_done_head); + done = letoh32(sc->sc_hcca->hcca_done_head); if (done != 0) { if (done & ~OHCI_DONE_INTRS) intrs = OHCI_WDH; @@ -1130,7 +1130,7 @@ ohci_intr1(ohci_softc_t *sc) intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS); /* If we've flushed out a WDH then reread */ if (intrs & OHCI_WDH) { - done = le32toh(sc->sc_hcca->hcca_done_head); + done = letoh32(sc->sc_hcca->hcca_done_head); sc->sc_hcca->hcca_done_head = 0; } } @@ -1263,7 +1263,7 @@ ohci_add_done(ohci_softc_t *sc, ohci_physaddr_t done) std = ohci_hash_find_td(sc, done); if (std != NULL) { std->dnext = sdone; - done = le32toh(std->td.td_nexttd); + done = letoh32(std->td.td_nexttd); sdone = std; DPRINTFN(10,("add TD %p\n", std)); continue; @@ -1271,7 +1271,7 @@ ohci_add_done(ohci_softc_t *sc, ohci_physaddr_t done) sitd = ohci_hash_find_itd(sc, done); if (sitd != NULL) { sitd->dnext = sidone; - done = le32toh(sitd->itd.itd_nextitd); + done = letoh32(sitd->itd.itd_nextitd); sidone = sitd; DPRINTFN(5,("add ITD %p\n", sitd)); continue; @@ -1345,14 +1345,14 @@ ohci_softintr(void *v) len = std->len; if (std->td.td_cbp != 0) - len -= le32toh(std->td.td_be) - - le32toh(std->td.td_cbp) + 1; + len -= letoh32(std->td.td_be) - + letoh32(std->td.td_cbp) + 1; DPRINTFN(10, ("ohci_process_done: len=%d, flags=0x%x\n", len, std->flags)); if (std->flags & OHCI_ADD_LEN) xfer->actlen += len; - cc = OHCI_TD_GET_CC(le32toh(std->td.td_flags)); + cc = OHCI_TD_GET_CC(letoh32(std->td.td_flags)); if (cc == OHCI_CC_NO_ERROR) { if (std->flags & OHCI_CALL_DONE) { xfer->status = USBD_NORMAL_COMPLETION; @@ -1371,8 +1371,8 @@ ohci_softintr(void *v) opipe = (struct ohci_pipe *)xfer->pipe; DPRINTFN(15,("ohci_process_done: error cc=%d (%s)\n", - OHCI_TD_GET_CC(le32toh(std->td.td_flags)), - ohci_cc_strs[OHCI_TD_GET_CC(le32toh(std->td.td_flags))])); + OHCI_TD_GET_CC(letoh32(std->td.td_flags)), + ohci_cc_strs[OHCI_TD_GET_CC(letoh32(std->td.td_flags))])); /* remove TDs */ for (p = std; p->xfer == xfer; p = n) { @@ -1432,17 +1432,17 @@ ohci_softintr(void *v) for (i = 0, sitd = xfer->hcpriv;; sitd = next) { next = sitd->nextitd; - if (OHCI_ITD_GET_CC(le32toh(sitd-> + if (OHCI_ITD_GET_CC(letoh32(sitd-> itd.itd_flags)) != OHCI_CC_NO_ERROR) xfer->status = USBD_IOERROR; /* For input, update frlengths with actual */ /* XXX anything necessary for output? */ if (uedir == UE_DIR_IN && xfer->status == USBD_NORMAL_COMPLETION) { - iframes = OHCI_ITD_GET_FC(le32toh( + iframes = OHCI_ITD_GET_FC(letoh32( sitd->itd.itd_flags)); for (j = 0; j < iframes; i++, j++) { - len = le16toh(sitd-> + len = letoh16(sitd-> itd.itd_offset[j]); if ((OHCI_ITD_PSW_GET_CC(len) & OHCI_CC_NOT_ACCESSED_MASK) @@ -1522,7 +1522,7 @@ ohci_device_intr_done(usbd_xfer_handle xfer) data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf, 0)); data->nexttd = tail; data->td.td_nexttd = htole32(tail->physaddr); - data->td.td_be = htole32(le32toh(data->td.td_cbp) + + data->td.td_be = htole32(letoh32(data->td.td_cbp) + xfer->length - 1); data->len = xfer->length; data->xfer = xfer; @@ -1685,7 +1685,7 @@ ohci_device_request(usbd_xfer_handle xfer) /* XXX This only needs to be done once, but it's too early in open. */ /* XXXX Should not touch ED here! */ sed->ed.ed_flags = htole32( - (le32toh(sed->ed.ed_flags) & ~(OHCI_ED_ADDRMASK | OHCI_ED_MAXPMASK)) | + (letoh32(sed->ed.ed_flags) & ~(OHCI_ED_ADDRMASK | OHCI_ED_MAXPMASK)) | OHCI_ED_SET_FA(addr) | OHCI_ED_SET_MAXP(UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize))); @@ -1712,7 +1712,7 @@ ohci_device_request(usbd_xfer_handle xfer) setup->td.td_cbp = htole32(DMAADDR(&opipe->u.ctl.reqdma, 0)); setup->nexttd = next; setup->td.td_nexttd = htole32(next->physaddr); - setup->td.td_be = htole32(le32toh(setup->td.td_cbp) + sizeof *req - 1); + setup->td.td_be = htole32(letoh32(setup->td.td_cbp) + sizeof *req - 1); setup->len = 0; setup->xfer = xfer; setup->flags = 0; @@ -1936,19 +1936,19 @@ ohci_dump_td(ohci_soft_td_t *std) { char sbuf[128]; - bitmask_snprintf((u_int32_t)le32toh(std->td.td_flags), + bitmask_snprintf((u_int32_t)letoh32(std->td.td_flags), "\20\23R\24OUT\25IN\31TOG1\32SETTOGGLE", sbuf, sizeof(sbuf)); printf("TD(%p) at %08lx: %s delay=%d ec=%d cc=%d\ncbp=0x%08lx " "nexttd=0x%08lx be=0x%08lx\n", std, (u_long)std->physaddr, sbuf, - OHCI_TD_GET_DI(le32toh(std->td.td_flags)), - OHCI_TD_GET_EC(le32toh(std->td.td_flags)), - OHCI_TD_GET_CC(le32toh(std->td.td_flags)), - (u_long)le32toh(std->td.td_cbp), - (u_long)le32toh(std->td.td_nexttd), - (u_long)le32toh(std->td.td_be)); + OHCI_TD_GET_DI(letoh32(std->td.td_flags)), + OHCI_TD_GET_EC(letoh32(std->td.td_flags)), + OHCI_TD_GET_CC(letoh32(std->td.td_flags)), + (u_long)letoh32(std->td.td_cbp), + (u_long)letoh32(std->td.td_nexttd), + (u_long)letoh32(std->td.td_be)); } void @@ -1959,16 +1959,16 @@ ohci_dump_itd(ohci_soft_itd_t *sitd) printf("ITD(%p) at %08lx: sf=%d di=%d fc=%d cc=%d\n" "bp0=0x%08lx next=0x%08lx be=0x%08lx\n", sitd, (u_long)sitd->physaddr, - OHCI_ITD_GET_SF(le32toh(sitd->itd.itd_flags)), - OHCI_ITD_GET_DI(le32toh(sitd->itd.itd_flags)), - OHCI_ITD_GET_FC(le32toh(sitd->itd.itd_flags)), - OHCI_ITD_GET_CC(le32toh(sitd->itd.itd_flags)), - (u_long)le32toh(sitd->itd.itd_bp0), - (u_long)le32toh(sitd->itd.itd_nextitd), - (u_long)le32toh(sitd->itd.itd_be)); + OHCI_ITD_GET_SF(letoh32(sitd->itd.itd_flags)), + OHCI_ITD_GET_DI(letoh32(sitd->itd.itd_flags)), + OHCI_ITD_GET_FC(letoh32(sitd->itd.itd_flags)), + OHCI_ITD_GET_CC(letoh32(sitd->itd.itd_flags)), + (u_long)letoh32(sitd->itd.itd_bp0), + (u_long)letoh32(sitd->itd.itd_nextitd), + (u_long)letoh32(sitd->itd.itd_be)); for (i = 0; i < OHCI_ITD_NOFFSET; i++) printf("offs[%d]=0x%04x ", i, - (u_int)le16toh(sitd->itd.itd_offset[i])); + (u_int)letoh16(sitd->itd.itd_offset[i])); printf("\n"); } @@ -1984,21 +1984,21 @@ ohci_dump_ed(ohci_soft_ed_t *sed) { char sbuf[128], sbuf2[128]; - bitmask_snprintf((u_int32_t)le32toh(sed->ed.ed_flags), + bitmask_snprintf((u_int32_t)letoh32(sed->ed.ed_flags), "\20\14OUT\15IN\16LOWSPEED\17SKIP\20ISO", sbuf, sizeof(sbuf)); - bitmask_snprintf((u_int32_t)le32toh(sed->ed.ed_headp), + bitmask_snprintf((u_int32_t)letoh32(sed->ed.ed_headp), "\20\1HALT\2CARRY", sbuf2, sizeof(sbuf2)); printf("ED(%p) at 0x%08lx: addr=%d endpt=%d maxp=%d flags=%s\n" "tailp=0x%08lx headflags=%s headp=0x%08lx nexted=0x%08lx\n", sed, (u_long)sed->physaddr, - OHCI_ED_GET_FA(le32toh(sed->ed.ed_flags)), - OHCI_ED_GET_EN(le32toh(sed->ed.ed_flags)), - OHCI_ED_GET_MAXP(le32toh(sed->ed.ed_flags)), sbuf, - (u_long)le32toh(sed->ed.ed_tailp), sbuf2, - (u_long)le32toh(sed->ed.ed_headp), - (u_long)le32toh(sed->ed.ed_nexted)); + OHCI_ED_GET_FA(letoh32(sed->ed.ed_flags)), + OHCI_ED_GET_EN(letoh32(sed->ed.ed_flags)), + OHCI_ED_GET_MAXP(letoh32(sed->ed.ed_flags)), sbuf, + (u_long)letoh32(sed->ed.ed_tailp), sbuf2, + (u_long)letoh32(sed->ed.ed_headp), + (u_long)letoh32(sed->ed.ed_nexted)); } #endif @@ -2130,14 +2130,14 @@ ohci_close_pipe(usbd_pipe_handle pipe, ohci_soft_ed_t *head) s = splusb(); #ifdef DIAGNOSTIC sed->ed.ed_flags |= htole32(OHCI_ED_SKIP); - if ((le32toh(sed->ed.ed_tailp) & OHCI_HEADMASK) != - (le32toh(sed->ed.ed_headp) & OHCI_HEADMASK)) { + if ((letoh32(sed->ed.ed_tailp) & OHCI_HEADMASK) != + (letoh32(sed->ed.ed_headp) & OHCI_HEADMASK)) { ohci_soft_td_t *std; - std = ohci_hash_find_td(sc, le32toh(sed->ed.ed_headp)); + std = ohci_hash_find_td(sc, letoh32(sed->ed.ed_headp)); printf("ohci_close_pipe: pipe not empty sed=%p hd=0x%x " "tl=0x%x pipe=%p, std=%p\n", sed, - (int)le32toh(sed->ed.ed_headp), - (int)le32toh(sed->ed.ed_tailp), + (int)letoh32(sed->ed.ed_headp), + (int)letoh32(sed->ed.ed_tailp), pipe, std); #ifdef USB_DEBUG usbd_dump_pipe(&opipe->pipe); @@ -2148,8 +2148,8 @@ ohci_close_pipe(usbd_pipe_handle pipe, ohci_soft_ed_t *head) ohci_dump_td(std); #endif usb_delay_ms(&sc->sc_bus, 2); - if ((le32toh(sed->ed.ed_tailp) & OHCI_HEADMASK) != - (le32toh(sed->ed.ed_headp) & OHCI_HEADMASK)) + if ((letoh32(sed->ed.ed_tailp) & OHCI_HEADMASK) != + (letoh32(sed->ed.ed_headp) & OHCI_HEADMASK)) printf("ohci_close_pipe: pipe still not empty\n"); } #endif @@ -2158,7 +2158,7 @@ ohci_close_pipe(usbd_pipe_handle pipe, ohci_soft_ed_t *head) usb_delay_ms(&sc->sc_bus, 1); splx(s); pipe->endpoint->savedtoggle = - (le32toh(sed->ed.ed_headp) & OHCI_TOGGLECARRY) ? 1 : 0; + (letoh32(sed->ed.ed_headp) & OHCI_TOGGLECARRY) ? 1 : 0; ohci_free_sed(sc, opipe->sed); } @@ -2247,19 +2247,19 @@ ohci_abort_xfer(usbd_xfer_handle xfer, usbd_status status) ohci_dump_tds(p); } #endif - headp = le32toh(sed->ed.ed_headp) & OHCI_HEADMASK; + headp = letoh32(sed->ed.ed_headp) & OHCI_HEADMASK; hit = 0; for (; p->xfer == xfer; p = n) { hit |= headp == p->physaddr; n = p->nexttd; - if (OHCI_TD_GET_CC(le32toh(p->td.td_flags)) == + if (OHCI_TD_GET_CC(letoh32(p->td.td_flags)) == OHCI_CC_NOT_ACCESSED) ohci_free_std(sc, p); } /* Zap headp register if hardware pointed inside the xfer. */ if (hit) { DPRINTFN(1,("ohci_abort_xfer: set hd=0x%08x, tl=0x%08x\n", - (int)p->physaddr, (int)le32toh(sed->ed.ed_tailp))); + (int)p->physaddr, (int)letoh32(sed->ed.ed_tailp))); sed->ed.ed_headp = htole32(p->physaddr); /* unlink TDs */ } else { DPRINTFN(1,("ohci_abort_xfer: no hit\n")); @@ -2881,7 +2881,7 @@ ohci_device_bulk_start(usbd_xfer_handle xfer) /* Update device address */ sed->ed.ed_flags = htole32( - (le32toh(sed->ed.ed_flags) & ~OHCI_ED_ADDRMASK) | + (letoh32(sed->ed.ed_flags) & ~OHCI_ED_ADDRMASK) | OHCI_ED_SET_FA(addr)); /* Allocate a chain of new TDs (including a new tail). */ @@ -2901,10 +2901,10 @@ ohci_device_bulk_start(usbd_xfer_handle xfer) DPRINTFN(4,("ohci_device_bulk_start: ed_flags=0x%08x td_flags=0x%08x " "td_cbp=0x%08x td_be=0x%08x\n", - (int)le32toh(sed->ed.ed_flags), - (int)le32toh(data->td.td_flags), - (int)le32toh(data->td.td_cbp), - (int)le32toh(data->td.td_be))); + (int)letoh32(sed->ed.ed_flags), + (int)letoh32(data->td.td_flags), + (int)letoh32(data->td.td_cbp), + (int)letoh32(data->td.td_be))); #ifdef OHCI_DEBUG if (ohcidebug > 5) { @@ -3024,7 +3024,7 @@ ohci_device_intr_start(usbd_xfer_handle xfer) data->td.td_cbp = htole32(DMAADDR(&xfer->dmabuf, 0)); data->nexttd = tail; data->td.td_nexttd = htole32(tail->physaddr); - data->td.td_be = htole32(le32toh(data->td.td_cbp) + len - 1); + data->td.td_be = htole32(letoh32(data->td.td_cbp) + len - 1); data->len = len; data->xfer = xfer; data->flags = OHCI_CALL_DONE | OHCI_ADD_LEN; @@ -3090,8 +3090,8 @@ ohci_device_intr_close(usbd_pipe_handle pipe) pipe, nslots, pos)); s = splusb(); sed->ed.ed_flags |= htole32(OHCI_ED_SKIP); - if ((le32toh(sed->ed.ed_tailp) & OHCI_HEADMASK) != - (le32toh(sed->ed.ed_headp) & OHCI_HEADMASK)) + if ((letoh32(sed->ed.ed_tailp) & OHCI_HEADMASK) != + (letoh32(sed->ed.ed_headp) & OHCI_HEADMASK)) usb_delay_ms(&sc->sc_bus, 2); for (p = sc->sc_eds[pos]; p && p->next != sed; p = p->next) @@ -3223,7 +3223,7 @@ ohci_device_isoc_enter(usbd_xfer_handle xfer) if (iso->next == -1) { /* Not in use yet, schedule it a few frames ahead. */ - iso->next = le32toh(sc->sc_hcca->hcca_frame_number) + 5; + iso->next = letoh32(sc->sc_hcca->hcca_frame_number) + 5; DPRINTFN(2,("ohci_device_isoc_enter: start next=%d\n", iso->next)); } @@ -3299,7 +3299,7 @@ ohci_device_isoc_enter(usbd_xfer_handle xfer) #ifdef OHCI_DEBUG if (ohcidebug > 5) { DPRINTF(("ohci_device_isoc_enter: frame=%d\n", - le32toh(sc->sc_hcca->hcca_frame_number))); + letoh32(sc->sc_hcca->hcca_frame_number))); ohci_dump_itds(xfer->hcpriv); ohci_dump_ed(sed); } @@ -3315,7 +3315,7 @@ ohci_device_isoc_enter(usbd_xfer_handle xfer) if (ohcidebug > 5) { delay(150000); DPRINTF(("ohci_device_isoc_enter: after frame=%d\n", - le32toh(sc->sc_hcca->hcca_frame_number))); + letoh32(sc->sc_hcca->hcca_frame_number))); ohci_dump_itds(xfer->hcpriv); ohci_dump_ed(sed); } diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 1ce5752646c..5a2275dbacb 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.53 2007/05/21 04:55:14 jsg Exp $ */ +/* $OpenBSD: uhci.c,v 1.54 2007/05/21 06:10:43 jsg Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -347,7 +347,7 @@ uhci_find_prev_qh(uhci_soft_qh_t *pqh, uhci_soft_qh_t *sqh) for (; pqh->hlink != sqh; pqh = pqh->hlink) { #if defined(DIAGNOSTIC) || defined(UHCI_DEBUG) - if (le32toh(pqh->qh.qh_hlink) & UHCI_PTR_T) { + if (letoh32(pqh->qh.qh_hlink) & UHCI_PTR_T) { printf("uhci_find_prev_qh: QH not found\n"); return (NULL); } @@ -762,35 +762,35 @@ uhci_dump_td(uhci_soft_td_t *p) DPRINTFN(-1,("TD(%p) at %08lx = link=0x%08lx status=0x%08lx " "token=0x%08lx buffer=0x%08lx\n", p, (long)p->physaddr, - (long)le32toh(p->td.td_link), - (long)le32toh(p->td.td_status), - (long)le32toh(p->td.td_token), - (long)le32toh(p->td.td_buffer))); + (long)letoh32(p->td.td_link), + (long)letoh32(p->td.td_status), + (long)letoh32(p->td.td_token), + (long)letoh32(p->td.td_buffer))); - bitmask_snprintf((u_int32_t)le32toh(p->td.td_link), "\20\1T\2Q\3VF", + bitmask_snprintf((u_int32_t)letoh32(p->td.td_link), "\20\1T\2Q\3VF", sbuf, sizeof(sbuf)); - bitmask_snprintf((u_int32_t)le32toh(p->td.td_status), + bitmask_snprintf((u_int32_t)letoh32(p->td.td_status), "\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27" "STALLED\30ACTIVE\31IOC\32ISO\33LS\36SPD", sbuf2, sizeof(sbuf2)); DPRINTFN(-1,(" %s %s,errcnt=%d,actlen=%d pid=%02x,addr=%d,endpt=%d," "D=%d,maxlen=%d\n", sbuf, sbuf2, - UHCI_TD_GET_ERRCNT(le32toh(p->td.td_status)), - UHCI_TD_GET_ACTLEN(le32toh(p->td.td_status)), - UHCI_TD_GET_PID(le32toh(p->td.td_token)), - UHCI_TD_GET_DEVADDR(le32toh(p->td.td_token)), - UHCI_TD_GET_ENDPT(le32toh(p->td.td_token)), - UHCI_TD_GET_DT(le32toh(p->td.td_token)), - UHCI_TD_GET_MAXLEN(le32toh(p->td.td_token)))); + UHCI_TD_GET_ERRCNT(letoh32(p->td.td_status)), + UHCI_TD_GET_ACTLEN(letoh32(p->td.td_status)), + UHCI_TD_GET_PID(letoh32(p->td.td_token)), + UHCI_TD_GET_DEVADDR(letoh32(p->td.td_token)), + UHCI_TD_GET_ENDPT(letoh32(p->td.td_token)), + UHCI_TD_GET_DT(letoh32(p->td.td_token)), + UHCI_TD_GET_MAXLEN(letoh32(p->td.td_token)))); } void uhci_dump_qh(uhci_soft_qh_t *sqh) { DPRINTFN(-1,("QH(%p) at %08x: hlink=%08x elink=%08x\n", sqh, - (int)sqh->physaddr, le32toh(sqh->qh.qh_hlink), - le32toh(sqh->qh.qh_elink))); + (int)sqh->physaddr, letoh32(sqh->qh.qh_hlink), + letoh32(sqh->qh.qh_elink))); } @@ -830,12 +830,12 @@ uhci_dump_qhs(uhci_soft_qh_t *sqh) */ - if (sqh->hlink != NULL && !(le32toh(sqh->qh.qh_hlink) & UHCI_PTR_T)) + if (sqh->hlink != NULL && !(letoh32(sqh->qh.qh_hlink) & UHCI_PTR_T)) uhci_dump_qhs(sqh->hlink); else DPRINTF(("No QH\n")); - if (sqh->elink != NULL && !(le32toh(sqh->qh.qh_elink) & UHCI_PTR_T)) + if (sqh->elink != NULL && !(letoh32(sqh->qh.qh_elink) & UHCI_PTR_T)) uhci_dump_tds(sqh->elink); else DPRINTF(("No TD\n")); @@ -854,8 +854,8 @@ uhci_dump_tds(uhci_soft_td_t *std) * printing the free list in case the queue/TD has * already been moved there (seatbelt). */ - if (le32toh(td->td.td_link) & UHCI_PTR_T || - le32toh(td->td.td_link) == 0) + if (letoh32(td->td.td_link) & UHCI_PTR_T || + letoh32(td->td.td_link) == 0) break; } } @@ -1293,10 +1293,10 @@ uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii) * is an error somewhere in the middle, or whether there was a * short packet (SPD and not ACTIVE). */ - if (le32toh(lstd->td.td_status) & UHCI_TD_ACTIVE) { + if (letoh32(lstd->td.td_status) & UHCI_TD_ACTIVE) { DPRINTFN(12, ("uhci_check_intr: active ii=%p\n", ii)); for (std = ii->stdstart; std != lstd; std = std->link.std) { - status = le32toh(std->td.td_status); + status = letoh32(std->td.td_status); /* If there's an active TD the xfer isn't done. */ if (status & UHCI_TD_ACTIVE) break; @@ -1306,7 +1306,7 @@ uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii) /* We want short packets, and it is short: it's done */ if ((status & UHCI_TD_SPD) && UHCI_TD_GET_ACTLEN(status) < - UHCI_TD_GET_MAXLEN(le32toh(std->td.td_token))) + UHCI_TD_GET_MAXLEN(letoh32(std->td.td_token))) goto done; } DPRINTFN(12, ("uhci_check_intr: ii=%p std=%p still active\n", @@ -1368,7 +1368,7 @@ uhci_idone(uhci_intr_info_t *ii) #endif if (++n >= UHCI_VFRAMELIST_COUNT) n = 0; - status = le32toh(std->td.td_status); + status = letoh32(std->td.td_status); len = UHCI_TD_GET_ACTLEN(status); xfer->frlengths[i] = len; actlen += len; @@ -1389,12 +1389,12 @@ uhci_idone(uhci_intr_info_t *ii) /* The transfer is done, compute actual length and status. */ actlen = 0; for (std = ii->stdstart; std != NULL; std = std->link.std) { - nstatus = le32toh(std->td.td_status); + nstatus = letoh32(std->td.td_status); if (nstatus & UHCI_TD_ACTIVE) break; status = nstatus; - if (UHCI_TD_GET_PID(le32toh(std->td.td_token)) != + if (UHCI_TD_GET_PID(letoh32(std->td.td_token)) != UHCI_TD_PID_SETUP) actlen += UHCI_TD_GET_ACTLEN(status); else { @@ -1409,7 +1409,7 @@ uhci_idone(uhci_intr_info_t *ii) } /* If there are left over TDs we need to update the toggle. */ if (std != NULL) - upipe->nexttoggle = UHCI_TD_GET_DT(le32toh(std->td.td_token)); + upipe->nexttoggle = UHCI_TD_GET_DT(letoh32(std->td.td_token)); status &= UHCI_TD_ERROR; DPRINTFN(10, ("uhci_idone: actlen=%d, status=0x%x\n", @@ -1618,7 +1618,7 @@ uhci_free_std(uhci_softc_t *sc, uhci_soft_td_t *std) { #ifdef DIAGNOSTIC #define TD_IS_FREE 0x12345678 - if (le32toh(std->td.td_token) == TD_IS_FREE) { + if (letoh32(std->td.td_token) == TD_IS_FREE) { printf("uhci_free_std: freeing free TD %p\n", std); return; } @@ -2247,7 +2247,7 @@ uhci_device_request(usbd_xfer_handle xfer) for (std = sc->sc_vframes[0].htd, link = 0; (link & UHCI_PTR_QH) == 0; std = std->link.std) { - link = le32toh(std->td.td_link); + link = letoh32(std->td.td_link); uhci_dump_td(std); } sxqh = (uhci_soft_qh_t *)std; @@ -2446,7 +2446,7 @@ uhci_device_isoc_abort(usbd_xfer_handle xfer) for (i = 0; i < nframes; i++) { std = stds[n]; std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC)); - len = UHCI_TD_GET_MAXLEN(le32toh(std->td.td_token)); + len = UHCI_TD_GET_MAXLEN(letoh32(std->td.td_token)); if (len > maxlen) maxlen = len; if (++n >= UHCI_VFRAMELIST_COUNT) diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h index b220cea9890..2d8af4cdc11 100644 --- a/sys/dev/usb/usb_port.h +++ b/sys/dev/usb/usb_port.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_port.h,v 1.66 2007/05/21 05:40:28 jsg Exp $ */ +/* $OpenBSD: usb_port.h,v 1.67 2007/05/21 06:10:44 jsg Exp $ */ /* $NetBSD: usb_port.h,v 1.62 2003/02/15 18:33:30 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -104,16 +104,6 @@ typedef struct proc *usb_proc_ptr; #define mstohz(ms) ((ms) * hz / 1000) -/* - * The UHCI/OHCI controllers are little endian, so on big endian machines - * the data stored in memory needs to be swapped. - */ - -#if defined(letoh32) -#define le32toh(x) letoh32(x) -#define le16toh(x) letoh16(x) -#endif - #define sel_klist si_note typedef int usb_malloc_type; |