mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
[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 <[email protected]> CC: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
263756ec22
commit
1d8f430c15
3 changed files with 141 additions and 39 deletions
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue