public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: akpm@osdl.org, petero2@telia.com, linux-kernel@vger.kernel.org
Subject: [PATCH 3/6] Add black list to handler<->device matching
Date: Tue, 30 Sep 2003 01:15:55 -0500	[thread overview]
Message-ID: <200309300114.57761.dtor_core@ameritech.net> (raw)
In-Reply-To: <200309300112.50076.dtor_core@ameritech.net>

Input: Introduce an optional blacklist field in input_handler structure.
       When loading a new device or a new handler try to match device
       against handler's black list before doing match on required 
       attributes.
       This allows to get rid of "surprises" in connect functions, IMO
       connect should only fail when it physically can not connect, not
       because it decides it does not like device.


 drivers/input/input.c  |   14 ++++++++------
 drivers/input/joydev.c |   14 ++++++++++----
 include/linux/input.h  |    1 +
 3 files changed, 19 insertions(+), 10 deletions(-)

===================================================================

diff -Nru a/drivers/input/input.c b/drivers/input/input.c
--- a/drivers/input/input.c	Tue Sep 30 01:13:54 2003
+++ b/drivers/input/input.c	Tue Sep 30 01:13:54 2003
@@ -447,9 +447,10 @@
 	list_add_tail(&dev->node, &input_dev_list);
 
 	list_for_each_entry(handler, &input_handler_list, node)
-		if ((id = input_match_device(handler->id_table, dev)))
-			if ((handle = handler->connect(handler, dev, id)))
-				input_link_handle(handle);
+		if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
+			if ((id = input_match_device(handler->id_table, dev)))
+				if ((handle = handler->connect(handler, dev, id)))
+					input_link_handle(handle);
 
 #ifdef CONFIG_HOTPLUG
 	input_call_hotplug("add", dev);
@@ -507,9 +508,10 @@
 	list_add_tail(&handler->node, &input_handler_list);
 	
 	list_for_each_entry(dev, &input_dev_list, node)
-		if ((id = input_match_device(handler->id_table, dev)))
-			if ((handle = handler->connect(handler, dev, id)))
-				input_link_handle(handle);
+		if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
+			if ((id = input_match_device(handler->id_table, dev)))
+				if ((handle = handler->connect(handler, dev, id)))
+					input_link_handle(handle);
 
 #ifdef CONFIG_PROC_FS
 	input_devices_state++;
diff -Nru a/drivers/input/joydev.c b/drivers/input/joydev.c
--- a/drivers/input/joydev.c	Tue Sep 30 01:13:54 2003
+++ b/drivers/input/joydev.c	Tue Sep 30 01:13:54 2003
@@ -380,10 +380,6 @@
 	struct joydev *joydev;
 	int i, j, t, minor;
 
-	/* Avoid tablets */
-        if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit))
-		return NULL;
-
 	for (minor = 0; minor < JOYDEV_MINORS && joydev_table[minor]; minor++);
 	if (minor == JOYDEV_MINORS) {
 		printk(KERN_ERR "joydev: no more free joydev devices\n");
@@ -464,6 +460,15 @@
 		joydev_free(joydev);
 }
 
+static struct input_device_id joydev_blacklist[] = {
+	{
+		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT,
+		.evbit = { BIT(EV_KEY) },
+		.keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
+	}, 	/* Avoid itouchpads, touchscreens and tablets */
+	{ }, 	/* Terminating entry */
+};
+
 static struct input_device_id joydev_ids[] = {
 	{
 		.flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
@@ -493,6 +498,7 @@
 	.minor =	JOYDEV_MINOR_BASE,
 	.name =		"joydev",
 	.id_table =	joydev_ids,
+	.blacklist = 	joydev_blacklist,
 };
 
 static int __init joydev_init(void)
diff -Nru a/include/linux/input.h b/include/linux/input.h
--- a/include/linux/input.h	Tue Sep 30 01:13:54 2003
+++ b/include/linux/input.h	Tue Sep 30 01:13:54 2003
@@ -870,6 +870,7 @@
 	char *name;
 
 	struct input_device_id *id_table;
+	struct input_device_id *blacklist;
 
 	struct list_head	h_list;
 	struct list_head	node;


  reply	other threads:[~2003-09-30  6:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-30  6:24 2.6: New set of input patches Dmitry Torokhov
2003-09-30  6:06 ` [PATCH 1/6] serio: rename serio_[un]register_slave_port to __serio_[un]register_port Dmitry Torokhov
2003-09-30  6:15   ` [PATCH 2/6] serio: possible race between port removal and kseriod Dmitry Torokhov
2003-09-30  6:15     ` Dmitry Torokhov [this message]
2003-09-30  6:20       ` [PATCH 4/6] Synaptics: code cleanup Dmitry Torokhov
2003-09-30  6:23         ` [PATCH 5/6] serio: reconnect facility Dmitry Torokhov
2003-09-30  6:27           ` [PATCH 6/6] Synaptics: use serio_reconnect Dmitry Torokhov

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=200309300114.57761.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petero2@telia.com \
    --cc=vojtech@suse.cz \
    /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