Duncan: My knowledge of sysfs is very sketchy, at best. I've read the stuff in the Documentation directory, but I haven't looked at the code so I don't know how it works in practice.
On Fri, 7 Feb 2003, Duncan Sands wrote: > > > - driver (module) registers with USB subsystem > > > - probe function is called, driver is bound to an interface > > > - (driver cannot be unloaded now - this is done in sysfs, no?) > > > > Just what does sysfs do here? So far as I am aware, it does nothing to > > prevent the driver from being unloaded. And if it does do something, how > > does the user tell it when he wants to allow the module to be unloaded? > > That was a guess - and it seems wrong (I should have taken the 30 seconds > needed to check...). I can't in fact see anything that stops the module > being unloaded after a successful probe! I assumed that the driver would > be registered with sysfs and sysfs would take a reference, but if so I can't > find it. Well, that makes sense. Once a driver is loaded and its probe() succeeds, you've got to be able to unload it somehow -- and that means there shouldn't be anything preventing an unload. In usb-storage, the driver registers the device as a SCSI host interface. The SCSI code then takes over and won't let the module be unloaded as long as there are any references to a drive on that interface (drive mounted or raw device file open). But if you unmount your USB drive, then you can go right ahead and unload the module. > > Depending on the usage model the driver follows, this might not be true. > > For instance, one commonly recommended theme is for the driver to > > increment its module-use-count each time it submits an urb and decrement > > the count in the completion routine. When this approach is used, the > > kernel won't allow the module to be unloaded until there are no active > > urbs. > > I thought MOD_INC_USE_COUNT had gone away in 2.5, but perhaps it > still exists under another name. I wish someone would explain how modules are supposed to work in 2.5. (And I wish that they actually did work! The few times I have tried loading a module under 2.5 it crashed my system deader than a smelt.) > Still, shouldn't the USB subsystem be doing > this for you in 2.5? Probably not. The USB core doesn't know enough about how your driver works to try managing it at that level. It doesn't even know whether your driver is a module or is compiled into the kernel. > > If a driver was written to work this way, that would indeed be sad. I > > guess the best advice is: Don't write your drivers like that! > > Sure. In 2.4 it is clear that you should be using MOD_INC_USE_COUNT. > But in 2.5 that way of doing things seems to be deprecated. So what provides an equivalent functionality? Anybody? Alan Stern ------------------------------------------------------- This SF.NET email is sponsored by: SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! http://www.vasoftware.com _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
