Newbie: advice on general driver design
- From: "[rob desbois]" <rob.desbois@xxxxxxxxx>
- Date: Fri, 28 Mar 2008 10:10:09 -0700 (PDT)
I'm new to device drivers and LKMs, but have spent a couple of weeks
with the Linux Device Drivers (3rd edition - kernel 2.6) book.
I've successfully written an LKM for a board proprietary to my company
- I now have a /dev entry which I can cat a firmware file into to
program a particular volatile chip controlled via some of the CPU's
Programmable I/O lines. (I know there's a request_firmware API for
this, forget that for the moment :-D)
There are several other board-specific devices controlled/read through
the PIO pins including front-panel LEDs, push buttons, and a dry
relay.
What is the 'best' way to (or how would you) design a driver for this?
My current feeling is to continue with what I have for the chip
programming - it's not going to change, and will only be programmed by
a startup script.
The other functions do not involve transfer of data, but are more like
command-type functions. I will implement a set of ioctl() commands (or
look at sysfs for this) to do the following:
SET_LED const u32* led /* turn on LED */
CLEAR_LED const u32* led /* turn off LED */
SET_RELAY const u8* nc /* set relay to (nc? normally-closed :
normally-open) */
GET_BUTTON const u32* button, u8* down /* down = true if button is
down */
Any comments on this design? I hope this is a decent question, I found
a lot of info about how to program drivers / LKMs but not a lot on how
to design them. Pointers to good documents in that area would also be
welcomed.
TIA,
--rob
.
- Follow-Ups:
- Re: Newbie: advice on general driver design
- From: Rainer Weikusat
- Re: Newbie: advice on general driver design
- Prev by Date: determine cpu count from module.ko
- Next by Date: Re: Newbie: advice on general driver design
- Previous by thread: determine cpu count from module.ko
- Next by thread: Re: Newbie: advice on general driver design
- Index(es):