On Mon, 3 Sep 2012, Lan Tianyu wrote:

> ACPI provide "_PLD" and "_UPC" aml methods to describe usb port
> visibility and connectability. This patch is to use those information
> to set usb port's DeviceRemovable.
> 
> Signed-off-by: Lan Tianyu <tianyu....@intel.com>
> ---
> v2: Set DeviceRemovable according acpi infomation in the hub_configure()
> instead of calling get_hub_descriptor().

> @@ -1566,6 +1566,25 @@ static int hub_configure(struct usb_hub *hub,
>                       dev_err(hub->intfdev,
>                               "couldn't create port%d device.\n", i + 1);
>  
> +     if (hub_is_superspeed(hdev)) {
> +             for (i = 1; i <= hdev->maxchild; i++)
> +                     if (hub->ports[i - 1]->connect_type
> +                                     == USB_PORT_CONNECT_TYPE_HARD_WIRED)
> +                             hub->descriptor->u.hs.DeviceRemovable[i/8]
> +                                     |= 1 << (i%8);
> +     } else  {
> +             u16 port_removable = 0;
> +
> +             for (i = i; i <= hdev->maxchild; i++)
> +                     if (hub->ports[i - 1]->connect_type
> +                                     == USB_PORT_CONNECT_TYPE_HARD_WIRED)
> +                             port_removable |= 1 << i;
> +
> +             memset(&hub->descriptor->u.ss.DeviceRemovable,
> +                     (__force __u16) cpu_to_le16(port_removable),
> +                     sizeof(__u16));

Use put_unaligned_le16() instead of memset, if you're worried about 
alignment.

This isn't right, because you overwrite information provided by the hub 
with what ACPI says, even if ACPI doesn't say anything.  You should 
initialize port_removable to the original value of 
u.ss.DeviceRemovable, not to 0.

Alan Stern

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

Reply via email to