aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/file2alias.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r--scripts/mod/file2alias.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index e3d144a3f10b..e0eedffe565b 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -16,8 +16,10 @@
16 * use either stdint.h or inttypes.h for the rest. */ 16 * use either stdint.h or inttypes.h for the rest. */
17#if KERNEL_ELFCLASS == ELFCLASS32 17#if KERNEL_ELFCLASS == ELFCLASS32
18typedef Elf32_Addr kernel_ulong_t; 18typedef Elf32_Addr kernel_ulong_t;
19#define BITS_PER_LONG 32
19#else 20#else
20typedef Elf64_Addr kernel_ulong_t; 21typedef Elf64_Addr kernel_ulong_t;
22#define BITS_PER_LONG 64
21#endif 23#endif
22#ifdef __sun__ 24#ifdef __sun__
23#include <inttypes.h> 25#include <inttypes.h>
@@ -35,6 +37,7 @@ typedef unsigned char __u8;
35 * even potentially has different endianness and word sizes, since 37 * even potentially has different endianness and word sizes, since
36 * we handle those differences explicitly below */ 38 * we handle those differences explicitly below */
37#include "../../include/linux/mod_devicetable.h" 39#include "../../include/linux/mod_devicetable.h"
40#include "../../include/linux/input.h"
38 41
39#define ADD(str, sep, cond, field) \ 42#define ADD(str, sep, cond, field) \
40do { \ 43do { \
@@ -366,6 +369,61 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *i2c, char *a
366 return 1; 369 return 1;
367} 370}
368 371
372#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
373
374static void do_input(char *alias,
375 kernel_ulong_t *arr, unsigned int min, unsigned int max)
376{
377 unsigned int i;
378 for (i = min; i < max; i++) {
379 if (arr[i/BITS_PER_LONG] & (1 << (i%BITS_PER_LONG)))
380 sprintf(alias+strlen(alias), "%X,*", i);
381 }
382}
383
384/* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */
385static int do_input_entry(const char *filename, struct input_device_id *id,
386 char *alias)
387{
388 sprintf(alias, "input:");
389
390 ADD(alias, "b", id->flags&INPUT_DEVICE_ID_MATCH_BUS, id->id.bustype);
391 ADD(alias, "v", id->flags&INPUT_DEVICE_ID_MATCH_VENDOR, id->id.vendor);
392 ADD(alias, "p", id->flags&INPUT_DEVICE_ID_MATCH_PRODUCT,
393 id->id.product);
394 ADD(alias, "e", id->flags&INPUT_DEVICE_ID_MATCH_VERSION,
395 id->id.version);
396
397 sprintf(alias + strlen(alias), "-e*");
398 if (id->flags&INPUT_DEVICE_ID_MATCH_EVBIT)
399 do_input(alias, id->evbit, 0, EV_MAX);
400 sprintf(alias + strlen(alias), "k*");
401 if (id->flags&INPUT_DEVICE_ID_MATCH_KEYBIT)
402 do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX);
403 sprintf(alias + strlen(alias), "r*");
404 if (id->flags&INPUT_DEVICE_ID_MATCH_RELBIT)
405 do_input(alias, id->relbit, 0, REL_MAX);
406 sprintf(alias + strlen(alias), "a*");
407 if (id->flags&INPUT_DEVICE_ID_MATCH_ABSBIT)
408 do_input(alias, id->absbit, 0, ABS_MAX);
409 sprintf(alias + strlen(alias), "m*");
410 if (id->flags&INPUT_DEVICE_ID_MATCH_MSCIT)
411 do_input(alias, id->mscbit, 0, MSC_MAX);
412 sprintf(alias + strlen(alias), "l*");
413 if (id->flags&INPUT_DEVICE_ID_MATCH_LEDBIT)
414 do_input(alias, id->ledbit, 0, LED_MAX);
415 sprintf(alias + strlen(alias), "s*");
416 if (id->flags&INPUT_DEVICE_ID_MATCH_SNDBIT)
417 do_input(alias, id->sndbit, 0, SND_MAX);
418 sprintf(alias + strlen(alias), "f*");
419 if (id->flags&INPUT_DEVICE_ID_MATCH_FFBIT)
420 do_input(alias, id->ffbit, 0, SND_MAX);
421 sprintf(alias + strlen(alias), "w*");
422 if (id->flags&INPUT_DEVICE_ID_MATCH_SWBIT)
423 do_input(alias, id->swbit, 0, SW_MAX);
424 return 1;
425}
426
369/* Ignore any prefix, eg. v850 prepends _ */ 427/* Ignore any prefix, eg. v850 prepends _ */
370static inline int sym_is(const char *symbol, const char *name) 428static inline int sym_is(const char *symbol, const char *name)
371{ 429{
@@ -453,7 +511,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
453 else if (sym_is(symname, "__mod_i2c_device_table")) 511 else if (sym_is(symname, "__mod_i2c_device_table"))
454 do_table(symval, sym->st_size, sizeof(struct i2c_device_id), 512 do_table(symval, sym->st_size, sizeof(struct i2c_device_id),
455 do_i2c_entry, mod); 513 do_i2c_entry, mod);
456 514 else if (sym_is(symname, "__mod_input_device_table"))
515 do_table(symval, sym->st_size, sizeof(struct input_device_id),
516 do_input_entry, mod);
457} 517}
458 518
459/* Now add out buffered information to the generated C source */ 519/* Now add out buffered information to the generated C source */