Date: Mon, 9 Mar 2009 20:08:08 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r189599 - head/sys/dev/usb Message-ID: <200903092008.n29K88Ys036295@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Mon Mar 9 20:08:08 2009 New Revision: 189599 URL: http://svn.freebsd.org/changeset/base/189599 Log: MFp4 //depot/projects/usb 158942,158948 Allow USB to be compiled without ugen support. Submitted by: Hans Petter Selasky Modified: head/sys/dev/usb/usb_core.h head/sys/dev/usb/usb_device.c head/sys/dev/usb/usb_hub.c Modified: head/sys/dev/usb/usb_core.h ============================================================================== --- head/sys/dev/usb/usb_core.h Mon Mar 9 20:05:46 2009 (r189598) +++ head/sys/dev/usb/usb_core.h Mon Mar 9 20:08:08 2009 (r189599) @@ -38,6 +38,10 @@ #define USB_USE_CONDVAR 0 #endif +#ifndef USB_HAVE_UGEN +#define USB_HAVE_UGEN 1 +#endif + #ifndef USB_TD_GET_PROC #define USB_TD_GET_PROC(td) (td)->td_proc #endif @@ -46,24 +50,6 @@ #define USB_PROC_GET_GID(td) (td)->p_pgid #endif -#ifndef USB_VNOPS_FO_CLOSE -#define USB_VNOPS_FO_CLOSE(fp, td, perr) do { \ - (td)->td_fpop = (fp); \ - *(perr) = vnops.fo_close(fp, td); \ - (td)->td_fpop = NULL; \ -} while (0) -#endif - -#ifndef USB_VNOPS_FO_STAT -#define USB_VNOPS_FO_STAT(fp, sb, cred, td) \ - vnops.fo_stat(fp, sb, cred, td) -#endif - -#ifndef USB_VNOPS_FO_TRUNCATE -#define USB_VNOPS_FO_TRUNCATE(fp, length, cred, td) \ - vnops.fo_truncate(fp, length, cred, td) -#endif - /* Include files */ #include <sys/stdint.h> Modified: head/sys/dev/usb/usb_device.c ============================================================================== --- head/sys/dev/usb/usb_device.c Mon Mar 9 20:05:46 2009 (r189598) +++ head/sys/dev/usb/usb_device.c Mon Mar 9 20:08:08 2009 (r189599) @@ -73,11 +73,14 @@ static void usb2_check_strings(struct us 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_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 *); static void usb2_cdev_free(struct usb2_device *); static void usb2_cdev_cleanup(void *); +#endif /* This variable is global to allow easy access to it: */ @@ -543,11 +546,13 @@ usb2_set_config_index(struct usb2_device /* detach all interface drivers */ usb2_detach_device(udev, USB_IFACE_INDEX_ANY, 1); +#if USB_HAVE_UGEN /* free all FIFOs except control endpoint FIFOs */ usb2_fifo_free_wrap(udev, USB_IFACE_INDEX_ANY, 0); /* free all configuration data structures */ usb2_cdev_free(udev); +#endif usb2_free_iface_data(udev); if (index == USB_UNCONFIG_INDEX) { @@ -657,13 +662,17 @@ usb2_set_config_index(struct usb2_device goto done; } } +#if USB_HAVE_UGEN /* create device nodes for each endpoint */ usb2_cdev_create(udev); +#endif done: DPRINTF("error=%s\n", usb2_errstr(err)); if (err) { +#if USB_HAVE_UGEN usb2_cdev_free(udev); +#endif usb2_free_iface_data(udev); } if (do_unlock) { @@ -717,11 +726,13 @@ usb2_set_alt_interface_index(struct usb2 goto done; } } +#if USB_HAVE_UGEN /* * Free all generic FIFOs for this interface, except control * endpoint FIFOs: */ usb2_fifo_free_wrap(udev, iface_index, 0); +#endif err = usb2_fill_iface_data(udev, iface_index, alt_index); if (err) { @@ -1433,13 +1444,17 @@ usb2_alloc_device(device_t parent_dev, s /* set device index */ udev->device_index = device_index; - /* 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 */ + /* 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 + /* 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) { @@ -1692,7 +1707,9 @@ repeat_set_config: parent_hub->hub->ports + port_index : NULL, udev, device_index); /* Link and announce the ugen device name */ +#if USB_HAVE_UGEN udev->ugen_symlink = usb2_alloc_symlink(udev->ugen_name); +#endif printf("%s: <%s> at %s\n", udev->ugen_name, udev->manufacturer, device_get_nameunit(udev->bus->bdev)); @@ -1706,6 +1723,7 @@ done: return (udev); } +#if USB_HAVE_UGEN static struct cdev * usb2_make_dev(struct usb2_device *udev, int ep, int mode) { @@ -1812,6 +1830,7 @@ usb2_cdev_cleanup(void* arg) { free(arg, M_USBDEV); } +#endif /*------------------------------------------------------------------------* * usb2_free_device @@ -1832,7 +1851,9 @@ usb2_free_device(struct usb2_device *ude /* Destroy UGEN symlink, if any */ if (udev->ugen_symlink) { +#if USB_HAVE_UGEN usb2_free_symlink(udev->ugen_symlink); +#endif udev->ugen_symlink = NULL; } /* @@ -1843,6 +1864,7 @@ usb2_free_device(struct usb2_device *ude udev->parent_hub->hub->ports + udev->port_index : NULL, NULL, USB_ROOT_HUB_ADDR); +#if USB_HAVE_UGEN /* wait for all pending references to go away: */ mtx_lock(&usb2_ref_lock); @@ -1851,11 +1873,13 @@ usb2_free_device(struct usb2_device *ude usb2_cv_wait(udev->default_cv + 1, &usb2_ref_lock); } mtx_unlock(&usb2_ref_lock); +#endif if (udev->flags.usb2_mode == USB_MODE_DEVICE) { /* stop receiving any control transfers (Device Side Mode) */ usb2_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX); } +#if USB_HAVE_UGEN /* free all FIFOs */ usb2_fifo_free_wrap(udev, USB_IFACE_INDEX_ANY, 1); @@ -1863,9 +1887,12 @@ usb2_free_device(struct usb2_device *ude * Free all interface related data and FIFOs, if any. */ usb2_cdev_free(udev); +#endif usb2_free_iface_data(udev); +#if USB_HAVE_UGEN destroy_dev_sched_cb(udev->default_dev, usb2_cdev_cleanup, udev->default_dev->si_drv1); +#endif /* unsetup any leftover default USB transfers */ usb2_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX); @@ -2263,6 +2290,7 @@ usb2_notify_addq(const char *type, struc devctl_queue_data(data); } +#if USB_HAVE_UGEN /*------------------------------------------------------------------------* * usb2_fifo_free_wrap * @@ -2319,6 +2347,7 @@ usb2_fifo_free_wrap(struct usb2_device * usb2_fifo_free(f); } } +#endif /*------------------------------------------------------------------------* * usb2_peer_can_wakeup Modified: head/sys/dev/usb/usb_hub.c ============================================================================== --- head/sys/dev/usb/usb_hub.c Mon Mar 9 20:05:46 2009 (r189598) +++ head/sys/dev/usb/usb_hub.c Mon Mar 9 20:08:08 2009 (r189599) @@ -1324,9 +1324,13 @@ usb2_bus_port_set_device(struct usb2_bus * Make relationships to our new device */ if (device_index != 0) { +#if USB_HAVE_UGEN mtx_lock(&usb2_ref_lock); +#endif bus->devices[device_index] = udev; +#if USB_HAVE_UGEN mtx_unlock(&usb2_ref_lock); +#endif } /* * Debug print
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903092008.n29K88Ys036295>