@@ -37,6 +37,7 @@
* the PCI back-end driver in Hyper-V.
*/
+#include <linux/find_atomic.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -3599,12 +3600,9 @@ static u16 hv_get_dom_num(u16 dom)
if (test_and_set_bit(dom, hvpci_dom_map) == 0)
return dom;
- for_each_clear_bit(i, hvpci_dom_map, HVPCI_DOM_MAP_SIZE) {
- if (test_and_set_bit(i, hvpci_dom_map) == 0)
- return i;
- }
+ i = find_and_set_bit(hvpci_dom_map, HVPCI_DOM_MAP_SIZE);
- return HVPCI_DOM_INVALID;
+ return i < HVPCI_DOM_MAP_SIZE ? i : HVPCI_DOM_INVALID;
}
/**