resource.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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. #ifdef CONFIG_ISA_DMA_API
  346. int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
  347. {
  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. }
  395. #endif /* CONFIG_ISA_DMA_API */
  396. unsigned long pnp_resource_type(struct resource *res)
  397. {
  398. return res->flags & (IORESOURCE_IO | IORESOURCE_MEM |
  399. IORESOURCE_IRQ | IORESOURCE_DMA |
  400. IORESOURCE_BUS);
  401. }
  402. struct resource *pnp_get_resource(struct pnp_dev *dev,
  403. unsigned long type, unsigned int num)
  404. {
  405. struct pnp_resource *pnp_res;
  406. struct resource *res;
  407. list_for_each_entry(pnp_res, &dev->resources, list) {
  408. res = &pnp_res->res;
  409. if (pnp_resource_type(res) == type && num-- == 0)
  410. return res;
  411. }
  412. return NULL;
  413. }
  414. EXPORT_SYMBOL(pnp_get_resource);
  415. static struct pnp_resource *pnp_new_resource(struct pnp_dev *dev)
  416. {
  417. struct pnp_resource *pnp_res;
  418. pnp_res = kzalloc(sizeof(struct pnp_resource), GFP_KERNEL);
  419. if (!pnp_res)
  420. return NULL;
  421. list_add_tail(&pnp_res->list, &dev->resources);
  422. return pnp_res;
  423. }
  424. struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
  425. int flags)
  426. {
  427. struct pnp_resource *pnp_res;
  428. struct resource *res;
  429. pnp_res = pnp_new_resource(dev);
  430. if (!pnp_res) {
  431. dev_err(&dev->dev, "can't add resource for IRQ %d\n", irq);
  432. return NULL;
  433. }
  434. res = &pnp_res->res;
  435. res->flags = IORESOURCE_IRQ | flags;
  436. res->start = irq;
  437. res->end = irq;
  438. dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
  439. return pnp_res;
  440. }
  441. struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
  442. int flags)
  443. {
  444. struct pnp_resource *pnp_res;
  445. struct resource *res;
  446. pnp_res = pnp_new_resource(dev);
  447. if (!pnp_res) {
  448. dev_err(&dev->dev, "can't add resource for DMA %d\n", dma);
  449. return NULL;
  450. }
  451. res = &pnp_res->res;
  452. res->flags = IORESOURCE_DMA | flags;
  453. res->start = dma;
  454. res->end = dma;
  455. dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
  456. return pnp_res;
  457. }
  458. struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev,
  459. resource_size_t start,
  460. resource_size_t end, int flags)
  461. {
  462. struct pnp_resource *pnp_res;
  463. struct resource *res;
  464. pnp_res = pnp_new_resource(dev);
  465. if (!pnp_res) {
  466. dev_err(&dev->dev, "can't add resource for IO %#llx-%#llx\n",
  467. (unsigned long long) start,
  468. (unsigned long long) end);
  469. return NULL;
  470. }
  471. res = &pnp_res->res;
  472. res->flags = IORESOURCE_IO | flags;
  473. res->start = start;
  474. res->end = end;
  475. dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
  476. return pnp_res;
  477. }
  478. struct pnp_resource *pnp_add_mem_resource(struct pnp_dev *dev,
  479. resource_size_t start,
  480. resource_size_t end, int flags)
  481. {
  482. struct pnp_resource *pnp_res;
  483. struct resource *res;
  484. pnp_res = pnp_new_resource(dev);
  485. if (!pnp_res) {
  486. dev_err(&dev->dev, "can't add resource for MEM %#llx-%#llx\n",
  487. (unsigned long long) start,
  488. (unsigned long long) end);
  489. return NULL;
  490. }
  491. res = &pnp_res->res;
  492. res->flags = IORESOURCE_MEM | flags;
  493. res->start = start;
  494. res->end = end;
  495. dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
  496. return pnp_res;
  497. }
  498. struct pnp_resource *pnp_add_bus_resource(struct pnp_dev *dev,
  499. resource_size_t start,
  500. resource_size_t end)
  501. {
  502. struct pnp_resource *pnp_res;
  503. struct resource *res;
  504. pnp_res = pnp_new_resource(dev);
  505. if (!pnp_res) {
  506. dev_err(&dev->dev, "can't add resource for BUS %#llx-%#llx\n",
  507. (unsigned long long) start,
  508. (unsigned long long) end);
  509. return NULL;
  510. }
  511. res = &pnp_res->res;
  512. res->flags = IORESOURCE_BUS;
  513. res->start = start;
  514. res->end = end;
  515. dev_printk(KERN_DEBUG, &dev->dev, "%pR\n", res);
  516. return pnp_res;
  517. }
  518. /*
  519. * Determine whether the specified resource is a possible configuration
  520. * for this device.
  521. */
  522. int pnp_possible_config(struct pnp_dev *dev, int type, resource_size_t start,
  523. resource_size_t size)
  524. {
  525. struct pnp_option *option;
  526. struct pnp_port *port;
  527. struct pnp_mem *mem;
  528. struct pnp_irq *irq;
  529. struct pnp_dma *dma;
  530. list_for_each_entry(option, &dev->options, list) {
  531. if (option->type != type)
  532. continue;
  533. switch (option->type) {
  534. case IORESOURCE_IO:
  535. port = &option->u.port;
  536. if (port->min == start && port->size == size)
  537. return 1;
  538. break;
  539. case IORESOURCE_MEM:
  540. mem = &option->u.mem;
  541. if (mem->min == start && mem->size == size)
  542. return 1;
  543. break;
  544. case IORESOURCE_IRQ:
  545. irq = &option->u.irq;
  546. if (start < PNP_IRQ_NR &&
  547. test_bit(start, irq->map.bits))
  548. return 1;
  549. break;
  550. case IORESOURCE_DMA:
  551. dma = &option->u.dma;
  552. if (dma->map & (1 << start))
  553. return 1;
  554. break;
  555. }
  556. }
  557. return 0;
  558. }
  559. EXPORT_SYMBOL(pnp_possible_config);
  560. int pnp_range_reserved(resource_size_t start, resource_size_t end)
  561. {
  562. struct pnp_dev *dev;
  563. struct pnp_resource *pnp_res;
  564. resource_size_t *dev_start, *dev_end;
  565. pnp_for_each_dev(dev) {
  566. list_for_each_entry(pnp_res, &dev->resources, list) {
  567. dev_start = &pnp_res->res.start;
  568. dev_end = &pnp_res->res.end;
  569. if (ranged_conflict(&start, &end, dev_start, dev_end))
  570. return 1;
  571. }
  572. }
  573. return 0;
  574. }
  575. EXPORT_SYMBOL(pnp_range_reserved);
  576. /* format is: pnp_reserve_irq=irq1[,irq2] .... */
  577. static int __init pnp_setup_reserve_irq(char *str)
  578. {
  579. int i;
  580. for (i = 0; i < 16; i++)
  581. if (get_option(&str, &pnp_reserve_irq[i]) != 2)
  582. break;
  583. return 1;
  584. }
  585. __setup("pnp_reserve_irq=", pnp_setup_reserve_irq);
  586. /* format is: pnp_reserve_dma=dma1[,dma2] .... */
  587. static int __init pnp_setup_reserve_dma(char *str)
  588. {
  589. int i;
  590. for (i = 0; i < 8; i++)
  591. if (get_option(&str, &pnp_reserve_dma[i]) != 2)
  592. break;
  593. return 1;
  594. }
  595. __setup("pnp_reserve_dma=", pnp_setup_reserve_dma);
  596. /* format is: pnp_reserve_io=io1,size1[,io2,size2] .... */
  597. static int __init pnp_setup_reserve_io(char *str)
  598. {
  599. int i;
  600. for (i = 0; i < 16; i++)
  601. if (get_option(&str, &pnp_reserve_io[i]) != 2)
  602. break;
  603. return 1;
  604. }
  605. __setup("pnp_reserve_io=", pnp_setup_reserve_io);
  606. /* format is: pnp_reserve_mem=mem1,size1[,mem2,size2] .... */
  607. static int __init pnp_setup_reserve_mem(char *str)
  608. {
  609. int i;
  610. for (i = 0; i < 16; i++)
  611. if (get_option(&str, &pnp_reserve_mem[i]) != 2)
  612. break;
  613. return 1;
  614. }
  615. __setup("pnp_reserve_mem=", pnp_setup_reserve_mem);