[PATCH 1/3] param: Add info function
Sascha Hauer
s.hauer at pengutronix.de
Thu May 23 09:56:15 EDT 2013
Some parameters may wish to provide some information about their
meaning or possible values. Provide an info callback for parameters.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/base/driver.c | 8 ++++++--
include/param.h | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index edd49b3..30a4bc5 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -495,8 +495,12 @@ static int do_devinfo(int argc, char *argv[])
printf("%s\n", list_empty(&dev->parameters) ?
"no parameters available" : "Parameters:");
- list_for_each_entry(param, &dev->parameters, list)
- printf("%16s = %s\n", param->name, dev_get_param(dev, param->name));
+ list_for_each_entry(param, &dev->parameters, list) {
+ printf("%16s = %s", param->name, dev_get_param(dev, param->name));
+ if (param->info)
+ param->info(param);
+ printf("\n");
+ }
#ifdef CONFIG_OFDEVICE
if (dev->device_node) {
printf("\ndevice node: %s\n", dev->device_node->full_name);
diff --git a/include/param.h b/include/param.h
index 4af2d09..54dea56 100644
--- a/include/param.h
+++ b/include/param.h
@@ -12,6 +12,7 @@ typedef unsigned long IPaddr_t;
struct param_d {
const char* (*get)(struct device_d *, struct param_d *param);
int (*set)(struct device_d *, struct param_d *param, const char *val);
+ void (*info)(struct param_d *param);
unsigned int flags;
char *name;
char *value;
--
1.8.2.rc2
More information about the barebox
mailing list