summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-12-10 05:41:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-12-10 05:41:45 +0100
commit28e374e062aede65b6bb6f341376f196e5ac4fc7 (patch)
tree603f97f7495cc6c234482424fcb4b39dc77369da /lib
parent4b05f14d96afde2fb8e7e9a92893ca3c684870d0 (diff)
parentaade8d53cf6cccf7958d2c11e5791dfcd85a584f (diff)
downloadbarebox-28e374e062aede65b6bb6f341376f196e5ac4fc7.tar.gz
Merge branch 'for-next/watchdog'
Diffstat (limited to 'lib')
-rw-r--r--lib/parameter.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/parameter.c b/lib/parameter.c
index fdbb2e71d1..22695634e5 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -588,6 +588,28 @@ struct param_d *dev_add_param_enum(struct device_d *dev, const char *name,
return &pe->param;
}
+static const char *const tristate_names[] = {
+ [PARAM_TRISTATE_UNKNOWN] = "unknown",
+ [PARAM_TRISTATE_TRUE] = "1",
+ [PARAM_TRISTATE_FALSE] = "0",
+};
+
+struct param_d *dev_add_param_tristate(struct device_d *dev, const char *name,
+ int (*set)(struct param_d *p, void *priv),
+ int (*get)(struct param_d *p, void *priv),
+ int *value, void *priv)
+{
+ return dev_add_param_enum(dev, name, set, get, value, tristate_names,
+ ARRAY_SIZE(tristate_names), priv);
+}
+
+struct param_d *dev_add_param_tristate_ro(struct device_d *dev, const char *name,
+ int *value)
+{
+ return dev_add_param_enum_ro(dev, name, value, tristate_names,
+ ARRAY_SIZE(tristate_names));
+}
+
struct param_bitmask {
struct param_d param;
unsigned long *value;