From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg KH Date: Mon, 16 May 2005 21:53:26 +0000 Subject: Re: Need persistent node to USB port naming Message-Id: <20050516215326.GC12480@kroah.com> 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 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_id344&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