diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-07 11:57:08 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-04-11 08:33:48 +0200 |
commit | c5d95eb4c72a2639c10d01a801df00b4c34db315 (patch) | |
tree | 5b8c0afce59f832d2f102e4114feb3c16ffd98a0 /common | |
parent | c0511abbd1fa99ee8eff80d5bf207ff5f349cf8a (diff) | |
download | barebox-c5d95eb4c72a2639c10d01a801df00b4c34db315.tar.gz barebox-c5d95eb4c72a2639c10d01a801df00b4c34db315.tar.xz |
param: make parameter functions more consistent
This patch creates a consitent set of device parameter functions.
With this we have: dev_add_param_<type><access>
"type" is one of: int32, uint32, int64, uint64, string, mac, ipv4, enum, bitmask
The improvement here is that we now can exactly specify the width of the
int type parameters and also correctly distinguish between signed and
unsigned variables which means that a variable no longer ends up with
INT_MAX when it's assigned -1.
"access" can be empty for regular read/write parameter, "_ro" for readonly
parameters which get their value from a variable pointer in the
background or "_fixed" for parameters which are set to a fixed value
(without a pointer in the background).
Some more exotic types are not (yet) implemented, like
dev_add_param_ip_ro.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/console.c | 2 | ||||
-rw-r--r-- | common/partitions/dos.c | 2 | ||||
-rw-r--r-- | common/state/state_variables.c | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/common/console.c b/common/console.c index 1bcb13fa0b..f4c799fa54 100644 --- a/common/console.c +++ b/common/console.c @@ -328,7 +328,7 @@ int console_register(struct console_device *newcdev) if (ret) return ret; newcdev->baudrate_param = newcdev->baudrate = CONFIG_BAUDRATE; - dev_add_param_int(dev, "baudrate", console_baudrate_set, + dev_add_param_uint32(dev, "baudrate", console_baudrate_set, NULL, &newcdev->baudrate_param, "%u", newcdev); } diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 5f08e253ee..91b5399079 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -251,7 +251,7 @@ static void dos_partition(void *buf, struct block_device *blk, * signature and pp is a zero-filled hex representation of the 1-based * partition number. */ - dev_add_param_int(blk->dev, "nt_signature", + dev_add_param_uint32(blk->dev, "nt_signature", dos_set_disk_signature, dos_get_disk_signature, &dsp->signature, "%08x", dsp); } diff --git a/common/state/state_variables.c b/common/state/state_variables.c index 5b8e6284d9..56bcd9590a 100644 --- a/common/state/state_variables.c +++ b/common/state/state_variables.c @@ -108,7 +108,7 @@ static struct state_variable *state_uint8_create(struct state *state, su32 = xzalloc(sizeof(*su32)); - param = dev_add_param_int(&state->dev, name, state_uint8_set, + param = dev_add_param_uint32(&state->dev, name, state_uint8_set, NULL, &su32->value, "%u", &su32->var); if (IS_ERR(param)) { free(su32); @@ -136,7 +136,7 @@ static struct state_variable *state_uint32_create(struct state *state, su32 = xzalloc(sizeof(*su32)); - param = dev_add_param_int(&state->dev, name, state_set_dirty, + param = dev_add_param_uint32(&state->dev, name, state_set_dirty, NULL, &su32->value, "%u", &su32->var); if (IS_ERR(param)) { free(su32); |