openprom.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. /*
  2. * Linux/SPARC PROM Configuration Driver
  3. * Copyright (C) 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
  4. * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
  5. *
  6. * This character device driver allows user programs to access the
  7. * PROM device tree. It is compatible with the SunOS /dev/openprom
  8. * driver and the NetBSD /dev/openprom driver. The SunOS eeprom
  9. * utility works without any modifications.
  10. *
  11. * The driver uses a minor number under the misc device major. The
  12. * file read/write mode determines the type of access to the PROM.
  13. * Interrupts are disabled whenever the driver calls into the PROM for
  14. * sanity's sake.
  15. */
  16. /* This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation; either version 2 of the
  19. * License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful, but
  22. * WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  24. * General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. */
  30. #include <linux/module.h>
  31. #include <linux/kernel.h>
  32. #include <linux/errno.h>
  33. #include <linux/slab.h>
  34. #include <linux/mutex.h>
  35. #include <linux/string.h>
  36. #include <linux/miscdevice.h>
  37. #include <linux/init.h>
  38. #include <linux/fs.h>
  39. #include <asm/oplib.h>
  40. #include <asm/prom.h>
  41. #include <asm/uaccess.h>
  42. #include <asm/openpromio.h>
  43. #ifdef CONFIG_PCI
  44. #include <linux/pci.h>
  45. #endif
  46. MODULE_AUTHOR("Thomas K. Dyas (tdyas@noc.rutgers.edu) and Eddie C. Dost (ecd@skynet.be)");
  47. MODULE_DESCRIPTION("OPENPROM Configuration Driver");
  48. MODULE_LICENSE("GPL");
  49. MODULE_VERSION("1.0");
  50. MODULE_ALIAS_MISCDEV(SUN_OPENPROM_MINOR);
  51. /* Private data kept by the driver for each descriptor. */
  52. typedef struct openprom_private_data
  53. {
  54. struct device_node *current_node; /* Current node for SunOS ioctls. */
  55. struct device_node *lastnode; /* Last valid node used by BSD ioctls. */
  56. } DATA;
  57. /* ID of the PROM node containing all of the EEPROM options. */
  58. static DEFINE_MUTEX(openprom_mutex);
  59. static struct device_node *options_node;
  60. /*
  61. * Copy an openpromio structure into kernel space from user space.
  62. * This routine does error checking to make sure that all memory
  63. * accesses are within bounds. A pointer to the allocated openpromio
  64. * structure will be placed in "*opp_p". Return value is the length
  65. * of the user supplied buffer.
  66. */
  67. static int copyin(struct openpromio __user *info, struct openpromio **opp_p)
  68. {
  69. unsigned int bufsize;
  70. if (!info || !opp_p)
  71. return -EFAULT;
  72. if (get_user(bufsize, &info->oprom_size))
  73. return -EFAULT;
  74. if (bufsize == 0)
  75. return -EINVAL;
  76. /* If the bufsize is too large, just limit it.
  77. * Fix from Jason Rappleye.
  78. */
  79. if (bufsize > OPROMMAXPARAM)
  80. bufsize = OPROMMAXPARAM;
  81. if (!(*opp_p = kzalloc(sizeof(int) + bufsize + 1, GFP_KERNEL)))
  82. return -ENOMEM;
  83. if (copy_from_user(&(*opp_p)->oprom_array,
  84. &info->oprom_array, bufsize)) {
  85. kfree(*opp_p);
  86. return -EFAULT;
  87. }
  88. return bufsize;
  89. }
  90. static int getstrings(struct openpromio __user *info, struct openpromio **opp_p)
  91. {
  92. int n, bufsize;
  93. char c;
  94. if (!info || !opp_p)
  95. return -EFAULT;
  96. if (!(*opp_p = kzalloc(sizeof(int) + OPROMMAXPARAM + 1, GFP_KERNEL)))
  97. return -ENOMEM;
  98. (*opp_p)->oprom_size = 0;
  99. n = bufsize = 0;
  100. while ((n < 2) && (bufsize < OPROMMAXPARAM)) {
  101. if (get_user(c, &info->oprom_array[bufsize])) {
  102. kfree(*opp_p);
  103. return -EFAULT;
  104. }
  105. if (c == '\0')
  106. n++;
  107. (*opp_p)->oprom_array[bufsize++] = c;
  108. }
  109. if (!n) {
  110. kfree(*opp_p);
  111. return -EINVAL;
  112. }
  113. return bufsize;
  114. }
  115. /*
  116. * Copy an openpromio structure in kernel space back to user space.
  117. */
  118. static int copyout(void __user *info, struct openpromio *opp, int len)
  119. {
  120. if (copy_to_user(info, opp, len))
  121. return -EFAULT;
  122. return 0;
  123. }
  124. static int opromgetprop(void __user *argp, struct device_node *dp, struct openpromio *op, int bufsize)
  125. {
  126. const void *pval;
  127. int len;
  128. if (!dp ||
  129. !(pval = of_get_property(dp, op->oprom_array, &len)) ||
  130. len <= 0 || len > bufsize)
  131. return copyout(argp, op, sizeof(int));
  132. memcpy(op->oprom_array, pval, len);
  133. op->oprom_array[len] = '\0';
  134. op->oprom_size = len;
  135. return copyout(argp, op, sizeof(int) + bufsize);
  136. }
  137. static int opromnxtprop(void __user *argp, struct device_node *dp, struct openpromio *op, int bufsize)
  138. {
  139. struct property *prop;
  140. int len;
  141. if (!dp)
  142. return copyout(argp, op, sizeof(int));
  143. if (op->oprom_array[0] == '\0') {
  144. prop = dp->properties;
  145. if (!prop)
  146. return copyout(argp, op, sizeof(int));
  147. len = strlen(prop->name);
  148. } else {
  149. prop = of_find_property(dp, op->oprom_array, NULL);
  150. if (!prop ||
  151. !prop->next ||
  152. (len = strlen(prop->next->name)) + 1 > bufsize)
  153. return copyout(argp, op, sizeof(int));
  154. prop = prop->next;
  155. }
  156. memcpy(op->oprom_array, prop->name, len);
  157. op->oprom_array[len] = '\0';
  158. op->oprom_size = ++len;
  159. return copyout(argp, op, sizeof(int) + bufsize);
  160. }
  161. static int opromsetopt(struct device_node *dp, struct openpromio *op, int bufsize)
  162. {
  163. char *buf = op->oprom_array + strlen(op->oprom_array) + 1;
  164. int len = op->oprom_array + bufsize - buf;
  165. return of_set_property(options_node, op->oprom_array, buf, len);
  166. }
  167. static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp, struct openpromio *op, int bufsize, DATA *data)
  168. {
  169. phandle ph;
  170. BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
  171. if (bufsize < sizeof(phandle))
  172. return -EINVAL;
  173. ph = *((int *) op->oprom_array);
  174. if (ph) {
  175. dp = of_find_node_by_phandle(ph);
  176. if (!dp)
  177. return -EINVAL;
  178. switch (cmd) {
  179. case OPROMNEXT:
  180. dp = dp->sibling;
  181. break;
  182. case OPROMCHILD:
  183. dp = dp->child;
  184. break;
  185. case OPROMSETCUR:
  186. default:
  187. break;
  188. }
  189. } else {
  190. /* Sibling of node zero is the root node. */
  191. if (cmd != OPROMNEXT)
  192. return -EINVAL;
  193. dp = of_find_node_by_path("/");
  194. }
  195. ph = 0;
  196. if (dp)
  197. ph = dp->phandle;
  198. data->current_node = dp;
  199. *((int *) op->oprom_array) = ph;
  200. op->oprom_size = sizeof(phandle);
  201. return copyout(argp, op, bufsize + sizeof(int));
  202. }
  203. static int oprompci2node(void __user *argp, struct device_node *dp, struct openpromio *op, int bufsize, DATA *data)
  204. {
  205. int err = -EINVAL;
  206. if (bufsize >= 2*sizeof(int)) {
  207. #ifdef CONFIG_PCI
  208. struct pci_dev *pdev;
  209. struct device_node *dp;
  210. pdev = pci_get_bus_and_slot (((int *) op->oprom_array)[0],
  211. ((int *) op->oprom_array)[1]);
  212. dp = pci_device_to_OF_node(pdev);
  213. data->current_node = dp;
  214. *((int *)op->oprom_array) = dp->phandle;
  215. op->oprom_size = sizeof(int);
  216. err = copyout(argp, op, bufsize + sizeof(int));
  217. pci_dev_put(pdev);
  218. #endif
  219. }
  220. return err;
  221. }
  222. static int oprompath2node(void __user *argp, struct device_node *dp, struct openpromio *op, int bufsize, DATA *data)
  223. {
  224. phandle ph = 0;
  225. dp = of_find_node_by_path(op->oprom_array);
  226. if (dp)
  227. ph = dp->phandle;
  228. data->current_node = dp;
  229. *((int *)op->oprom_array) = ph;
  230. op->oprom_size = sizeof(int);
  231. return copyout(argp, op, bufsize + sizeof(int));
  232. }
  233. static int opromgetbootargs(void __user *argp, struct openpromio *op, int bufsize)
  234. {
  235. char *buf = saved_command_line;
  236. int len = strlen(buf);
  237. if (len > bufsize)
  238. return -EINVAL;
  239. strcpy(op->oprom_array, buf);
  240. op->oprom_size = len;
  241. return copyout(argp, op, bufsize + sizeof(int));
  242. }
  243. /*
  244. * SunOS and Solaris /dev/openprom ioctl calls.
  245. */
  246. static long openprom_sunos_ioctl(struct file * file,
  247. unsigned int cmd, unsigned long arg,
  248. struct device_node *dp)
  249. {
  250. DATA *data = file->private_data;
  251. struct openpromio *opp = NULL;
  252. int bufsize, error = 0;
  253. static int cnt;
  254. void __user *argp = (void __user *)arg;
  255. if (cmd == OPROMSETOPT)
  256. bufsize = getstrings(argp, &opp);
  257. else
  258. bufsize = copyin(argp, &opp);
  259. if (bufsize < 0)
  260. return bufsize;
  261. mutex_lock(&openprom_mutex);
  262. switch (cmd) {
  263. case OPROMGETOPT:
  264. case OPROMGETPROP:
  265. error = opromgetprop(argp, dp, opp, bufsize);
  266. break;
  267. case OPROMNXTOPT:
  268. case OPROMNXTPROP:
  269. error = opromnxtprop(argp, dp, opp, bufsize);
  270. break;
  271. case OPROMSETOPT:
  272. case OPROMSETOPT2:
  273. error = opromsetopt(dp, opp, bufsize);
  274. break;
  275. case OPROMNEXT:
  276. case OPROMCHILD:
  277. case OPROMSETCUR:
  278. error = opromnext(argp, cmd, dp, opp, bufsize, data);
  279. break;
  280. case OPROMPCI2NODE:
  281. error = oprompci2node(argp, dp, opp, bufsize, data);
  282. break;
  283. case OPROMPATH2NODE:
  284. error = oprompath2node(argp, dp, opp, bufsize, data);
  285. break;
  286. case OPROMGETBOOTARGS:
  287. error = opromgetbootargs(argp, opp, bufsize);
  288. break;
  289. case OPROMU2P:
  290. case OPROMGETCONS:
  291. case OPROMGETFBNAME:
  292. if (cnt++ < 10)
  293. printk(KERN_INFO "openprom_sunos_ioctl: unimplemented ioctl\n");
  294. error = -EINVAL;
  295. break;
  296. default:
  297. if (cnt++ < 10)
  298. printk(KERN_INFO "openprom_sunos_ioctl: cmd 0x%X, arg 0x%lX\n", cmd, arg);
  299. error = -EINVAL;
  300. break;
  301. }
  302. kfree(opp);
  303. mutex_unlock(&openprom_mutex);
  304. return error;
  305. }
  306. static struct device_node *get_node(phandle n, DATA *data)
  307. {
  308. struct device_node *dp = of_find_node_by_phandle(n);
  309. if (dp)
  310. data->lastnode = dp;
  311. return dp;
  312. }
  313. /* Copy in a whole string from userspace into kernelspace. */
  314. static int copyin_string(char __user *user, size_t len, char **ptr)
  315. {
  316. char *tmp;
  317. if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0)
  318. return -EINVAL;
  319. tmp = kmalloc(len + 1, GFP_KERNEL);
  320. if (!tmp)
  321. return -ENOMEM;
  322. if (copy_from_user(tmp, user, len)) {
  323. kfree(tmp);
  324. return -EFAULT;
  325. }
  326. tmp[len] = '\0';
  327. *ptr = tmp;
  328. return 0;
  329. }
  330. /*
  331. * NetBSD /dev/openprom ioctl calls.
  332. */
  333. static int opiocget(void __user *argp, DATA *data)
  334. {
  335. struct opiocdesc op;
  336. struct device_node *dp;
  337. char *str;
  338. const void *pval;
  339. int err, len;
  340. if (copy_from_user(&op, argp, sizeof(op)))
  341. return -EFAULT;
  342. dp = get_node(op.op_nodeid, data);
  343. err = copyin_string(op.op_name, op.op_namelen, &str);
  344. if (err)
  345. return err;
  346. pval = of_get_property(dp, str, &len);
  347. err = 0;
  348. if (!pval || len > op.op_buflen) {
  349. err = -EINVAL;
  350. } else {
  351. op.op_buflen = len;
  352. if (copy_to_user(argp, &op, sizeof(op)) ||
  353. copy_to_user(op.op_buf, pval, len))
  354. err = -EFAULT;
  355. }
  356. kfree(str);
  357. return err;
  358. }
  359. static int opiocnextprop(void __user *argp, DATA *data)
  360. {
  361. struct opiocdesc op;
  362. struct device_node *dp;
  363. struct property *prop;
  364. char *str;
  365. int err, len;
  366. if (copy_from_user(&op, argp, sizeof(op)))
  367. return -EFAULT;
  368. dp = get_node(op.op_nodeid, data);
  369. if (!dp)
  370. return -EINVAL;
  371. err = copyin_string(op.op_name, op.op_namelen, &str);
  372. if (err)
  373. return err;
  374. if (str[0] == '\0') {
  375. prop = dp->properties;
  376. } else {
  377. prop = of_find_property(dp, str, NULL);
  378. if (prop)
  379. prop = prop->next;
  380. }
  381. kfree(str);
  382. if (!prop)
  383. len = 0;
  384. else
  385. len = prop->length;
  386. if (len > op.op_buflen)
  387. len = op.op_buflen;
  388. if (copy_to_user(argp, &op, sizeof(op)))
  389. return -EFAULT;
  390. if (len &&
  391. copy_to_user(op.op_buf, prop->value, len))
  392. return -EFAULT;
  393. return 0;
  394. }
  395. static int opiocset(void __user *argp, DATA *data)
  396. {
  397. struct opiocdesc op;
  398. struct device_node *dp;
  399. char *str, *tmp;
  400. int err;
  401. if (copy_from_user(&op, argp, sizeof(op)))
  402. return -EFAULT;
  403. dp = get_node(op.op_nodeid, data);
  404. if (!dp)
  405. return -EINVAL;
  406. err = copyin_string(op.op_name, op.op_namelen, &str);
  407. if (err)
  408. return err;
  409. err = copyin_string(op.op_buf, op.op_buflen, &tmp);
  410. if (err) {
  411. kfree(str);
  412. return err;
  413. }
  414. err = of_set_property(dp, str, tmp, op.op_buflen);
  415. kfree(str);
  416. kfree(tmp);
  417. return err;
  418. }
  419. static int opiocgetnext(unsigned int cmd, void __user *argp)
  420. {
  421. struct device_node *dp;
  422. phandle nd;
  423. BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
  424. if (copy_from_user(&nd, argp, sizeof(phandle)))
  425. return -EFAULT;
  426. if (nd == 0) {
  427. if (cmd != OPIOCGETNEXT)
  428. return -EINVAL;
  429. dp = of_find_node_by_path("/");
  430. } else {
  431. dp = of_find_node_by_phandle(nd);
  432. nd = 0;
  433. if (dp) {
  434. if (cmd == OPIOCGETNEXT)
  435. dp = dp->sibling;
  436. else
  437. dp = dp->child;
  438. }
  439. }
  440. if (dp)
  441. nd = dp->phandle;
  442. if (copy_to_user(argp, &nd, sizeof(phandle)))
  443. return -EFAULT;
  444. return 0;
  445. }
  446. static int openprom_bsd_ioctl(struct file * file,
  447. unsigned int cmd, unsigned long arg)
  448. {
  449. DATA *data = file->private_data;
  450. void __user *argp = (void __user *)arg;
  451. int err;
  452. mutex_lock(&openprom_mutex);
  453. switch (cmd) {
  454. case OPIOCGET:
  455. err = opiocget(argp, data);
  456. break;
  457. case OPIOCNEXTPROP:
  458. err = opiocnextprop(argp, data);
  459. break;
  460. case OPIOCSET:
  461. err = opiocset(argp, data);
  462. break;
  463. case OPIOCGETOPTNODE:
  464. BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
  465. err = 0;
  466. if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
  467. err = -EFAULT;
  468. break;
  469. case OPIOCGETNEXT:
  470. case OPIOCGETCHILD:
  471. err = opiocgetnext(cmd, argp);
  472. break;
  473. default:
  474. err = -EINVAL;
  475. break;
  476. }
  477. mutex_unlock(&openprom_mutex);
  478. return err;
  479. }
  480. /*
  481. * Handoff control to the correct ioctl handler.
  482. */
  483. static long openprom_ioctl(struct file * file,
  484. unsigned int cmd, unsigned long arg)
  485. {
  486. DATA *data = file->private_data;
  487. switch (cmd) {
  488. case OPROMGETOPT:
  489. case OPROMNXTOPT:
  490. if ((file->f_mode & FMODE_READ) == 0)
  491. return -EPERM;
  492. return openprom_sunos_ioctl(file, cmd, arg,
  493. options_node);
  494. case OPROMSETOPT:
  495. case OPROMSETOPT2:
  496. if ((file->f_mode & FMODE_WRITE) == 0)
  497. return -EPERM;
  498. return openprom_sunos_ioctl(file, cmd, arg,
  499. options_node);
  500. case OPROMNEXT:
  501. case OPROMCHILD:
  502. case OPROMGETPROP:
  503. case OPROMNXTPROP:
  504. if ((file->f_mode & FMODE_READ) == 0)
  505. return -EPERM;
  506. return openprom_sunos_ioctl(file, cmd, arg,
  507. data->current_node);
  508. case OPROMU2P:
  509. case OPROMGETCONS:
  510. case OPROMGETFBNAME:
  511. case OPROMGETBOOTARGS:
  512. case OPROMSETCUR:
  513. case OPROMPCI2NODE:
  514. case OPROMPATH2NODE:
  515. if ((file->f_mode & FMODE_READ) == 0)
  516. return -EPERM;
  517. return openprom_sunos_ioctl(file, cmd, arg, NULL);
  518. case OPIOCGET:
  519. case OPIOCNEXTPROP:
  520. case OPIOCGETOPTNODE:
  521. case OPIOCGETNEXT:
  522. case OPIOCGETCHILD:
  523. if ((file->f_mode & FMODE_READ) == 0)
  524. return -EBADF;
  525. return openprom_bsd_ioctl(file,cmd,arg);
  526. case OPIOCSET:
  527. if ((file->f_mode & FMODE_WRITE) == 0)
  528. return -EBADF;
  529. return openprom_bsd_ioctl(file,cmd,arg);
  530. default:
  531. return -EINVAL;
  532. };
  533. }
  534. static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
  535. unsigned long arg)
  536. {
  537. long rval = -ENOTTY;
  538. /*
  539. * SunOS/Solaris only, the NetBSD one's have embedded pointers in
  540. * the arg which we'd need to clean up...
  541. */
  542. switch (cmd) {
  543. case OPROMGETOPT:
  544. case OPROMSETOPT:
  545. case OPROMNXTOPT:
  546. case OPROMSETOPT2:
  547. case OPROMNEXT:
  548. case OPROMCHILD:
  549. case OPROMGETPROP:
  550. case OPROMNXTPROP:
  551. case OPROMU2P:
  552. case OPROMGETCONS:
  553. case OPROMGETFBNAME:
  554. case OPROMGETBOOTARGS:
  555. case OPROMSETCUR:
  556. case OPROMPCI2NODE:
  557. case OPROMPATH2NODE:
  558. rval = openprom_ioctl(file, cmd, arg);
  559. break;
  560. }
  561. return rval;
  562. }
  563. static int openprom_open(struct inode * inode, struct file * file)
  564. {
  565. DATA *data;
  566. data = kmalloc(sizeof(DATA), GFP_KERNEL);
  567. if (!data)
  568. return -ENOMEM;
  569. mutex_lock(&openprom_mutex);
  570. data->current_node = of_find_node_by_path("/");
  571. data->lastnode = data->current_node;
  572. file->private_data = (void *) data;
  573. mutex_unlock(&openprom_mutex);
  574. return 0;
  575. }
  576. static int openprom_release(struct inode * inode, struct file * file)
  577. {
  578. kfree(file->private_data);
  579. return 0;
  580. }
  581. static const struct file_operations openprom_fops = {
  582. .owner = THIS_MODULE,
  583. .llseek = no_llseek,
  584. .unlocked_ioctl = openprom_ioctl,
  585. .compat_ioctl = openprom_compat_ioctl,
  586. .open = openprom_open,
  587. .release = openprom_release,
  588. };
  589. static struct miscdevice openprom_dev = {
  590. .minor = SUN_OPENPROM_MINOR,
  591. .name = "openprom",
  592. .fops = &openprom_fops,
  593. };
  594. static int __init openprom_init(void)
  595. {
  596. struct device_node *dp;
  597. int err;
  598. err = misc_register(&openprom_dev);
  599. if (err)
  600. return err;
  601. dp = of_find_node_by_path("/");
  602. dp = dp->child;
  603. while (dp) {
  604. if (!strcmp(dp->name, "options"))
  605. break;
  606. dp = dp->sibling;
  607. }
  608. options_node = dp;
  609. if (!options_node) {
  610. misc_deregister(&openprom_dev);
  611. return -EIO;
  612. }
  613. return 0;
  614. }
  615. static void __exit openprom_cleanup(void)
  616. {
  617. misc_deregister(&openprom_dev);
  618. }
  619. module_init(openprom_init);
  620. module_exit(openprom_cleanup);