* Need persistent node to USB port naming
@ 2005-05-12 19:58 Stephen Morgan
2005-05-13 8:50 ` ocomber
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Stephen Morgan @ 2005-05-12 19:58 UTC (permalink / raw)
To: linux-hotplug
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
-------------------------------------------------------
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Need persistent node to USB port naming
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
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ocomber @ 2005-05-13 8:50 UTC (permalink / raw)
To: linux-hotplug
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_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
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Need persistent node to USB port naming
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
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Stephen Morgan @ 2005-05-13 16:55 UTC (permalink / raw)
To: linux-hotplug
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.
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? 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?
>
> 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_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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Need persistent node to USB port naming
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
2005-05-13 23:29 ` Stephen Morgan
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2005-05-13 18:55 UTC (permalink / raw)
To: linux-hotplug
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (2 preceding siblings ...)
2005-05-13 18:55 ` Greg KH
@ 2005-05-13 23:29 ` Stephen Morgan
2005-05-14 6:04 ` Greg KH
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Stephen Morgan @ 2005-05-13 23:29 UTC (permalink / raw)
To: linux-hotplug
On Fri, May 13, 2005 at 12:55 PM, Greg KH wrote:
> 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.
Thanks, Greg. That's what I needed to hear.
>
> > 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.
Any thoughts on how to create this dummy device node?
> >
> > 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (3 preceding siblings ...)
2005-05-13 23:29 ` Stephen Morgan
@ 2005-05-14 6:04 ` Greg KH
2005-05-14 16:33 ` Ian Pilcher
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2005-05-14 6:04 UTC (permalink / raw)
To: linux-hotplug
On Fri, May 13, 2005 at 06:29:16PM -0500, Stephen Morgan wrote:
>On Fri, May 13, 2005 at 12:55 PM, Greg KH wrote:
>> On Fri, May 13, 2005 at 11:55:05AM -0500, Stephen Morgan wrote:
>>> 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.
>
> Any thoughts on how to create this dummy device node?
Um, I can't recommend _ever_ doing this kind of thing.
That being said, what do you want to get to and from the driver? Why
not just use sysfs files that you put in your driver's directory? That
is what they are there for :)
Hope this helps,
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (4 preceding siblings ...)
2005-05-14 6:04 ` Greg KH
@ 2005-05-14 16:33 ` Ian Pilcher
2005-05-16 15:40 ` Stephen Morgan
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Ian Pilcher @ 2005-05-14 16:33 UTC (permalink / raw)
To: linux-hotplug
Greg KH wrote:
> On Fri, May 13, 2005 at 06:29:16PM -0500, Stephen Morgan wrote:
>
>>
>>Any thoughts on how to create this dummy device node?
>
>
> Um, I can't recommend _ever_ doing this kind of thing.
>
Don't recent versions of udev do this for you? I only have FC3, which
uses a very old version of udev, available right now, but I seem to
remember the man page on FC4t3 saying something about this.
--
====================================
Ian Pilcher i.pilcher@comcast.net
====================================
-------------------------------------------------------
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
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (5 preceding siblings ...)
2005-05-14 16:33 ` Ian Pilcher
@ 2005-05-16 15:40 ` Stephen Morgan
2005-05-16 15:56 ` Greg KH
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Stephen Morgan @ 2005-05-16 15:40 UTC (permalink / raw)
To: linux-hotplug
> On Sat, May 14, 2005 at 12:04 AM, Greg KH wrote:
> On Fri, May 13, 2005 at 06:29:16PM -0500, Stephen Morgan wrote:
> >On Fri, May 13, 2005 at 12:55 PM, Greg KH wrote:
> >> On Fri, May 13, 2005 at 11:55:05AM -0500, Stephen Morgan wrote:
> >>> 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.
> >
> > Any thoughts on how to create this dummy device node?
>
> Um, I can't recommend _ever_ doing this kind of thing.
>
> That being said, what do you want to get to and from the driver?
It's mostly useful during development. For instance, I can change the
driver's debug print priority on the fly. Eventually, I'll use it to
retrieve diagnostic info the driver is collecting.
> Why not just use sysfs files that you put in your driver's directory?
That
> is what they are there for :)
Okay, I'm not sure what you just said, so I'm gonna go read sysfs.txt.
> Hope this helps,
Me too :-)
Thanks,
Stephen
>
> 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_idt12&alloc_id\x16344&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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (6 preceding siblings ...)
2005-05-16 15:40 ` Stephen Morgan
@ 2005-05-16 15:56 ` Greg KH
2005-05-16 21:40 ` Stephen Morgan
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2005-05-16 15:56 UTC (permalink / raw)
To: linux-hotplug
On Mon, May 16, 2005 at 10:40:40AM -0500, Stephen Morgan wrote:
> > On Sat, May 14, 2005 at 12:04 AM, Greg KH wrote:
> > On Fri, May 13, 2005 at 06:29:16PM -0500, Stephen Morgan wrote:
> > >On Fri, May 13, 2005 at 12:55 PM, Greg KH wrote:
> > >> On Fri, May 13, 2005 at 11:55:05AM -0500, Stephen Morgan wrote:
> > >>> 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.
> > >
> > > Any thoughts on how to create this dummy device node?
> >
> > Um, I can't recommend _ever_ doing this kind of thing.
> >
> > That being said, what do you want to get to and from the driver?
>
> It's mostly useful during development. For instance, I can change the
> driver's debug print priority on the fly.
That is useful. So useful that if you look at any usb-serial driver,
they already do this in the /sys/modules/MODULE_NAME/paramaters/debug
file :)
You can get this for free too with the module_param() macro.
> Eventually, I'll use it to retrieve diagnostic info the driver is
> collecting.
sysfs is for 1 value per file. For diagnostic information, I suggest
using debugfs instead, that is what it is there for.
> > Why not just use sysfs files that you put in your driver's directory? That
> > is what they are there for :)
>
> Okay, I'm not sure what you just said, so I'm gonna go read sysfs.txt.
Try the Third Edition of Linux Device Drivers from Oreilly. It's much
better than that outdated file. It's also online for free if you don't
want to buy it.
Good luck,
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_idt12&alloc_id\x16344&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
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (7 preceding siblings ...)
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
10 siblings, 0 replies; 12+ messages in thread
From: Stephen Morgan @ 2005-05-16 21:40 UTC (permalink / raw)
To: linux-hotplug
On Mon, May 16, 2005 at 9:56 AM, Greg KH wrote:
> On Mon, May 16, 2005 at 10:40:40AM -0500, Stephen Morgan wrote:
> > > On Sat, May 14, 2005 at 12:04 AM, Greg KH wrote:
> > > On Fri, May 13, 2005 at 06:29:16PM -0500, Stephen Morgan wrote:
> > > >On Fri, May 13, 2005 at 12:55 PM, Greg KH wrote:
> > > >> On Fri, May 13, 2005 at 11:55:05AM -0500, Stephen Morgan wrote:
> > > >>> 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.
> > > >
> > > > Any thoughts on how to create this dummy device node?
> > >
> > > Um, I can't recommend _ever_ doing this kind of thing.
> > >
> > > That being said, what do you want to get to and from the driver?
> >
> > It's mostly useful during development. For instance, I can change the
> > driver's debug print priority on the fly.
>
> That is useful. So useful that if you look at any usb-serial driver,
> they already do this in the /sys/modules/MODULE_NAME/paramaters/debug
> file :)
I guess I'm missing something here. What should I be looking for (I assume
in /drivers/usb/serial/)?
In usb-serial.h, I see your dbg macro, which has a fixed priority of
KERN_DEBUG and can be turned on and off with the 'debug' variable.
I'm using ...
#define dbug(level, format, arg...) do { if (debug & level)
printk(KERN_NOTICE __FILE__ ": " format "\n" , ## arg); } while (0)
... so each call can use one of several values of "level", and by passing
"debug" in through an ioctl(), I have pretty good control over printk
traffic, assuming I chose my levels wisely.
>
> You can get this for free too with the module_param() macro.
But, isn't that only able to set the parameter once, at load time?
>
> > Eventually, I'll use it to retrieve diagnostic info the driver is
> > collecting.
>
> sysfs is for 1 value per file. For diagnostic information, I suggest
> using debugfs instead, that is what it is there for.
Can you recommend a good reference on debugfs? The only thing I've found is
the man page that calls it "an interactive file system debugger."
>
> > > Why not just use sysfs files that you put in your driver's
> directory? That
> > > is what they are there for :)
> >
> > Okay, I'm not sure what you just said, so I'm gonna go read sysfs.txt.
>
> Try the Third Edition of Linux Device Drivers from Oreilly. It's much
> better than that outdated file. It's also online for free if you don't
> want to buy it.
Okay, thanks. I've got that now.
>
> Good luck,
>
> 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_idt12&alloc_id\x16344&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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (8 preceding siblings ...)
2005-05-16 21:40 ` Stephen Morgan
@ 2005-05-16 21:53 ` Greg KH
2005-05-18 20:56 ` Stephen Morgan
10 siblings, 0 replies; 12+ messages in thread
From: Greg KH @ 2005-05-16 21:53 UTC (permalink / raw)
To: linux-hotplug
On Mon, May 16, 2005 at 04:40:27PM -0500, Stephen Morgan wrote:
> On Mon, May 16, 2005 at 9:56 AM, Greg KH wrote:
> > On Mon, May 16, 2005 at 10:40:40AM -0500, Stephen Morgan wrote:
> > > > On Sat, May 14, 2005 at 12:04 AM, Greg KH wrote:
> > > > On Fri, May 13, 2005 at 06:29:16PM -0500, Stephen Morgan wrote:
> > > > >On Fri, May 13, 2005 at 12:55 PM, Greg KH wrote:
> > > > >> On Fri, May 13, 2005 at 11:55:05AM -0500, Stephen Morgan wrote:
> > > > >>> 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.
> > > > >
> > > > > Any thoughts on how to create this dummy device node?
> > > >
> > > > Um, I can't recommend _ever_ doing this kind of thing.
> > > >
> > > > That being said, what do you want to get to and from the driver?
> > >
> > > It's mostly useful during development. For instance, I can change the
> > > driver's debug print priority on the fly.
> >
> > That is useful. So useful that if you look at any usb-serial driver,
> > they already do this in the /sys/modules/MODULE_NAME/paramaters/debug
> > file :)
>
> I guess I'm missing something here. What should I be looking for (I assume
> in /drivers/usb/serial/)?
module_param()
> In usb-serial.h, I see your dbg macro, which has a fixed priority of
> KERN_DEBUG and can be turned on and off with the 'debug' variable.
>
> I'm using ...
>
> #define dbug(level, format, arg...) do { if (debug & level)
> printk(KERN_NOTICE __FILE__ ": " format "\n" , ## arg); } while (0)
>
> ... so each call can use one of several values of "level", and by passing
> "debug" in through an ioctl(), I have pretty good control over printk
> traffic, assuming I chose my levels wisely.
>
> >
> > You can get this for free too with the module_param() macro.
>
> But, isn't that only able to set the parameter once, at load time?
Nope. Not if you set the last value to a valid file mode. If it is not
0000, then a file will be created in /sys/module/MODULE_NAME/paramaters/
with the name of the module paramater, and the mode specified. This
happens if the code is built as a module or not (that way built-in
modules get access to this info too.)
If you notice the debug paramater, it is defined as:
module_param(debug, bool, S_IRUGO | S_IWUSR);
Which lets the value to be read by any user, but set only by root.
You can also override the default functions that are called when the
value is written to, in order to do different things when this happens,
but that functionality is only rarely needed.
> > > Eventually, I'll use it to retrieve diagnostic info the driver is
> > > collecting.
> >
> > sysfs is for 1 value per file. For diagnostic information, I suggest
> > using debugfs instead, that is what it is there for.
>
> Can you recommend a good reference on debugfs? The only thing I've found is
> the man page that calls it "an interactive file system debugger."
My post to lkml about how to use it is a good start. I think it got
referenced on kerneltrap.org. Yeah, here it is:
http://kerneltrap.org/node/4394
The "interactive file system debugger" is a userspace program called
debugfs, a totally different thing. Also read the debugfs code (in
fs/debugfs/*), it contains a lot of built-in documentation.
Hope this helps,
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_idt12&alloc_id\x16344&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
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: Need persistent node to USB port naming
2005-05-12 19:58 Need persistent node to USB port naming Stephen Morgan
` (9 preceding siblings ...)
2005-05-16 21:53 ` Greg KH
@ 2005-05-18 20:56 ` Stephen Morgan
10 siblings, 0 replies; 12+ messages in thread
From: Stephen Morgan @ 2005-05-18 20:56 UTC (permalink / raw)
To: linux-hotplug
> You can also override the default functions that are called when the
> value is written to, in order to do different things when this happens,
> but that functionality is only rarely needed.
I think that's got it, Greg. Thanks very much for your help.
Stephen
/**************************************************/
static int my_command_set(const char *val, struct kernel_param *kp)
{
// convert val to an int and switch() on it
return 0;
}
int my_command;
// use my 'set' but use the kernel's default 'get'
module_param_call(my_command, my_command_set, param_get_int, &my_command,
S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(my_command, "My Driver Command");
/**************************************************/
-------------------------------------------------------
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_idt12&alloc_id\x16344&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
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2005-05-18 20:56 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).