11 #include <linux/slab.h>
12 #include <linux/kernel.h>
13 #include <linux/bitmap.h>
15 #include <asm/setup.h>
28 spin_unlock_irqrestore(&bmp->
lock, flags);
30 pr_debug(
"msi_bitmap: allocated 0x%x (2^%d) at offset 0x%x\n",
40 int order = get_count_order(num);
42 pr_debug(
"msi_bitmap: freeing 0x%x (2^%d) at offset 0x%x\n",
47 spin_unlock_irqrestore(&bmp->
lock, flags);
54 pr_debug(
"msi_bitmap: reserving hwirq 0x%x\n", hwirq);
58 spin_unlock_irqrestore(&bmp->
lock, flags);
82 pr_debug(
"msi_bitmap: no msi-available-ranges property " \
83 "found on %s\n", bmp->
of_node->full_name);
87 if (len % (2 *
sizeof(
u32)) != 0) {
89 " property on %s\n", bmp->
of_node->full_name);
95 spin_lock(&bmp->
lock);
98 len /= 2 *
sizeof(
u32);
99 for (i = 0; i < len; i++, p += 2) {
100 for (j = 0; j < *(p + 1); j++)
104 spin_unlock(&bmp->
lock);
118 pr_debug(
"msi_bitmap: allocator bitmap size is 0x%x bytes\n", size);
122 pr_debug(
"msi_bitmap: ENOMEM allocating allocator bitmap!\n");
128 bmp->
of_node = of_node_get(of_node);
141 #ifdef CONFIG_MSI_BITMAP_SELFTEST
144 if (!(x)) printk("msi_bitmap: test failed at line %d\n", __LINE__);
146 void __init test_basics(
void)
159 get_count_order(size)));
167 get_count_order(size)));
171 for (i = 0; i <
size; i++)
191 void __init test_of_node(
void)
193 u32 prop_data[] = { 10, 10, 25, 3, 40, 1, 100, 100, 200, 20 };
194 const char *expected_str =
"0-9,20-24,28-39,41-99,220-255";
195 char *prop_name =
"msi-available-ranges";
215 get_count_order(size)));
221 memset(&prop, 0,
sizeof(prop));
222 prop.name = prop_name;
223 prop.value = &prop_data;
224 prop.length =
sizeof(prop_data);
233 check(bitmap_equal(expected, bmp.bitmap, size));
239 int __init msi_bitmap_selftest(
void)