From: Karel Zak Date: Thu, 5 Sep 2024 10:23:15 +0000 (+0200) Subject: hwclock: add -param-index X-Git-Tag: v2.42-start~210^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a494f7220ab0df730784f0f13ea917ea4b5c04dd;p=thirdparty%2Futil-linux.git hwclock: add -param-index Addresses: https://github.com/util-linux/util-linux/issues/3180 Signed-off-by: Karel Zak --- diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c index 659a7a707..2796f2e8a 100644 --- a/sys-utils/hwclock-rtc.c +++ b/sys-utils/hwclock-rtc.c @@ -439,7 +439,7 @@ int get_param_rtc(const struct hwclock_control *ctl, const char *name, uint64_t *id, uint64_t *value) { int rtc_fd; - struct rtc_param param = { .param = 0 }; + struct rtc_param param = { .index = ctl->param_idx }; /* handle name */ if (resolve_rtc_param_alias(name, ¶m.param) != 0 @@ -479,7 +479,7 @@ int get_param_rtc(const struct hwclock_control *ctl, int set_param_rtc(const struct hwclock_control *ctl, const char *opt0) { int rtc_fd, rc = 1; - struct rtc_param param = { .param = 0 }; + struct rtc_param param = { .index = ctl->param_idx }; char *tok, *opt = xstrdup(opt0); /* handle name */ diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index ca851a491..cea249ebb 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -1236,6 +1236,7 @@ usage(void) #ifdef __linux__ puts(_(" --param-get display the RTC parameter")); puts(_(" --param-set = set the RTC parameter")); + puts(_(" --param-index parameter index (default 0)")); puts(_(" --vl-read read voltage low information")); puts(_(" --vl-clear clear voltage low information")); #endif @@ -1309,6 +1310,7 @@ int main(int argc, char **argv) OPT_NOADJFILE, OPT_PARAM_GET, OPT_PARAM_SET, + OPT_PARAM_IDX, OPT_VL_READ, OPT_VL_CLEAR, OPT_PREDICT, @@ -1340,6 +1342,7 @@ int main(int argc, char **argv) #ifdef __linux__ { "param-get", required_argument, NULL, OPT_PARAM_GET }, { "param-set", required_argument, NULL, OPT_PARAM_SET }, + { "param-index", required_argument, NULL, OPT_PARAM_IDX }, { "vl-read", no_argument, NULL, OPT_VL_READ }, { "vl-clear", no_argument, NULL, OPT_VL_CLEAR }, #endif @@ -1466,6 +1469,9 @@ int main(int argc, char **argv) ctl.show = 0; ctl.hwaudit_on = 1; break; + case OPT_PARAM_IDX: + ctl.param_idx = strtou32_or_err(optarg, _("failed to parse param-index")); + break; case OPT_VL_READ: ctl.vl_read = 1; ctl.show = 0; diff --git a/sys-utils/hwclock.h b/sys-utils/hwclock.h index 91b10a73b..21b7efa3d 100644 --- a/sys-utils/hwclock.h +++ b/sys-utils/hwclock.h @@ -37,6 +37,7 @@ struct hwclock_control { #endif #ifdef __linux__ char *rtc_dev_name; + uint32_t param_idx; /* --param-index */ #endif char *param_get_option; char *param_set_option;