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.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 32197efe67ed..5180405c1a84 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -25,6 +25,8 @@ typedef Elf64_Addr kernel_ulong_t;
25#include <stdint.h> 25#include <stdint.h>
26#endif 26#endif
27 27
28#include <ctype.h>
29
28typedef uint32_t __u32; 30typedef uint32_t __u32;
29typedef uint16_t __u16; 31typedef uint16_t __u16;
30typedef unsigned char __u8; 32typedef unsigned char __u8;
@@ -287,6 +289,58 @@ static int do_pnp_card_entry(const char *filename,
287 return 1; 289 return 1;
288} 290}
289 291
292/* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
293static int do_pcmcia_entry(const char *filename,
294 struct pcmcia_device_id *id, char *alias)
295{
296 unsigned int i;
297
298 id->manf_id = TO_NATIVE(id->manf_id);
299 id->card_id = TO_NATIVE(id->card_id);
300 id->func_id = TO_NATIVE(id->func_id);
301 id->function = TO_NATIVE(id->function);
302 id->device_no = TO_NATIVE(id->device_no);
303 for (i=0; i<4; i++) {
304 id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]);
305 }
306
307 strcpy(alias, "pcmcia:");
308 ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID,
309 id->manf_id);
310 ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID,
311 id->card_id);
312 ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID,
313 id->func_id);
314 ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION,
315 id->function);
316 ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO,
317 id->device_no);
318 ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]);
319 ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]);
320 ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]);
321 ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]);
322
323 return 1;
324}
325
326
327
328static int do_of_entry (const char *filename, struct of_device_id *of, char *alias)
329{
330 char *tmp;
331 sprintf (alias, "of:N%sT%sC%s",
332 of->name[0] ? of->name : "*",
333 of->type[0] ? of->type : "*",
334 of->compatible[0] ? of->compatible : "*");
335
336 /* Replace all whitespace with underscores */
337 for (tmp = alias; tmp && *tmp; tmp++)
338 if (isspace (*tmp))
339 *tmp = '_';
340
341 return 1;
342}
343
290/* Ignore any prefix, eg. v850 prepends _ */ 344/* Ignore any prefix, eg. v850 prepends _ */
291static inline int sym_is(const char *symbol, const char *name) 345static inline int sym_is(const char *symbol, const char *name)
292{ 346{
@@ -362,6 +416,13 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
362 else if (sym_is(symname, "__mod_pnp_card_device_table")) 416 else if (sym_is(symname, "__mod_pnp_card_device_table"))
363 do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id), 417 do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
364 do_pnp_card_entry, mod); 418 do_pnp_card_entry, mod);
419 else if (sym_is(symname, "__mod_pcmcia_device_table"))
420 do_table(symval, sym->st_size, sizeof(struct pcmcia_device_id),
421 do_pcmcia_entry, mod);
422 else if (sym_is(symname, "__mod_of_device_table"))
423 do_table(symval, sym->st_size, sizeof(struct of_device_id),
424 do_of_entry, mod);
425
365} 426}
366 427
367/* Now add out buffered information to the generated C source */ 428/* Now add out buffered information to the generated C source */