Commit 347563f5 authored by David Brownell's avatar David Brownell Committed by Trond Myklebust

[PATCH] USB: driverfs paths

I noticed a minor goof, basically an open issue coming home to
roost.  For the root hub, usb_device->devpath was "/" so it
caused problems using devpath when constructing names for
interfaces.  Driverfs doesn't reject it, but of course the
resulting directory names can't be used...

This patch (untested, but compiles) should make devpath in that
case be "0" ... which can't collide with any path through hub
ports (first port == "1") so it's possible to use driverfs
paths again.
parent 9f07518f
......@@ -876,10 +876,11 @@ static void usb_hub_port_connect_change(struct usb_hub *hubstate, int port,
* (quite rare, since most hubs have 4-6 ports).
*/
pdev = dev->parent;
if (pdev->devpath [0] != '/') /* parent not root */
if (pdev->devpath [0] != '0') /* parent not root? */
len = snprintf (dev->devpath, sizeof dev->devpath,
"%s.%d", pdev->devpath, port + 1);
else /* root == "/", root port 2 == "2", port 3 that hub "/2.3" */
/* root == "0", root port 2 == "2", port 3 that hub "2.3" */
else
len = snprintf (dev->devpath, sizeof dev->devpath,
"%d", port + 1);
if (len == sizeof dev->devpath)
......
......@@ -1014,7 +1014,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus)
usb_bus_get(bus);
if (!parent)
dev->devpath [0] = '/';
dev->devpath [0] = '0';
dev->bus = bus;
dev->parent = parent;
atomic_set(&dev->refcnt, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment