Re: [PATCH 2/2] usb: Set device visibility based on hub port data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 06-10-2011 19:14, Matthew Garrett wrote:

Hubs have a flag to indicate whether a given port carries removable devices
or not. We can use this to give a hint to userspace as to the device
visibility. This is not strictly accurate in that some built-in devices
will be flagged as visible, but followup patches will make use of platform
data to make this more reliable.

Signed-off-by: Matthew Garrett<mjg@xxxxxxxxxx>
---
  drivers/usb/core/hub.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
  1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a428aa0..e8e470e 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1838,6 +1838,46 @@ fail:
  	return err;
  }

+/**
+ * usb_probe_device_visibility - determine a device's visibility
+ * @udev: pointer to device whose visibility should be probed
+ *
+ * Examines a hub's DeviceRemovable descriptor to determine whether a given
+ * device is externally visible or not. This is likely to flag many
+ * built-in devices as visible, but can be overridden by platform-specific
+ * data sources.
+ */
+static void usb_set_device_visibility(struct usb_device *udev)
+{
+	struct usb_device *hdev = udev->parent;
+	struct usb_hub *hub;
+	u8 port = udev->portnum;
+	u16 wHubCharacteristics;
+	bool visible = true;
+
+	if (!hdev)
+		return;
+
+	hub = hdev_to_hub(udev->parent);
+
+	wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
+
+	if (!wHubCharacteristics & HUB_CHAR_COMPOUND)

Are you sure thatre should be no parens around 'wHubCharacteristics & HUB_CHAR_COMPOUND'? Otherwise this code doesn't seem to make sense...

WBR, Sergei


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux