rsrc_mgr.c 1.5 KB

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