/* The bit positions 0 through @bits are valid positions in @buf.  */
static int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits)
/* The bit positions 0 through @bits are valid positions in @buf.  */
static int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits)
{
	int pos = 0;
	if (ord >= 0 && ord < bits) {
		int i;
		for (i = find_first_bit(buf, bits);
		     i < bits && ord > 0;
		     i = find_next_bit(buf, bits, i + 1))
	     		ord--;
		if (i < bits && ord == 0)
			pos = i;
	}
	return pos;
}