Re: [PATCH 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]

 



Hello.

On 23-10-2012 11:18, Lan Tianyu wrote:

To show the relationship between usb port and child device,
add link file "port" under usb device's sysfs directoy and
"child" 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 |   17 +++++++++++++++++
  1 file changed, 17 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4d0eebc..0981aea 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
[...]
@@ -1999,6 +2001,9 @@ 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,
+			"child");

   No need to break the line here.

  	usb_remove_ep_devs(&udev->ep0);
  	usb_unlock_device(udev);

@@ -2291,6 +2296,18 @@ int usb_new_device(struct usb_device *udev)
  		goto fail;
  	}

+	/* Create link files between child device and usb port device. */
+	if (udev->parent) {
+		int no_warn;

  I think 'ret' or 'result' is a better name...

+		struct usb_port *port_dev =
+			hdev_to_hub(udev->parent)->ports[udev->portnum - 1];
+
+		no_warn = sysfs_create_link(&udev->dev.kobj,
+				&port_dev->dev.kobj, "port");
+		no_warn = sysfs_create_link(&port_dev->dev.kobj,
+				&udev->dev.kobj, "child");

I guess you are not supposed to ignore the result if the function requires it not to be ignored.

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