From owner-p4-projects@FreeBSD.ORG Sat Jul 25 11:01:09 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A82551065670; Sat, 25 Jul 2009 11:01:09 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E9D7106566B for ; Sat, 25 Jul 2009 11:01:09 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4C8E98FC21 for ; Sat, 25 Jul 2009 11:01:09 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n6PB19lo082279 for ; Sat, 25 Jul 2009 11:01:09 GMT (envelope-from syl@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n6PB19o2082277 for perforce@freebsd.org; Sat, 25 Jul 2009 11:01:09 GMT (envelope-from syl@FreeBSD.org) Date: Sat, 25 Jul 2009 11:01:09 GMT Message-Id: <200907251101.n6PB19o2082277@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to syl@FreeBSD.org using -f From: Sylvestre Gallon To: Perforce Change Reviews Cc: Subject: PERFORCE change 166547 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jul 2009 11:01:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=166547 Change 166547 by syl@syl_atuin on 2009/07/25 11:01:01 Fix some errors, typo and style. Spotted by a diff between s3c24xxdci.c and at91dci.c. Affected files ... .. //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/s3c24xxdci.c#15 edit .. //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/s3c24xxdci.h#11 edit Differences ... ==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/s3c24xxdci.c#15 (text+ko) ==== @@ -107,7 +107,7 @@ .support_bulk = 1, .support_interrupt = 1, .support_in = 1, - .support_out = 1 , + .support_out = 1, }, [2] = { .max_in_frame_size = 64, @@ -116,7 +116,7 @@ .support_bulk = 1, .support_interrupt = 1, .support_in = 1, - .support_out = 1 , + .support_out = 1, }, [3] = { .max_in_frame_size = 64, @@ -125,7 +125,7 @@ .support_bulk = 1, .support_interrupt = 1, .support_in = 1, - .support_out = 1 , + .support_out = 1, }, [4] = { .max_in_frame_size = 64, @@ -134,7 +134,7 @@ .support_bulk = 1, .support_interrupt = 1, .support_in = 1, - .support_out = 1 , + .support_out = 1, }, }; @@ -142,10 +142,11 @@ s3c24dci_get_hw_ep_profile(struct usb_device *udev, const struct usb_hw_ep_profile **ppf, uint8_t ep_addr) { - if (ep_addr < S3C24XX_DCI_EP_MAX) + if (ep_addr < S3C24XX_DCI_EP_MAX) { *ppf = (s3c24dci_ep_profile + ep_addr); - else + } else { *ppf = NULL; + } } static void @@ -208,6 +209,7 @@ } S3C24XX_DCI_WRITE_4(sc, S3C24_DCI_PWR, S3C24_DCI_MCU_RESUME); + /* wait 8 milliseconds */ /* Wait for reset to complete. */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); @@ -249,9 +251,9 @@ td = xfer->td_transfer_cache; while (1) { - if ((td->func)(td)) { + if ((td->func) (td)) { /* operation in progress */ - break ; + break; } if (((void *)td) == xfer->td_transfer_last) { goto done; @@ -267,17 +269,17 @@ goto done; } } - /* + /* * Fetch the next transfer descriptor and transfer - * some flags to the next transfer descriptor. + * some flags to the next transfer descriptor */ td = td->obj_next; xfer->td_transfer_cache = td; } - return (1); + return (1); /* not complete */ done: s3c24dci_standard_done(xfer); - return (0); + return (0); /* complete */ } static void @@ -328,8 +330,8 @@ uint8_t need_sync; DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", - xfer->address, UE_GET_ADDR(xfer->endpointno), - xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); + xfer->address, UE_GET_ADDR(xfer->endpointno), + xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); temp.max_frame_size = xfer->max_frame_size; @@ -340,7 +342,7 @@ /* setup temp */ temp.td = NULL; - temp.td_next = xfer->td_start[0]; + temp.td_next = xfer->td_start[0]; temp.offset = 0; temp.setup_alt_next = xfer->flags_int.short_frames_ok; temp.did_stall = !xfer->flags_int.control_stall; @@ -352,6 +354,7 @@ if (xfer->flags_int.control_xfr) { if (xfer->flags_int.control_hdr) { + temp.func = &s3c24dci_setup_rx; temp.len = xfer->frlengths[0]; temp.pc = xfer->frbuffers + 0; @@ -362,6 +365,7 @@ if (xfer->flags_int.control_act) temp.setup_alt_next = 0; } + s3c24dci_setup_standard_chain_sub(&temp); } x = 1; @@ -375,7 +379,7 @@ need_sync = 1; } else { temp.func = &s3c24dci_data_rx; - need_sync = 1; + need_sync = 0; } /* setup "pc" pointer */ @@ -386,7 +390,9 @@ while (x != xfer->nframes) { /* DATA0 / DATA2 message */ + temp.len = xfer->frlengths[x]; + x++; if (x == xfer->nframes) { @@ -406,9 +412,11 @@ } else { - /* regular data pointer */ + /* regular data transfer */ + temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1; } + s3c24dci_setup_standard_chain_sub(&temp); if (xfer->flags_int.isochronous_xfr) { @@ -423,24 +431,24 @@ if (xfer->flags_int.control_xfr) { /* always setup a valid "pc" pointer for status and sync */ - temp.pc = xfer->frbuffers + 0 ; + temp.pc = xfer->frbuffers + 0; temp.len = 0; temp.short_pkt = 0; temp.setup_alt_next = 0; /* check if we need to sync */ if (need_sync) { - /* we need a SYNC point afer TX */ + /* we need a SYNC point after TX */ temp.func = &s3c24dci_data_tx_sync; s3c24dci_setup_standard_chain_sub(&temp); - } /* check if we should append a status stage */ if (!xfer->flags_int.control_act) { + /* - * Sen a DATA1 message and invert the current - * endpoint direction + * Send a DATA1 message and invert the current + * endpoint direction. */ if (xfer->endpointno & UE_DIR_IN) { temp.func = &s3c24dci_data_rx; @@ -459,7 +467,7 @@ } } - /* must have at least one frame ! */ + /* must have at least one frame! */ td = temp.td; xfer->td_transfer_last = td; } @@ -484,6 +492,7 @@ /* poll one time */ if (s3c24dci_xfer_do_fifo(xfer)) { + struct s3c24dci_softc *sc = S3C24_DCI_BUS2SC(xfer->xroot->bus); uint8_t ep_no = xfer->endpointno & UE_ADDR; uint32_t ittmp; @@ -580,22 +589,26 @@ usb_error_t err = 0; DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n", - xfer, xfer->endpoint); + xfer, xfer->endpoint); /* reset scanner */ xfer->td_transfer_cache = xfer->td_transfer_first; if (xfer->flags_int.control_xfr) { + if (xfer->flags_int.control_hdr) { + err = s3c24dci_standard_done_sub(xfer); } xfer->aframes = 1; + if (xfer->td_transfer_cache == NULL) { goto done; } } while (xfer->aframes != xfer->nframes) { + err = s3c24dci_standard_done_sub(xfer); xfer->aframes++; @@ -606,6 +619,7 @@ if (xfer->flags_int.control_xfr && !xfer->flags_int.control_act) { + err = s3c24dci_standard_done_sub(xfer); } done: @@ -639,7 +653,7 @@ DPRINTFN(15, "disable interrupts on endpoint %d\n", ep_no); } - + /* dequeue transfer and start next transfer */ usbd_transfer_done(xfer, error); } @@ -765,17 +779,20 @@ DPRINTFN(5, "endpoint=%p\n", ep); + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + /* check mode */ if (udev->flags.usb_mode != USB_MODE_DEVICE) { /* not supported */ - return ; + return; } /* get softc */ sc = S3C24_DCI_BUS2SC(udev->bus); - /* get endpoint descriptors */ + /* get endpoint descriptor */ ed = ep->edesc; + /* reset endpoint */ s3c24dci_clear_stall_sub(sc, (ed->bEndpointAddress & UE_ADDR), (ed->bmAttributes & UE_XFERTYPE), @@ -880,7 +897,6 @@ .bDeviceProtocol = UDPROTO_FSHUB, .bMaxPacketSize0 = 0, .bNumConfigurations = 0, - }; static const struct s3c24dci_config_desc s3c24dci_confd = { @@ -1204,8 +1220,6 @@ tr_handle_clear_halt: goto tr_valid; - return (USB_ERR_STALLED); - tr_handle_clear_port_feature: if (index != 1) { goto tr_stalled; @@ -1359,14 +1373,24 @@ usbd_transfer_setup_sub(parm); + /* + * compute maximum number of TDs + */ if (parm->methods == &s3c24dci_device_ctrl_methods) { - ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ - + 1 /* SYNC 2 */; + + ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ + + 1 /* SYNC 2 */ ; + } else if (parm->methods == &s3c24dci_device_bulk_methods) { - ntd = xfer->nframes + 1 /* SYNC */; + + ntd = xfer->nframes + 1 /* SYNC */ ; + } else if (parm->methods == &s3c24dci_device_intr_methods) { - ntd = xfer->nframes + 1 /* SYNC */; + + ntd = xfer->nframes + 1 /* SYNC */ ; + } else { + ntd = 0; } @@ -1374,30 +1398,40 @@ * check if "usbd_transfer_setup_sub" set an error */ if (parm->err) { - return ; + return; } - + /* + * allocate transfer descriptors + */ last_obj = NULL; + /* + * get profile stuff + */ if (ntd) { + ep_no = xfer->endpointno & UE_ADDR; s3c24dci_get_hw_ep_profile(parm->udev, &pf, ep_no); if (pf == NULL) { + /* should not happen */ parm->err = USB_ERR_INVAL; - return ; + return; } } else { ep_no = 0; pf = NULL; } + /* align data */ parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); - for (n = 0 ; n != ntd ; n++) { + for (n = 0; n != ntd; n++) { + struct s3c24dci_td *td; if (parm->buf) { + td = USB_ADD_BYTES(parm->buf, parm->size[0]); /* init TD */ @@ -1406,7 +1440,7 @@ td->max_packet_size = xfer->max_packet_size; td->ep_no = ep_no; td->obj_next = last_obj; - + last_obj = td; } parm->size[0] += sizeof(*td); @@ -1418,7 +1452,7 @@ static void s3c24dci_xfer_unsetup(struct usb_xfer *xfer) { - return ; + return; } static void @@ -1428,28 +1462,30 @@ struct s3c24dci_softc *sc = S3C24_DCI_BUS2SC(udev->bus); DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d (%d)\n", - ep, udev->address, edesc->bEndpointAddress, - udev->flags.usb_mode, sc->sc_rt_addr); + ep, udev->address, + edesc->bEndpointAddress, udev->flags.usb_mode, + sc->sc_rt_addr); if (udev->device_index != sc->sc_rt_addr) { + if (udev->flags.usb_mode != USB_MODE_DEVICE) { /* not supported */ - return ; + return; } if (udev->speed != USB_SPEED_FULL) { /* not supported */ - return ; + return; } switch (edesc->bmAttributes & UE_XFERTYPE) { case UE_CONTROL: ep->methods = &s3c24dci_device_ctrl_methods; - break ; + break; case UE_INTERRUPT: ep->methods = &s3c24dci_device_intr_methods; - break ; + break; case UE_BULK: ep->methods = &s3c24dci_device_bulk_methods; - break ; + break; default: break; } ==== //depot/projects/soc2009/syl_usb/src/sys/dev/usb/controller/s3c24xxdci.h#11 (text+ko) ====