From: Greg KH <greg@kroah.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Need persistent node to USB port naming
Date: Fri, 13 May 2005 18:55:26 +0000 [thread overview]
Message-ID: <20050513185526.GB13518@kroah.com> (raw)
In-Reply-To: <NDBBIKDDCLAGMMFDHHDBEEEPDAAA.stephenm@glw.com>
On Fri, May 13, 2005 at 11:55:05AM -0500, Stephen Morgan wrote:
> On Fri, 2005-05-03 at 2:50 ocomber wrote:
> > 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.
>
> It does - it's called PLACE :-) (or, more recently, ID) and it works - I
> just want to make sure this is the best way to get the nodes I need.
Yes it is. PLACE is just for what you are looking for.
> One problem I've run into is trying to create a dummy node that allows me to
> communicate with the driver thru ioctl's even when no device is plugged in.
> In 2.4, I just created a node with a minor I knew would never be used, and
> in the driver, I filtered for that minor.
>
> Do I <need> to use udev?
Not if you don't want to, no.
> It's obviously working, but can I turn it off and make nodes the way I
> did in 2.4? If so, how would I turn it off? What kinds of havoc
> would that wreak in 2.6?
Depends on your distro, and how it is set up. Lots of people use 2.6
without using udev.
thanks,
greg k-h
-------------------------------------------------------
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_id\x16281&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
next prev parent reply other threads:[~2005-05-13 18:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
2005-05-13 8:50 ` ocomber
2005-05-13 16:55 ` Stephen Morgan
2005-05-13 18:55 ` Greg KH [this message]
2005-05-13 23:29 ` Stephen Morgan
2005-05-14 6:04 ` Greg KH
2005-05-14 16:33 ` Ian Pilcher
2005-05-16 15:40 ` Stephen Morgan
2005-05-16 15:56 ` Greg KH
2005-05-16 21:40 ` Stephen Morgan
2005-05-16 21:53 ` Greg KH
2005-05-18 20:56 ` Stephen Morgan
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=20050513185526.GB13518@kroah.com \
--to=greg@kroah.com \
--cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).