/* This function returns positive resulting integer in case of success and a negative error code in case of failure.  */
static int __init bytes_str_to_int(const char *str)
/* This function returns positive resulting integer in case of success and a negative error code in case of failure.  */
static int __init bytes_str_to_int(const char *str)
{
	char *endp;
	unsigned long result;
	result = simple_strtoul(str, &endp, 0);
	if (str == endp || result < 0) {
		printk(KERN_ERR "UBI error: incorrect bytes count: \"%s\"\n",
		       str);
		return -EINVAL;
	}
	switch (*endp) {
	case 'G':
		result *= 1024;
	case 'M':
		result *= 1024;
	case 'K':
		result *= 1024;
		if (endp[1] == 'i' && endp[2] == 'B')
			endp += 2;
	case '\0':
		break;
	default:
		printk(KERN_ERR "UBI error: incorrect bytes count: \"%s\"\n",
		       str);
		return -EINVAL;
	}
	return result;
}