Quote:
What is the correct way to block (wait for input) in a device?

The interrupt routine increments "samples_collected", but the driver needs to wait until 256 samples have been collected.

Is there some sort of kernel mutex I set in the interrupt routine and wait on in the driver?



There are other ways, but one of the simplest is to use a semaphore:

Code:


struct semaphore mysem = MUTEX_LOCKED;

...

// Interrupt handler:

if (++count == desired_number)
up(&mysem); /* signal that data is available */

...

// mainline driver's read() or ioctl() routines:
...
down(&mysem); /* wait for data */
...



Note that these are "counting" semaphores, so you could even get clever with them if you want, but the simple form above will work.

Cheers