argc -= 2;
argv += 2;
- if (argc > 0) {
- str_pwm = *argv;
- argc--;
- argv++;
- }
+ str_pwm = *argv;
+ argc--;
+ argv++;
if (!str_pwm)
return CMD_RET_USAGE;
switch (*str_cmd) {
case 'i':
sub_cmd = PWM_SET_INVERT;
+ if (argc != 2)
+ return CMD_RET_USAGE;
break;
case 'c':
sub_cmd = PWM_SET_CONFIG;
+ if (argc != 3)
+ return CMD_RET_USAGE;
break;
case 'e':
sub_cmd = PWM_SET_ENABLE;
+ if (argc != 1)
+ return CMD_RET_USAGE;
break;
case 'd':
sub_cmd = PWM_SET_DISABLE;
+ if (argc != 1)
+ return CMD_RET_USAGE;
break;
default:
return CMD_RET_USAGE;
return cmd_process_error(cmdtp, ret);
}
- if (argc > 0) {
- str_channel = *argv;
- channel = simple_strtoul(str_channel, NULL, 10);
- argc--;
- argv++;
- } else {
- return CMD_RET_USAGE;
- }
+ str_channel = *argv;
+ channel = simple_strtoul(str_channel, NULL, 10);
+ argc--;
+ argv++;
- if (sub_cmd == PWM_SET_INVERT && argc > 0) {
+ if (sub_cmd == PWM_SET_INVERT) {
str_enable = *argv;
pwm_enable = simple_strtoul(str_enable, NULL, 10);
ret = pwm_set_invert(dev, channel, pwm_enable);
- } else if (sub_cmd == PWM_SET_CONFIG && argc == 2) {
+ } else if (sub_cmd == PWM_SET_CONFIG) {
str_period = *argv;
argc--;
argv++;
period_ns = simple_strtoul(str_period, NULL, 10);
- if (argc > 0) {
- str_duty = *argv;
- duty_ns = simple_strtoul(str_duty, NULL, 10);
- }
+ str_duty = *argv;
+ duty_ns = simple_strtoul(str_duty, NULL, 10);
ret = pwm_set_config(dev, channel, period_ns, duty_ns);
} else if (sub_cmd == PWM_SET_ENABLE) {
ret = pwm_set_enable(dev, channel, 1);
} else if (sub_cmd == PWM_SET_DISABLE) {
ret = pwm_set_enable(dev, channel, 0);
- } else {
- printf("PWM arguments missing\n");
- return CMD_RET_FAILURE;
}
if (ret) {