[RFC PATCH 2/6] Input: Add info about EV_BTN

Tomasz Pakuła posted 6 patches 3 days, 1 hour ago
[RFC PATCH 2/6] Input: Add info about EV_BTN
Posted by Tomasz Pakuła 3 days, 1 hour ago
Add necessary bits to modalias etc. Store the number of buttons.

Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
---
 drivers/input/input.c | 10 ++++++++++
 include/linux/input.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index a500e1e276c2..e926327443bb 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -258,6 +258,10 @@ static int input_get_disposition(struct input_dev *dev,
 		}
 		break;
 
+	case EV_BTN:
+		disposition = INPUT_PASS_TO_HANDLERS;
+		break;
+
 	case EV_ABS:
 		if (is_event_supported(code, dev->absbit, ABS_MAX))
 			disposition = input_handle_abs_event(dev, code, &value);
@@ -1124,6 +1128,8 @@ static int input_devices_seq_show(struct seq_file *seq, void *v)
 		input_seq_print_bitmap(seq, "FF", dev->ffbit, FF_MAX);
 	if (test_bit(EV_SW, dev->evbit))
 		input_seq_print_bitmap(seq, "SW", dev->swbit, SW_MAX);
+	if (test_bit(EV_BTN, dev->evbit))
+		seq_printf(seq, "I: BTN=%u\n", dev->button_count);
 
 	seq_putc(seq, '\n');
 
@@ -1347,6 +1353,7 @@ static int input_print_modalias_parts(char *buf, int size, int full_len,
 				'f', id->ffbit, 0, FF_MAX);
 	len += input_print_modalias_bits(buf + len, size - len,
 				'w', id->swbit, 0, SW_MAX);
+	len += snprintf(buf + len, size - len, "t%u", id->button_count);
 
 	return len;
 }
@@ -1679,6 +1686,8 @@ static int input_dev_uevent(const struct device *device, struct kobj_uevent_env
 		INPUT_ADD_HOTPLUG_BM_VAR("FF=", dev->ffbit, FF_MAX);
 	if (test_bit(EV_SW, dev->evbit))
 		INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
+	if (test_bit(EV_BTN, dev->evbit))
+		INPUT_ADD_HOTPLUG_VAR("BTN=%u", dev->button_count);
 
 	INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev);
 
@@ -2113,6 +2122,7 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
 		break;
 
 	case EV_PWR:
+	case EV_BTN:
 		/* do nothing */
 		break;
 
diff --git a/include/linux/input.h b/include/linux/input.h
index 7d7cb0593a63..f6389de4a4d1 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -59,6 +59,7 @@ enum input_clock_type {
  * @sndbit: bitmap of sound effects supported by the device
  * @ffbit: bitmap of force feedback effects supported by the device
  * @swbit: bitmap of switches present on the device
+ * @button_count: number of generic buttons present on the device.
  * @hint_events_per_packet: average number of events generated by the
  *	device in a packet (between EV_SYN/SYN_REPORT events). Used by
  *	event handlers to estimate size of the buffer needed to hold
@@ -152,6 +153,7 @@ struct input_dev {
 	unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
 	unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
 
+	unsigned int button_count;
 	unsigned int hint_events_per_packet;
 
 	unsigned int keycodemax;
-- 
2.52.0