* getting configuration info into a driver at load-time
@ 2008-10-27 23:07 Sebastian Kuzminsky
2008-10-28 9:21 ` Alan Cox
2008-10-28 22:14 ` Kay Sievers
0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Kuzminsky @ 2008-10-27 23:07 UTC (permalink / raw)
To: linux-kernel
Hi folks, i'm looking for a way to pass structured configuration
information to a device driver at load-time.
I'm working on a device driver for a family of FPGA cards for motion
control of industrial robots and computer-controlled machine tools. The
driver loads the FPGA firmware with request_firmware() and sends it to
the FPGA.
Once the FPGA is up and running, the user needs to configure the
firmware specifically for their machine, by telling the firmware things
like "my machine has two stepper motors and three servo motors, and the
second servo motor has an encoder with an index channel". The details
of the information being relayed isnt important, the key thing is that
it's like a struct containing a couple of arrays of different kinds
structs, something like this:
struct config {
struct {
bool enabled;
bool index_enabled;
bool index_mask_enabled;
} encoder_config[];
struct {
bool enabled;
} pwmgen_config[];
struct {
bool enabled;
uint width;
} stepgen_config[];
char *firmware;
bool enable_raw;
} board_config;
Each board that the driver finds should get its own "board_config".
I thought about exposing this config structure in /sys or /proc (in a
per-board directory), and let the user poke in the config values after
the driver has loaded, but I'd really prefer to make the information
available at load-time.
Currently the driver has a module param array of char*, with each
board's configuration encoded into an ascii string which gets decoded
"by hand" in the driver. Pretty grotty.
Is there some easier/cleaner way to do this?
--
Sebastian Kuzminsky
what i like best about 12648430 is the coffee
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: getting configuration info into a driver at load-time
2008-10-27 23:07 getting configuration info into a driver at load-time Sebastian Kuzminsky
@ 2008-10-28 9:21 ` Alan Cox
2008-10-28 22:14 ` Kay Sievers
1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2008-10-28 9:21 UTC (permalink / raw)
To: Sebastian Kuzminsky; +Cc: linux-kernel
> I thought about exposing this config structure in /sys or /proc (in a
> per-board directory), and let the user poke in the config values after
> the driver has loaded, but I'd really prefer to make the information
> available at load-time.
Various drivers do load it after load time (and for one that allows you
to change the configuration without a restart which is usually a good
thing). In some cases driver that need a configuration to do sane things
fails other I/O with an error like EIO until a configuration is
established via ioctl or sysfs or similar.
> Currently the driver has a module param array of char*, with each
> board's configuration encoded into an ascii string which gets decoded
> "by hand" in the driver. Pretty grotty.
>
> Is there some easier/cleaner way to do this?
You can always request_firmware() the tables... bit hackish but works
Alan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: getting configuration info into a driver at load-time
2008-10-27 23:07 getting configuration info into a driver at load-time Sebastian Kuzminsky
2008-10-28 9:21 ` Alan Cox
@ 2008-10-28 22:14 ` Kay Sievers
1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2008-10-28 22:14 UTC (permalink / raw)
To: Sebastian Kuzminsky; +Cc: linux-kernel
On Tue, Oct 28, 2008 at 00:07, Sebastian Kuzminsky <seb@highlab.com> wrote:
> Hi folks, i'm looking for a way to pass structured configuration information
> to a device driver at load-time.
>
> I'm working on a device driver for a family of FPGA cards for motion control
> of industrial robots and computer-controlled machine tools. The driver
> loads the FPGA firmware with request_firmware() and sends it to the FPGA.
>
> Once the FPGA is up and running, the user needs to configure the firmware
> specifically for their machine, by telling the firmware things like "my
> machine has two stepper motors and three servo motors, and the second servo
> motor has an encoder with an index channel". The details of the information
> being relayed isnt important, the key thing is that it's like a struct
> containing a couple of arrays of different kinds structs, something like
> this:
>
> struct config {
>
> struct {
> bool enabled;
> bool index_enabled;
> bool index_mask_enabled;
> } encoder_config[];
>
> struct {
> bool enabled;
> } pwmgen_config[];
>
> struct {
> bool enabled;
> uint width;
> } stepgen_config[];
>
> char *firmware;
>
> bool enable_raw;
>
> } board_config;
>
>
> Each board that the driver finds should get its own "board_config".
>
> I thought about exposing this config structure in /sys or /proc (in a
> per-board directory), and let the user poke in the config values after the
> driver has loaded, but I'd really prefer to make the information available
> at load-time.
>
> Currently the driver has a module param array of char*, with each board's
> configuration encoded into an ascii string which gets decoded "by hand" in
> the driver. Pretty grotty.
>
> Is there some easier/cleaner way to do this?
Maybe configfs?
Kay
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-28 22:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-27 23:07 getting configuration info into a driver at load-time Sebastian Kuzminsky
2008-10-28 9:21 ` Alan Cox
2008-10-28 22:14 ` Kay Sievers
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).