From: Greg KH <greg@kroah.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Need persistent node to USB port naming
Date: Mon, 16 May 2005 21:53:26 +0000 [thread overview]
Message-ID: <20050516215326.GC12480@kroah.com> (raw)
In-Reply-To: <NDBBIKDDCLAGMMFDHHDBEEEPDAAA.stephenm@glw.com>
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
next prev parent reply other threads:[~2005-05-16 21:53 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
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 [this message]
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=20050516215326.GC12480@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).