/* This function computes the start and end addresses for both erase and protect commands. The range of the addresses on which either of the commands is to operate can be given in two forms: */
static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
/* This function computes the start and end addresses for both erase and protect commands. The range of the addresses on which either of the commands is to operate can be given in two forms: */
static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
{
	char *ep;
	char len_used;
	*addr_first = simple_strtoul(arg1, &ep, 16);
	if (ep == arg1 || *ep != '\0')
		return -1;
	len_used = 0;
	if (arg2 && *arg2 == '+'){
		len_used = 1;
		++arg2;
	}
	*addr_last = simple_strtoul(arg2, &ep, 16);
	if (ep == arg2 || *ep != '\0')
		return -1;
	if (len_used){
		*addr_last = *addr_first + *addr_last - 1;
		if (flash_sect_roundb(addr_last) > 0)
			return -1;
	}
	return 1;
}