rsrc_mgr.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * rsrc_mgr.c -- Resource management routines and/or wrappers
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * The initial developer of the original code is David A. Hinds
  9. * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
  10. * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
  11. *
  12. * (C) 1999 David A. Hinds
  13. */
  14. #include <linux/slab.h>
  15. #include <linux/module.h>
  16. #include <linux/kernel.h>
  17. #include <pcmcia/ss.h>
  18. #include <pcmcia/cistpl.h>
  19. #include "cs_internal.h"
  20. int static_init(struct pcmcia_socket *s)
  21. {
  22. /* the good thing about SS_CAP_STATIC_MAP sockets is
  23. * that they don't need a resource database */
  24. s->resource_setup_done = 1;
  25. return 0;
  26. }
  27. struct resource *pcmcia_make_resource(resource_size_t start,
  28. resource_size_t end,
  29. unsigned long flags, const char *name)
  30. {
  31. struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
  32. if (res) {
  33. res->name = name;
  34. res->start = start;
  35. res->end = start + end - 1;
  36. res->flags = flags;
  37. }
  38. return res;
  39. }
  40. static int static_find_io(struct pcmcia_socket *s, unsigned int attr,
  41. unsigned int *base, unsigned int num,
  42. unsigned int align, struct resource **parent)
  43. {
  44. if (!s->io_offset)
  45. return -EINVAL;
  46. *base = s->io_offset | (*base & 0x0fff);
  47. *parent = NULL;
  48. return 0;
  49. }
  50. struct pccard_resource_ops pccard_static_ops = {
  51. .validate_mem = NULL,
  52. .find_io = static_find_io,
  53. .find_mem = NULL,
  54. .init = static_init,
  55. .exit = NULL,
  56. };
  57. EXPORT_SYMBOL(pccard_static_ops);
  58. MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
  59. MODULE_LICENSE("GPL");
  60. MODULE_ALIAS("rsrc_nonstatic");