RE: [PATCH V3 3/4] usb: Create link files between child device and usb port device.

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

 



Hi Alan:
		Thanks for your review. I will update soon.

Best Regards 
Tianyu Lan 


-----Original Message-----
From: Alan Stern [mailto:stern@xxxxxxxxxxxxxxxxxxx] 
Sent: Monday, November 05, 2012 10:55 PM
To: Lan, Tianyu
Cc: gregkh@xxxxxxxxxxxxxxxxxxx; sarah.a.sharp@xxxxxxxxxxxxxxx; linux-usb@xxxxxxxxxxxxxxx
Subject: Re: [PATCH V3 3/4] usb: Create link files between child device and usb port device.

On Sun, 4 Nov 2012, Lan Tianyu wrote:

> To show the relationship between usb port and child device, add link 
> file "port" under usb device's sysfs directoy and "device" under usb 
> port device's sysfs directory. They are linked to each other.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx>
> ---
>  drivers/usb/core/hub.c |   22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 
> 706db5c..a08a018 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -2015,6 +2015,8 @@ void usb_disconnect(struct usb_device **pdev)  {
>  	struct usb_device	*udev = *pdev;
>  	struct usb_hub		*hub = hdev_to_hub(udev);
> +	struct usb_port	*port_dev =
> +		hdev_to_hub(udev->parent)->ports[udev->portnum - 1];

This is bad.  It will crash if udev->parent is NULL.

>  	int			i;
>  
>  	/* mark the device as inactive, so any further urb submissions for 
> @@ -2041,6 +2043,8 @@ void usb_disconnect(struct usb_device **pdev)
>  	usb_disable_device(udev, 0);
>  	usb_hcd_synchronize_unlinks(udev);
>  
> +	sysfs_remove_link(&udev->dev.kobj, "port");
> +	sysfs_remove_link(&port_dev->dev.kobj, "device");

You might as well avoid defining port_dev until here.

Alan Stern

--
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