Date: Wed, 7 Apr 2010 00:33:00 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r206331 - stable/8/sys/dev/usb Message-ID: <201004070033.o370X0Pl030266@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Wed Apr 7 00:32:59 2010 New Revision: 206331 URL: http://svn.freebsd.org/changeset/base/206331 Log: MFC r205036 Implement USB kernel driver detach from userland. Submitted by: Hans Petter Selasky Modified: stable/8/sys/dev/usb/usb_device.c stable/8/sys/dev/usb/usb_device.h stable/8/sys/dev/usb/usb_generic.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/dev/usb/usb_device.c ============================================================================== --- stable/8/sys/dev/usb/usb_device.c Wed Apr 7 00:30:25 2010 (r206330) +++ stable/8/sys/dev/usb/usb_device.c Wed Apr 7 00:32:59 2010 (r206331) @@ -80,7 +80,6 @@ static void usb_init_endpoint(struct usb_device *, uint8_t, struct usb_endpoint_descriptor *, struct usb_endpoint *); static void usb_unconfigure(struct usb_device *, uint8_t); -static void usb_detach_device(struct usb_device *, uint8_t, uint8_t); static void usb_detach_device_sub(struct usb_device *, device_t *, uint8_t); static uint8_t usb_probe_and_attach_sub(struct usb_device *, Modified: stable/8/sys/dev/usb/usb_device.h ============================================================================== --- stable/8/sys/dev/usb/usb_device.h Wed Apr 7 00:30:25 2010 (r206330) +++ stable/8/sys/dev/usb/usb_device.h Wed Apr 7 00:32:59 2010 (r206331) @@ -196,6 +196,7 @@ struct usb_device *usb_alloc_device(devi enum usb_dev_speed speed, enum usb_hc_mode mode); usb_error_t usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index); +void usb_detach_device(struct usb_device *, uint8_t, uint8_t); usb_error_t usb_reset_iface_endpoints(struct usb_device *udev, uint8_t iface_index); usb_error_t usbd_set_config_index(struct usb_device *udev, uint8_t index); Modified: stable/8/sys/dev/usb/usb_generic.c ============================================================================== --- stable/8/sys/dev/usb/usb_generic.c Wed Apr 7 00:30:25 2010 (r206330) +++ stable/8/sys/dev/usb/usb_generic.c Wed Apr 7 00:32:59 2010 (r206331) @@ -2095,17 +2095,32 @@ ugen_ioctl_post(struct usb_fifo *f, u_lo break; case USB_IFACE_DRIVER_ACTIVE: - /* TODO */ - *u.pint = 0; + + n = *u.pint & 0xFF; + + iface = usbd_get_iface(f->udev, n); + + if (iface && iface->subdev) + error = 0; + else + error = ENXIO; break; case USB_IFACE_DRIVER_DETACH: - /* TODO */ + error = priv_check(curthread, PRIV_DRIVER); - if (error) { + + if (error) + break; + + n = *u.pint & 0xFF; + + if (n == USB_IFACE_INDEX_ANY) { + error = EINVAL; break; } - error = EINVAL; + + usb_detach_device(f->udev, n, 0); break; case USB_SET_POWER_MODE:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004070033.o370X0Pl030266>