From owner-svn-src-all@FreeBSD.ORG Thu Oct 9 15:01:58 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 207833E4; Thu, 9 Oct 2014 15:01:58 +0000 (UTC) Received: from mail-qc0-x237.google.com (mail-qc0-x237.google.com [IPv6:2607:f8b0:400d:c01::237]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A1279A7A; Thu, 9 Oct 2014 15:01:57 +0000 (UTC) Received: by mail-qc0-f183.google.com with SMTP id r5so107415qcx.0 for ; Thu, 09 Oct 2014 08:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version:content-type; bh=2XJ2sFDe0ExwgJS0ET79+1vkNlQUC8mPekYWV5woqWA=; b=iOyrJ3YZGLlmZGhxu/fKgnYpjMsXMXEpTULIDZF/DAik62P0f9nvfErl6ENIlZfYH2 sDhQYOXogJZGWARqdHEqvbOMl31N4kp/YR8ApR/NuL2ZRtOUiC2FVR2f29ZaYRq56ClP kwy/97DPW6bFRg+3EjdyUvqiq1v4f6U8rOab2l9PqjIDESzG/aOb/2RCO3Jw34jzOY38 OGYdHzTxIdFcxGgg+h6fJlKdm5a0vL8vQaFKxLnVWpi/tPSoElcbHZhytFWF0JMxSt3F AgenW9IZdSX6qQJ1jrbgP8LIWQaB6Rdx0Dt/pUI7md7WOL2+vifJ2ylqBne7UPLwpRY1 UV1w== X-Received: by 10.182.81.169 with SMTP id b9mr118883oby.8.1412866916746; Thu, 09 Oct 2014 08:01:56 -0700 (PDT) X-Google-Doc-Id: d1ec095ca66d579e X-Google-Web-Client: true Date: Thu, 9 Oct 2014 08:01:55 -0700 (PDT) From: roseknr1 To: bsdmailinglist@googlegroups.com Message-Id: <56602668-32d8-422a-85d2-9b2b1fdfdf11@googlegroups.com> In-Reply-To: <201410091443.s99EhiJ4021595@svn.freebsd.org> References: <201410091443.s99EhiJ4021595@svn.freebsd.org> Subject: Re: svn commit: r272822 - head/sys/dev/usb MIME-Version: 1.0 X-Google-IP: 117.221.202.78 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, hselasky@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Thu, 09 Oct 2014 15:01:58 -0000 *join free social network clickcare * On Thursday, October 9, 2014 8:13:51 PM UTC+5:30, Hans Petter Selasky wrote: > > Author: hselasky > Date: Thu Oct 9 14:43:43 2014 > New Revision: 272822 > URL: https://svnweb.freebsd.org/changeset/base/272822 > > Log: > Add sysctl knob to disable port power on a specific USB HUB. You need > to reset the USB HUB using "usbconfig -d X.Y reset" or boot having the > setting in /boot/loader.conf before it activates. > > Modified: > head/sys/dev/usb/usb_hub.c > > Modified: head/sys/dev/usb/usb_hub.c > ============================================================================== > > --- head/sys/dev/usb/usb_hub.c Thu Oct 9 14:33:20 > 2014 (r272821) > +++ head/sys/dev/usb/usb_hub.c Thu Oct 9 14:43:43 > 2014 (r272822) > @@ -101,6 +101,10 @@ SYSCTL_INT(_hw_usb, OID_AUTO, power_time > static int usb_disable_enumeration = 0; > SYSCTL_INT(_hw_usb, OID_AUTO, disable_enumeration, CTLFLAG_RWTUN, > &usb_disable_enumeration, 0, "Set to disable all USB device > enumeration."); > + > +static int usb_disable_port_power = 0; > +SYSCTL_INT(_hw_usb, OID_AUTO, disable_port_power, CTLFLAG_RWTUN, > + &usb_disable_port_power, 0, "Set to disable all USB port power."); > #endif > > struct uhub_current_state { > @@ -119,6 +123,7 @@ struct uhub_softc { > struct usb_xfer *sc_xfer[UHUB_N_TRANSFER]; /* interrupt > xfer */ > #if USB_HAVE_DISABLE_ENUM > int sc_disable_enumeration; > + int sc_disable_port_power; > #endif > uint8_t sc_flags; > #define UHUB_FLAG_DID_EXPLORE 0x01 > @@ -1406,6 +1411,24 @@ uhub_attach(device_t dev) > /* wait with power off for a while */ > usb_pause_mtx(NULL, USB_MS_TO_TICKS(USB_POWER_DOWN_TIME)); > > +#if USB_HAVE_DISABLE_ENUM > + /* Add device sysctls */ > + > + sysctl_ctx = device_get_sysctl_ctx(dev); > + sysctl_tree = device_get_sysctl_tree(dev); > + > + if (sysctl_ctx != NULL && sysctl_tree != NULL) { > + (void) SYSCTL_ADD_INT(sysctl_ctx, > SYSCTL_CHILDREN(sysctl_tree), > + OID_AUTO, "disable_enumeration", CTLFLAG_RWTUN, > + &sc->sc_disable_enumeration, 0, > + "Set to disable enumeration on this USB HUB."); > + > + (void) SYSCTL_ADD_INT(sysctl_ctx, > SYSCTL_CHILDREN(sysctl_tree), > + OID_AUTO, "disable_port_power", CTLFLAG_RWTUN, > + &sc->sc_disable_port_power, 0, > + "Set to disable USB port power on this USB HUB."); > + } > +#endif > /* > * To have the best chance of success we do things in the exact > same > * order as Windoze98. This should not be necessary, but some > @@ -1460,13 +1483,27 @@ uhub_attach(device_t dev) > removable++; > break; > } > - if (!err) { > - /* turn the power on */ > - err = usbd_req_set_port_feature(udev, NULL, > - portno, UHF_PORT_POWER); > + if (err == 0) { > +#if USB_HAVE_DISABLE_ENUM > + /* check if we should disable USB port power or > not */ > + if (usb_disable_port_power != 0 || > + sc->sc_disable_port_power != 0) { > + /* turn the power off */ > + DPRINTFN(0, "Turning port %d power > off\n", portno); > + err = usbd_req_clear_port_feature(udev, > NULL, > + portno, UHF_PORT_POWER); > + } else { > +#endif > + /* turn the power on */ > + DPRINTFN(0, "Turning port %d power on\n", > portno); > + err = usbd_req_set_port_feature(udev, > NULL, > + portno, UHF_PORT_POWER); > +#if USB_HAVE_DISABLE_ENUM > + } > +#endif > } > - if (err) { > - DPRINTFN(0, "port %d power on failed, %s\n", > + if (err != 0) { > + DPRINTFN(0, "port %d power on or off failed, > %s\n", > portno, usbd_errstr(err)); > } > DPRINTF("turn on port %d power\n", > @@ -1490,19 +1527,6 @@ uhub_attach(device_t dev) > > usbd_set_power_mode(udev, USB_POWER_MODE_SAVE); > > -#if USB_HAVE_DISABLE_ENUM > - /* Add device sysctls */ > - > - sysctl_ctx = device_get_sysctl_ctx(dev); > - sysctl_tree = device_get_sysctl_tree(dev); > - > - if (sysctl_ctx != NULL && sysctl_tree != NULL) { > - (void) SYSCTL_ADD_INT(sysctl_ctx, > SYSCTL_CHILDREN(sysctl_tree), > - OID_AUTO, "disable_enumeration", CTLFLAG_RWTUN, > - &sc->sc_disable_enumeration, 0, > - "Set to disable enumeration on this USB HUB."); > - } > -#endif > return (0); > > error: > _______________________________________________ > svn-s...@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-all > To unsubscribe, send any mail to "svn-src-all...@freebsd.org " > >