/* simple_strtoul just ignores the successive invalid characters and return the converted value of prefix part of the string.  */
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
/* simple_strtoul just ignores the successive invalid characters and return the converted value of prefix part of the string.  */
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
	char *tail;
	unsigned long val;
	size_t len;
	*res = 0;
	len = strlen(cp);
	if (len == 0)
		return -EINVAL;
	val = simple_strtoul(cp, &tail, base);
	if (tail == cp)
		return -EINVAL;
	if ((*tail == '\0') ||
		((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
		*res = val;
		return 0;
	}
	return -EINVAL;
}