file2alias.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. /* Simple code to turn various tables in an ELF file into alias definitions.
  2. * This deals with kernel datastructures where they should be
  3. * dealt with: in the kernel source.
  4. *
  5. * Copyright 2002-2003 Rusty Russell, IBM Corporation
  6. * 2003 Kai Germaschewski
  7. *
  8. *
  9. * This software may be used and distributed according to the terms
  10. * of the GNU General Public License, incorporated herein by reference.
  11. */
  12. #include "modpost.h"
  13. /* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
  14. * use either stdint.h or inttypes.h for the rest. */
  15. #if KERNEL_ELFCLASS == ELFCLASS32
  16. typedef Elf32_Addr kernel_ulong_t;
  17. #define BITS_PER_LONG 32
  18. #else
  19. typedef Elf64_Addr kernel_ulong_t;
  20. #define BITS_PER_LONG 64
  21. #endif
  22. #ifdef __sun__
  23. #include <inttypes.h>
  24. #else
  25. #include <stdint.h>
  26. #endif
  27. #include <ctype.h>
  28. typedef uint32_t __u32;
  29. typedef uint16_t __u16;
  30. typedef unsigned char __u8;
  31. /* Big exception to the "don't include kernel headers into userspace, which
  32. * even potentially has different endianness and word sizes, since
  33. * we handle those differences explicitly below */
  34. #include "../../include/linux/mod_devicetable.h"
  35. #include "../../include/linux/input.h"
  36. #define ADD(str, sep, cond, field) \
  37. do { \
  38. strcat(str, sep); \
  39. if (cond) \
  40. sprintf(str + strlen(str), \
  41. sizeof(field) == 1 ? "%02X" : \
  42. sizeof(field) == 2 ? "%04X" : \
  43. sizeof(field) == 4 ? "%08X" : "", \
  44. field); \
  45. else \
  46. sprintf(str + strlen(str), "*"); \
  47. } while(0)
  48. /* USB is special because the bcdDevice can be matched against a numeric range */
  49. /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipN" */
  50. static void do_usb_entry(struct usb_device_id *id,
  51. unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
  52. unsigned char range_lo, unsigned char range_hi,
  53. struct module *mod)
  54. {
  55. char alias[500];
  56. strcpy(alias, "usb:");
  57. ADD(alias, "v", id->match_flags&USB_DEVICE_ID_MATCH_VENDOR,
  58. id->idVendor);
  59. ADD(alias, "p", id->match_flags&USB_DEVICE_ID_MATCH_PRODUCT,
  60. id->idProduct);
  61. strcat(alias, "d");
  62. if (bcdDevice_initial_digits)
  63. sprintf(alias + strlen(alias), "%0*X",
  64. bcdDevice_initial_digits, bcdDevice_initial);
  65. if (range_lo == range_hi)
  66. sprintf(alias + strlen(alias), "%u", range_lo);
  67. else if (range_lo > 0 || range_hi < 9)
  68. sprintf(alias + strlen(alias), "[%u-%u]", range_lo, range_hi);
  69. if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
  70. strcat(alias, "*");
  71. ADD(alias, "dc", id->match_flags&USB_DEVICE_ID_MATCH_DEV_CLASS,
  72. id->bDeviceClass);
  73. ADD(alias, "dsc",
  74. id->match_flags&USB_DEVICE_ID_MATCH_DEV_SUBCLASS,
  75. id->bDeviceSubClass);
  76. ADD(alias, "dp",
  77. id->match_flags&USB_DEVICE_ID_MATCH_DEV_PROTOCOL,
  78. id->bDeviceProtocol);
  79. ADD(alias, "ic",
  80. id->match_flags&USB_DEVICE_ID_MATCH_INT_CLASS,
  81. id->bInterfaceClass);
  82. ADD(alias, "isc",
  83. id->match_flags&USB_DEVICE_ID_MATCH_INT_SUBCLASS,
  84. id->bInterfaceSubClass);
  85. ADD(alias, "ip",
  86. id->match_flags&USB_DEVICE_ID_MATCH_INT_PROTOCOL,
  87. id->bInterfaceProtocol);
  88. /* Always end in a wildcard, for future extension */
  89. if (alias[strlen(alias)-1] != '*')
  90. strcat(alias, "*");
  91. buf_printf(&mod->dev_table_buf,
  92. "MODULE_ALIAS(\"%s\");\n", alias);
  93. }
  94. static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
  95. {
  96. unsigned int devlo, devhi;
  97. unsigned char chi, clo;
  98. int ndigits;
  99. id->match_flags = TO_NATIVE(id->match_flags);
  100. id->idVendor = TO_NATIVE(id->idVendor);
  101. id->idProduct = TO_NATIVE(id->idProduct);
  102. devlo = id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO ?
  103. TO_NATIVE(id->bcdDevice_lo) : 0x0U;
  104. devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ?
  105. TO_NATIVE(id->bcdDevice_hi) : ~0x0U;
  106. /*
  107. * Some modules (visor) have empty slots as placeholder for
  108. * run-time specification that results in catch-all alias
  109. */
  110. if (!(id->idVendor | id->bDeviceClass | id->bInterfaceClass))
  111. return;
  112. /* Convert numeric bcdDevice range into fnmatch-able pattern(s) */
  113. for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) {
  114. clo = devlo & 0xf;
  115. chi = devhi & 0xf;
  116. if (chi > 9) /* it's bcd not hex */
  117. chi = 9;
  118. devlo >>= 4;
  119. devhi >>= 4;
  120. if (devlo == devhi || !ndigits) {
  121. do_usb_entry(id, devlo, ndigits, clo, chi, mod);
  122. break;
  123. }
  124. if (clo > 0)
  125. do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
  126. if (chi < 9)
  127. do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
  128. }
  129. }
  130. static void do_usb_table(void *symval, unsigned long size,
  131. struct module *mod)
  132. {
  133. unsigned int i;
  134. const unsigned long id_size = sizeof(struct usb_device_id);
  135. if (size % id_size || size < id_size) {
  136. fprintf(stderr, "*** Warning: %s ids %lu bad size "
  137. "(each on %lu)\n", mod->name, size, id_size);
  138. }
  139. /* Leave last one: it's the terminator. */
  140. size -= id_size;
  141. for (i = 0; i < size; i += id_size)
  142. do_usb_entry_multi(symval + i, mod);
  143. }
  144. /* Looks like: ieee1394:venNmoNspNverN */
  145. static int do_ieee1394_entry(const char *filename,
  146. struct ieee1394_device_id *id, char *alias)
  147. {
  148. id->match_flags = TO_NATIVE(id->match_flags);
  149. id->vendor_id = TO_NATIVE(id->vendor_id);
  150. id->model_id = TO_NATIVE(id->model_id);
  151. id->specifier_id = TO_NATIVE(id->specifier_id);
  152. id->version = TO_NATIVE(id->version);
  153. strcpy(alias, "ieee1394:");
  154. ADD(alias, "ven", id->match_flags & IEEE1394_MATCH_VENDOR_ID,
  155. id->vendor_id);
  156. ADD(alias, "mo", id->match_flags & IEEE1394_MATCH_MODEL_ID,
  157. id->model_id);
  158. ADD(alias, "sp", id->match_flags & IEEE1394_MATCH_SPECIFIER_ID,
  159. id->specifier_id);
  160. ADD(alias, "ver", id->match_flags & IEEE1394_MATCH_VERSION,
  161. id->version);
  162. return 1;
  163. }
  164. /* Looks like: pci:vNdNsvNsdNbcNscNiN. */
  165. static int do_pci_entry(const char *filename,
  166. struct pci_device_id *id, char *alias)
  167. {
  168. /* Class field can be divided into these three. */
  169. unsigned char baseclass, subclass, interface,
  170. baseclass_mask, subclass_mask, interface_mask;
  171. id->vendor = TO_NATIVE(id->vendor);
  172. id->device = TO_NATIVE(id->device);
  173. id->subvendor = TO_NATIVE(id->subvendor);
  174. id->subdevice = TO_NATIVE(id->subdevice);
  175. id->class = TO_NATIVE(id->class);
  176. id->class_mask = TO_NATIVE(id->class_mask);
  177. strcpy(alias, "pci:");
  178. ADD(alias, "v", id->vendor != PCI_ANY_ID, id->vendor);
  179. ADD(alias, "d", id->device != PCI_ANY_ID, id->device);
  180. ADD(alias, "sv", id->subvendor != PCI_ANY_ID, id->subvendor);
  181. ADD(alias, "sd", id->subdevice != PCI_ANY_ID, id->subdevice);
  182. baseclass = (id->class) >> 16;
  183. baseclass_mask = (id->class_mask) >> 16;
  184. subclass = (id->class) >> 8;
  185. subclass_mask = (id->class_mask) >> 8;
  186. interface = id->class;
  187. interface_mask = id->class_mask;
  188. if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
  189. || (subclass_mask != 0 && subclass_mask != 0xFF)
  190. || (interface_mask != 0 && interface_mask != 0xFF)) {
  191. fprintf(stderr,
  192. "*** Warning: Can't handle masks in %s:%04X\n",
  193. filename, id->class_mask);
  194. return 0;
  195. }
  196. ADD(alias, "bc", baseclass_mask == 0xFF, baseclass);
  197. ADD(alias, "sc", subclass_mask == 0xFF, subclass);
  198. ADD(alias, "i", interface_mask == 0xFF, interface);
  199. return 1;
  200. }
  201. /* looks like: "ccw:tNmNdtNdmN" */
  202. static int do_ccw_entry(const char *filename,
  203. struct ccw_device_id *id, char *alias)
  204. {
  205. id->match_flags = TO_NATIVE(id->match_flags);
  206. id->cu_type = TO_NATIVE(id->cu_type);
  207. id->cu_model = TO_NATIVE(id->cu_model);
  208. id->dev_type = TO_NATIVE(id->dev_type);
  209. id->dev_model = TO_NATIVE(id->dev_model);
  210. strcpy(alias, "ccw:");
  211. ADD(alias, "t", id->match_flags&CCW_DEVICE_ID_MATCH_CU_TYPE,
  212. id->cu_type);
  213. ADD(alias, "m", id->match_flags&CCW_DEVICE_ID_MATCH_CU_MODEL,
  214. id->cu_model);
  215. ADD(alias, "dt", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
  216. id->dev_type);
  217. ADD(alias, "dm", id->match_flags&CCW_DEVICE_ID_MATCH_DEVICE_TYPE,
  218. id->dev_model);
  219. return 1;
  220. }
  221. /* Looks like: "serio:tyNprNidNexN" */
  222. static int do_serio_entry(const char *filename,
  223. struct serio_device_id *id, char *alias)
  224. {
  225. id->type = TO_NATIVE(id->type);
  226. id->proto = TO_NATIVE(id->proto);
  227. id->id = TO_NATIVE(id->id);
  228. id->extra = TO_NATIVE(id->extra);
  229. strcpy(alias, "serio:");
  230. ADD(alias, "ty", id->type != SERIO_ANY, id->type);
  231. ADD(alias, "pr", id->proto != SERIO_ANY, id->proto);
  232. ADD(alias, "id", id->id != SERIO_ANY, id->id);
  233. ADD(alias, "ex", id->extra != SERIO_ANY, id->extra);
  234. return 1;
  235. }
  236. /* looks like: "pnp:dD" */
  237. static int do_pnp_entry(const char *filename,
  238. struct pnp_device_id *id, char *alias)
  239. {
  240. sprintf(alias, "pnp:d%s", id->id);
  241. return 1;
  242. }
  243. /* looks like: "pnp:cCdD..." */
  244. static int do_pnp_card_entry(const char *filename,
  245. struct pnp_card_device_id *id, char *alias)
  246. {
  247. int i;
  248. sprintf(alias, "pnp:c%s", id->id);
  249. for (i = 0; i < PNP_MAX_DEVICES; i++) {
  250. if (! *id->devs[i].id)
  251. break;
  252. sprintf(alias + strlen(alias), "d%s", id->devs[i].id);
  253. }
  254. return 1;
  255. }
  256. /* Looks like: pcmcia:mNcNfNfnNpfnNvaNvbNvcNvdN. */
  257. static int do_pcmcia_entry(const char *filename,
  258. struct pcmcia_device_id *id, char *alias)
  259. {
  260. unsigned int i;
  261. id->match_flags = TO_NATIVE(id->match_flags);
  262. id->manf_id = TO_NATIVE(id->manf_id);
  263. id->card_id = TO_NATIVE(id->card_id);
  264. id->func_id = TO_NATIVE(id->func_id);
  265. id->function = TO_NATIVE(id->function);
  266. id->device_no = TO_NATIVE(id->device_no);
  267. for (i=0; i<4; i++) {
  268. id->prod_id_hash[i] = TO_NATIVE(id->prod_id_hash[i]);
  269. }
  270. strcpy(alias, "pcmcia:");
  271. ADD(alias, "m", id->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID,
  272. id->manf_id);
  273. ADD(alias, "c", id->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID,
  274. id->card_id);
  275. ADD(alias, "f", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID,
  276. id->func_id);
  277. ADD(alias, "fn", id->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION,
  278. id->function);
  279. ADD(alias, "pfn", id->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO,
  280. id->device_no);
  281. ADD(alias, "pa", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1, id->prod_id_hash[0]);
  282. ADD(alias, "pb", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2, id->prod_id_hash[1]);
  283. ADD(alias, "pc", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3, id->prod_id_hash[2]);
  284. ADD(alias, "pd", id->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4, id->prod_id_hash[3]);
  285. return 1;
  286. }
  287. static int do_of_entry (const char *filename, struct of_device_id *of, char *alias)
  288. {
  289. char *tmp;
  290. sprintf (alias, "of:N%sT%sC%s",
  291. of->name[0] ? of->name : "*",
  292. of->type[0] ? of->type : "*",
  293. of->compatible[0] ? of->compatible : "*");
  294. /* Replace all whitespace with underscores */
  295. for (tmp = alias; tmp && *tmp; tmp++)
  296. if (isspace (*tmp))
  297. *tmp = '_';
  298. return 1;
  299. }
  300. static int do_vio_entry(const char *filename, struct vio_device_id *vio,
  301. char *alias)
  302. {
  303. char *tmp;
  304. sprintf(alias, "vio:T%sS%s", vio->type[0] ? vio->type : "*",
  305. vio->compat[0] ? vio->compat : "*");
  306. /* Replace all whitespace with underscores */
  307. for (tmp = alias; tmp && *tmp; tmp++)
  308. if (isspace (*tmp))
  309. *tmp = '_';
  310. return 1;
  311. }
  312. static int do_i2c_entry(const char *filename, struct i2c_device_id *i2c, char *alias)
  313. {
  314. strcpy(alias, "i2c:");
  315. ADD(alias, "id", 1, i2c->id);
  316. return 1;
  317. }
  318. #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  319. static void do_input(char *alias,
  320. kernel_ulong_t *arr, unsigned int min, unsigned int max)
  321. {
  322. unsigned int i;
  323. for (i = min; i < max; i++) {
  324. if (arr[i/BITS_PER_LONG] & (1 << (i%BITS_PER_LONG)))
  325. sprintf(alias+strlen(alias), "%X,*", i);
  326. }
  327. }
  328. /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */
  329. static int do_input_entry(const char *filename, struct input_device_id *id,
  330. char *alias)
  331. {
  332. sprintf(alias, "input:");
  333. ADD(alias, "b", id->flags&INPUT_DEVICE_ID_MATCH_BUS, id->id.bustype);
  334. ADD(alias, "v", id->flags&INPUT_DEVICE_ID_MATCH_VENDOR, id->id.vendor);
  335. ADD(alias, "p", id->flags&INPUT_DEVICE_ID_MATCH_PRODUCT,
  336. id->id.product);
  337. ADD(alias, "e", id->flags&INPUT_DEVICE_ID_MATCH_VERSION,
  338. id->id.version);
  339. sprintf(alias + strlen(alias), "-e*");
  340. if (id->flags&INPUT_DEVICE_ID_MATCH_EVBIT)
  341. do_input(alias, id->evbit, 0, EV_MAX);
  342. sprintf(alias + strlen(alias), "k*");
  343. if (id->flags&INPUT_DEVICE_ID_MATCH_KEYBIT)
  344. do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX);
  345. sprintf(alias + strlen(alias), "r*");
  346. if (id->flags&INPUT_DEVICE_ID_MATCH_RELBIT)
  347. do_input(alias, id->relbit, 0, REL_MAX);
  348. sprintf(alias + strlen(alias), "a*");
  349. if (id->flags&INPUT_DEVICE_ID_MATCH_ABSBIT)
  350. do_input(alias, id->absbit, 0, ABS_MAX);
  351. sprintf(alias + strlen(alias), "m*");
  352. if (id->flags&INPUT_DEVICE_ID_MATCH_MSCIT)
  353. do_input(alias, id->mscbit, 0, MSC_MAX);
  354. sprintf(alias + strlen(alias), "l*");
  355. if (id->flags&INPUT_DEVICE_ID_MATCH_LEDBIT)
  356. do_input(alias, id->ledbit, 0, LED_MAX);
  357. sprintf(alias + strlen(alias), "s*");
  358. if (id->flags&INPUT_DEVICE_ID_MATCH_SNDBIT)
  359. do_input(alias, id->sndbit, 0, SND_MAX);
  360. sprintf(alias + strlen(alias), "f*");
  361. if (id->flags&INPUT_DEVICE_ID_MATCH_FFBIT)
  362. do_input(alias, id->ffbit, 0, FF_MAX);
  363. sprintf(alias + strlen(alias), "w*");
  364. if (id->flags&INPUT_DEVICE_ID_MATCH_SWBIT)
  365. do_input(alias, id->swbit, 0, SW_MAX);
  366. return 1;
  367. }
  368. /* Ignore any prefix, eg. v850 prepends _ */
  369. static inline int sym_is(const char *symbol, const char *name)
  370. {
  371. const char *match;
  372. match = strstr(symbol, name);
  373. if (!match)
  374. return 0;
  375. return match[strlen(symbol)] == '\0';
  376. }
  377. static void do_table(void *symval, unsigned long size,
  378. unsigned long id_size,
  379. void *function,
  380. struct module *mod)
  381. {
  382. unsigned int i;
  383. char alias[500];
  384. int (*do_entry)(const char *, void *entry, char *alias) = function;
  385. if (size % id_size || size < id_size) {
  386. fprintf(stderr, "*** Warning: %s ids %lu bad size "
  387. "(each on %lu)\n", mod->name, size, id_size);
  388. }
  389. /* Leave last one: it's the terminator. */
  390. size -= id_size;
  391. for (i = 0; i < size; i += id_size) {
  392. if (do_entry(mod->name, symval+i, alias)) {
  393. /* Always end in a wildcard, for future extension */
  394. if (alias[strlen(alias)-1] != '*')
  395. strcat(alias, "*");
  396. buf_printf(&mod->dev_table_buf,
  397. "MODULE_ALIAS(\"%s\");\n", alias);
  398. }
  399. }
  400. }
  401. /* Create MODULE_ALIAS() statements.
  402. * At this time, we cannot write the actual output C source yet,
  403. * so we write into the mod->dev_table_buf buffer. */
  404. void handle_moddevtable(struct module *mod, struct elf_info *info,
  405. Elf_Sym *sym, const char *symname)
  406. {
  407. void *symval;
  408. /* We're looking for a section relative symbol */
  409. if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
  410. return;
  411. symval = (void *)info->hdr
  412. + info->sechdrs[sym->st_shndx].sh_offset
  413. + sym->st_value;
  414. if (sym_is(symname, "__mod_pci_device_table"))
  415. do_table(symval, sym->st_size, sizeof(struct pci_device_id),
  416. do_pci_entry, mod);
  417. else if (sym_is(symname, "__mod_usb_device_table"))
  418. /* special case to handle bcdDevice ranges */
  419. do_usb_table(symval, sym->st_size, mod);
  420. else if (sym_is(symname, "__mod_ieee1394_device_table"))
  421. do_table(symval, sym->st_size, sizeof(struct ieee1394_device_id),
  422. do_ieee1394_entry, mod);
  423. else if (sym_is(symname, "__mod_ccw_device_table"))
  424. do_table(symval, sym->st_size, sizeof(struct ccw_device_id),
  425. do_ccw_entry, mod);
  426. else if (sym_is(symname, "__mod_serio_device_table"))
  427. do_table(symval, sym->st_size, sizeof(struct serio_device_id),
  428. do_serio_entry, mod);
  429. else if (sym_is(symname, "__mod_pnp_device_table"))
  430. do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
  431. do_pnp_entry, mod);
  432. else if (sym_is(symname, "__mod_pnp_card_device_table"))
  433. do_table(symval, sym->st_size, sizeof(struct pnp_card_device_id),
  434. do_pnp_card_entry, mod);
  435. else if (sym_is(symname, "__mod_pcmcia_device_table"))
  436. do_table(symval, sym->st_size, sizeof(struct pcmcia_device_id),
  437. do_pcmcia_entry, mod);
  438. else if (sym_is(symname, "__mod_of_device_table"))
  439. do_table(symval, sym->st_size, sizeof(struct of_device_id),
  440. do_of_entry, mod);
  441. else if (sym_is(symname, "__mod_vio_device_table"))
  442. do_table(symval, sym->st_size, sizeof(struct vio_device_id),
  443. do_vio_entry, mod);
  444. else if (sym_is(symname, "__mod_i2c_device_table"))
  445. do_table(symval, sym->st_size, sizeof(struct i2c_device_id),
  446. do_i2c_entry, mod);
  447. else if (sym_is(symname, "__mod_input_device_table"))
  448. do_table(symval, sym->st_size, sizeof(struct input_device_id),
  449. do_input_entry, mod);
  450. }
  451. /* Now add out buffered information to the generated C source */
  452. void add_moddevtable(struct buffer *buf, struct module *mod)
  453. {
  454. buf_printf(buf, "\n");
  455. buf_write(buf, mod->dev_table_buf.p, mod->dev_table_buf.pos);
  456. free(mod->dev_table_buf.p);
  457. }