summaryrefslogtreecommitdiffstats
path: root/scripts/mod
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2016-05-05 19:22:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-05 20:38:53 -0400
commitacbef7b7662953cec96c243db4009ac561d88989 (patch)
tree1928b99a105f10d5d532335bb622c870733ce984 /scripts/mod
parent8148a73c9901a8794a50f950083c00ccf97d43b3 (diff)
modpost: fix module autoloading for OF devices with generic compatible property
Since the wildcard at the end of OF module aliases is gone, autoloading of modules that don't match a device's last (most generic) compatible value fails. For example the CODA960 VPU on i.MX6Q has the SoC specific compatible "fsl,imx6q-vpu" and the generic compatible "cnm,coda960". Since the driver currently only works with knowledge about the SoC specific integration, it doesn't list "cnm,cod960" in the module device table. This results in the device compatible "of:NvpuT<NULL>Cfsl,imx6q-vpuCcnm,coda960" not matching the module alias "of:N*T*Cfsl,imx6q-vpu" anymore, whereas before commit 2f632369ab79 ("modpost: don't add a trailing wildcard for OF module aliases") it matched the module alias "of:N*T*Cfsl,imx6q-vpu*". This patch adds two module aliases for each compatible, one without the wildcard and one with "C*" appended. $ modinfo coda | grep imx6q alias: of:N*T*Cfsl,imx6q-vpuC* alias: of:N*T*Cfsl,imx6q-vpu Fixes: 2f632369ab79 ("modpost: don't add a trailing wildcard for OF module aliases") Link: http://lkml.kernel.org/r/1462203339-15340-1-git-send-email-p.zabel@pengutronix.de Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Cc: Javier Martinez Canillas <javier@osg.samsung.com> Cc: Brian Norris <computersforpeace@gmail.com> Cc: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: <stable@vger.kernel.org> [4.5+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/mod')
-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"))