From owner-svn-src-all@FreeBSD.ORG Fri Mar 20 23:12:15 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 53F06106566C; Fri, 20 Mar 2009 23:12:15 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4170D8FC15; Fri, 20 Mar 2009 23:12:15 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2KNCEO4016731; Fri, 20 Mar 2009 23:12:14 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2KNCEue016723; Fri, 20 Mar 2009 23:12:14 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200903202312.n2KNCEue016723@svn.freebsd.org> From: Andrew Thompson Date: Fri, 20 Mar 2009 23:12:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190191 - head/sys/dev/usb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2009 23:12:16 -0000 Author: thompsa Date: Fri Mar 20 23:12:14 2009 New Revision: 190191 URL: http://svn.freebsd.org/changeset/base/190191 Log: Fix compile with USB_HAVE_BUSDMA/USB_HAVE_UGEN/USB_HAVE_STRINGS. Submitted by: Hans Petter Selasky Modified: head/sys/dev/usb/usb_bus.h head/sys/dev/usb/usb_busdma.h head/sys/dev/usb/usb_dev.c head/sys/dev/usb/usb_device.c head/sys/dev/usb/usb_device.h head/sys/dev/usb/usb_generic.c head/sys/dev/usb/usb_hub.c head/sys/dev/usb/usb_util.c Modified: head/sys/dev/usb/usb_bus.h ============================================================================== --- head/sys/dev/usb/usb_bus.h Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_bus.h Fri Mar 20 23:12:14 2009 (r190191) @@ -75,9 +75,10 @@ struct usb2_bus { device_t parent; device_t bdev; /* filled by HC driver */ +#if USB_HAVE_BUSDMA struct usb2_dma_parent_tag dma_parent_tag[1]; struct usb2_dma_tag dma_tags[USB_BUS_DMA_TAG_MAX]; - +#endif struct usb2_bus_methods *methods; /* filled by HC driver */ struct usb2_device **devices; Modified: head/sys/dev/usb/usb_busdma.h ============================================================================== --- head/sys/dev/usb/usb_busdma.h Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_busdma.h Fri Mar 20 23:12:14 2009 (r190191) @@ -48,6 +48,7 @@ struct usb2_xfer_root; struct usb2_dma_parent_tag; +struct usb2_dma_tag; /* * The following typedef defines the USB DMA load done callback. @@ -115,11 +116,11 @@ struct usb2_page_cache { /* * The following structure describes the parent USB DMA tag. */ +#if USB_HAVE_BUSDMA struct usb2_dma_parent_tag { -#if USB_HAVE_BUSDMA && defined(__FreeBSD__) +#if defined(__FreeBSD__) struct cv cv[1]; /* internal condition variable */ #endif -#if USB_HAVE_BUSDMA bus_dma_tag_t tag; /* always set */ struct mtx *mtx; /* private mutex, always set */ @@ -128,27 +129,31 @@ struct usb2_dma_parent_tag { uint8_t dma_error; /* set if DMA load operation failed */ uint8_t dma_bits; /* number of DMA address lines */ uint8_t utag_max; /* number of USB DMA tags */ -#endif }; +#else +struct usb2_dma_parent_tag {}; /* empty struct */ +#endif /* * The following structure describes an USB DMA tag. */ +#if USB_HAVE_BUSDMA struct usb2_dma_tag { -#if USB_HAVE_BUSDMA && defined(__NetBSD__) +#if defined(__NetBSD__) bus_dma_segment_t *p_seg; #endif -#if USB_HAVE_BUSDMA struct usb2_dma_parent_tag *tag_parent; bus_dma_tag_t tag; usb2_size_t align; usb2_size_t size; -#endif -#if USB_HAVE_BUSDMA && defined(__NetBSD__) +#if defined(__NetBSD__) usb2_size_t n_seg; #endif }; +#else +struct usb2_dma_tag {}; /* empty struct */ +#endif /* function prototypes */ Modified: head/sys/dev/usb/usb_dev.c ============================================================================== --- head/sys/dev/usb/usb_dev.c Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_dev.c Fri Mar 20 23:12:14 2009 (r190191) @@ -54,6 +54,8 @@ #include +#if USB_HAVE_UGEN + #if USB_DEBUG static int usb2_fifo_debug = 0; @@ -2195,3 +2197,4 @@ usb2_fifo_set_close_zlp(struct usb2_fifo /* send a Zero Length Packet, ZLP, before close */ f->flag_short = onoff; } +#endif /* USB_HAVE_UGEN */ Modified: head/sys/dev/usb/usb_device.c ============================================================================== --- head/sys/dev/usb/usb_device.c Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_device.c Fri Mar 20 23:12:14 2009 (r190191) @@ -75,9 +75,8 @@ static void usb2_check_strings(struct us #endif static usb2_error_t usb2_fill_iface_data(struct usb2_device *, uint8_t, uint8_t); -static void usb2_notify_addq(const char *type, struct usb2_device *); - #if USB_HAVE_UGEN +static void usb2_notify_addq(const char *type, struct usb2_device *); static void usb2_fifo_free_wrap(struct usb2_device *, uint8_t, uint8_t); static struct cdev *usb2_make_dev(struct usb2_device *, int, int); static void usb2_cdev_create(struct usb2_device *); @@ -738,7 +737,6 @@ usb2_set_alt_interface_index(struct usb2 */ usb2_fifo_free_wrap(udev, iface_index, 0); #endif - err = usb2_fill_iface_data(udev, iface_index, alt_index); if (err) { goto done; @@ -1378,8 +1376,6 @@ usb2_alloc_device(device_t parent_dev, s usb2_cv_init(udev->default_cv, "WCTRL"); usb2_cv_init(udev->default_cv + 1, "UGONE"); - LIST_INIT(&udev->pd_list); - /* initialise our mutex */ mtx_init(udev->default_mtx, "USB device mutex", NULL, MTX_DEF); @@ -1449,18 +1445,19 @@ usb2_alloc_device(device_t parent_dev, s /* set device index */ udev->device_index = device_index; +#if USB_HAVE_UGEN /* Create ugen name */ snprintf(udev->ugen_name, sizeof(udev->ugen_name), USB_GENERIC_NAME "%u.%u", device_get_unit(bus->bdev), device_index); -#if USB_HAVE_UGEN + LIST_INIT(&udev->pd_list); + /* Create the control endpoint device */ udev->default_dev = usb2_make_dev(udev, 0, FREAD|FWRITE); /* Create a link from /dev/ugenX.X to the default endpoint */ make_dev_alias(udev->default_dev, udev->ugen_name); #endif - if (udev->flags.usb2_mode == USB_MODE_HOST) { err = usb2_req_set_address(udev, NULL, device_index); @@ -1713,14 +1710,17 @@ repeat_set_config: usb2_bus_port_set_device(bus, parent_hub ? parent_hub->hub->ports + port_index : NULL, udev, device_index); - /* Link and announce the ugen device name */ #if USB_HAVE_UGEN + /* Symlink the ugen device name */ udev->ugen_symlink = usb2_alloc_symlink(udev->ugen_name); -#endif + + /* Announce device */ +#if USB_HAVE_STRINGS printf("%s: <%s> at %s\n", udev->ugen_name, udev->manufacturer, device_get_nameunit(udev->bus->bdev)); - +#endif usb2_notify_addq("+", udev); +#endif done: if (err) { /* free device */ @@ -1824,7 +1824,6 @@ usb2_cdev_free(struct usb2_device *udev) while ((pd = LIST_FIRST(&udev->pd_list)) != NULL) { KASSERT(pd->cdev->si_drv1 == pd, ("privdata corrupt")); - KASSERT(pd->ep_addr > 0, ("freeing EP0")); destroy_dev_sched_cb(pd->cdev, usb2_cdev_cleanup, pd); pd->cdev = NULL; @@ -1851,18 +1850,20 @@ usb2_free_device(struct usb2_device *ude DPRINTFN(4, "udev=%p port=%d\n", udev, udev->port_no); +#if USB_HAVE_UGEN usb2_notify_addq("-", udev); +#if USB_HAVE_STRINGS printf("%s: <%s> at %s (disconnected)\n", udev->ugen_name, udev->manufacturer, device_get_nameunit(bus->bdev)); +#endif /* Destroy UGEN symlink, if any */ if (udev->ugen_symlink) { -#if USB_HAVE_UGEN usb2_free_symlink(udev->ugen_symlink); -#endif udev->ugen_symlink = NULL; } +#endif /* * Unregister our device first which will prevent any further * references: @@ -1873,7 +1874,6 @@ usb2_free_device(struct usb2_device *ude #if USB_HAVE_UGEN /* wait for all pending references to go away: */ - mtx_lock(&usb2_ref_lock); udev->refcount--; while (udev->refcount != 0) { @@ -1923,7 +1923,9 @@ usb2_free_device(struct usb2_device *ude usb2_cv_destroy(udev->default_cv + 1); mtx_destroy(udev->default_mtx); +#if USB_HAVE_UGEN KASSERT(LIST_FIRST(&udev->pd_list) == NULL, ("leaked cdev entries")); +#endif /* free device */ free(udev, M_USB); @@ -2026,14 +2028,24 @@ usb2_devinfo(struct usb2_device *udev, c if (udd->bDeviceClass != 0xFF) { snprintf(dst_ptr, dst_len, "%s %s, class %d/%d, rev %x.%02x/" - "%x.%02x, addr %d", udev->manufacturer, udev->product, + "%x.%02x, addr %d", +#if USB_HAVE_STRINGS + udev->manufacturer, udev->product, +#else + "-", "-", +#endif udd->bDeviceClass, udd->bDeviceSubClass, (bcdUSB >> 8), bcdUSB & 0xFF, (bcdDevice >> 8), bcdDevice & 0xFF, udev->address); } else { snprintf(dst_ptr, dst_len, "%s %s, rev %x.%02x/" - "%x.%02x, addr %d", udev->manufacturer, udev->product, + "%x.%02x, addr %d", +#if USB_HAVE_STRINGS + udev->manufacturer, udev->product, +#else + "-", "-", +#endif (bcdUSB >> 8), bcdUSB & 0xFF, (bcdDevice >> 8), bcdDevice & 0xFF, udev->address); @@ -2230,6 +2242,7 @@ usb2_get_device_index(struct usb2_device return (udev->device_index); } +#if USB_HAVE_UGEN /*------------------------------------------------------------------------* * usb2_notify_addq * @@ -2271,35 +2284,19 @@ usb2_notify_addq(const char *type, struc UGETW(udev->ddesc.idProduct), udev->ddesc.bDeviceClass, udev->ddesc.bDeviceSubClass, +#if USB_HAVE_STRINGS udev->serial, +#else + "", +#endif udev->port_no, - udev->parent_hub->ugen_name); - } else { - snprintf(data, 1024, - "%s" - "%s " - "vendor=0x%04x " - "product=0x%04x " - "devclass=0x%02x " - "devsubclass=0x%02x " - "sernum=\"%s\" " - "at port=%u " - "on " - "%s\n", - type, - udev->ugen_name, - UGETW(udev->ddesc.idVendor), - UGETW(udev->ddesc.idProduct), - udev->ddesc.bDeviceClass, - udev->ddesc.bDeviceSubClass, - udev->serial, - udev->port_no, - device_get_nameunit(device_get_parent(udev->bus->bdev))); + udev->parent_hub != NULL ? + udev->parent_hub->ugen_name : + device_get_nameunit(device_get_parent(udev->bus->bdev))); } devctl_queue_data(data); } -#if USB_HAVE_UGEN /*------------------------------------------------------------------------* * usb2_fifo_free_wrap * Modified: head/sys/dev/usb/usb_device.h ============================================================================== --- head/sys/dev/usb/usb_device.h Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_device.h Fri Mar 20 23:12:14 2009 (r190191) @@ -27,7 +27,7 @@ #ifndef _USB2_DEVICE_H_ #define _USB2_DEVICE_H_ -struct usb2_symlink; +struct usb2_symlink; /* UGEN */ struct usb_device; /* linux compat */ #define USB_DEFAULT_XFER_MAX 2 @@ -121,13 +121,12 @@ struct usb2_device { struct usb2_xfer *default_xfer[USB_DEFAULT_XFER_MAX]; struct usb2_temp_data *usb2_template_ptr; struct usb2_pipe *pipe_curr; /* current clear stall pipe */ +#if USB_HAVE_UGEN struct usb2_fifo *fifo[USB_FIFO_MAX]; - - char ugen_name[20]; /* name of ugenX.X device */ struct usb2_symlink *ugen_symlink; /* our generic symlink */ - LIST_HEAD(,usb2_fs_privdata) pd_list; - + char ugen_name[20]; /* name of ugenX.X device */ +#endif usb2_ticks_t plugtime; /* copy of "ticks" */ uint16_t refcount; @@ -156,9 +155,11 @@ struct usb2_device { struct usb2_endpoint_descriptor default_ep_desc; /* for pipe 0 */ struct usb2_device_descriptor ddesc; /* device descriptor */ +#if USB_HAVE_STRINGS char serial[64]; /* serial number */ char manufacturer[64]; /* manufacturer string */ char product[64]; /* product string */ +#endif }; /* globals */ Modified: head/sys/dev/usb/usb_generic.c ============================================================================== --- head/sys/dev/usb/usb_generic.c Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_generic.c Fri Mar 20 23:12:14 2009 (r190191) @@ -47,6 +47,8 @@ #include #include +#if USB_HAVE_UGEN + /* defines */ #define UGEN_BULK_FS_BUFFER_SIZE (64*32) /* bytes */ @@ -799,12 +801,14 @@ usb2_gen_fill_deviceinfo(struct usb2_fif di->udi_bus = device_get_unit(udev->bus->bdev); di->udi_addr = udev->address; di->udi_index = udev->device_index; +#if USB_HAVE_STRINGS strlcpy(di->udi_serial, udev->serial, sizeof(di->udi_serial)); strlcpy(di->udi_vendor, udev->manufacturer, sizeof(di->udi_vendor)); strlcpy(di->udi_product, udev->product, sizeof(di->udi_product)); +#endif usb2_printBCD(di->udi_release, sizeof(di->udi_release), UGETW(udev->ddesc.bcdDevice)); di->udi_vendorNo = UGETW(udev->ddesc.idVendor); @@ -2183,3 +2187,4 @@ ugen_default_fs_callback(struct usb2_xfe break; } } +#endif /* USB_HAVE_UGEN */ Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_hub.c Fri Mar 20 23:12:14 2009 (r190191) @@ -978,7 +978,11 @@ uhub_child_pnpinfo_string(device_t paren UGETW(res.udev->ddesc.idProduct), res.udev->ddesc.bDeviceClass, res.udev->ddesc.bDeviceSubClass, +#if USB_HAVE_STRINGS res.udev->serial, +#else + "", +#endif iface->idesc->bInterfaceClass, iface->idesc->bInterfaceSubClass); } else { Modified: head/sys/dev/usb/usb_util.c ============================================================================== --- head/sys/dev/usb/usb_util.c Fri Mar 20 23:06:16 2009 (r190190) +++ head/sys/dev/usb/usb_util.c Fri Mar 20 23:12:14 2009 (r190191) @@ -167,7 +167,6 @@ usb2_pause_mtx(struct mtx *mtx, int _tic * pointed to by "p" having a maximum length of "p_len" bytes * including the terminating zero. *------------------------------------------------------------------------*/ -#if USB_HAVE_STRINGS void usb2_printBCD(char *p, uint16_t p_len, uint16_t bcd) { @@ -175,7 +174,6 @@ usb2_printBCD(char *p, uint16_t p_len, u /* ignore any errors */ } } -#endif /*------------------------------------------------------------------------* * usb2_trim_spaces