summaryrefslogtreecommitdiffstats
path: root/netlink/module-eeprom.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:34:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:34:19 +0000
commit942dc614706293cdedc7dede7dc09d8fdf9583f2 (patch)
tree39a8bf3ebede54ce9aea189de4036398199ee6e9 /netlink/module-eeprom.c
parentAdding upstream version 1:6.9. (diff)
downloadethtool-upstream/1%6.10.tar.xz
ethtool-upstream/1%6.10.zip
Adding upstream version 1:6.10.upstream/1%6.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netlink/module-eeprom.c')
-rw-r--r--netlink/module-eeprom.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/netlink/module-eeprom.c b/netlink/module-eeprom.c
index fe02c5a..2b30d04 100644
--- a/netlink/module-eeprom.c
+++ b/netlink/module-eeprom.c
@@ -22,6 +22,7 @@
#define ETH_I2C_MAX_ADDRESS 0x7F
struct cmd_params {
+ unsigned long present;
u8 dump_hex;
u8 dump_raw;
u32 offset;
@@ -31,6 +32,14 @@ struct cmd_params {
u32 i2c_address;
};
+enum {
+ PARAM_OFFSET = 2,
+ PARAM_LENGTH,
+ PARAM_PAGE,
+ PARAM_BANK,
+ PARAM_I2C,
+};
+
static const struct param_parser getmodule_params[] = {
{
.arg = "hex",
@@ -44,31 +53,31 @@ static const struct param_parser getmodule_params[] = {
.dest_offset = offsetof(struct cmd_params, dump_raw),
.min_argc = 1,
},
- {
+ [PARAM_OFFSET] = {
.arg = "offset",
.handler = nl_parse_direct_u32,
.dest_offset = offsetof(struct cmd_params, offset),
.min_argc = 1,
},
- {
+ [PARAM_LENGTH] = {
.arg = "length",
.handler = nl_parse_direct_u32,
.dest_offset = offsetof(struct cmd_params, length),
.min_argc = 1,
},
- {
+ [PARAM_PAGE] = {
.arg = "page",
.handler = nl_parse_direct_u32,
.dest_offset = offsetof(struct cmd_params, page),
.min_argc = 1,
},
- {
+ [PARAM_BANK] = {
.arg = "bank",
.handler = nl_parse_direct_u32,
.dest_offset = offsetof(struct cmd_params, bank),
.min_argc = 1,
},
- {
+ [PARAM_I2C] = {
.arg = "i2c",
.handler = nl_parse_direct_u32,
.dest_offset = offsetof(struct cmd_params, i2c_address),
@@ -267,15 +276,18 @@ int nl_getmodule(struct cmd_context *ctx)
* ioctl. Netlink can only request specific pages.
*/
if ((getmodule_cmd_params.dump_hex || getmodule_cmd_params.dump_raw) &&
- !getmodule_cmd_params.page && !getmodule_cmd_params.bank &&
- !getmodule_cmd_params.i2c_address) {
+ !(getmodule_cmd_params.present & (1 << PARAM_PAGE |
+ 1 << PARAM_BANK |
+ 1 << PARAM_I2C))) {
nlctx->ioctl_fallback = true;
return -EOPNOTSUPP;
}
#ifdef ETHTOOL_ENABLE_PRETTY_DUMP
- if (getmodule_cmd_params.page || getmodule_cmd_params.bank ||
- getmodule_cmd_params.offset || getmodule_cmd_params.length)
+ if (getmodule_cmd_params.present & (1 << PARAM_PAGE |
+ 1 << PARAM_BANK |
+ 1 << PARAM_OFFSET |
+ 1 << PARAM_LENGTH))
#endif
getmodule_cmd_params.dump_hex = true;