openprom.c 16 KB

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