state: use packet attribute for on storage structs
PATCH 1/4 state: use packet 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 packet attribute the later.
--- 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(-)
common/state/backend_bucket_circular.c +1 -1
@@ -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; };
common/state/backend_bucket_direct.c +1 -1
@@ -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; };
common/state/backend_format_raw.c +1 -1
@@ -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;
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/4 state: fix indentation
--- common/state/state_variables.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
common/state/state_variables.c +3 -3
@@ -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",
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/4 state: fix state is not saved when string variable is changed
In reply to Stefan LengfeldThe dirty flag was not set properly.
--- common/state/state_variables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/state/state_variables.c +1 -1
@@ -383,7 +383,7 @@ static int state_string_set(struct param_d *p, void *priv)if (ret)return ret; -return state_set_dirty (p, sv->state); +return state_set_dirty (p, sv); }static int state_string_get (struct param_d *p,void *priv)
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/4 docs: state: make string variable type clearer
In reply to Stefan LengfeldOnly fixed length strings are supported. Make the wording clearer.
--- Documentation/devicetree/bindings/barebox/barebox,state.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/barebox/barebox,state.rst +2 -2
@@ -51,8 +51,8 @@ variable. The node name may end with ``@<ADDRESS>``, but the suffix is stripped from the variable name. State variables have a type. Currenty supported types are: ``uint8``, -``uint32``, ``enum32``, ``mac`` address or ``string``. Variable length -strings are not planned. +``uint32``, ``enum32``, ``mac`` address or ``string`` (fixed length string). +Variable length strings are not planned. Required properties:
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 4 lines · Stefan Lengfeld
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 packet attribute
"packed" instead of "packet"?
Quoted 14 lines
the later.
Signed-off-by Stefan Lengfeld <[email protected]>--- 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(-)common/state/backend_bucket_circular.c +0
-0
common/state/backend_bucket_circular.c struct state_backend_storage_bucket_circular { · line 50
Quoted 5 lines
common/state/backend_bucket_circular.c +1
-1@@ -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 {
#include <linux/compiler.h> defines "__packed" macro which might make things less verbose. Ditto for the rest of the changes in this patch.
Quoted 33 lines
common/state/backend_bucket_circular.c +0
-0uint32_t magic;uint32_t written_length; };common/state/backend_bucket_direct.c +1
-1@@ -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; };common/state/backend_format_raw.c +1
-2@@ -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; --1.9.1
Quoted 4 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 7 lines · Stefan Lengfeld
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 packet attribute the later.Signed-off-by Stefan Lengfeld <[email protected]>
Applied all, thanks. 3/4 went to master, the rest to next. Also fixed s/packet/packed/ while applying.
Sascha
Quoted 54 lines
--- 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(-)common/state/backend_bucket_circular.c +1
-1@@ -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; };common/state/backend_bucket_direct.c +1
-1@@ -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; };common/state/backend_format_raw.c +1
-1@@ -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;Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Sascha,
Quoted 7 lines · Sascha Hauer
Quoted 6 lines · Stefan Lengfeld
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 packet attribute the later.
Quoted 6 lines
Quoted 1 line
Signed-off-by Stefan Lengfeld <[email protected]>Applied all, thanks. 3/4 went to master, the rest to next. Also fixed s/packet/packed/ while applying.
Sascha
thanks for fixing my typo :-)
Mit freundlichen Grüßen / Kind regards,
Stefan Lengfeld
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox