lkml.org 
[lkml]   [2012]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC]Is usb port number fixed?
On Fri, 20 Apr 2012, Greg KH wrote:

> > Make the question precise.
> > I assme there are two usb ports in my notebook at left and right separately.
> > When I plug mouse into
> > left usb port, I get 2-1.1:1.0
> > right usb port, I get 2-1.2:1.0
> >
> > I want to know whether it is right that no matter how many times I reboot the machine,
>
> Not always.
>
> > the test result above will be the same.And if it will be the same, then why it will be the same.
>
> You got lucky :)
>
> USB ports on a hub are all enumerated the same, but the root hubs
> aren't, and sometimes hubs on the same bus are not as well.
>
> But usually, things do come up in the same way all the time, so
> depending on your use case, you can rely on this, but it is recommended
> that you look for something else a bit more unique, like a serial number
> on a device (if it is present), if you wish to uniquely identify a
> device all the time.

In this particular case, it is guaranteed that the left USB port will
always be numbered as X-1.1:1.0 and the right port as X-1.2:1.0, where
the number X may change from one boot to another. But the -1.1:1.0 and
-1.2:1.0 parts will always be the same.

This is because X is the bus number, which is allowed to change. The
-1.1:1.0 and -1.2:1.0 values are port, configuration, and interface
numbers. They will never change, because they come from the hardware.

Alan Stern



\
 
 \ /
  Last update: 2012-04-21 02:35    [W:0.056 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site