From mboxrd@z Thu Jan 1 00:00:00 1970 From: ocomber Date: Fri, 13 May 2005 08:50:22 +0000 Subject: Re: Need persistent node to USB port naming Message-Id: <1115974222.10045.168.camel@localhost.localdomain> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org On Thu, 2005-05-12 at 14:58 -0500, Stephen Morgan wrote: > Hello all, > > I'm converting a driver for a USB device from Linux 2.4 to 2.6. The device > is embedded and the host is an embedded PC. There may be as many as 6 > identical devices attached. The only way they are differentiated is by the > USB port they're plugged into - the cabling is fixed. So, when the user > asks for 'foo_dev0' for instance, he wants the first USB device - 'foo_dev1' > should give him the 2nd device, etc. > > Under 2.4, I created six nodes, assigning them minors 192 thru 197. In the > driver's probe(), I used usb_make_path to create an index to the device. > For file ops, I used (MINOR(inode_p->i_rdev) - 192) to get an index from the > node. > > So far, under 2.6, the best approach I can see is to create a udev .rules > file to make the nodes, like so: BUS="usb", PLACE="1-1", NAME="usb/foo_dev0" > > Is this the best way to go, or have I overlooked something simpler? > > Thanks > > Stephen Morgan If your driver is aware of which usb port it is plugged into, it could turn this into a sysfs attribute which can be picked up by udev: BUS="usb", KERNEL="foo", NAME="%k", SYMLINK="%s{USBPORT}" It may be that the USB port already exists as a sysfs attribute without you having to explicitly code this - I can't check this at the mo. You can find what sysfs attributes exist for your devices with something like: udevinfo -a -p /class/usb/(DEVICE) Hope this helps :0) -Oli ------------------------------------------------------- This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes! http://ads.osdn.com/?ad_ids93&alloc_id281&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel