public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Wang YanQing <Udknight@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-usb@vger.kernel.org
Subject: Re: [RFC]Is usb port number fixed?
Date: Fri, 20 Apr 2012 08:37:27 -0700	[thread overview]
Message-ID: <20120420153727.GA29331@kroah.com> (raw)
In-Reply-To: <20120420093738.GA12755@udknight>

On Fri, Apr 20, 2012 at 05:37:38PM +0800, Wang YanQing wrote:
> On Fri, Apr 20, 2012 at 05:25:25PM +0800, Wang YanQing wrote:
> > Hi!
> > when I execute the command below:
> > 
> > "ls /sys/bus/usb/devices/"
> > 
> > I get:
> > "1-0:1.0 1-1 1-1:1.0 2-0:1.0 2-1 2-1.1 2-1:1.0 2-1.1:1.0 2-1.5 2-1.5:1.0 2-1.5:1.1  usb1  usb2"
> > 
> > the output format is bus-port.port:config.interface
> > I want to know whether the port number is fixed after I reboot machine time by time.
> > And if it is fixed, then what make it.
> > 
> > Thanks!
> 
> 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.

good luck,

greg k-h

  reply	other threads:[~2012-04-20 15:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20  9:25 [RFC]Is usb port number fixed? Wang YanQing
2012-04-20  9:37 ` Wang YanQing
2012-04-20 15:37   ` Greg KH [this message]
     [not found]     ` <CAHkwNT=VW8qF-7QRxpiaWkmQm0UFdsbahFLhT-PCc4OMnVs1Gg@mail.gmail.com>
2012-04-20 16:19       ` Greg KH
2012-04-21  0:32     ` Alan Stern
2012-04-21  5:56       ` Wang YanQing
2012-04-21 17:23         ` Alan Stern
     [not found] <CAHkwNT=DTjdhZmEg+SFGOVi+ZcS-NpHWH8Hh3XV+-BPzHRC7NA@mail.gmail.com>
2012-04-22 12:47 ` Alan Stern
2012-04-23  1:52   ` Wang YanQing
2012-04-23 15:13     ` Alan Stern
2012-04-24  2:16       ` Wang YanQing
2012-04-24 14:14         ` Alan Stern
2012-04-24 15:58           ` Wang YanQing
2012-04-24 14:22         ` anil
2012-04-24  2:24       ` Wang YanQing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120420153727.GA29331@kroah.com \
    --to=greg@kroah.com \
    --cc=Udknight@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox