aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMarek BehĂșn <kabel@kernel.org>2024-05-21 09:13:31 +0200
committerTom Rini <trini@konsulko.com>2024-06-07 10:47:59 -0600
commitfda747c8f1f287607ffac7c6c3b2d99c7f08540e (patch)
tree5e484f27d2d5aaf97cb8e9142fa0c0c8aa7b7d72 /cmd
parent2d49dafe4ac572228fe4309cf0445b5f82ff2fd5 (diff)
downloadu-boot-fda747c8f1f287607ffac7c6c3b2d99c7f08540e.zip
u-boot-fda747c8f1f287607ffac7c6c3b2d99c7f08540e.tar.gz
u-boot-fda747c8f1f287607ffac7c6c3b2d99c7f08540e.tar.bz2
cmd: eeprom: Deduplicate parse_i2c_bus_addr() calls
Deduplicate the calls to parse_i2c_bus_addr(). Signed-off-by: Marek BehĂșn <kabel@kernel.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/eeprom.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/cmd/eeprom.c b/cmd/eeprom.c
index d610dc9..12902e8 100644
--- a/cmd/eeprom.c
+++ b/cmd/eeprom.c
@@ -339,6 +339,21 @@ static int eeprom_execute_command(enum eeprom_action action, int i2c_bus,
return rcode;
}
+static int eeprom_action_expected_argc(enum eeprom_action action)
+{
+ switch (action) {
+ case EEPROM_READ:
+ case EEPROM_WRITE:
+ return 3;
+ case EEPROM_PRINT:
+ return 0;
+ case EEPROM_UPDATE:
+ return 2;
+ default:
+ return CMD_RET_USAGE;
+ }
+}
+
#define NEXT_PARAM(argc, index) { (argc)--; (index)++; }
int do_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
@@ -371,25 +386,8 @@ int do_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
#endif
- switch (action) {
- case EEPROM_READ:
- case EEPROM_WRITE:
- ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc,
- argv + index, 3);
- break;
- case EEPROM_PRINT:
- ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc,
- argv + index, 0);
- break;
- case EEPROM_UPDATE:
- ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc,
- argv + index, 2);
- break;
- default:
- /* Get compiler to stop whining */
- return CMD_RET_USAGE;
- }
-
+ ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc, argv + index,
+ eeprom_action_expected_argc(action));
if (ret == CMD_RET_USAGE)
return ret;