sysfs and configuration of a driver

Chase Douglas
2005-07-12T21:03:05Z

I'm trying to update the ati_remote module so that it is configurable
without having to change the source and recompile. I'm rather new to
kernel module development and was wondering how I should go about
creating an interface for configuration. My current implementation
creates a device node for configuration. When you read from it, it dumps
key bindings for the remote. When you write to it, you can change the
key bindings like this:

echo "play KIND_FILTERED 207" > /dev/ati_remote

Which would change the play button on the remote to send the KEY_PLAY
(207 in linux/input.h) button instead of what was previously configured.
This works alright, but it seems to me that this should be handled in
sysfs. I was thinking that since hardly anyone would have more than one
remote, there should be one interface that would configure any remote
that is plugged into the computer. It should be permanent in my opinion
so I thought it should go somewhere in /sys/module/ati_remote/.

Would this be a good way of configuring the remote? If it is, how can I
create a sysfs file in the module directory and not the actual usb
device directory?

If this isn't a good way, how should it be done?

Also, how could a permanent configuration be achieved so that if you
reboot the computer or re-modprobe the driver, your previous mappings
are still intact?

Thank you

P.S.: Please CC me to your responses