33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 1) // SPDX-License-Identifier: GPL-2.0-only
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 2) /* identifiers for device / performance-differentiated memory regions */
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 3) #include <linux/idr.h>
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 4) #include <linux/types.h>
ffa550cd691b8 (Jason Yan 2020-09-25 21:19:21 -0700 5) #include <linux/memregion.h>
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 6)
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 7) static DEFINE_IDA(memregion_ids);
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 8)
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 9) int memregion_alloc(gfp_t gfp)
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 10) {
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 11) return ida_alloc(&memregion_ids, gfp);
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 12) }
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 13) EXPORT_SYMBOL(memregion_alloc);
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 14)
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 15) void memregion_free(int id)
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 16) {
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 17) ida_free(&memregion_ids, id);
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 18) }
33dd70752cd76 (Dan Williams 2019-11-06 17:43:31 -0800 19) EXPORT_SYMBOL(memregion_free);