Date: Sun, 6 Jan 2008 22:30:05 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 132651 for review Message-ID: <200801062230.m06MU5jo084685@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=132651 Change 132651 by hselasky@hselasky_laptop001 on 2008/01/06 22:29:10 Style change by "usb_style.sh". Affected files ... .. //depot/projects/usb/src/sys/dev/usb/if_cdce.c#46 edit .. //depot/projects/usb/src/sys/dev/usb/if_cdcereg.h#17 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/if_cdce.c#46 (text+ko) ==== @@ -307,7 +307,7 @@ i = id->bInterfaceNumber; alt_index = 0; while ((desc = usbd_desc_foreach( - usbd_get_config_descriptor(uaa->device), desc))) { + usbd_get_config_descriptor(uaa->device), desc))) { id = (void *)desc; if ((id->bDescriptorType == UDESC_INTERFACE) && (id->bLength >= sizeof(*id))) { @@ -316,8 +316,8 @@ break; } if ((id->bInterfaceClass == UICLASS_CDC) && - (id->bInterfaceSubClass == - UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL) && + (id->bInterfaceSubClass == + UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL) && (id->bInterfaceProtocol == UIPROTO_CDC_ETH_512X4)) { alt_index = id->bAlternateSetting; @@ -507,11 +507,11 @@ ifp->if_init = cdce_init_cb; ifp->if_baudrate = 11000000; if (sc->sc_iface_protocol == UIPROTO_CDC_ETH_512X4) { - IFQ_SET_MAXLEN(&ifp->if_snd, CDCE_512X4_IFQ_MAXLEN); - ifp->if_snd.ifq_drv_maxlen = CDCE_512X4_IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, CDCE_512X4_IFQ_MAXLEN); + ifp->if_snd.ifq_drv_maxlen = CDCE_512X4_IFQ_MAXLEN; } else { - IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); - ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; } IFQ_SET_READY(&ifp->if_snd); @@ -602,11 +602,12 @@ static uint32_t cdce_m_frags(struct mbuf *m) { - uint32_t temp = 1; - while ((m = m->m_next)) { - temp ++; - } - return (temp); + uint32_t temp = 1; + + while ((m = m->m_next)) { + temp++; + } + return (temp); } static void @@ -682,7 +683,7 @@ case USBD_ST_TRANSFERRED: DPRINTF(sc, 10, "transfer complete: " "%u bytes in %u fragments and %u frames\n", - xfer->actlen, xfer->nframes, sc->sc_tx_mq.ifq_len); + xfer->actlen, xfer->nframes, sc->sc_tx_mq.ifq_len); /* update packet counter */ ifp->if_opackets += sc->sc_tx_mq.ifq_len; @@ -698,10 +699,9 @@ usbd_transfer_start(sc->sc_xfer[2]); break; } + x = 0; /* number of frames */ + y = 1; /* number of fragments */ - x = 0; /* number of frames */ - y = 1; /* number of fragments */ - while (x != CDCE_512X4_FRAMES_MAX) { IFQ_DRV_DEQUEUE(&(ifp->if_snd), m); @@ -723,7 +723,6 @@ } m = mt; } - _IF_ENQUEUE(&(sc->sc_tx_mq), m); /* @@ -737,38 +736,36 @@ #endif do { - flen = m->m_len & CDCE_512X4_FRAG_LENGTH_MASK; - xfer->frlengths[y] = m->m_len; - usbd_set_frame_data(xfer, m->m_data, y); + flen = m->m_len & CDCE_512X4_FRAG_LENGTH_MASK; + xfer->frlengths[y] = m->m_len; + usbd_set_frame_data(xfer, m->m_data, y); - if (m->m_next == NULL) { - flen |= CDCE_512X4_FRAG_LAST_MASK; - } + if (m->m_next == NULL) { + flen |= CDCE_512X4_FRAG_LAST_MASK; + } + USETW(sc->sc_tx.hdr.wFragLength[y - 1], flen); - USETW(sc->sc_tx.hdr.wFragLength[y-1], flen); + y++; - y++; - } while ((m = m->m_next)); x++; } if (y == 1) { - /* no data to transmit */ - break; + /* no data to transmit */ + break; } - /* fill in Signature */ sc->sc_tx.hdr.bSig[0] = 'F'; sc->sc_tx.hdr.bSig[1] = 'L'; - /* - * We ensure that the header results in a short packet - * by making the length odd ! + /* + * We ensure that the header results in a short packet by + * making the length odd ! */ - USETW(sc->sc_tx.hdr.wFragLength[y-1], 0); - xfer->frlengths[0] = CDCE_512X4_FRAG_LENGTH_OFFSET + ((y-1) * 2) + 1; + USETW(sc->sc_tx.hdr.wFragLength[y - 1], 0); + xfer->frlengths[0] = CDCE_512X4_FRAG_LENGTH_OFFSET + ((y - 1) * 2) + 1; usbd_set_frame_data(xfer, &(sc->sc_tx.hdr), 0); xfer->nframes = y; usbd_start_hardware(xfer); @@ -821,51 +818,49 @@ usbd_transfer_start(sc->sc_xfer[2]); break; } + IFQ_DRV_DEQUEUE(&(ifp->if_snd), m); - IFQ_DRV_DEQUEUE(&(ifp->if_snd), m); + if (m == NULL) { + break; + } + if (sc->sc_flags & CDCE_FLAG_ZAURUS) { + /* + * Zaurus wants a 32-bit CRC appended to + * every frame + */ - if (m == NULL) { - break; - } - if (sc->sc_flags & CDCE_FLAG_ZAURUS) { - /* - * Zaurus wants a 32-bit CRC appended to - * every frame - */ + crc = cdce_m_crc32(m, 0, m->m_pkthdr.len); + crc = htole32(crc); - crc = cdce_m_crc32(m, 0, m->m_pkthdr.len); - crc = htole32(crc); - - if (!m_append(m, 4, (void *)&crc)) { - m_freem(m); - ifp->if_oerrors++; - goto tr_setup; - } + if (!m_append(m, 4, (void *)&crc)) { + m_freem(m); + ifp->if_oerrors++; + goto tr_setup; } - if (m->m_len != m->m_pkthdr.len) { - mt = m_defrag(m, M_DONTWAIT); - if (mt == NULL) { - m_freem(m); - ifp->if_oerrors++; - goto tr_setup; - } - m = mt; + } + if (m->m_len != m->m_pkthdr.len) { + mt = m_defrag(m, M_DONTWAIT); + if (mt == NULL) { + m_freem(m); + ifp->if_oerrors++; + goto tr_setup; } - if (m->m_pkthdr.len > MCLBYTES) { - m->m_pkthdr.len = MCLBYTES; - } + m = mt; + } + if (m->m_pkthdr.len > MCLBYTES) { + m->m_pkthdr.len = MCLBYTES; + } + _IF_ENQUEUE(&(sc->sc_tx_mq), m); - _IF_ENQUEUE(&(sc->sc_tx_mq), m); + xfer->frlengths[0] = m->m_len; + usbd_set_frame_data(xfer, m->m_data, 0); + xfer->nframes = 1; - xfer->frlengths[0] = m->m_len; - usbd_set_frame_data(xfer, m->m_data, 0); - xfer->nframes = 1; - - /* - * if there's a BPF listener, bounce a copy - * of this frame to him: - */ - BPF_MTAP(ifp, m); + /* + * if there's a BPF listener, bounce a copy + * of this frame to him: + */ + BPF_MTAP(ifp, m); usbd_start_hardware(xfer); break; @@ -1096,13 +1091,12 @@ xfer->flags.stall_pipe = 1; goto tr_setup; } - rx_frags = (xfer->actlen - + rx_frags = (xfer->actlen - CDCE_512X4_FRAG_LENGTH_OFFSET) / 2; if (rx_frags != 0) { /* start receiving data */ sc->sc_flags |= CDCE_FLAG_RX_DATA; } - DPRINTF(sc, 0, "doing %u fragments\n", rx_frags); } else { @@ -1141,7 +1135,6 @@ xfer->flags.stall_pipe = 1; goto tr_setup; } - /* check if the last fragment does not complete a frame */ x = rx_frags - 1; flen = UGETW(sc->sc_rx.hdr.wFragLength[x]); @@ -1220,8 +1213,8 @@ xfer->frlengths[x] = (flen & CDCE_512X4_FRAG_LENGTH_MASK); - DPRINTF(sc, 16, "length[%u] = %u\n", - x, xfer->frlengths[x]); + DPRINTF(sc, 16, "length[%u] = %u\n", + x, xfer->frlengths[x]); offset += xfer->frlengths[x]; @@ -1266,7 +1259,7 @@ /* * At the end of a USB callback it is always safe to unlock - * the private mutex of a device! + * the private mutex of a device! * * * By safe we mean that if "usbd_transfer_stop()" is called, @@ -1276,7 +1269,6 @@ if (fwd_mq) { cdce_fwd_mq(sc, &(sc->sc_rx_mq)); } - if (free_mq) { cdce_free_mq(&(sc->sc_rx_mq)); } @@ -1304,7 +1296,6 @@ xfer->frlengths[0] -= 4; } } - _IF_DEQUEUE(&(sc->sc_rx_mq), m); if (m) { @@ -1495,5 +1486,5 @@ const void *req, void **pptr, uint16_t *plen, uint16_t offset, uint8_t is_complete) { - return (ENXIO); /* use builtin handler */ + return (ENXIO); /* use builtin handler */ } ==== //depot/projects/usb/src/sys/dev/usb/if_cdcereg.h#17 (text+ko) ==== @@ -44,12 +44,12 @@ uint16_t cdce_flags; }; -union cdce_eth_rx { /* multiframe header */ +union cdce_eth_rx { /* multiframe header */ usb_cdc_mf_eth_512x4_header_t hdr; - uint8_t data[MCLBYTES]; + uint8_t data[MCLBYTES]; } __aligned(USB_HOST_ALIGN); -union cdce_eth_tx { /* multiframe header */ +union cdce_eth_tx { /* multiframe header */ usb_cdc_mf_eth_512x4_header_t hdr; } __aligned(USB_HOST_ALIGN); @@ -86,7 +86,7 @@ uint8_t sc_name[16]; uint8_t sc_data_iface_no; uint8_t sc_ifaces_index[2]; - uint8_t sc_iface_protocol; + uint8_t sc_iface_protocol; }; #endif /* _USB_IF_CDCEREG_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801062230.m06MU5jo084685>