diff mbox

input: evdev: Add a read() callback

Message ID 1298297930-3937-1-git-send-email-bgat@billgatliff.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bill Gatliff Feb. 21, 2011, 2:18 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index c8471a2..b49b601 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -370,12 +370,19 @@  static ssize_t evdev_read(struct file *file, char __user *buffer,
 {
 	struct evdev_client *client = file->private_data;
 	struct evdev *evdev = client->evdev;
+	struct input_dev *dev = evdev->handle.dev;
 	struct input_event event;
 	int retval;
 
 	if (count < input_event_size())
 		return -EINVAL;
 
+	if (client->head == client->tail && dev->read) {
+		retval = dev->read(dev);
+		if (retval)
+			return retval;
+	}
+
 	if (client->head == client->tail && evdev->exist &&
 	    (file->f_flags & O_NONBLOCK))
 		return -EAGAIN;
@@ -407,6 +414,9 @@  static unsigned int evdev_poll(struct file *file, poll_table *wait)
 	struct evdev *evdev = client->evdev;
 	unsigned int mask;
 
+	if (client->head == client->tail && dev->read)
+		dev->read(dev);
+
 	poll_wait(file, &evdev->wait, wait);
 
 	mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR;
diff --git a/include/linux/input.h b/include/linux/input.h
index e428382..eac7f77 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -1264,6 +1264,7 @@  struct input_dev {
 
 	int (*open)(struct input_dev *dev);
 	void (*close)(struct input_dev *dev);
+	int (*read)(struct input_dev *dev);
 	int (*flush)(struct input_dev *dev, struct file *file);
 	int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);