/* Returns 0 on success, -errno on invalid input strings. Error values: %-EINVAL: second number in range smaller than first %-EINVAL: invalid character in string %-ERANGE: bit number specified too large for mask  */
int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
/* Returns 0 on success, -errno on invalid input strings. Error values: %-EINVAL: second number in range smaller than first %-EINVAL: invalid character in string %-ERANGE: bit number specified too large for mask  */
int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
{
	unsigned a, b;
	bitmap_zero(maskp, nmaskbits);
	do {
		if (!isdigit(*bp))
			return -EINVAL;
		b = a = simple_strtoul(bp, (char **)&bp, BASEDEC);
		if (*bp == '-') {
			bp++;
			if (!isdigit(*bp))
				return -EINVAL;
			b = simple_strtoul(bp, (char **)&bp, BASEDEC);
		}
		if (!(a <= b))
			return -EINVAL;
		if (b >= nmaskbits)
			return -ERANGE;
		while (a <= b) {
			set_bit(a, maskp);
			a++;
		}
		if (*bp == ',')
			bp++;
	} while (*bp != '\0' && *bp != '\n');
	return 0;
}