The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: linux-kernel@vger.kernel.org
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Dmitry Torokhov <dtor@mail.ru>,
	Richard Purdie <rpurdie@rpsys.net>
Subject: [PATCH] Input: add flags bitfield
Date: Sun, 16 Mar 2008 17:14:11 -0300	[thread overview]
Message-ID: <1205698451-1640-1-git-send-email-hmh@hmh.eng.br> (raw)

Add a flags bitfield to the input_dev structure, which can be used for
internal coordination among kernel input devices and input handlers without
the need to use ever-expanding blacklists on the input handlers.

Add initial flag bits which allows an input driver to request that joystick
emulation (joydev) or mouse emulation (mousedev) not be attached to an
input device.

This will be used by accelerometer drivers exporting a raw interface which
is not to be used as a joystick device (not to confuse this with the usual
fuzzed joystick interface these drivers export for enhanced Neverball
productivity), for example.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Richard Purdie <rpurdie@rpsys.net>
---
 drivers/input/joydev.c   |    3 +++
 drivers/input/mousedev.c |    3 +++
 include/linux/input.h    |   10 ++++++++++
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 22b2789..3837389 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -727,6 +727,9 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
 	int i, j, t, minor;
 	int error;
 
+	if (dev->flags & EV_F_NOJOYSTICK)
+		return -ENODEV;
+
 	for (minor = 0; minor < JOYDEV_MINORS; minor++)
 		if (!joydev_table[minor])
 			break;
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index bbbe5e8..716975f 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -962,6 +962,9 @@ static int mousedev_connect(struct input_handler *handler,
 	int minor;
 	int error;
 
+	if (dev->flags & EV_F_NOMOUSE)
+		return -ENODEV;
+
 	for (minor = 0; minor < MOUSEDEV_MINORS; minor++)
 		if (!mousedev_table[minor])
 			break;
diff --git a/include/linux/input.h b/include/linux/input.h
index 1bdc39a..a5654fe 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -951,12 +951,20 @@ struct ff_effect {
 #include <linux/timer.h>
 #include <linux/mod_devicetable.h>
 
+/*
+ * input device special flags
+ */
+
+#define EV_F_NOMOUSE		0x0001	/* Do not attach mousedev */
+#define EV_F_NOJOYSTICK		0x0002	/* Do not attach joydev */
+
 /**
  * struct input_dev - represents an input device
  * @name: name of the device
  * @phys: physical path to the device in the system hierarchy
  * @uniq: unique identification code for the device (if device has it)
  * @id: id of the device (struct input_id)
+ * @flags: bitmap of special flags (EV_F_*)
  * @evbit: bitmap of types of events supported by the device (EV_KEY,
  *	EV_REL, etc.)
  * @keybit: bitmap of keys/buttons this device has
@@ -1034,6 +1042,8 @@ struct input_dev {
 	const char *uniq;
 	struct input_id id;
 
+	unsigned long flags;
+
 	unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
 	unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
 	unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
-- 
1.5.4.4


             reply	other threads:[~2008-03-16 20:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-16 20:14 Henrique de Moraes Holschuh [this message]
2008-03-21 20:07 ` [PATCH] Input: add flags bitfield Dmitry Torokhov
2008-03-21 21:56   ` Henrique de Moraes Holschuh
2008-03-22  7:09     ` Henrique de Moraes Holschuh
2008-03-24  1:02       ` Dmitry Torokhov
2008-03-24  3:25         ` Henrique de Moraes Holschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1205698451-1640-1-git-send-email-hmh@hmh.eng.br \
    --to=hmh@hmh.eng.br \
    --cc=dtor@mail.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox