rsrc_mgr.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/cs_types.h>
  18. #include <pcmcia/ss.h>
  19. #include <pcmcia/cs.h>
  20. #include <pcmcia/cistpl.h>
  21. #include "cs_internal.h"
  22. int static_init(struct pcmcia_socket *s)
  23. {
  24. /* the good thing about SS_CAP_STATIC_MAP sockets is
  25. * that they don't need a resource database */
  26. s->resource_setup_done = 1;
  27. return 0;
  28. }
  29. struct resource *pcmcia_make_resource(unsigned long start, unsigned long end,
  30. int flags, const char *name)
  31. {
  32. struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
  33. if (res) {
  34. res->name = name;
  35. res->start = start;
  36. res->end = start + end - 1;
  37. res->flags = flags;
  38. }
  39. return res;
  40. }
  41. static int static_find_io(struct pcmcia_socket *s, unsigned int attr,
  42. unsigned int *base, unsigned int num,
  43. unsigned int align)
  44. {
  45. if (!s->io_offset)
  46. return -EINVAL;
  47. *base = s->io_offset | (*base & 0x0fff);
  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. .add_io = NULL,
  55. .add_mem = NULL,
  56. .init = static_init,
  57. .exit = NULL,
  58. };
  59. EXPORT_SYMBOL(pccard_static_ops);
  60. MODULE_AUTHOR("David A. Hinds, Dominik Brodowski");
  61. MODULE_LICENSE("GPL");
  62. MODULE_ALIAS("rsrc_nonstatic");