resource_ext.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2015, Intel Corporation
  3. * Author: Jiang Liu <jiang.liu@linux.intel.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _LINUX_RESOURCE_EXT_H
  15. #define _LINUX_RESOURCE_EXT_H
  16. #include <linux/types.h>
  17. #include <linux/list.h>
  18. #include <linux/ioport.h>
  19. #include <linux/slab.h>
  20. /* Represent resource window for bridge devices */
  21. struct resource_win {
  22. struct resource res; /* In master (CPU) address space */
  23. resource_size_t offset; /* Translation offset for bridge */
  24. };
  25. /*
  26. * Common resource list management data structure and interfaces to support
  27. * ACPI, PNP and PCI host bridge etc.
  28. */
  29. struct resource_entry {
  30. struct list_head node;
  31. struct resource *res; /* In master (CPU) address space */
  32. resource_size_t offset; /* Translation offset for bridge */
  33. struct resource __res; /* Default storage for res */
  34. };
  35. extern struct resource_entry *
  36. resource_list_create_entry(struct resource *res, size_t extra_size);
  37. extern void resource_list_free(struct list_head *head);
  38. static inline void resource_list_add(struct resource_entry *entry,
  39. struct list_head *head)
  40. {
  41. list_add(&entry->node, head);
  42. }
  43. static inline void resource_list_add_tail(struct resource_entry *entry,
  44. struct list_head *head)
  45. {
  46. list_add_tail(&entry->node, head);
  47. }
  48. static inline void resource_list_del(struct resource_entry *entry)
  49. {
  50. list_del(&entry->node);
  51. }
  52. static inline void resource_list_free_entry(struct resource_entry *entry)
  53. {
  54. kfree(entry);
  55. }
  56. static inline void
  57. resource_list_destroy_entry(struct resource_entry *entry)
  58. {
  59. resource_list_del(entry);
  60. resource_list_free_entry(entry);
  61. }
  62. #define resource_list_for_each_entry(entry, list) \
  63. list_for_each_entry((entry), (list), node)
  64. #define resource_list_for_each_entry_safe(entry, tmp, list) \
  65. list_for_each_entry_safe((entry), (tmp), (list), node)
  66. #endif /* _LINUX_RESOURCE_EXT_H */