resource.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. /*
  2. * resource.c - Contains functions for registering and analyzing resource information
  3. *
  4. * based on isapnp.c resource management (c) Jaroslav Kysela <perex@perex.cz>
  5. * Copyright 2003 Adam Belay <ambx1@neo.rr.com>
  6. */
  7. #include <linux/module.h>
  8. #include <linux/errno.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/kernel.h>
  11. #include <asm/io.h>
  12. #include <asm/dma.h>
  13. #include <asm/irq.h>
  14. #include <linux/pci.h>
  15. #include <linux/ioport.h>
  16. #include <linux/init.h>
  17. #include <linux/pnp.h>
  18. #include "base.h"
  19. static int pnp_reserve_irq[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some IRQ */
  20. static int pnp_reserve_dma[8] = {[0 ... 7] = -1 }; /* reserve (don't use) some DMA */
  21. static int pnp_reserve_io[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some I/O region */
  22. static int pnp_reserve_mem[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some memory region */
  23. /*
  24. * option registration
  25. */
  26. struct pnp_option *pnp_build_option(int priority)
  27. {
  28. struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option));
  29. if (!option)
  30. return NULL;
  31. option->priority = priority & 0xff;
  32. /* make sure the priority is valid */
  33. if (option->priority > PNP_RES_PRIORITY_FUNCTIONAL)
  34. option->priority = PNP_RES_PRIORITY_INVALID;
  35. return option;
  36. }
  37. struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev)
  38. {
  39. struct pnp_option *option;
  40. option = pnp_build_option(PNP_RES_PRIORITY_PREFERRED);
  41. /* this should never happen but if it does we'll try to continue */
  42. if (dev->independent)
  43. dev_err(&dev->dev, "independent resource already registered\n");
  44. dev->independent = option;
  45. dev_dbg(&dev->dev, "new independent option\n");
  46. return option;
  47. }
  48. struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
  49. int priority)
  50. {
  51. struct pnp_option *option;
  52. option = pnp_build_option(priority);
  53. if (dev->dependent) {
  54. struct pnp_option *parent = dev->dependent;
  55. while (parent->next)
  56. parent = parent->next;
  57. parent->next = option;
  58. } else
  59. dev->dependent = option;
  60. dev_dbg(&dev->dev, "new dependent option (priority %#x)\n", priority);
  61. return option;
  62. }
  63. int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
  64. struct pnp_irq *data)
  65. {
  66. struct pnp_irq *ptr;
  67. #ifdef DEBUG
  68. char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */
  69. #endif
  70. ptr = option->irq;
  71. while (ptr && ptr->next)
  72. ptr = ptr->next;
  73. if (ptr)
  74. ptr->next = data;
  75. else
  76. option->irq = data;
  77. #ifdef CONFIG_PCI
  78. {
  79. int i;
  80. for (i = 0; i < 16; i++)
  81. if (test_bit(i, data->map))
  82. pcibios_penalize_isa_irq(i, 0);
  83. }
  84. #endif
  85. #ifdef DEBUG
  86. bitmap_scnprintf(buf, sizeof(buf), data->map, PNP_IRQ_NR);
  87. dev_dbg(&dev->dev, " irq bitmask %s flags %#x\n", buf,
  88. data->flags);
  89. #endif
  90. return 0;
  91. }
  92. int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
  93. struct pnp_dma *data)
  94. {
  95. struct pnp_dma *ptr;
  96. ptr = option->dma;
  97. while (ptr && ptr->next)
  98. ptr = ptr->next;
  99. if (ptr)
  100. ptr->next = data;
  101. else
  102. option->dma = data;
  103. dev_dbg(&dev->dev, " dma bitmask %#x flags %#x\n", data->map,
  104. data->flags);
  105. return 0;
  106. }
  107. int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
  108. struct pnp_port *data)
  109. {
  110. struct pnp_port *ptr;
  111. ptr = option->port;
  112. while (ptr && ptr->next)
  113. ptr = ptr->next;
  114. if (ptr)
  115. ptr->next = data;
  116. else
  117. option->port = data;
  118. dev_dbg(&dev->dev, " io "
  119. "min %#x max %#x align %d size %d flags %#x\n",
  120. data->min, data->max, data->align, data->size, data->flags);
  121. return 0;
  122. }
  123. int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option,
  124. struct pnp_mem *data)
  125. {
  126. struct pnp_mem *ptr;
  127. ptr = option->mem;
  128. while (ptr && ptr->next)
  129. ptr = ptr->next;
  130. if (ptr)
  131. ptr->next = data;
  132. else
  133. option->mem = data;
  134. dev_dbg(&dev->dev, " mem "
  135. "min %#x max %#x align %d size %d flags %#x\n",
  136. data->min, data->max, data->align, data->size, data->flags);
  137. return 0;
  138. }
  139. static void pnp_free_port(struct pnp_port *port)
  140. {
  141. struct pnp_port *next;
  142. while (port) {
  143. next = port->next;
  144. kfree(port);
  145. port = next;
  146. }
  147. }
  148. static void pnp_free_irq(struct pnp_irq *irq)
  149. {
  150. struct pnp_irq *next;
  151. while (irq) {
  152. next = irq->next;
  153. kfree(irq);
  154. irq = next;
  155. }
  156. }
  157. static void pnp_free_dma(struct pnp_dma *dma)
  158. {
  159. struct pnp_dma *next;
  160. while (dma) {
  161. next = dma->next;
  162. kfree(dma);
  163. dma = next;
  164. }
  165. }
  166. static void pnp_free_mem(struct pnp_mem *mem)
  167. {
  168. struct pnp_mem *next;
  169. while (mem) {
  170. next = mem->next;
  171. kfree(mem);
  172. mem = next;
  173. }
  174. }
  175. void pnp_free_option(struct pnp_option *option)
  176. {
  177. struct pnp_option *next;
  178. while (option) {
  179. next = option->next;
  180. pnp_free_port(option->port);
  181. pnp_free_irq(option->irq);
  182. pnp_free_dma(option->dma);
  183. pnp_free_mem(option->mem);
  184. kfree(option);
  185. option = next;
  186. }
  187. }
  188. /*
  189. * resource validity checking
  190. */
  191. #define length(start, end) (*(end) - *(start) + 1)
  192. /* Two ranges conflict if one doesn't end before the other starts */
  193. #define ranged_conflict(starta, enda, startb, endb) \
  194. !((*(enda) < *(startb)) || (*(endb) < *(starta)))
  195. #define cannot_compare(flags) \
  196. ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED))
  197. int pnp_check_port(struct pnp_dev *dev, struct resource *res)
  198. {
  199. int i;
  200. struct pnp_dev *tdev;
  201. struct resource *tres;
  202. resource_size_t *port, *end, *tport, *tend;
  203. port = &res->start;
  204. end = &res->end;
  205. /* if the resource doesn't exist, don't complain about it */
  206. if (cannot_compare(res->flags))
  207. return 1;
  208. /* check if the resource is already in use, skip if the
  209. * device is active because it itself may be in use */
  210. if (!dev->active) {
  211. if (__check_region(&ioport_resource, *port, length(port, end)))
  212. return 0;
  213. }
  214. /* check if the resource is reserved */
  215. for (i = 0; i < 8; i++) {
  216. int rport = pnp_reserve_io[i << 1];
  217. int rend = pnp_reserve_io[(i << 1) + 1] + rport - 1;
  218. if (ranged_conflict(port, end, &rport, &rend))
  219. return 0;
  220. }
  221. /* check for internal conflicts */
  222. for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
  223. if (tres != res && tres->flags & IORESOURCE_IO) {
  224. tport = &tres->start;
  225. tend = &tres->end;
  226. if (ranged_conflict(port, end, tport, tend))
  227. return 0;
  228. }
  229. }
  230. /* check for conflicts with other pnp devices */
  231. pnp_for_each_dev(tdev) {
  232. if (tdev == dev)
  233. continue;
  234. for (i = 0;
  235. (tres = pnp_get_resource(tdev, IORESOURCE_IO, i));
  236. i++) {
  237. if (tres->flags & IORESOURCE_IO) {
  238. if (cannot_compare(tres->flags))
  239. continue;
  240. tport = &tres->start;
  241. tend = &tres->end;
  242. if (ranged_conflict(port, end, tport, tend))
  243. return 0;
  244. }
  245. }
  246. }
  247. return 1;
  248. }
  249. int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
  250. {
  251. int i;
  252. struct pnp_dev *tdev;
  253. struct resource *tres;
  254. resource_size_t *addr, *end, *taddr, *tend;
  255. addr = &res->start;
  256. end = &res->end;
  257. /* if the resource doesn't exist, don't complain about it */
  258. if (cannot_compare(res->flags))
  259. return 1;
  260. /* check if the resource is already in use, skip if the
  261. * device is active because it itself may be in use */
  262. if (!dev->active) {
  263. if (check_mem_region(*addr, length(addr, end)))
  264. return 0;
  265. }
  266. /* check if the resource is reserved */
  267. for (i = 0; i < 8; i++) {
  268. int raddr = pnp_reserve_mem[i << 1];
  269. int rend = pnp_reserve_mem[(i << 1) + 1] + raddr - 1;
  270. if (ranged_conflict(addr, end, &raddr, &rend))
  271. return 0;
  272. }
  273. /* check for internal conflicts */
  274. for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
  275. if (tres != res && tres->flags & IORESOURCE_MEM) {
  276. taddr = &tres->start;
  277. tend = &tres->end;
  278. if (ranged_conflict(addr, end, taddr, tend))
  279. return 0;
  280. }
  281. }
  282. /* check for conflicts with other pnp devices */
  283. pnp_for_each_dev(tdev) {
  284. if (tdev == dev)
  285. continue;
  286. for (i = 0;
  287. (tres = pnp_get_resource(tdev, IORESOURCE_MEM, i));
  288. i++) {
  289. if (tres->flags & IORESOURCE_MEM) {
  290. if (cannot_compare(tres->flags))
  291. continue;
  292. taddr = &tres->start;
  293. tend = &tres->end;
  294. if (ranged_conflict(addr, end, taddr, tend))
  295. return 0;
  296. }
  297. }
  298. }
  299. return 1;
  300. }
  301. static irqreturn_t pnp_test_handler(int irq, void *dev_id)
  302. {
  303. return IRQ_HANDLED;
  304. }
  305. int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
  306. {
  307. int i;
  308. struct pnp_dev *tdev;
  309. struct resource *tres;
  310. resource_size_t *irq;
  311. irq = &res->start;
  312. /* if the resource doesn't exist, don't complain about it */
  313. if (cannot_compare(res->flags))
  314. return 1;
  315. /* check if the resource is valid */
  316. if (*irq < 0 || *irq > 15)
  317. return 0;
  318. /* check if the resource is reserved */
  319. for (i = 0; i < 16; i++) {
  320. if (pnp_reserve_irq[i] == *irq)
  321. return 0;
  322. }
  323. /* check for internal conflicts */
  324. for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
  325. if (tres != res && tres->flags & IORESOURCE_IRQ) {
  326. if (tres->start == *irq)
  327. return 0;
  328. }
  329. }
  330. #ifdef CONFIG_PCI
  331. /* check if the resource is being used by a pci device */
  332. {
  333. struct pci_dev *pci = NULL;
  334. for_each_pci_dev(pci) {
  335. if (pci->irq == *irq) {
  336. pci_dev_put(pci);
  337. return 0;
  338. }
  339. }
  340. }
  341. #endif
  342. /* check if the resource is already in use, skip if the
  343. * device is active because it itself may be in use */
  344. if (!dev->active) {
  345. if (request_irq(*irq, pnp_test_handler,
  346. IRQF_DISABLED | IRQF_PROBE_SHARED, "pnp", NULL))
  347. return 0;
  348. free_irq(*irq, NULL);
  349. }
  350. /* check for conflicts with other pnp devices */
  351. pnp_for_each_dev(tdev) {
  352. if (tdev == dev)
  353. continue;
  354. for (i = 0;
  355. (tres = pnp_get_resource(tdev, IORESOURCE_IRQ, i));
  356. i++) {
  357. if (tres->flags & IORESOURCE_IRQ) {
  358. if (cannot_compare(tres->flags))
  359. continue;
  360. if (tres->start == *irq)
  361. return 0;
  362. }
  363. }
  364. }
  365. return 1;
  366. }
  367. int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
  368. {
  369. #ifndef CONFIG_IA64
  370. int i;
  371. struct pnp_dev *tdev;
  372. struct resource *tres;
  373. resource_size_t *dma;
  374. dma = &res->start;
  375. /* if the resource doesn't exist, don't complain about it */
  376. if (cannot_compare(res->flags))
  377. return 1;
  378. /* check if the resource is valid */
  379. if (*dma < 0 || *dma == 4 || *dma > 7)
  380. return 0;
  381. /* check if the resource is reserved */
  382. for (i = 0; i < 8; i++) {
  383. if (pnp_reserve_dma[i] == *dma)
  384. return 0;
  385. }
  386. /* check for internal conflicts */
  387. for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
  388. if (tres != res && tres->flags & IORESOURCE_DMA) {
  389. if (tres->start == *dma)
  390. return 0;
  391. }
  392. }
  393. /* check if the resource is already in use, skip if the
  394. * device is active because it itself may be in use */
  395. if (!dev->active) {
  396. if (request_dma(*dma, "pnp"))
  397. return 0;
  398. free_dma(*dma);
  399. }
  400. /* check for conflicts with other pnp devices */
  401. pnp_for_each_dev(tdev) {
  402. if (tdev == dev)
  403. continue;
  404. for (i = 0;
  405. (tres = pnp_get_resource(tdev, IORESOURCE_DMA, i));
  406. i++) {
  407. if (tres->flags & IORESOURCE_DMA) {
  408. if (cannot_compare(tres->flags))
  409. continue;
  410. if (tres->start == *dma)
  411. return 0;
  412. }
  413. }
  414. }
  415. return 1;
  416. #else
  417. /* IA64 does not have legacy DMA */
  418. return 0;
  419. #endif
  420. }
  421. int pnp_resource_type(struct resource *res)
  422. {
  423. return res->flags & (IORESOURCE_IO | IORESOURCE_MEM |
  424. IORESOURCE_IRQ | IORESOURCE_DMA);
  425. }
  426. struct pnp_resource *pnp_get_pnp_resource(struct pnp_dev *dev,
  427. unsigned int type, unsigned int num)
  428. {
  429. struct pnp_resource_table *res = dev->res;
  430. switch (type) {
  431. case IORESOURCE_IO:
  432. if (num >= PNP_MAX_PORT)
  433. return NULL;
  434. return &res->port[num];
  435. case IORESOURCE_MEM:
  436. if (num >= PNP_MAX_MEM)
  437. return NULL;
  438. return &res->mem[num];
  439. case IORESOURCE_IRQ:
  440. if (num >= PNP_MAX_IRQ)
  441. return NULL;
  442. return &res->irq[num];
  443. case IORESOURCE_DMA:
  444. if (num >= PNP_MAX_DMA)
  445. return NULL;
  446. return &res->dma[num];
  447. }
  448. return NULL;
  449. }
  450. struct resource *pnp_get_resource(struct pnp_dev *dev,
  451. unsigned int type, unsigned int num)
  452. {
  453. struct pnp_resource *pnp_res;
  454. pnp_res = pnp_get_pnp_resource(dev, type, num);
  455. if (pnp_res)
  456. return &pnp_res->res;
  457. return NULL;
  458. }
  459. EXPORT_SYMBOL(pnp_get_resource);
  460. static struct pnp_resource *pnp_new_resource(struct pnp_dev *dev, int type)
  461. {
  462. struct pnp_resource *pnp_res;
  463. int i;
  464. switch (type) {
  465. case IORESOURCE_IO:
  466. for (i = 0; i < PNP_MAX_PORT; i++) {
  467. pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, i);
  468. if (pnp_res && !pnp_resource_valid(&pnp_res->res))
  469. return pnp_res;
  470. }
  471. break;
  472. case IORESOURCE_MEM:
  473. for (i = 0; i < PNP_MAX_MEM; i++) {
  474. pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, i);
  475. if (pnp_res && !pnp_resource_valid(&pnp_res->res))
  476. return pnp_res;
  477. }
  478. break;
  479. case IORESOURCE_IRQ:
  480. for (i = 0; i < PNP_MAX_IRQ; i++) {
  481. pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, i);
  482. if (pnp_res && !pnp_resource_valid(&pnp_res->res))
  483. return pnp_res;
  484. }
  485. break;
  486. case IORESOURCE_DMA:
  487. for (i = 0; i < PNP_MAX_DMA; i++) {
  488. pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, i);
  489. if (pnp_res && !pnp_resource_valid(&pnp_res->res))
  490. return pnp_res;
  491. }
  492. break;
  493. }
  494. return NULL;
  495. }
  496. struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
  497. int flags)
  498. {
  499. struct pnp_resource *pnp_res;
  500. struct resource *res;
  501. static unsigned char warned;
  502. pnp_res = pnp_new_resource(dev, IORESOURCE_IRQ);
  503. if (!pnp_res) {
  504. if (!warned) {
  505. dev_err(&dev->dev, "can't add resource for IRQ %d\n",
  506. irq);
  507. warned = 1;
  508. }
  509. return NULL;
  510. }
  511. res = &pnp_res->res;
  512. res->flags = IORESOURCE_IRQ | flags;
  513. res->start = irq;
  514. res->end = irq;
  515. dev_dbg(&dev->dev, " add irq %d flags %#x\n", irq, flags);
  516. return pnp_res;
  517. }
  518. struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
  519. int flags)
  520. {
  521. struct pnp_resource *pnp_res;
  522. struct resource *res;
  523. static unsigned char warned;
  524. pnp_res = pnp_new_resource(dev, IORESOURCE_DMA);
  525. if (!pnp_res) {
  526. if (!warned) {
  527. dev_err(&dev->dev, "can't add resource for DMA %d\n",
  528. dma);
  529. warned = 1;
  530. }
  531. return NULL;
  532. }
  533. res = &pnp_res->res;
  534. res->flags = IORESOURCE_DMA | flags;
  535. res->start = dma;
  536. res->end = dma;
  537. dev_dbg(&dev->dev, " add dma %d flags %#x\n", dma, flags);
  538. return pnp_res;
  539. }
  540. struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev,
  541. resource_size_t start,
  542. resource_size_t end, int flags)
  543. {
  544. struct pnp_resource *pnp_res;
  545. struct resource *res;
  546. static unsigned char warned;
  547. pnp_res = pnp_new_resource(dev, IORESOURCE_IO);
  548. if (!pnp_res) {
  549. if (!warned) {
  550. dev_err(&dev->dev, "can't add resource for IO "
  551. "%#llx-%#llx\n",(unsigned long long) start,
  552. (unsigned long long) end);
  553. warned = 1;
  554. }
  555. return NULL;
  556. }
  557. res = &pnp_res->res;
  558. res->flags = IORESOURCE_IO | flags;
  559. res->start = start;
  560. res->end = end;
  561. dev_dbg(&dev->dev, " add io %#llx-%#llx flags %#x\n",
  562. (unsigned long long) start, (unsigned long long) end, flags);
  563. return pnp_res;
  564. }
  565. struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
  566. resource_size_t start,
  567. resource_size_t end, int flags)
  568. {
  569. struct pnp_resource *pnp_res;
  570. struct resource *res;
  571. static unsigned char warned;
  572. pnp_res = pnp_new_resource(dev, IORESOURCE_MEM);
  573. if (!pnp_res) {
  574. if (!warned) {
  575. dev_err(&dev->dev, "can't add resource for MEM "
  576. "%#llx-%#llx\n",(unsigned long long) start,
  577. (unsigned long long) end);
  578. warned = 1;
  579. }
  580. return NULL;
  581. }
  582. res = &pnp_res->res;
  583. res->flags = IORESOURCE_MEM | flags;
  584. res->start = start;
  585. res->end = end;
  586. dev_dbg(&dev->dev, " add mem %#llx-%#llx flags %#x\n",
  587. (unsigned long long) start, (unsigned long long) end, flags);
  588. return pnp_res;
  589. }
  590. /* format is: pnp_reserve_irq=irq1[,irq2] .... */
  591. static int __init pnp_setup_reserve_irq(char *str)
  592. {
  593. int i;
  594. for (i = 0; i < 16; i++)
  595. if (get_option(&str, &pnp_reserve_irq[i]) != 2)
  596. break;
  597. return 1;
  598. }
  599. __setup("pnp_reserve_irq=", pnp_setup_reserve_irq);
  600. /* format is: pnp_reserve_dma=dma1[,dma2] .... */
  601. static int __init pnp_setup_reserve_dma(char *str)
  602. {
  603. int i;
  604. for (i = 0; i < 8; i++)
  605. if (get_option(&str, &pnp_reserve_dma[i]) != 2)
  606. break;
  607. return 1;
  608. }
  609. __setup("pnp_reserve_dma=", pnp_setup_reserve_dma);
  610. /* format is: pnp_reserve_io=io1,size1[,io2,size2] .... */
  611. static int __init pnp_setup_reserve_io(char *str)
  612. {
  613. int i;
  614. for (i = 0; i < 16; i++)
  615. if (get_option(&str, &pnp_reserve_io[i]) != 2)
  616. break;
  617. return 1;
  618. }
  619. __setup("pnp_reserve_io=", pnp_setup_reserve_io);
  620. /* format is: pnp_reserve_mem=mem1,size1[,mem2,size2] .... */
  621. static int __init pnp_setup_reserve_mem(char *str)
  622. {
  623. int i;
  624. for (i = 0; i < 16; i++)
  625. if (get_option(&str, &pnp_reserve_mem[i]) != 2)
  626. break;
  627. return 1;
  628. }
  629. __setup("pnp_reserve_mem=", pnp_setup_reserve_mem);