/* This function is called when a user space program attempts to read /dev/nwbutton. It puts the device to sleep on the wait queue until button_sequence_finished writes some data to the buffer and flushes the queue, at which point it writes the data out to the device and returns the number of characters it has written. This function is reentrant, so that many processes can be attempting to read from the device at any one time.  */
static int button_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
/* This function is called when a user space program attempts to read /dev/nwbutton. It puts the device to sleep on the wait queue until button_sequence_finished writes some data to the buffer and flushes the queue, at which point it writes the data out to the device and returns the number of characters it has written. This function is reentrant, so that many processes can be attempting to read from the device at any one time.  */
static int button_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
{
	interruptible_sleep_on (&button_wait_queue);
	return (copy_to_user (buffer, &button_output_buffer, bcount))
		 ? -EFAULT : bcount;
}