Re: [RFC PATCH 2/2] USB: Set usb port's DevicerRemovable according acpi information in EHCI

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

 



On 2012年08月21日 22:56, Alan Stern wrote:
> On Tue, 21 Aug 2012, Lan Tianyu wrote:
> 
>> From: "Signed-off-by: Lan Tianyu" <tianyu.lan@xxxxxxxxx>
> 
> What happened here?  That's not right.
> 
This was added by git sendmail... I have no idea.

>> 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.
> 
> By the way, what tree are these patches based on?  None of the new 
> hub-port stuff seems to be in Greg's USB tree yet.
Yes. I based on my previous patchset which is still not merged in the
usb-next tree. I will add this in the change log.
http://marc.info/?l=linux-usb&m=134517695007182&w=2

usb : Add sysfs files to control port power.
usb: Fail a get config when the port is powered off.
usb/acpi: Use ACPI methods to power off ports.
xhci: Handle clear PORT_POWER feature.
usb/acpi: Store info on device removability.
usb/acpi: Bind ACPI node to USB port, not usb_device.
usb: move children to struct usb_port
usb: make usb port a real device

> 
>> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
>> index 65c91300..4c631d3 100644
>> --- a/drivers/usb/core/hub.c
>> +++ b/drivers/usb/core/hub.c
>> @@ -1560,6 +1560,10 @@ static int hub_configure(struct usb_hub *hub,
>>  			dev_err(hub->intfdev,
>>  				"couldn't create port%d device.\n", i + 1);
>>  
>> +	/*  Get hub descriptor again to sync port's DeviceRemovable
>> +	 *  after the usb port devices being created.
>> +	 */
>> +	get_hub_descriptor(hdev, hub->descriptor);
> 
> Why is this needed?  Do you have any reason to think the hub descriptor 
> has changed since the first time we retrieved it?

At first time, the usb port devices have not been created and not bound
with acpi. So at that time, port's DeviceRemovable is not set according
acpi information. After ports' devices are created, binding procedure is
completed. Request hub descriptor again and DeviceRemovable will be
updated by acpi information.

> 
> 
>> diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
>> index c788022..0a3bb05 100644
>> --- a/drivers/usb/host/ehci-hub.c
>> +++ b/drivers/usb/host/ehci-hub.c
>> @@ -636,6 +636,7 @@ ehci_hub_descriptor (
>>  	struct usb_hub_descriptor	*desc
>>  ) {
>>  	int		ports = HCS_N_PORTS (ehci->hcs_params);
>> +	int		i;
>>  	u16		temp;
>>  
>>  	desc->bDescriptorType = 0x29;
>> @@ -648,7 +649,14 @@ ehci_hub_descriptor (
>>  
>>  	/* two bitmaps:  ports removable, and usb 1.0 legacy PortPwrCtrlMask */
>>  	memset(&desc->u.hs.DeviceRemovable[0], 0, temp);
>> -	memset(&desc->u.hs.DeviceRemovable[temp], 0xff, temp);
>> +	memset(&desc->u.hs.DeviceRemovable[temp], 0xff, ltemp);
> 
> What is ltemp?  Did you really mean to change this line?
> 
A typo.
>> +
>> +	for (i = 1; i <= ports; i++) {
>> +		if (usb_get_hub_port_connect_type(hcd->self.root_hub, i);
>> +				== USB_PORT_CONNECT_TYPE_HARD_WIRED)
>> +			desc->u.hs.DeviceRemovable[ports/8] |= 1 << (i%8);
> 
> You have "ports/8" where it should be "i/8".
> 
Yeah. so careless.
>> +	}
>> +
>>  
>>  	temp = 0x0008;			/* per-port overcurrent reporting */
>>  	if (HCS_PPC (ehci->hcs_params))
> 
> Alan Stern
> 


-- 
Best regards
Tianyu Lan
--
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