rsrc_mgr.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:19k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*======================================================================
  2.     Resource management routines
  3.     rsrc_mgr.c 1.79 2000/08/30 20:23:58
  4.     The contents of this file are subject to the Mozilla Public
  5.     License Version 1.1 (the "License"); you may not use this file
  6.     except in compliance with the License. You may obtain a copy of
  7.     the License at http://www.mozilla.org/MPL/
  8.     Software distributed under the License is distributed on an "AS
  9.     IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.     implied. See the License for the specific language governing
  11.     rights and limitations under the License.
  12.     The initial developer of the original code is David A. Hinds
  13.     <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
  14.     are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
  15.     Alternatively, the contents of this file may be used under the
  16.     terms of the GNU General Public License version 2 (the "GPL"), in which
  17.     case the provisions of the GPL are applicable instead of the
  18.     above.  If you wish to allow the use of your version of this file
  19.     only under the terms of the GPL and not to allow others to use
  20.     your version of this file under the MPL, indicate your decision
  21.     by deleting the provisions above and replace them with the notice
  22.     and other provisions required by the GPL.  If you do not delete
  23.     the provisions above, a recipient may use your version of this
  24.     file under either the MPL or the GPL.
  25.     
  26. ======================================================================*/
  27. #define __NO_VERSION__
  28. #include <linux/config.h>
  29. #include <linux/module.h>
  30. #include <linux/init.h>
  31. #include <linux/sched.h>
  32. #include <linux/kernel.h>
  33. #include <linux/errno.h>
  34. #include <linux/types.h>
  35. #include <linux/slab.h>
  36. #include <linux/ioport.h>
  37. #include <linux/timer.h>
  38. #include <linux/proc_fs.h>
  39. #include <linux/pci.h>
  40. #include <asm/irq.h>
  41. #include <asm/io.h>
  42. #include <pcmcia/cs_types.h>
  43. #include <pcmcia/ss.h>
  44. #include <pcmcia/cs.h>
  45. #include <pcmcia/bulkmem.h>
  46. #include <pcmcia/cistpl.h>
  47. #include "cs_internal.h"
  48. /*====================================================================*/
  49. /* Parameters that can be set with 'insmod' */
  50. #define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
  51. INT_MODULE_PARM(probe_mem, 1); /* memory probe? */
  52. #ifdef CONFIG_ISA
  53. INT_MODULE_PARM(probe_io, 1); /* IO port probe? */
  54. INT_MODULE_PARM(mem_limit, 0x10000);
  55. #endif
  56. /*======================================================================
  57.     The resource_map_t structures are used to track what resources are
  58.     available for allocation for PC Card devices.
  59. ======================================================================*/
  60. typedef struct resource_map_t {
  61.     u_long base, num;
  62.     struct resource_map_t *next;
  63. } resource_map_t;
  64. /* Memory resource database */
  65. static resource_map_t mem_db = { 0, 0, &mem_db };
  66. /* IO port resource database */
  67. static resource_map_t io_db = { 0, 0, &io_db };
  68. #ifdef CONFIG_ISA
  69. typedef struct irq_info_t {
  70.     u_int Attributes;
  71.     int time_share, dyn_share;
  72.     struct socket_info_t *Socket;
  73. } irq_info_t;
  74. /* Table of IRQ assignments */
  75. static irq_info_t irq_table[NR_IRQS] = { { 0, 0, 0 }, /* etc */ };
  76. #endif
  77. /*======================================================================
  78.     Linux resource management extensions
  79. ======================================================================*/
  80. static struct resource *resource_parent(unsigned long b, unsigned long n,
  81. int flags, struct pci_dev *dev)
  82. {
  83. #ifdef CONFIG_PCI
  84. struct resource res, *pr;
  85. if (dev != NULL) {
  86. res.start = b;
  87. res.end = b + n - 1;
  88. res.flags = flags;
  89. pr = pci_find_parent_resource(dev, &res);
  90. if (pr)
  91. return pr;
  92. }
  93. #endif /* CONFIG_PCI */
  94. if (flags & IORESOURCE_MEM)
  95. return &iomem_resource;
  96. return &ioport_resource;
  97. }
  98. static inline int check_io_resource(unsigned long b, unsigned long n,
  99.     struct pci_dev *dev)
  100. {
  101. return check_resource(resource_parent(b, n, IORESOURCE_IO, dev), b, n);
  102. }
  103. static inline int check_mem_resource(unsigned long b, unsigned long n,
  104.      struct pci_dev *dev)
  105. {
  106. return check_resource(resource_parent(b, n, IORESOURCE_MEM, dev), b, n);
  107. }
  108. static struct resource *make_resource(unsigned long b, unsigned long n,
  109.       int flags, char *name)
  110. {
  111. struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL);
  112. if (res) {
  113. memset(res, 0, sizeof(*res));
  114. res->name = name;
  115. res->start = b;
  116. res->end = b + n - 1;
  117. res->flags = flags | IORESOURCE_BUSY;
  118. }
  119. return res;
  120. }
  121. static int request_io_resource(unsigned long b, unsigned long n,
  122.        char *name, struct pci_dev *dev)
  123. {
  124. struct resource *res = make_resource(b, n, IORESOURCE_IO, name);
  125. struct resource *pr = resource_parent(b, n, IORESOURCE_IO, dev);
  126. int err = -ENOMEM;
  127. if (res) {
  128. err = request_resource(pr, res);
  129. if (err)
  130. kfree(res);
  131. }
  132. return err;
  133. }
  134. static int request_mem_resource(unsigned long b, unsigned long n,
  135. char *name, struct pci_dev *dev)
  136. {
  137. struct resource *res = make_resource(b, n, IORESOURCE_MEM, name);
  138. struct resource *pr = resource_parent(b, n, IORESOURCE_MEM, dev);
  139. int err = -ENOMEM;
  140. if (res) {
  141. err = request_resource(pr, res);
  142. if (err)
  143. kfree(res);
  144. }
  145. return err;
  146. }
  147. /*======================================================================
  148.     These manage the internal databases of available resources.
  149.     
  150. ======================================================================*/
  151. static int add_interval(resource_map_t *map, u_long base, u_long num)
  152. {
  153.     resource_map_t *p, *q;
  154.     for (p = map; ; p = p->next) {
  155. if ((p != map) && (p->base+p->num-1 >= base))
  156.     return -1;
  157. if ((p->next == map) || (p->next->base > base+num-1))
  158.     break;
  159.     }
  160.     q = kmalloc(sizeof(resource_map_t), GFP_KERNEL);
  161.     if (!q) return CS_OUT_OF_RESOURCE;
  162.     q->base = base; q->num = num;
  163.     q->next = p->next; p->next = q;
  164.     return CS_SUCCESS;
  165. }
  166. /*====================================================================*/
  167. static int sub_interval(resource_map_t *map, u_long base, u_long num)
  168. {
  169.     resource_map_t *p, *q;
  170.     for (p = map; ; p = q) {
  171. q = p->next;
  172. if (q == map)
  173.     break;
  174. if ((q->base+q->num > base) && (base+num > q->base)) {
  175.     if (q->base >= base) {
  176. if (q->base+q->num <= base+num) {
  177.     /* Delete whole block */
  178.     p->next = q->next;
  179.     kfree(q);
  180.     /* don't advance the pointer yet */
  181.     q = p;
  182. } else {
  183.     /* Cut off bit from the front */
  184.     q->num = q->base + q->num - base - num;
  185.     q->base = base + num;
  186. }
  187.     } else if (q->base+q->num <= base+num) {
  188. /* Cut off bit from the end */
  189. q->num = base - q->base;
  190.     } else {
  191. /* Split the block into two pieces */
  192. p = kmalloc(sizeof(resource_map_t), GFP_KERNEL);
  193. if (!p) return CS_OUT_OF_RESOURCE;
  194. p->base = base+num;
  195. p->num = q->base+q->num - p->base;
  196. q->num = base - q->base;
  197. p->next = q->next ; q->next = p;
  198.     }
  199. }
  200.     }
  201.     return CS_SUCCESS;
  202. }
  203. /*======================================================================
  204.     These routines examine a region of IO or memory addresses to
  205.     determine what ranges might be genuinely available.
  206.     
  207. ======================================================================*/
  208. #ifdef CONFIG_ISA
  209. static void do_io_probe(ioaddr_t base, ioaddr_t num)
  210. {
  211.     
  212.     ioaddr_t i, j, bad, any;
  213.     u_char *b, hole, most;
  214.     
  215.     printk(KERN_INFO "cs: IO port probe 0x%04x-0x%04x:",
  216.    base, base+num-1);
  217.     
  218.     /* First, what does a floating port look like? */
  219.     b = kmalloc(256, GFP_KERNEL);
  220.     if (!b) {
  221.             printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes");
  222.             return;
  223.     }   
  224.     memset(b, 0, 256);
  225.     for (i = base, most = 0; i < base+num; i += 8) {
  226. if (check_io_resource(i, 8, NULL))
  227.     continue;
  228. hole = inb(i);
  229. for (j = 1; j < 8; j++)
  230.     if (inb(i+j) != hole) break;
  231. if ((j == 8) && (++b[hole] > b[most]))
  232.     most = hole;
  233. if (b[most] == 127) break;
  234.     }
  235.     kfree(b);
  236.     bad = any = 0;
  237.     for (i = base; i < base+num; i += 8) {
  238. if (check_io_resource(i, 8, NULL))
  239.     continue;
  240. for (j = 0; j < 8; j++)
  241.     if (inb(i+j) != most) break;
  242. if (j < 8) {
  243.     if (!any)
  244. printk(" excluding");
  245.     if (!bad)
  246. bad = any = i;
  247. } else {
  248.     if (bad) {
  249. sub_interval(&io_db, bad, i-bad);
  250. printk(" %#04x-%#04x", bad, i-1);
  251. bad = 0;
  252.     }
  253. }
  254.     }
  255.     if (bad) {
  256. if ((num > 16) && (bad == base) && (i == base+num)) {
  257.     printk(" nothing: probe failed.n");
  258.     return;
  259. } else {
  260.     sub_interval(&io_db, bad, i-bad);
  261.     printk(" %#04x-%#04x", bad, i-1);
  262. }
  263.     }
  264.     
  265.     printk(any ? "n" : " clean.n");
  266. }
  267. #endif
  268. /*======================================================================
  269.     The memory probe.  If the memory list includes a 64K-aligned block
  270.     below 1MB, we probe in 64K chunks, and as soon as we accumulate at
  271.     least mem_limit free space, we quit.
  272.     
  273. ======================================================================*/
  274. static int do_mem_probe(u_long base, u_long num,
  275. int (*is_valid)(u_long), int (*do_cksum)(u_long),
  276. socket_info_t *s)
  277. {
  278.     u_long i, j, bad, fail, step;
  279.     printk(KERN_INFO "cs: memory probe 0x%06lx-0x%06lx:",
  280.    base, base+num-1);
  281.     bad = fail = 0;
  282.     step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff);
  283.     for (i = j = base; i < base+num; i = j + step) {
  284. if (!fail) {
  285.     for (j = i; j < base+num; j += step)
  286. if ((check_mem_resource(j, step, s->cap.cb_dev) == 0) &&
  287.     is_valid(j))
  288.     break;
  289.     fail = ((i == base) && (j == base+num));
  290. }
  291. if (fail) {
  292.     for (j = i; j < base+num; j += 2*step)
  293. if ((check_mem_resource(j, 2*step, s->cap.cb_dev) == 0) &&
  294.     do_cksum(j) && do_cksum(j+step))
  295.     break;
  296. }
  297. if (i != j) {
  298.     if (!bad) printk(" excluding");
  299.     printk(" %#05lx-%#05lx", i, j-1);
  300.     sub_interval(&mem_db, i, j-i);
  301.     bad += j-i;
  302. }
  303.     }
  304.     printk(bad ? "n" : " clean.n");
  305.     return (num - bad);
  306. }
  307. #ifdef CONFIG_ISA
  308. static u_long inv_probe(int (*is_valid)(u_long),
  309. int (*do_cksum)(u_long),
  310. resource_map_t *m, socket_info_t *s)
  311. {
  312.     u_long ok;
  313.     if (m == &mem_db)
  314. return 0;
  315.     ok = inv_probe(is_valid, do_cksum, m->next, s);
  316.     if (ok) {
  317. if (m->base >= 0x100000)
  318.     sub_interval(&mem_db, m->base, m->num);
  319. return ok;
  320.     }
  321.     if (m->base < 0x100000)
  322. return 0;
  323.     return do_mem_probe(m->base, m->num, is_valid, do_cksum, s);
  324. }
  325. void validate_mem(int (*is_valid)(u_long), int (*do_cksum)(u_long),
  326.   int force_low, socket_info_t *s)
  327. {
  328.     resource_map_t *m, *n;
  329.     static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 };
  330.     static int hi = 0, lo = 0;
  331.     u_long b, i, ok = 0;
  332.     
  333.     if (!probe_mem) return;
  334.     /* We do up to four passes through the list */
  335.     if (!force_low) {
  336. if (hi++ || (inv_probe(is_valid, do_cksum, mem_db.next, s) > 0))
  337.     return;
  338. printk(KERN_NOTICE "cs: warning: no high memory space "
  339.        "available!n");
  340.     }
  341.     if (lo++) return;
  342.     for (m = mem_db.next; m != &mem_db; m = n) {
  343. n = m->next;
  344. /* Only probe < 1 MB */
  345. if (m->base >= 0x100000) continue;
  346. if ((m->base | m->num) & 0xffff) {
  347.     ok += do_mem_probe(m->base, m->num, is_valid, do_cksum, s);
  348.     continue;
  349. }
  350. /* Special probe for 64K-aligned block */
  351. for (i = 0; i < 4; i++) {
  352.     b = order[i] << 12;
  353.     if ((b >= m->base) && (b+0x10000 <= m->base+m->num)) {
  354. if (ok >= mem_limit)
  355.     sub_interval(&mem_db, b, 0x10000);
  356. else
  357.     ok += do_mem_probe(b, 0x10000, is_valid, do_cksum, s);
  358.     }
  359. }
  360.     }
  361. }
  362. #else /* CONFIG_ISA */
  363. void validate_mem(int (*is_valid)(u_long), int (*do_cksum)(u_long),
  364.   int force_low, socket_info_t *s)
  365. {
  366.     resource_map_t *m;
  367.     static int done = 0;
  368.     
  369.     if (!probe_mem || done++)
  370. return;
  371.     for (m = mem_db.next; m != &mem_db; m = m->next)
  372. if (do_mem_probe(m->base, m->num, is_valid, do_cksum, s))
  373.     return;
  374. }
  375. #endif /* CONFIG_ISA */
  376. /*======================================================================
  377.     These find ranges of I/O ports or memory addresses that are not
  378.     currently allocated by other devices.
  379.     The 'align' field should reflect the number of bits of address
  380.     that need to be preserved from the initial value of *base.  It
  381.     should be a power of two, greater than or equal to 'num'.  A value
  382.     of 0 means that all bits of *base are significant.  *base should
  383.     also be strictly less than 'align'.
  384.     
  385. ======================================================================*/
  386. int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align,
  387.    char *name, socket_info_t *s)
  388. {
  389.     ioaddr_t try;
  390.     resource_map_t *m;
  391.     
  392.     for (m = io_db.next; m != &io_db; m = m->next) {
  393. try = (m->base & ~(align-1)) + *base;
  394. for (try = (try >= m->base) ? try : try+align;
  395.      (try >= m->base) && (try+num <= m->base+m->num);
  396.      try += align) {
  397.     if (request_io_resource(try, num, name, s->cap.cb_dev) == 0) {
  398. *base = try;
  399. return 0;
  400.     }
  401.     if (!align) break;
  402. }
  403.     }
  404.     return -1;
  405. }
  406. int find_mem_region(u_long *base, u_long num, u_long align,
  407.     int force_low, char *name, socket_info_t *s)
  408. {
  409.     u_long try;
  410.     resource_map_t *m;
  411.     while (1) {
  412. for (m = mem_db.next; m != &mem_db; m = m->next) {
  413.     /* first pass >1MB, second pass <1MB */
  414.     if ((force_low != 0) ^ (m->base < 0x100000)) continue;
  415.     try = (m->base & ~(align-1)) + *base;
  416.     for (try = (try >= m->base) ? try : try+align;
  417.  (try >= m->base) && (try+num <= m->base+m->num);
  418.  try += align) {
  419. if (request_mem_resource(try, num, name, s->cap.cb_dev) == 0) {
  420.     *base = try;
  421.     return 0;
  422. }
  423. if (!align) break;
  424.     }
  425. }
  426. if (force_low) break;
  427. force_low++;
  428.     }
  429.     return -1;
  430. }
  431. /*======================================================================
  432.     This checks to see if an interrupt is available, with support
  433.     for interrupt sharing.  We don't support reserving interrupts
  434.     yet.  If the interrupt is available, we allocate it.
  435.     
  436. ======================================================================*/
  437. #ifdef CONFIG_ISA
  438. static void fake_irq(int i, void *d, struct pt_regs *r) { }
  439. static inline int check_irq(int irq)
  440. {
  441.     if (request_irq(irq, fake_irq, 0, "bogus", NULL) != 0)
  442. return -1;
  443.     free_irq(irq, NULL);
  444.     return 0;
  445. }
  446. int try_irq(u_int Attributes, int irq, int specific)
  447. {
  448.     irq_info_t *info = &irq_table[irq];
  449.     if (info->Attributes & RES_ALLOCATED) {
  450. switch (Attributes & IRQ_TYPE) {
  451. case IRQ_TYPE_EXCLUSIVE:
  452.     return CS_IN_USE;
  453. case IRQ_TYPE_TIME:
  454.     if ((info->Attributes & RES_IRQ_TYPE)
  455. != RES_IRQ_TYPE_TIME)
  456. return CS_IN_USE;
  457.     if (Attributes & IRQ_FIRST_SHARED)
  458. return CS_BAD_ATTRIBUTE;
  459.     info->Attributes |= RES_IRQ_TYPE_TIME | RES_ALLOCATED;
  460.     info->time_share++;
  461.     break;
  462. case IRQ_TYPE_DYNAMIC_SHARING:
  463.     if ((info->Attributes & RES_IRQ_TYPE)
  464. != RES_IRQ_TYPE_DYNAMIC)
  465. return CS_IN_USE;
  466.     if (Attributes & IRQ_FIRST_SHARED)
  467. return CS_BAD_ATTRIBUTE;
  468.     info->Attributes |= RES_IRQ_TYPE_DYNAMIC | RES_ALLOCATED;
  469.     info->dyn_share++;
  470.     break;
  471. }
  472.     } else {
  473. if ((info->Attributes & RES_RESERVED) && !specific)
  474.     return CS_IN_USE;
  475. if (check_irq(irq) != 0)
  476.     return CS_IN_USE;
  477. switch (Attributes & IRQ_TYPE) {
  478. case IRQ_TYPE_EXCLUSIVE:
  479.     info->Attributes |= RES_ALLOCATED;
  480.     break;
  481. case IRQ_TYPE_TIME:
  482.     if (!(Attributes & IRQ_FIRST_SHARED))
  483. return CS_BAD_ATTRIBUTE;
  484.     info->Attributes |= RES_IRQ_TYPE_TIME | RES_ALLOCATED;
  485.     info->time_share = 1;
  486.     break;
  487. case IRQ_TYPE_DYNAMIC_SHARING:
  488.     if (!(Attributes & IRQ_FIRST_SHARED))
  489. return CS_BAD_ATTRIBUTE;
  490.     info->Attributes |= RES_IRQ_TYPE_DYNAMIC | RES_ALLOCATED;
  491.     info->dyn_share = 1;
  492.     break;
  493. }
  494.     }
  495.     return 0;
  496. }
  497. #endif
  498. /*====================================================================*/
  499. #ifdef CONFIG_ISA
  500. void undo_irq(u_int Attributes, int irq)
  501. {
  502.     irq_info_t *info;
  503.     info = &irq_table[irq];
  504.     switch (Attributes & IRQ_TYPE) {
  505.     case IRQ_TYPE_EXCLUSIVE:
  506. info->Attributes &= RES_RESERVED;
  507. break;
  508.     case IRQ_TYPE_TIME:
  509. info->time_share--;
  510. if (info->time_share == 0)
  511.     info->Attributes &= RES_RESERVED;
  512. break;
  513.     case IRQ_TYPE_DYNAMIC_SHARING:
  514. info->dyn_share--;
  515. if (info->dyn_share == 0)
  516.     info->Attributes &= RES_RESERVED;
  517. break;
  518.     }
  519. }
  520. #endif
  521. /*======================================================================
  522.     The various adjust_* calls form the external interface to the
  523.     resource database.
  524.     
  525. ======================================================================*/
  526. static int adjust_memory(adjust_t *adj)
  527. {
  528.     u_long base, num;
  529.     int i, ret;
  530.     base = adj->resource.memory.Base;
  531.     num = adj->resource.memory.Size;
  532.     if ((num == 0) || (base+num-1 < base))
  533. return CS_BAD_SIZE;
  534.     ret = CS_SUCCESS;
  535.     switch (adj->Action) {
  536.     case ADD_MANAGED_RESOURCE:
  537. ret = add_interval(&mem_db, base, num);
  538. break;
  539.     case REMOVE_MANAGED_RESOURCE:
  540. ret = sub_interval(&mem_db, base, num);
  541. if (ret == CS_SUCCESS) {
  542.     for (i = 0; i < sockets; i++) {
  543. release_cis_mem(socket_table[i]);
  544. #ifdef CONFIG_CARDBUS
  545. cb_release_cis_mem(socket_table[i]);
  546. #endif
  547.     }
  548. }
  549. break;
  550.     default:
  551. ret = CS_UNSUPPORTED_FUNCTION;
  552.     }
  553.     
  554.     return ret;
  555. }
  556. /*====================================================================*/
  557. static int adjust_io(adjust_t *adj)
  558. {
  559.     int base, num;
  560.     
  561.     base = adj->resource.io.BasePort;
  562.     num = adj->resource.io.NumPorts;
  563.     if ((base < 0) || (base > 0xffff))
  564. return CS_BAD_BASE;
  565.     if ((num <= 0) || (base+num > 0x10000) || (base+num <= base))
  566. return CS_BAD_SIZE;
  567.     switch (adj->Action) {
  568.     case ADD_MANAGED_RESOURCE:
  569. if (add_interval(&io_db, base, num) != 0)
  570.     return CS_IN_USE;
  571. #ifdef CONFIG_ISA
  572. if (probe_io)
  573.     do_io_probe(base, num);
  574. #endif
  575. break;
  576.     case REMOVE_MANAGED_RESOURCE:
  577. sub_interval(&io_db, base, num);
  578. break;
  579.     default:
  580. return CS_UNSUPPORTED_FUNCTION;
  581. break;
  582.     }
  583.     return CS_SUCCESS;
  584. }
  585. /*====================================================================*/
  586. static int adjust_irq(adjust_t *adj)
  587. {
  588. #ifdef CONFIG_ISA
  589.     int irq;
  590.     irq_info_t *info;
  591.     
  592.     irq = adj->resource.irq.IRQ;
  593.     if ((irq < 0) || (irq > 15))
  594. return CS_BAD_IRQ;
  595.     info = &irq_table[irq];
  596.     
  597.     switch (adj->Action) {
  598.     case ADD_MANAGED_RESOURCE:
  599. if (info->Attributes & RES_REMOVED)
  600.     info->Attributes &= ~(RES_REMOVED|RES_ALLOCATED);
  601. else
  602.     if (adj->Attributes & RES_ALLOCATED)
  603. return CS_IN_USE;
  604. if (adj->Attributes & RES_RESERVED)
  605.     info->Attributes |= RES_RESERVED;
  606. else
  607.     info->Attributes &= ~RES_RESERVED;
  608. break;
  609.     case REMOVE_MANAGED_RESOURCE:
  610. if (info->Attributes & RES_REMOVED)
  611.     return 0;
  612. if (info->Attributes & RES_ALLOCATED)
  613.     return CS_IN_USE;
  614. info->Attributes |= RES_ALLOCATED|RES_REMOVED;
  615. info->Attributes &= ~RES_RESERVED;
  616. break;
  617.     default:
  618. return CS_UNSUPPORTED_FUNCTION;
  619. break;
  620.     }
  621. #endif
  622.     return CS_SUCCESS;
  623. }
  624. /*====================================================================*/
  625. int pcmcia_adjust_resource_info(client_handle_t handle, adjust_t *adj)
  626. {
  627.     if (CHECK_HANDLE(handle))
  628. return CS_BAD_HANDLE;
  629.     
  630.     switch (adj->Resource) {
  631.     case RES_MEMORY_RANGE:
  632. return adjust_memory(adj);
  633. break;
  634.     case RES_IO_RANGE:
  635. return adjust_io(adj);
  636. break;
  637.     case RES_IRQ:
  638. return adjust_irq(adj);
  639. break;
  640.     }
  641.     return CS_UNSUPPORTED_FUNCTION;
  642. }
  643. /*====================================================================*/
  644. void release_resource_db(void)
  645. {
  646.     resource_map_t *p, *q;
  647.     
  648.     for (p = mem_db.next; p != &mem_db; p = q) {
  649. q = p->next;
  650. kfree(p);
  651.     }
  652.     for (p = io_db.next; p != &io_db; p = q) {
  653. q = p->next;
  654. kfree(p);
  655.     }
  656. }