From patchwork Mon Feb 21 14:18:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Gatliff X-Patchwork-Id: 577651 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1LEHOlh022770 for ; Mon, 21 Feb 2011 14:17:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751686Ab1BUORY (ORCPT ); Mon, 21 Feb 2011 09:17:24 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:46357 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266Ab1BUORX (ORCPT ); Mon, 21 Feb 2011 09:17:23 -0500 Received: by iwn8 with SMTP id 8so1930906iwn.19 for ; Mon, 21 Feb 2011 06:17:23 -0800 (PST) Received: by 10.42.229.199 with SMTP id jj7mr1983255icb.510.1298297843032; Mon, 21 Feb 2011 06:17:23 -0800 (PST) Received: from mercury.billgatliff.com (adsl-75-23-113-209.dsl.peoril.sbcglobal.net [75.23.113.209]) by mx.google.com with ESMTPS id w5sm4292622icf.4.2011.02.21.06.17.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 Feb 2011 06:17:21 -0800 (PST) Received: from bgat by mercury.billgatliff.com with local (Exim 4.72) (envelope-from ) id 1PrWbH-000122-Tf; Mon, 21 Feb 2011 08:18:56 -0600 From: Bill Gatliff To: linux-input@vger.kernel.org Cc: Bill Gatliff Subject: [PATCH] input: evdev: Add a read() callback Date: Mon, 21 Feb 2011 08:18:50 -0600 Message-Id: <1298297930-3937-1-git-send-email-bgat@billgatliff.com> X-Mailer: git-send-email 1.7.2.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 21 Feb 2011 14:17:25 +0000 (UTC) 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);