nbhw16: shield: cleanup indent, don't show specific erros, show usage instead
This commit is contained in:
parent
1fe2efa399
commit
4c8d1c8447
|
|
@ -57,7 +57,6 @@ int shield_set_mode(const char* shield_type, int argc, char * const argv[])
|
||||||
static int do_shieldmode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
static int do_shieldmode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
puts("Invalid command (see help)\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ static int request_gpios(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
debug("Shiled configure gpios\n");
|
debug("Shield configure gpios\n");
|
||||||
ret = shield_gpio_request_as_input(NETBIRD_GPIO_RST_SHIELD_N, "shield-rst");
|
ret = shield_gpio_request_as_input(NETBIRD_GPIO_RST_SHIELD_N, "shield-rst");
|
||||||
if ((ret < 0))
|
if ((ret < 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -60,7 +60,7 @@ static int configure_shieldmode(int mode)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (mode < 0 || mode > 3) {
|
if (mode < 0 || mode > 3) {
|
||||||
printf("Invalid shield mode %d\n", mode);
|
debug("Invalid shield mode %d\n", mode);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,8 +144,8 @@ static int get_termination(const char* termination)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("Invalid termination mode %s (falling back to off)", termination);
|
debug ("Invalid termination mode %s (falling back to off)", termination);
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_mode_from_args(char * const argv[], int argc)
|
static int get_mode_from_args(char * const argv[], int argc)
|
||||||
|
|
@ -157,12 +157,15 @@ static int get_mode_from_args(char * const argv[], int argc)
|
||||||
assert(argc == (CAN_PORTS + 1));
|
assert(argc == (CAN_PORTS + 1));
|
||||||
|
|
||||||
if (strcmp ("termination", argv[0])) {
|
if (strcmp ("termination", argv[0])) {
|
||||||
puts("The only option for dualcan is terminations\n");
|
debug("The only option for dualcan is terminations\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CAN_PORTS; i ++) {
|
for (i = 0; i < CAN_PORTS; i ++) {
|
||||||
terminations[i] = get_termination(argv[i + 1]);
|
terminations[i] = get_termination(argv[i + 1]);
|
||||||
|
if (terminations[i] < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Termination is inverse */
|
/* Termination is inverse */
|
||||||
|
|
@ -172,12 +175,11 @@ static int get_mode_from_args(char * const argv[], int argc)
|
||||||
static int set_shieldmode(char * const argv[], int argc)
|
static int set_shieldmode(char * const argv[], int argc)
|
||||||
{
|
{
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
puts("Too few arguments for dualcan\n");
|
debug("Too few arguments for dualcan\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_shieldmode(get_mode_from_args(argv, argc));
|
return configure_shieldmode(get_mode_from_args(argv, argc));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct shield_t can_shield = {
|
struct shield_t can_shield = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue