From 8099956f6a99fbedc9a81ef5e3f480b9bc4e9424 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 20 Oct 2016 09:25:48 +0200 Subject: state: pass error code instead of inventing new one Both of_find_path() and of_find_path_by_node() return a meaningful error code, so forward it instead of inventing a new one. Do this especially for the -EPROBE_DEFER case which currently does not work. Signed-off-by: Sascha Hauer --- common/state/state.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'common/state') diff --git a/common/state/state.c b/common/state/state.c index 075618e5bb..2be3c8c5c5 100644 --- a/common/state/state.c +++ b/common/state/state.c @@ -466,9 +466,10 @@ struct state *state_new_from_node(struct device_node *node, char *path, of_path = partition_node->full_name; ret = of_find_path_by_node(partition_node, &path, 0); } - if (!path) { - pr_err("state failed to parse path to backend\n"); - ret = -EINVAL; + if (ret) { + if (ret != -EPROBE_DEFER) + pr_err("state failed to parse path to backend: %s\n", + strerror(-ret)); goto out_release_state; } } -- cgit v1.2.3 From 28d5eb1bbc8681de635d145fa1d0edccb1571e0d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 20 Oct 2016 09:34:42 +0200 Subject: state: Use dev_* for information rather than pr_* Signed-off-by: Sascha Hauer --- common/state/state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common/state') diff --git a/common/state/state.c b/common/state/state.c index 2be3c8c5c5..4020d5e1ea 100644 --- a/common/state/state.c +++ b/common/state/state.c @@ -468,7 +468,7 @@ struct state *state_new_from_node(struct device_node *node, char *path, } if (ret) { if (ret != -EPROBE_DEFER) - pr_err("state failed to parse path to backend: %s\n", + dev_err(&state->dev, "state failed to parse path to backend: %s\n", strerror(-ret)); goto out_release_state; } @@ -488,7 +488,7 @@ struct state *state_new_from_node(struct device_node *node, char *path, &storage_type); if (ret) { storage_type = NULL; - pr_info("No backend-storage-type found, using default.\n"); + dev_info(&state->dev, "No backend-storage-type found, using default.\n"); } ret = state_backend_init(&state->backend, &state->dev, node, @@ -512,10 +512,10 @@ struct state *state_new_from_node(struct device_node *node, char *path, ret = state_load(state); if (ret) { - pr_warn("Failed to load persistent state, continuing with defaults, %d\n", ret); + dev_warn(&state->dev, "Failed to load persistent state, continuing with defaults, %d\n", ret); } - pr_info("New state registered '%s'\n", alias); + dev_info(&state->dev, "New state registered '%s'\n", alias); return state; -- cgit v1.2.3 From 88b67f8ee47cee555342111481c252a39a390e44 Mon Sep 17 00:00:00 2001 From: Stefan Lengfeld Date: Wed, 2 Nov 2016 08:54:27 +0100 Subject: state: use packed attribute for on storage structs These structs are used for on-storage data layouts. They should be not affected by different integer precisions and alignment optimizations of 32bit or 64bit machines. Using the architecture independent integer data types, like uint32_t, achieves the former, using the packed attribute the later. Signed-off-by: Stefan Lengfeld Signed-off-by: Sascha Hauer --- common/state/backend_bucket_circular.c | 2 +- common/state/backend_bucket_direct.c | 2 +- common/state/backend_format_raw.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'common/state') diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 72e165e437..d8504e035c 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -47,7 +47,7 @@ struct state_backend_storage_bucket_circular { struct device_d *dev; }; -struct state_backend_storage_bucket_circular_meta { +struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta { uint32_t magic; uint32_t written_length; }; diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c index 08892f001e..5225433ec5 100644 --- a/common/state/backend_bucket_direct.c +++ b/common/state/backend_bucket_direct.c @@ -32,7 +32,7 @@ struct state_backend_storage_bucket_direct { struct device_d *dev; }; -struct state_backend_storage_bucket_direct_meta { +struct __attribute__((__packed__)) state_backend_storage_bucket_direct_meta { uint32_t magic; uint32_t written_length; }; diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c index 4209424130..e028ea616c 100644 --- a/common/state/backend_format_raw.c +++ b/common/state/backend_format_raw.c @@ -37,7 +37,7 @@ struct state_backend_format_raw { struct device_d *dev; }; -struct backend_raw_header { +struct __attribute__((__packed__)) backend_raw_header { uint32_t magic; uint16_t reserved; uint16_t data_len; -- cgit v1.2.3 From 2e93886c38dd5126f59481ff8fbc84c1cdc453ce Mon Sep 17 00:00:00 2001 From: Stefan Lengfeld Date: Wed, 2 Nov 2016 08:54:28 +0100 Subject: state: fix indentation Signed-off-by: Stefan Lengfeld Signed-off-by: Sascha Hauer --- common/state/state_variables.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common/state') diff --git a/common/state/state_variables.c b/common/state/state_variables.c index efc24562c1..1e37856c1f 100644 --- a/common/state/state_variables.c +++ b/common/state/state_variables.c @@ -441,9 +441,9 @@ static struct variable_type types[] = { { .type = STATE_TYPE_U8, .type_name = "uint8", - .export = state_uint32_export, - .import = state_uint32_import, - .create = state_uint8_create, + .export = state_uint32_export, + .import = state_uint32_import, + .create = state_uint8_create, }, { .type = STATE_TYPE_U32, .type_name = "uint32", -- cgit v1.2.3