Discussion:
Passing argument to USB Storage driver
Kevin Lloyd
2008-01-08 17:10:41 UTC
Permalink
Hi all,

I am writing an init function for a device in the unusual_devs.h file
and I was wondering if there is any standard way to pass an argument
to it (much like can be done with the 'modprobe _driver_
_parameters_', however I don't want to declare a parameter in the main
usb-storage driver that is only used for my driver should it be
loaded).

An acceptable solution would be to have the driver read settings from
the file-system. Is there a standardized way to do this (and location
for the files)?

Thanks,
-Kevin

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Oliver Neukum
2008-01-08 17:43:08 UTC
Permalink
Post by Kevin Lloyd
An acceptable solution would be to have the driver read settings from
the file-system. Is there a standardized way to do this (and location
for the files)?
This is not an acceptable solution. Before you commit such a layering
violation, use a module parameter.

Regards
Oliver


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Kevin Lloyd
2008-01-08 18:00:16 UTC
Permalink
Post by Oliver Neukum
Post by Kevin Lloyd
An acceptable solution would be to have the driver read settings from
the file-system. Is there a standardized way to do this (and location
for the files)?
This is not an acceptable solution. Before you commit such a layering
violation, use a module parameter.
Regards
Oliver
So my only option is to create a new module_param in the usb-storage
usb.c driver? Even if I #ifdef it it seems like little messy of a
solution, are there any other suggestions?

WRT to the other solution you suggested against (file-system based), I
know this is likely a dumb question, but is there not a way for
drivers to read user space controlled settings (something analogous to
the Windows registry)?

Thanks,
-Kevin

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Oliver Neukum
2008-01-08 18:08:13 UTC
Permalink
Post by Kevin Lloyd
Post by Oliver Neukum
Post by Kevin Lloyd
An acceptable solution would be to have the driver read settings from
the file-system. Is there a standardized way to do this (and location
for the files)?
This is not an acceptable solution. Before you commit such a layering
violation, use a module parameter.
Regards
Oliver
So my only option is to create a new module_param in the usb-storage
Yes.
Post by Kevin Lloyd
usb.c driver? Even if I #ifdef it it seems like little messy of a
solution, are there any other suggestions?
No.
Post by Kevin Lloyd
WRT to the other solution you suggested against (file-system based), I
know this is likely a dumb question, but is there not a way for
drivers to read user space controlled settings (something analogous to
the Windows registry)?
There is no such thing. Reading a file from a driver is anathema.

Regards
Oliver


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Alan Stern
2008-01-08 18:49:45 UTC
Permalink
Post by Kevin Lloyd
So my only option is to create a new module_param in the usb-storage
usb.c driver? Even if I #ifdef it it seems like little messy of a
solution, are there any other suggestions?
The module parameter doesn't have to live in usb.c. It can belong to
any source file in usb-storage.
Post by Kevin Lloyd
WRT to the other solution you suggested against (file-system based), I
know this is likely a dumb question, but is there not a way for
drivers to read user space controlled settings (something analogous to
the Windows registry)?
You can create attribute files in sysfs. For example, see the
definition of the max_sectors attribute in scsiglue.c.

Alan Stern


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Alex Villací­s Lasso
2008-01-08 19:27:33 UTC
Permalink
Post by Kevin Lloyd
Hi all,
I am writing an init function for a device in the unusual_devs.h file
and I was wondering if there is any standard way to pass an argument
to it (much like can be done with the 'modprobe _driver_
_parameters_', however I don't want to declare a parameter in the main
usb-storage driver that is only used for my driver should it be
loaded).
Maybe there is some confusion on where the driver code and module
parameters should go, and the purpose of unusual_devs.h, that leads to
this unusually-worded question.

First of all, could you please explain what kind of device are you
trying to use (if possible, with device/vendor IDs)? Is it a
mass-storage device (such as an external disk/DVD/flash memory), or is
it something else? If it is, then why do you need a parameter to
unusual_devs.h ? What kind of behavior do you need to control from
userspace? Why is none of the existing quirks useful for your device?
Maybe what you want is to add a new quirk flag, and there is nothing
wrong AFAIK with adding code to handle that particular flag.

If, on the other hand, your device is not a mass-storage device, then
nothing you do to unusual_devs.h might be useful. That file is only
relevant for mass-storage devices.

A quick description of your environment (target kernel version,
distribution, etc) won't go amiss.
--
perl -e '$x=2.4;print sprintf("%.0f + %.0f = %.0f\n",$x,$x,$x+$x);'


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Kevin Lloyd
2008-01-08 20:28:35 UTC
Permalink
On Jan 8, 2008 11:27 AM, Alex Villací­s Lasso
Post by Alex Villací­s Lasso
First of all, could you please explain what kind of device are you
trying to use (if possible, with device/vendor IDs)? Is it a
mass-storage device (such as an external disk/DVD/flash memory), or is
it something else? If it is, then why do you need a parameter to
unusual_devs.h ? What kind of behavior do you need to control from
userspace? Why is none of the existing quirks useful for your device?
Maybe what you want is to add a new quirk flag, and there is nothing
wrong AFAIK with adding code to handle that particular flag.
The device is an emulated external CD-Rom. The reason I'd like to have a
parameter or some other user-space input is so that the user can enable/
disable a feature in the driver without having to re-compile the driver.

