Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932501AbbDHXgV (ORCPT ); Wed, 8 Apr 2015 19:36:21 -0400 Received: from cavan.codon.org.uk ([93.93.128.6]:56086 "EHLO cavan.codon.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754888AbbDHXgS (ORCPT ); Wed, 8 Apr 2015 19:36:18 -0400 From: Matthew Garrett To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Garrett Date: Wed, 8 Apr 2015 16:36:00 -0700 Message-Id: <1428536161-2978-1-git-send-email-mjg59@coreos.com> X-Mailer: git-send-email 2.3.4 X-cavan-blacklisted-at: zen.spamhaus.org X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 67.169.119.23 X-SA-Exim-Mail-From: mjg59@coreos.com X-Spam-ASN: Subject: [PATCH 1/2] usb: Prefer firmware values when determining whether a port is removable X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:54:46 +0000) X-SA-Exim-Scanned: Yes (on cavan.codon.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2099 Lines: 67 Windows appears to pay more attention to the ACPI values than any hub configuration, so prefer the firmware's opinion on whether a port is fixed or removable before falling back to the hub values. Signed-off-by: Matthew Garrett --- drivers/usb/core/hub.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d7c3d5a..ac33fdd 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2350,6 +2350,23 @@ static void set_usb_port_removable(struct usb_device *udev) hub = usb_hub_to_struct_hub(udev->parent); + /* + * If the platform firmware has provided information about a port, + * use that to determine whether it's removable. + */ + switch (hub->ports[udev->portnum - 1]->connect_type) { + case USB_PORT_CONNECT_TYPE_HOT_PLUG: + udev->removable = USB_DEVICE_REMOVABLE; + return; + case USB_PORT_CONNECT_TYPE_HARD_WIRED: + udev->removable = USB_DEVICE_FIXED; + return; + } + + /* + * Otherwise, check whether the hub knows whether a port is removable + * or not + */ wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); if (!(wHubCharacteristics & HUB_CHAR_COMPOUND)) @@ -2369,21 +2386,6 @@ static void set_usb_port_removable(struct usb_device *udev) else udev->removable = USB_DEVICE_FIXED; - /* - * Platform firmware may have populated an alternative value for - * removable. If the parent port has a known connect_type use - * that instead. - */ - switch (hub->ports[udev->portnum - 1]->connect_type) { - case USB_PORT_CONNECT_TYPE_HOT_PLUG: - udev->removable = USB_DEVICE_REMOVABLE; - break; - case USB_PORT_CONNECT_TYPE_HARD_WIRED: - udev->removable = USB_DEVICE_FIXED; - break; - default: /* use what was set above */ - break; - } } /** -- 2.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/