params.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. /* Helpers for initial module or kernel cmdline parsing
  2. Copyright (C) 2001 Rusty Russell.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  14. */
  15. #include <linux/moduleparam.h>
  16. #include <linux/kernel.h>
  17. #include <linux/string.h>
  18. #include <linux/errno.h>
  19. #include <linux/module.h>
  20. #include <linux/device.h>
  21. #include <linux/err.h>
  22. #include <linux/slab.h>
  23. #if 0
  24. #define DEBUGP printk
  25. #else
  26. #define DEBUGP(fmt, a...)
  27. #endif
  28. static struct kobj_type module_ktype;
  29. static inline char dash2underscore(char c)
  30. {
  31. if (c == '-')
  32. return '_';
  33. return c;
  34. }
  35. static inline int parameq(const char *input, const char *paramname)
  36. {
  37. unsigned int i;
  38. for (i = 0; dash2underscore(input[i]) == paramname[i]; i++)
  39. if (input[i] == '\0')
  40. return 1;
  41. return 0;
  42. }
  43. static int parse_one(char *param,
  44. char *val,
  45. struct kernel_param *params,
  46. unsigned num_params,
  47. int (*handle_unknown)(char *param, char *val))
  48. {
  49. unsigned int i;
  50. /* Find parameter */
  51. for (i = 0; i < num_params; i++) {
  52. if (parameq(param, params[i].name)) {
  53. DEBUGP("They are equal! Calling %p\n",
  54. params[i].set);
  55. return params[i].set(val, &params[i]);
  56. }
  57. }
  58. if (handle_unknown) {
  59. DEBUGP("Unknown argument: calling %p\n", handle_unknown);
  60. return handle_unknown(param, val);
  61. }
  62. DEBUGP("Unknown argument `%s'\n", param);
  63. return -ENOENT;
  64. }
  65. /* You can use " around spaces, but can't escape ". */
  66. /* Hyphens and underscores equivalent in parameter names. */
  67. static char *next_arg(char *args, char **param, char **val)
  68. {
  69. unsigned int i, equals = 0;
  70. int in_quote = 0, quoted = 0;
  71. char *next;
  72. if (*args == '"') {
  73. args++;
  74. in_quote = 1;
  75. quoted = 1;
  76. }
  77. for (i = 0; args[i]; i++) {
  78. if (args[i] == ' ' && !in_quote)
  79. break;
  80. if (equals == 0) {
  81. if (args[i] == '=')
  82. equals = i;
  83. }
  84. if (args[i] == '"')
  85. in_quote = !in_quote;
  86. }
  87. *param = args;
  88. if (!equals)
  89. *val = NULL;
  90. else {
  91. args[equals] = '\0';
  92. *val = args + equals + 1;
  93. /* Don't include quotes in value. */
  94. if (**val == '"') {
  95. (*val)++;
  96. if (args[i-1] == '"')
  97. args[i-1] = '\0';
  98. }
  99. if (quoted && args[i-1] == '"')
  100. args[i-1] = '\0';
  101. }
  102. if (args[i]) {
  103. args[i] = '\0';
  104. next = args + i + 1;
  105. } else
  106. next = args + i;
  107. /* Chew up trailing spaces. */
  108. while (*next == ' ')
  109. next++;
  110. return next;
  111. }
  112. /* Args looks like "foo=bar,bar2 baz=fuz wiz". */
  113. int parse_args(const char *name,
  114. char *args,
  115. struct kernel_param *params,
  116. unsigned num,
  117. int (*unknown)(char *param, char *val))
  118. {
  119. char *param, *val;
  120. DEBUGP("Parsing ARGS: %s\n", args);
  121. /* Chew leading spaces */
  122. while (*args == ' ')
  123. args++;
  124. while (*args) {
  125. int ret;
  126. int irq_was_disabled;
  127. args = next_arg(args, &param, &val);
  128. irq_was_disabled = irqs_disabled();
  129. ret = parse_one(param, val, params, num, unknown);
  130. if (irq_was_disabled && !irqs_disabled()) {
  131. printk(KERN_WARNING "parse_args(): option '%s' enabled "
  132. "irq's!\n", param);
  133. }
  134. switch (ret) {
  135. case -ENOENT:
  136. printk(KERN_ERR "%s: Unknown parameter `%s'\n",
  137. name, param);
  138. return ret;
  139. case -ENOSPC:
  140. printk(KERN_ERR
  141. "%s: `%s' too large for parameter `%s'\n",
  142. name, val ?: "", param);
  143. return ret;
  144. case 0:
  145. break;
  146. default:
  147. printk(KERN_ERR
  148. "%s: `%s' invalid for parameter `%s'\n",
  149. name, val ?: "", param);
  150. return ret;
  151. }
  152. }
  153. /* All parsed OK. */
  154. return 0;
  155. }
  156. /* Lazy bastard, eh? */
  157. #define STANDARD_PARAM_DEF(name, type, format, tmptype, strtolfn) \
  158. int param_set_##name(const char *val, struct kernel_param *kp) \
  159. { \
  160. char *endp; \
  161. tmptype l; \
  162. \
  163. if (!val) return -EINVAL; \
  164. l = strtolfn(val, &endp, 0); \
  165. if (endp == val || ((type)l != l)) \
  166. return -EINVAL; \
  167. *((type *)kp->arg) = l; \
  168. return 0; \
  169. } \
  170. int param_get_##name(char *buffer, struct kernel_param *kp) \
  171. { \
  172. return sprintf(buffer, format, *((type *)kp->arg)); \
  173. }
  174. STANDARD_PARAM_DEF(byte, unsigned char, "%c", unsigned long, simple_strtoul);
  175. STANDARD_PARAM_DEF(short, short, "%hi", long, simple_strtol);
  176. STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, simple_strtoul);
  177. STANDARD_PARAM_DEF(int, int, "%i", long, simple_strtol);
  178. STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, simple_strtoul);
  179. STANDARD_PARAM_DEF(long, long, "%li", long, simple_strtol);
  180. STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, simple_strtoul);
  181. int param_set_charp(const char *val, struct kernel_param *kp)
  182. {
  183. if (!val) {
  184. printk(KERN_ERR "%s: string parameter expected\n",
  185. kp->name);
  186. return -EINVAL;
  187. }
  188. if (strlen(val) > 1024) {
  189. printk(KERN_ERR "%s: string parameter too long\n",
  190. kp->name);
  191. return -ENOSPC;
  192. }
  193. *(char **)kp->arg = (char *)val;
  194. return 0;
  195. }
  196. int param_get_charp(char *buffer, struct kernel_param *kp)
  197. {
  198. return sprintf(buffer, "%s", *((char **)kp->arg));
  199. }
  200. int param_set_bool(const char *val, struct kernel_param *kp)
  201. {
  202. /* No equals means "set"... */
  203. if (!val) val = "1";
  204. /* One of =[yYnN01] */
  205. switch (val[0]) {
  206. case 'y': case 'Y': case '1':
  207. *(int *)kp->arg = 1;
  208. return 0;
  209. case 'n': case 'N': case '0':
  210. *(int *)kp->arg = 0;
  211. return 0;
  212. }
  213. return -EINVAL;
  214. }
  215. int param_get_bool(char *buffer, struct kernel_param *kp)
  216. {
  217. /* Y and N chosen as being relatively non-coder friendly */
  218. return sprintf(buffer, "%c", (*(int *)kp->arg) ? 'Y' : 'N');
  219. }
  220. int param_set_invbool(const char *val, struct kernel_param *kp)
  221. {
  222. int boolval, ret;
  223. struct kernel_param dummy;
  224. dummy.arg = &boolval;
  225. ret = param_set_bool(val, &dummy);
  226. if (ret == 0)
  227. *(int *)kp->arg = !boolval;
  228. return ret;
  229. }
  230. int param_get_invbool(char *buffer, struct kernel_param *kp)
  231. {
  232. return sprintf(buffer, "%c", (*(int *)kp->arg) ? 'N' : 'Y');
  233. }
  234. /* We break the rule and mangle the string. */
  235. static int param_array(const char *name,
  236. const char *val,
  237. unsigned int min, unsigned int max,
  238. void *elem, int elemsize,
  239. int (*set)(const char *, struct kernel_param *kp),
  240. int *num)
  241. {
  242. int ret;
  243. struct kernel_param kp;
  244. char save;
  245. /* Get the name right for errors. */
  246. kp.name = name;
  247. kp.arg = elem;
  248. /* No equals sign? */
  249. if (!val) {
  250. printk(KERN_ERR "%s: expects arguments\n", name);
  251. return -EINVAL;
  252. }
  253. *num = 0;
  254. /* We expect a comma-separated list of values. */
  255. do {
  256. int len;
  257. if (*num == max) {
  258. printk(KERN_ERR "%s: can only take %i arguments\n",
  259. name, max);
  260. return -EINVAL;
  261. }
  262. len = strcspn(val, ",");
  263. /* nul-terminate and parse */
  264. save = val[len];
  265. ((char *)val)[len] = '\0';
  266. ret = set(val, &kp);
  267. if (ret != 0)
  268. return ret;
  269. kp.arg += elemsize;
  270. val += len+1;
  271. (*num)++;
  272. } while (save == ',');
  273. if (*num < min) {
  274. printk(KERN_ERR "%s: needs at least %i arguments\n",
  275. name, min);
  276. return -EINVAL;
  277. }
  278. return 0;
  279. }
  280. int param_array_set(const char *val, struct kernel_param *kp)
  281. {
  282. const struct kparam_array *arr = kp->arr;
  283. unsigned int temp_num;
  284. return param_array(kp->name, val, 1, arr->max, arr->elem,
  285. arr->elemsize, arr->set, arr->num ?: &temp_num);
  286. }
  287. int param_array_get(char *buffer, struct kernel_param *kp)
  288. {
  289. int i, off, ret;
  290. const struct kparam_array *arr = kp->arr;
  291. struct kernel_param p;
  292. p = *kp;
  293. for (i = off = 0; i < (arr->num ? *arr->num : arr->max); i++) {
  294. if (i)
  295. buffer[off++] = ',';
  296. p.arg = arr->elem + arr->elemsize * i;
  297. ret = arr->get(buffer + off, &p);
  298. if (ret < 0)
  299. return ret;
  300. off += ret;
  301. }
  302. buffer[off] = '\0';
  303. return off;
  304. }
  305. int param_set_copystring(const char *val, struct kernel_param *kp)
  306. {
  307. const struct kparam_string *kps = kp->str;
  308. if (!val) {
  309. printk(KERN_ERR "%s: missing param set value\n", kp->name);
  310. return -EINVAL;
  311. }
  312. if (strlen(val)+1 > kps->maxlen) {
  313. printk(KERN_ERR "%s: string doesn't fit in %u chars.\n",
  314. kp->name, kps->maxlen-1);
  315. return -ENOSPC;
  316. }
  317. strcpy(kps->string, val);
  318. return 0;
  319. }
  320. int param_get_string(char *buffer, struct kernel_param *kp)
  321. {
  322. const struct kparam_string *kps = kp->str;
  323. return strlcpy(buffer, kps->string, kps->maxlen);
  324. }
  325. /* sysfs output in /sys/modules/XYZ/parameters/ */
  326. extern struct kernel_param __start___param[], __stop___param[];
  327. #define MAX_KBUILD_MODNAME KOBJ_NAME_LEN
  328. struct param_attribute
  329. {
  330. struct module_attribute mattr;
  331. struct kernel_param *param;
  332. };
  333. struct module_param_attrs
  334. {
  335. struct attribute_group grp;
  336. struct param_attribute attrs[0];
  337. };
  338. #ifdef CONFIG_SYSFS
  339. #define to_param_attr(n) container_of(n, struct param_attribute, mattr);
  340. static ssize_t param_attr_show(struct module_attribute *mattr,
  341. struct module *mod, char *buf)
  342. {
  343. int count;
  344. struct param_attribute *attribute = to_param_attr(mattr);
  345. if (!attribute->param->get)
  346. return -EPERM;
  347. count = attribute->param->get(buf, attribute->param);
  348. if (count > 0) {
  349. strcat(buf, "\n");
  350. ++count;
  351. }
  352. return count;
  353. }
  354. /* sysfs always hands a nul-terminated string in buf. We rely on that. */
  355. static ssize_t param_attr_store(struct module_attribute *mattr,
  356. struct module *owner,
  357. const char *buf, size_t len)
  358. {
  359. int err;
  360. struct param_attribute *attribute = to_param_attr(mattr);
  361. if (!attribute->param->set)
  362. return -EPERM;
  363. err = attribute->param->set(buf, attribute->param);
  364. if (!err)
  365. return len;
  366. return err;
  367. }
  368. #endif
  369. #ifdef CONFIG_MODULES
  370. #define __modinit
  371. #else
  372. #define __modinit __init
  373. #endif
  374. #ifdef CONFIG_SYSFS
  375. /*
  376. * param_sysfs_setup - setup sysfs support for one module or KBUILD_MODNAME
  377. * @mk: struct module_kobject (contains parent kobject)
  378. * @kparam: array of struct kernel_param, the actual parameter definitions
  379. * @num_params: number of entries in array
  380. * @name_skip: offset where the parameter name start in kparam[].name. Needed for built-in "modules"
  381. *
  382. * Create a kobject for a (per-module) group of parameters, and create files
  383. * in sysfs. A pointer to the param_kobject is returned on success,
  384. * NULL if there's no parameter to export, or other ERR_PTR(err).
  385. */
  386. static __modinit struct module_param_attrs *
  387. param_sysfs_setup(struct module_kobject *mk,
  388. struct kernel_param *kparam,
  389. unsigned int num_params,
  390. unsigned int name_skip)
  391. {
  392. struct module_param_attrs *mp;
  393. unsigned int valid_attrs = 0;
  394. unsigned int i, size[2];
  395. struct param_attribute *pattr;
  396. struct attribute **gattr;
  397. int err;
  398. for (i=0; i<num_params; i++) {
  399. if (kparam[i].perm)
  400. valid_attrs++;
  401. }
  402. if (!valid_attrs)
  403. return NULL;
  404. size[0] = ALIGN(sizeof(*mp) +
  405. valid_attrs * sizeof(mp->attrs[0]),
  406. sizeof(mp->grp.attrs[0]));
  407. size[1] = (valid_attrs + 1) * sizeof(mp->grp.attrs[0]);
  408. mp = kmalloc(size[0] + size[1], GFP_KERNEL);
  409. if (!mp)
  410. return ERR_PTR(-ENOMEM);
  411. mp->grp.name = "parameters";
  412. mp->grp.attrs = (void *)mp + size[0];
  413. pattr = &mp->attrs[0];
  414. gattr = &mp->grp.attrs[0];
  415. for (i = 0; i < num_params; i++) {
  416. struct kernel_param *kp = &kparam[i];
  417. if (kp->perm) {
  418. pattr->param = kp;
  419. pattr->mattr.show = param_attr_show;
  420. pattr->mattr.store = param_attr_store;
  421. pattr->mattr.attr.name = (char *)&kp->name[name_skip];
  422. pattr->mattr.attr.mode = kp->perm;
  423. *(gattr++) = &(pattr++)->mattr.attr;
  424. }
  425. }
  426. *gattr = NULL;
  427. if ((err = sysfs_create_group(&mk->kobj, &mp->grp))) {
  428. kfree(mp);
  429. return ERR_PTR(err);
  430. }
  431. return mp;
  432. }
  433. #ifdef CONFIG_MODULES
  434. /*
  435. * module_param_sysfs_setup - setup sysfs support for one module
  436. * @mod: module
  437. * @kparam: module parameters (array)
  438. * @num_params: number of module parameters
  439. *
  440. * Adds sysfs entries for module parameters, and creates a link from
  441. * /sys/module/[mod->name]/parameters to /sys/parameters/[mod->name]/
  442. */
  443. int module_param_sysfs_setup(struct module *mod,
  444. struct kernel_param *kparam,
  445. unsigned int num_params)
  446. {
  447. struct module_param_attrs *mp;
  448. mp = param_sysfs_setup(&mod->mkobj, kparam, num_params, 0);
  449. if (IS_ERR(mp))
  450. return PTR_ERR(mp);
  451. mod->param_attrs = mp;
  452. return 0;
  453. }
  454. /*
  455. * module_param_sysfs_remove - remove sysfs support for one module
  456. * @mod: module
  457. *
  458. * Remove sysfs entries for module parameters and the corresponding
  459. * kobject.
  460. */
  461. void module_param_sysfs_remove(struct module *mod)
  462. {
  463. if (mod->param_attrs) {
  464. sysfs_remove_group(&mod->mkobj.kobj,
  465. &mod->param_attrs->grp);
  466. /* We are positive that no one is using any param
  467. * attrs at this point. Deallocate immediately. */
  468. kfree(mod->param_attrs);
  469. mod->param_attrs = NULL;
  470. }
  471. }
  472. #endif
  473. /*
  474. * kernel_param_sysfs_setup - wrapper for built-in params support
  475. */
  476. static void __init kernel_param_sysfs_setup(const char *name,
  477. struct kernel_param *kparam,
  478. unsigned int num_params,
  479. unsigned int name_skip)
  480. {
  481. struct module_kobject *mk;
  482. int ret;
  483. mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
  484. BUG_ON(!mk);
  485. mk->mod = THIS_MODULE;
  486. mk->kobj.kset = &module_subsys;
  487. mk->kobj.ktype = &module_ktype;
  488. kobject_set_name(&mk->kobj, name);
  489. kobject_init(&mk->kobj);
  490. ret = kobject_add(&mk->kobj);
  491. if (ret) {
  492. printk(KERN_ERR "Module '%s' failed to be added to sysfs, "
  493. "error number %d\n", name, ret);
  494. printk(KERN_ERR "The system will be unstable now.\n");
  495. return;
  496. }
  497. param_sysfs_setup(mk, kparam, num_params, name_skip);
  498. kobject_uevent(&mk->kobj, KOBJ_ADD);
  499. }
  500. /*
  501. * param_sysfs_builtin - add contents in /sys/parameters for built-in modules
  502. *
  503. * Add module_parameters to sysfs for "modules" built into the kernel.
  504. *
  505. * The "module" name (KBUILD_MODNAME) is stored before a dot, the
  506. * "parameter" name is stored behind a dot in kernel_param->name. So,
  507. * extract the "module" name for all built-in kernel_param-eters,
  508. * and for all who have the same, call kernel_param_sysfs_setup.
  509. */
  510. static void __init param_sysfs_builtin(void)
  511. {
  512. struct kernel_param *kp, *kp_begin = NULL;
  513. unsigned int i, name_len, count = 0;
  514. char modname[MAX_KBUILD_MODNAME + 1] = "";
  515. for (i=0; i < __stop___param - __start___param; i++) {
  516. char *dot;
  517. size_t max_name_len;
  518. kp = &__start___param[i];
  519. max_name_len =
  520. min_t(size_t, MAX_KBUILD_MODNAME, strlen(kp->name));
  521. dot = memchr(kp->name, '.', max_name_len);
  522. if (!dot) {
  523. DEBUGP("couldn't find period in first %d characters "
  524. "of %s\n", MAX_KBUILD_MODNAME, kp->name);
  525. continue;
  526. }
  527. name_len = dot - kp->name;
  528. /* new kbuild_modname? */
  529. if (strlen(modname) != name_len
  530. || strncmp(modname, kp->name, name_len) != 0) {
  531. /* add a new kobject for previous kernel_params. */
  532. if (count)
  533. kernel_param_sysfs_setup(modname,
  534. kp_begin,
  535. count,
  536. strlen(modname)+1);
  537. strncpy(modname, kp->name, name_len);
  538. modname[name_len] = '\0';
  539. count = 0;
  540. kp_begin = kp;
  541. }
  542. count++;
  543. }
  544. /* last kernel_params need to be registered as well */
  545. if (count)
  546. kernel_param_sysfs_setup(modname, kp_begin, count,
  547. strlen(modname)+1);
  548. }
  549. /* module-related sysfs stuff */
  550. #define to_module_attr(n) container_of(n, struct module_attribute, attr);
  551. #define to_module_kobject(n) container_of(n, struct module_kobject, kobj);
  552. static ssize_t module_attr_show(struct kobject *kobj,
  553. struct attribute *attr,
  554. char *buf)
  555. {
  556. struct module_attribute *attribute;
  557. struct module_kobject *mk;
  558. int ret;
  559. attribute = to_module_attr(attr);
  560. mk = to_module_kobject(kobj);
  561. if (!attribute->show)
  562. return -EIO;
  563. ret = attribute->show(attribute, mk->mod, buf);
  564. return ret;
  565. }
  566. static ssize_t module_attr_store(struct kobject *kobj,
  567. struct attribute *attr,
  568. const char *buf, size_t len)
  569. {
  570. struct module_attribute *attribute;
  571. struct module_kobject *mk;
  572. int ret;
  573. attribute = to_module_attr(attr);
  574. mk = to_module_kobject(kobj);
  575. if (!attribute->store)
  576. return -EIO;
  577. ret = attribute->store(attribute, mk->mod, buf, len);
  578. return ret;
  579. }
  580. static struct sysfs_ops module_sysfs_ops = {
  581. .show = module_attr_show,
  582. .store = module_attr_store,
  583. };
  584. static int uevent_filter(struct kset *kset, struct kobject *kobj)
  585. {
  586. struct kobj_type *ktype = get_ktype(kobj);
  587. if (ktype == &module_ktype)
  588. return 1;
  589. return 0;
  590. }
  591. static struct kset_uevent_ops module_uevent_ops = {
  592. .filter = uevent_filter,
  593. };
  594. decl_subsys(module, &module_uevent_ops);
  595. int module_sysfs_initialized;
  596. static void module_release(struct kobject *kobj)
  597. {
  598. /*
  599. * Stupid empty release function to allow the memory for the kobject to
  600. * be properly cleaned up. This will not need to be present for 2.6.25
  601. * with the upcoming kobject core rework.
  602. */
  603. }
  604. static struct kobj_type module_ktype = {
  605. .sysfs_ops = &module_sysfs_ops,
  606. .release = module_release,
  607. };
  608. /*
  609. * param_sysfs_init - wrapper for built-in params support
  610. */
  611. static int __init param_sysfs_init(void)
  612. {
  613. int ret;
  614. ret = subsystem_register(&module_subsys);
  615. if (ret < 0) {
  616. printk(KERN_WARNING "%s (%d): subsystem_register error: %d\n",
  617. __FILE__, __LINE__, ret);
  618. return ret;
  619. }
  620. module_sysfs_initialized = 1;
  621. param_sysfs_builtin();
  622. return 0;
  623. }
  624. subsys_initcall(param_sysfs_init);
  625. #else
  626. #if 0
  627. static struct sysfs_ops module_sysfs_ops = {
  628. .show = NULL,
  629. .store = NULL,
  630. };
  631. #endif
  632. #endif
  633. EXPORT_SYMBOL(param_set_byte);
  634. EXPORT_SYMBOL(param_get_byte);
  635. EXPORT_SYMBOL(param_set_short);
  636. EXPORT_SYMBOL(param_get_short);
  637. EXPORT_SYMBOL(param_set_ushort);
  638. EXPORT_SYMBOL(param_get_ushort);
  639. EXPORT_SYMBOL(param_set_int);
  640. EXPORT_SYMBOL(param_get_int);
  641. EXPORT_SYMBOL(param_set_uint);
  642. EXPORT_SYMBOL(param_get_uint);
  643. EXPORT_SYMBOL(param_set_long);
  644. EXPORT_SYMBOL(param_get_long);
  645. EXPORT_SYMBOL(param_set_ulong);
  646. EXPORT_SYMBOL(param_get_ulong);
  647. EXPORT_SYMBOL(param_set_charp);
  648. EXPORT_SYMBOL(param_get_charp);
  649. EXPORT_SYMBOL(param_set_bool);
  650. EXPORT_SYMBOL(param_get_bool);
  651. EXPORT_SYMBOL(param_set_invbool);
  652. EXPORT_SYMBOL(param_get_invbool);
  653. EXPORT_SYMBOL(param_array_set);
  654. EXPORT_SYMBOL(param_array_get);
  655. EXPORT_SYMBOL(param_set_copystring);
  656. EXPORT_SYMBOL(param_get_string);