resource.c 16 KB

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