[PATCH] INPUT: add MODALIAS to the event environment
input: add MODALIAS to the event environment Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
67daf5f11f
commit
bd37e5a951
1 changed files with 41 additions and 22 deletions
|
@ -528,40 +528,56 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
|
||||||
INPUT_DEV_STRING_ATTR_SHOW(phys);
|
INPUT_DEV_STRING_ATTR_SHOW(phys);
|
||||||
INPUT_DEV_STRING_ATTR_SHOW(uniq);
|
INPUT_DEV_STRING_ATTR_SHOW(uniq);
|
||||||
|
|
||||||
static int print_modalias_bits(char *buf, char prefix, unsigned long *arr,
|
static int print_modalias_bits(char *buf, int size, char prefix, unsigned long *arr,
|
||||||
unsigned int min, unsigned int max)
|
unsigned int min, unsigned int max)
|
||||||
{
|
{
|
||||||
int len, i;
|
int len, i;
|
||||||
|
|
||||||
len = sprintf(buf, "%c", prefix);
|
len = snprintf(buf, size, "%c", prefix);
|
||||||
for (i = min; i < max; i++)
|
for (i = min; i < max; i++)
|
||||||
if (arr[LONG(i)] & BIT(i))
|
if (arr[LONG(i)] & BIT(i))
|
||||||
len += sprintf(buf+len, "%X,", i);
|
len += snprintf(buf + len, size - len, "%X,", i);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int print_modalias(char *buf, int size, struct input_dev *id)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = snprintf(buf, size, "input:b%04Xv%04Xp%04Xe%04X-",
|
||||||
|
id->id.bustype,
|
||||||
|
id->id.vendor,
|
||||||
|
id->id.product,
|
||||||
|
id->id.version);
|
||||||
|
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'e', id->evbit,
|
||||||
|
0, EV_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'k', id->keybit,
|
||||||
|
KEY_MIN_INTERESTING, KEY_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'r', id->relbit,
|
||||||
|
0, REL_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'a', id->absbit,
|
||||||
|
0, ABS_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'm', id->mscbit,
|
||||||
|
0, MSC_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'l', id->ledbit,
|
||||||
|
0, LED_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 's', id->sndbit,
|
||||||
|
0, SND_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'f', id->ffbit,
|
||||||
|
0, FF_MAX);
|
||||||
|
len += print_modalias_bits(buf + len, size - len, 'w', id->swbit,
|
||||||
|
0, SW_MAX);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
|
static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
|
||||||
{
|
{
|
||||||
struct input_dev *id = to_input_dev(dev);
|
struct input_dev *id = to_input_dev(dev);
|
||||||
ssize_t len = 0;
|
ssize_t len;
|
||||||
|
|
||||||
len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-",
|
len = print_modalias(buf, PAGE_SIZE, id);
|
||||||
id->id.bustype,
|
len += snprintf(buf + len, PAGE_SIZE-len, "\n");
|
||||||
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;
|
return len;
|
||||||
}
|
}
|
||||||
static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
|
static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
|
||||||
|
@ -728,8 +744,11 @@ static int input_dev_uevent(struct class_device *cdev, char **envp,
|
||||||
if (test_bit(EV_SW, dev->evbit))
|
if (test_bit(EV_SW, dev->evbit))
|
||||||
INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
|
INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
|
||||||
|
|
||||||
envp[i] = NULL;
|
envp[i++] = buffer + len;
|
||||||
|
len += snprintf(buffer + len, buffer_size - len, "MODALIAS=");
|
||||||
|
len += print_modalias(buffer + len, buffer_size - len, dev) + 1;
|
||||||
|
|
||||||
|
envp[i] = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue