summaryrefslogtreecommitdiffstats
path: root/scripts/mod/file2alias.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-05 23:48:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-05 23:48:35 -0400
commit9caa7e78481f17fb6ff77dfaca774998e7440430 (patch)
tree4e4cf2931b24da9536efae5184ce45eb4659acb7 /scripts/mod/file2alias.c
parent43a3e837e22818c2c79dad95745a6b54d4e232f7 (diff)
parent7322dd755e7dd34bc5359aa27abeed1687e0f628 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "14 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: byteswap: try to avoid __builtin_constant_p gcc bug lib/stackdepot: avoid to return 0 handle mm: fix kcompactd hang during memory offlining modpost: fix module autoloading for OF devices with generic compatible property proc: prevent accessing /proc/<PID>/environ until it's ready mm/zswap: provide unique zpool name mm: thp: kvm: fix memory corruption in KVM with THP enabled MAINTAINERS: fix Rajendra Nayak's address mm, cma: prevent nr_isolated_* counters from going negative mm: update min_free_kbytes from khugepaged after core initialization huge pagecache: mmap_sem is unlocked when truncation splits pmd rapidio/mport_cdev: fix uapi type definitions mm: memcontrol: let v2 cgroups follow changes in system swappiness mm: thp: correct split_huge_pages file permission
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r--scripts/mod/file2alias.c69
1 files changed, 45 insertions, 24 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 161dd0d67da8..a9155077feef 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -371,6 +371,49 @@ static void do_usb_table(void *symval, unsigned long size,
371 do_usb_entry_multi(symval + i, mod); 371 do_usb_entry_multi(symval + i, mod);
372} 372}
373 373
374static void do_of_entry_multi(void *symval, struct module *mod)
375{
376 char alias[500];
377 int len;
378 char *tmp;
379
380 DEF_FIELD_ADDR(symval, of_device_id, name);
381 DEF_FIELD_ADDR(symval, of_device_id, type);
382 DEF_FIELD_ADDR(symval, of_device_id, compatible);
383
384 len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*",
385 (*type)[0] ? *type : "*");
386
387 if (compatible[0])
388 sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "",
389 *compatible);
390
391 /* Replace all whitespace with underscores */
392 for (tmp = alias; tmp && *tmp; tmp++)
393 if (isspace(*tmp))
394 *tmp = '_';
395
396 buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias);
397 strcat(alias, "C");
398 add_wildcard(alias);
399 buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias);
400}
401
402static void do_of_table(void *symval, unsigned long size,
403 struct module *mod)
404{
405 unsigned int i;
406 const unsigned long id_size = SIZE_of_device_id;
407
408 device_id_check(mod->name, "of", size, id_size, symval);
409
410 /* Leave last one: it's the terminator. */
411 size -= id_size;
412
413 for (i = 0; i < size; i += id_size)
414 do_of_entry_multi(symval + i, mod);
415}
416
374/* Looks like: hid:bNvNpN */ 417/* Looks like: hid:bNvNpN */
375static int do_hid_entry(const char *filename, 418static int do_hid_entry(const char *filename,
376 void *symval, char *alias) 419 void *symval, char *alias)
@@ -684,30 +727,6 @@ static int do_pcmcia_entry(const char *filename,
684} 727}
685ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry); 728ADD_TO_DEVTABLE("pcmcia", pcmcia_device_id, do_pcmcia_entry);
686 729
687static int do_of_entry (const char *filename, void *symval, char *alias)
688{
689 int len;
690 char *tmp;
691 DEF_FIELD_ADDR(symval, of_device_id, name);
692 DEF_FIELD_ADDR(symval, of_device_id, type);
693 DEF_FIELD_ADDR(symval, of_device_id, compatible);
694
695 len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*",
696 (*type)[0] ? *type : "*");
697
698 if (compatible[0])
699 sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "",
700 *compatible);
701
702 /* Replace all whitespace with underscores */
703 for (tmp = alias; tmp && *tmp; tmp++)
704 if (isspace (*tmp))
705 *tmp = '_';
706
707 return 1;
708}
709ADD_TO_DEVTABLE("of", of_device_id, do_of_entry);
710
711static int do_vio_entry(const char *filename, void *symval, 730static int do_vio_entry(const char *filename, void *symval,
712 char *alias) 731 char *alias)
713{ 732{
@@ -1348,6 +1367,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
1348 /* First handle the "special" cases */ 1367 /* First handle the "special" cases */
1349 if (sym_is(name, namelen, "usb")) 1368 if (sym_is(name, namelen, "usb"))
1350 do_usb_table(symval, sym->st_size, mod); 1369 do_usb_table(symval, sym->st_size, mod);
1370 if (sym_is(name, namelen, "of"))
1371 do_of_table(symval, sym->st_size, mod);
1351 else if (sym_is(name, namelen, "pnp")) 1372 else if (sym_is(name, namelen, "pnp"))
1352 do_pnp_device_entry(symval, sym->st_size, mod); 1373 do_pnp_device_entry(symval, sym->st_size, mod);
1353 else if (sym_is(name, namelen, "pnp_card")) 1374 else if (sym_is(name, namelen, "pnp_card"))