/* returns the number of bytes consumed, or negative value on error  */
int ipath_parse_ushort(const char *str, unsigned short *valp)
/* returns the number of bytes consumed, or negative value on error  */
int ipath_parse_ushort(const char *str, unsigned short *valp)
{
	unsigned long val;
	char *end;
	int ret;
	if (!isdigit(str[0])) {
		ret = -EINVAL;
		goto bail;
	}
	val = simple_strtoul(str, &end, 0);
	if (val > 0xffff) {
		ret = -EINVAL;
		goto bail;
	}
	*valp = val;
	ret = end + 1 - str;
	if (ret == 0)
		ret = -EINVAL;
bail:
	return ret;
}