Putting artificial delays in a char driver
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Thu May 19 07:30:33 EDT 2011
Hi All,
I was fiddling around with an IR remote driver for my embedded
platform to see if I can make the IR LED light (connected to GPIO's)
blink on IR activity.
The IR driver behaves like a char driver. The way to make the LED
on/off is to simply write to some GPIO reg with a 1/0. So I was
switching on the LED at the beginning of the function that reads data
(in ISR context) and then switching it off at the end of that
function.
The problem was that all this happens too fats and I'm barely able to
see the LED blink (there's only a faint flicker)! :)
I tired various places in the driver to keep on/off calls as "far" as
possible (ON in ISR and then OFF _after_ a copy_to_user()), but that
did not help much.
Whats the recommended way of solving this issue? I'm working on
drivers after a really long time (last time I worked on a driver was
when LDD 2nd ed was published!) so I'm not sure if bottom-halves or
work-queues should be used.
I was thinking what if I introduce an artificial delay in my driver
where I "sleep/wait" for a few millsecs after switching on the LED and
then switch it off after the incoming data has been processed. Is that
a good idea?
TIA,
-mandeep
More information about the Kernelnewbies
mailing list