Also, later on in the future it would be nice for the driver to access more
information on the system regarding device configuration (ideally
all aggregated in one file) which would then dictate how the driver loads the
device. I suppose one way to do this would be to create a user space
daemon that watches the usb devices and controls it via libusb.
Post by Alex Villací­s Lasso
A quick description of your environment (target kernel version,
distribution, etc) won't go amiss.
For now just targeting 2.6.23 or 24 with x86 and either Fedora 8 or Ubuntu 7.10

-Kevin
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://list
Kevin Lloyd
2008-01-08 22:48:20 UTC
Permalink
Post by Kevin Lloyd
The device is an emulated external CD-Rom. The reason I'd like to have a
parameter or some other user-space input is so that the user can enable/
disable a feature in the driver without having to re-compile the driver.
What sort of feature are you talking about?
The emulated external CD-Rom is part of an automatic install feature
and it will not always behave the same way upon start-up. The way this
feature has been designed is that it is controlled via USB vendor
specific control messages from the driver. Ideally the settings that
dictate how the driver acts are editable from user-space (preferably
non-volatile) and do not require re-compilation of the driver.

-Kevin

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Matthew Dharm
2008-01-09 15:20:19 UTC
Permalink
Post by Kevin Lloyd
Post by Kevin Lloyd
The device is an emulated external CD-Rom. The reason I'd like to have a
parameter or some other user-space input is so that the user can enable/
disable a feature in the driver without having to re-compile the driver.
What sort of feature are you talking about?
The emulated external CD-Rom is part of an automatic install feature
and it will not always behave the same way upon start-up. The way this
feature has been designed is that it is controlled via USB vendor
specific control messages from the driver. Ideally the settings that
dictate how the driver acts are editable from user-space (preferably
non-volatile) and do not require re-compilation of the driver.
Why not use libusb from userspace to send these control messages? Why mess
with the driver at all?

Do these control messages look anything like SCSI commands? Or are they
real "control endpoint" messages?

Matt
--
Matthew Dharm Home: mdharm-***@one-eyed-alien.net
Maintainer, Linux USB Mass Storage Driver

Somebody call an exorcist!
-- Dust Puppy
User Friendly, 5/16/1998
Kevin Lloyd
2008-01-09 16:12:07 UTC
Permalink
Post by Matthew Dharm
Why not use libusb from userspace to send these control messages? Why mess
with the driver at all?
It certainly is a possibility, it would be nice to have all of the
device control related
code in one location (i.e. in the driver). It also seems like over
kill to have a dedicated
process just to do this.
Does anyone know if there is a way to configure the system so that a particular
executable is run upon detection of a specific device (VID/PID)?
Post by Matthew Dharm
Do these control messages look anything like SCSI commands? Or are they
real "control endpoint" messages?
They are real control endpoint messages (which I understand would
still be able to
send via libusb).

Thanks,
-Kevin

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
linux-usb-***@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Matthew Dharm
2008-01-09 18:59:54 UTC
Permalink
Post by Kevin Lloyd
Post by Matthew Dharm
Why not use libusb from userspace to send these control messages? Why mess
with the driver at all?
It certainly is a possibility, it would be nice to have all of the
device control related
code in one location (i.e. in the driver). It also seems like over
kill to have a dedicated
process just to do this.
Does anyone know if there is a way to configure the system so that a particular
executable is run upon detection of a specific device (VID/PID)?
Look up udev -- it's designed for exactly such a scenario.
Post by Kevin Lloyd
Post by Matthew Dharm
Do these control messages look anything like SCSI commands? Or are they
real "control endpoint" messages?
They are real control endpoint messages (which I understand would
still be able to
send via libusb).
Yes, you can. If they happened to look like SCSI commands, you could have
also sent them via the SG_IO interface.

Matt
--
Matthew Dharm Home: mdharm-***@one-eyed-alien.net
Maintainer, Linux USB Mass Storage Driver

Pitr! That's brilliant! Funded by Microsoft refunds. What sweet irony!
-- A.J.
User Friendly, 2/15/1999
Matthew Dharm
2008-01-08 21:28:34 UTC
Permalink
Post by Kevin Lloyd
On Jan 8, 2008 11:27 AM, Alex Villací­s Lasso
Post by Alex Villací­s Lasso
First of all, could you please explain what kind of device are you
trying to use (if possible, with device/vendor IDs)? Is it a
mass-storage device (such as an external disk/DVD/flash memory), or is
it something else? If it is, then why do you need a parameter to
unusual_devs.h ? What kind of behavior do you need to control from
userspace? Why is none of the existing quirks useful for your device?
Maybe what you want is to add a new quirk flag, and there is nothing
wrong AFAIK with adding code to handle that particular flag.
The device is an emulated external CD-Rom. The reason I'd like to have a
parameter or some other user-space input is so that the user can enable/
disable a feature in the driver without having to re-compile the driver.
What sort of feature are you talking about?

Matt
--
Matthew Dharm Home: mdharm-***@one-eyed-alien.net
Maintainer, Linux USB Mass Storage Driver

I want my GPFs!!!
-- Stef
User Friendly, 11/9/1998
Loading...