All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: add flags bitfield
@ 2008-03-16 20:14 Henrique de Moraes Holschuh
  2008-03-21 20:07 ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Henrique de Moraes Holschuh @ 2008-03-16 20:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Henrique de Moraes Holschuh, Dmitry Torokhov, Richard Purdie

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-03-24  3:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-16 20:14 [PATCH] Input: add flags bitfield Henrique de Moraes Holschuh
2008-03-21 20:07 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.