Skip to contentSkip to conversation

state: use packet attribute for on storage structs

PATCH Applied Stefan Lengfeld 3 participants 7 messages Nov 2, 2016 – Nov 3, 2016 Device tree bindings

lore
Share & tools
lore
#1 lore raw

PATCH 2/4 state: fix indentation

In reply to Stefan Lengfeld
---
 common/state/state_variables.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/state/state_variables.c +3 -3
index efc2456..1e37856 100644
@@ -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
#3 lore raw

PATCH 4/4 docs: state: make string variable type clearer

In reply to Stefan Lengfeld

Only 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
index e39245f..438cc43 100644
@@ -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
#0 lore raw

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
index 72e165e..d8504e0 100644
@@ -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
index 08892f0..5225433 100644
@@ -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
index 4209424..e028ea6 100644
@@ -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
#2 lore raw

PATCH 3/4 state: fix state is not saved when string variable is changed

The 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
index 1e37856..fd072a0 100644
@@ -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
#4 lore raw
In reply to Stefan Lengfeld
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.

---
 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
index 72e165e..d8504e0 100644

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 -0
        uint32_t magic;
        uint32_t written_length;
 };
common/state/backend_bucket_direct.c +1 -1
index 08892f0..5225433 100644
@@ -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
index 4209424..e028ea6 100644
@@ -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

Applied
#5 lore raw
In reply to Stefan Lengfeld
Quoted 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.

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
index 72e165e..d8504e0 100644
@@ -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
index 08892f0..5225433 100644
@@ -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
index 4209424..e028ea6 100644
@@ -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
#6 lore raw

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

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