public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* USB & Sysfs Question ( posible issue )
@ 2006-06-26 15:52 Razvan Gavril
  2006-06-27  6:28 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Razvan Gavril @ 2006-06-26 15:52 UTC (permalink / raw)
  To: linux-kernel

If i had a usb-serial device in linux, i can/could find a symlink in 
/sys/bus/usb-serial/devices named ttyUSBX that is/was pointing to 
another sysfs directory, which is in /sys/device. The directory in the 
/device looked something like this : 
/devices/pci0000:00/0000:00:02.0/usb1/1-3/1-3:1.0/ttyUSBX . As far i 
could figure out the '... usb1/1-3/...' part from the path means that 
the device is connected to the port 3 of the 1st usb controler.

I used this for a long of time to uniquely identify phisical usb ports 
from a computer, when upgrading to 2.6.17, something strange started to 
happen: even if i didn't remove the usb device from a specified port of 
a the computer, sometimes when rebooting the usb controlers changed 
their numbers in sysfs. A device that was before the reboot 
'...usb1/1-3/...' can be now ' ...usb2/2-3...' or '...usb4/4-3...'.

The main idea is that an usb port can't no loger be identified only by 
looking on it's sysfs path. Is this a normal behavior ? I'm asking this 
as i didn't get this numbering change when using older 2.6 kernel.

Thanks

--
Razvan Gavril

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: USB & Sysfs Question ( posible issue )
  2006-06-26 15:52 USB & Sysfs Question ( posible issue ) Razvan Gavril
@ 2006-06-27  6:28 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2006-06-27  6:28 UTC (permalink / raw)
  To: Razvan Gavril; +Cc: linux-kernel

On Mon, Jun 26, 2006 at 06:52:35PM +0300, Razvan Gavril wrote:
> If i had a usb-serial device in linux, i can/could find a symlink in 
> /sys/bus/usb-serial/devices named ttyUSBX that is/was pointing to 
> another sysfs directory, which is in /sys/device. The directory in the 
> /device looked something like this : 
> /devices/pci0000:00/0000:00:02.0/usb1/1-3/1-3:1.0/ttyUSBX . As far i 
> could figure out the '... usb1/1-3/...' part from the path means that 
> the device is connected to the port 3 of the 1st usb controler.

Close, but not quite, as you soon discover:

> I used this for a long of time to uniquely identify phisical usb ports 
> from a computer, when upgrading to 2.6.17, something strange started to 
> happen: even if i didn't remove the usb device from a specified port of 
> a the computer, sometimes when rebooting the usb controlers changed 
> their numbers in sysfs. A device that was before the reboot 
> '...usb1/1-3/...' can be now ' ...usb2/2-3...' or '...usb4/4-3...'.
> 
> The main idea is that an usb port can't no loger be identified only by 
> looking on it's sysfs path. Is this a normal behavior ? I'm asking this 
> as i didn't get this numbering change when using older 2.6 kernel.

The first number is just the number of the USB bus.  That bus number is
simply incremented based on a new USB bus being created.  So, if you
load the USB controller drivers into the kernel in a different order,
you get different bus numbering.

I suggest going one step further up the device chain to the PCI device
itself.  Use the pci device number, as that is bit of a more stable
number (but be aware that it can change across reboots, and bios
upgrades have a tendancy to reorder things, and then there's the mess of
pci hotplug systems...)

Ideally, to solve this problem the best, you would just look at the
unique serial number in your usb-serial device, but unfortunatly, a lot
of them are not unique.  Is this the case for yours?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-06-27  6:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-26 15:52 USB & Sysfs Question ( posible issue ) Razvan Gavril
2006-06-27  6:28 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox