summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2005-12-07 21:40:34 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:18:09 -0800
commit1d8f430c15b3a345db990e285742c67c2f52f9a6 (patch)
tree7bf8ae0929ebf581c4de68e7f4be9f6ea672d453 /drivers
parent263756ec228f1cdd49fc50b1f87001a4cebdfe12 (diff)
[PATCH] Input: add modalias support
Here's the patch for modalias support for input classes. It uses comma-separated numbers, and doesn't describe all the potential keys (no module currently cares, and that would make the strings huge). The changes to input.h are to move the definitions needed by file2alias outside __KERNEL__. I chose not to move those definitions to mod_devicetable.h, because there are so many that it might break compile of something else in the kernel. The rest is fairly straightforward. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> CC: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/input.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 2d37b394e384..ef5824c8846b 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -528,10 +528,49 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
INPUT_DEV_STRING_ATTR_SHOW(phys);
INPUT_DEV_STRING_ATTR_SHOW(uniq);
+static int print_modalias_bits(char *buf, char prefix, unsigned long *arr,
+ unsigned int min, unsigned int max)
+{
+ int len, i;
+
+ len = sprintf(buf, "%c", prefix);
+ for (i = min; i < max; i++)
+ if (arr[LONG(i)] & BIT(i))
+ len += sprintf(buf+len, "%X,", i);
+ return len;
+}
+
+static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
+{
+ struct input_dev *id = to_input_dev(dev);
+ ssize_t len = 0;
+
+ len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-",
+ id->id.bustype,
+ id->id.vendor,
+ id->id.product,
+ id->id.version);
+
+ len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX);
+ len += print_modalias_bits(buf+len, 'k', id->keybit,
+ KEY_MIN_INTERESTING, KEY_MAX);
+ len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX);
+ len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX);
+ len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX);
+ len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX);
+ len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX);
+ len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX);
+ len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX);
+ len += sprintf(buf+len, "\n");
+ return len;
+}
+static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
+
static struct attribute *input_dev_attrs[] = {
&class_device_attr_name.attr,
&class_device_attr_phys.attr,
&class_device_attr_uniq.attr,
+ &class_device_attr_modalias.attr,
NULL
};