mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* HELP PLEASE: i2c in interrupt?
@ 2003-09-17 18:11 Abraham vd Merwe
  2003-09-17 18:45 ` Richard B. Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: Abraham vd Merwe @ 2003-09-17 18:11 UTC (permalink / raw)
  To: Linux Kernel Discussions

Hi!

I'm working on a keypad driver which is sitting on an I/O expander on an I2C
bus. Whenever a key is pressed, the I2C chip (the I/O expander) generates an
interrupt and then I have to read the events from the I2C chip.

The problem is

 (a) This operation is time critical. If I don't read the data from the I2C
     chip very fast (after the interrupt occurred) the events get lost

 (b) I2C is done in hardware which means a read goes like this: START
     WRITE_DATA wait_for_interrupt ... STOP.

The important part here is the wait_for_interrupt. That means i2c_transfer()
will wait on a wait queue which I can't do from an interupt so I created a
task to do this for me and from the keypad interrupt routine, I do 

        queue_task (&keypad.task,&tq_immediate);
        mark_bh (IMMEDIATE_BH);

However that triggers a BUG

------------< snip <------< snip <------< snip <------------
Scheduling in interrupt
kernel BUG at sched.c:566!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
------------< snip <------< snip <------< snip <------------

so it is obviously illegal to do that from an interrupt. So my question is,
how do I execute a function which will sleep _very_soon_ after an interrupt
occurs (i.e. what I don't want to do is interrupt -> poll wakes up ->
process does read -> i2c_transfer() - that's too long)

-- 

Regards
 Abraham

You will not be elected to public office this year.

___________________________________________________
 Abraham vd Merwe - Frogfoot Networks CC
 9 Kinnaird Court, 33 Main Street, Newlands, 7700
 Phone: +27 21 686 1665 Cell: +27 82 565 4451
 Http: http://www.frogfoot.net/ Email: abz@frogfoot.net


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-17 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-17 18:11 HELP PLEASE: i2c in interrupt? Abraham vd Merwe
2003-09-17 18:45 ` Richard B. Johnson
2003-09-17 19:15   ` Abraham van der Merwe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®