Skip to contentSkip to conversation

Input: support the specified input device number

RFC PATCH In review Joonyoung Shim 3 participants 4 messages Oct 8, 2009 – Oct 13, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Input: support the specified input device number

Currently, the input device number is decided by order of driver probe. But we need the specified input device number regardless of order of driver probe because the platform or the middleware tends to access using fixed device node of the input devices.

This patch supports to use the specified input device number when the input device is registered. If the input device number bigger than zero is registered before by other input device, returns error.

---
 drivers/input/evdev.c |   12 ++++--------
 drivers/input/input.c |   41 ++++++++++++++++++++++++++++++++++++++---
 include/linux/input.h |    2 ++
 3 files changed, 44 insertions(+), 11 deletions(-)
drivers/input/evdev.c +4 -8
index 1148140..91ee7a0 100644
@@ -791,16 +791,12 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
 			 const struct input_device_id *id)
 {
 	struct evdev *evdev;
-	int minor;
+	int minor = dev->input_no;
 	int error;
 
-	for (minor = 0; minor < EVDEV_MINORS; minor++)
-		if (!evdev_table[minor])
-			break;
-
-	if (minor == EVDEV_MINORS) {
-		printk(KERN_ERR "evdev: no more free evdev devices\n");
-		return -ENFILE;
+	if (minor >= EVDEV_MINORS) {
+		printk(KERN_ERR "evdev: invalid evdev device number\n");
+		return -EINVAL;
 	}
 
 	evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL);
drivers/input/input.c +38 -3

71 lines not on this page · raw message

include/linux/input.h +2 -0
index 0ccfc30..6145fb7 100644
@@ -1002,6 +1002,7 @@ struct ff_effect {
  * @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)
+ * @input_no: number of the input device
  * @evbit: bitmap of types of events supported by the device (EV_KEY,
  *	EV_REL, etc.)
  * @keybit: bitmap of keys/buttons this device has
@@ -1074,6 +1075,7 @@ struct input_dev {
 	const char *phys;
 	const char *uniq;
 	struct input_id id;
+	int input_no;
 
 	unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
 	unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
Signature · 1 line
1.6.0.4
maintainer
#1 lore raw

Hi Joonyoung,

Quoted 9 lines · Joonyoung Shim

Currently, the input device number is decided by order of driver probe. But we need the specified input device number regardless of order of driver probe because the platform or the middleware tends to access using fixed device node of the input devices.

This patch supports to use the specified input device number when the input device is registered. If the input device number bigger than zero is registered before by other input device, returns error.

No, I don't think this is a good solution. You can have persistent device nodes without hadrcoding it into the driver. See how UDEV creates 'by-id' and 'by-path' links.

Signature · 1 line
Dmitry
#2 lore raw

Hi,

Quoted 8 lines · Dmitry Torokhov

Hi Joonyoung,

Quoted 5 lines · Joonyoung Shim

Currently, the input device number is decided by order of driver probe. But we need the specified input device number regardless of order of driver probe because the platform or the middleware tends to access using fixed device node of the input devices.

Quoted 9 lines
Quoted 4 lines

This patch supports to use the specified input device number when the input device is registered. If the input device number bigger than zero is registered before by other input device, returns error.

No, I don't think this is a good solution. You can have persistent device nodes without hadrcoding it into the driver. See how UDEV creates 'by-id' and 'by-path' links.

Please let me know how to use udev at input device.

At our system,
input0: h/w keypad
input1: gpio key
input2: touchscreen
input3: jack or others

but in previous system, we always set the touchscreen as input1. Right we can modify it but it's not easy.
With this patch we always set touchscreen as input1.

How can we do this?

FYI: when launch the X, we set the tsdevice as input1 and keyboard as input0.

Thank you,
Kyungmin Park

maintainer
#3 lore raw
Quoted 30 lines · Kyungmin Park

Hi,

Quoted 8 lines · Dmitry Torokhov

Hi Joonyoung,

Quoted 5 lines · Joonyoung Shim

Currently, the input device number is decided by order of driver probe. But we need the specified input device number regardless of order of driver probe because the platform or the middleware tends to access using fixed device node of the input devices.

Quoted 9 lines
Quoted 4 lines

This patch supports to use the specified input device number when the input device is registered. If the input device number bigger than zero is registered before by other input device, returns error.

No, I don't think this is a good solution. You can have persistent device nodes without hadrcoding it into the driver. See how UDEV creates 'by-id' and 'by-path' links.

Please let me know how to use udev at input device.

At our system,
input0: h/w keypad
input1: gpio key
input2: touchscreen
input3: jack or others

Quoted 8 lines

but in previous system, we always set the touchscreen as input1. Right we can modify it but it's not easy.
With this patch we always set touchscreen as input1.

How can we do this?

FYI: when launch the X, we set the tsdevice as input1 and keyboard as input0.

Do you have udev running? On Fedora there is a rule here:

/lib/udev/rules.d/60-persistent-input.rules

that handles everythign and creates 'by-id' and 'by-path' symlinks.

Signature · 1 line
Dmitry