summaryrefslogtreecommitdiff
path: root/include/linux/property.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2019-11-07 20:22:21 -0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-12-03 11:46:19 +0100
commit996b0830f95d132e50891a5568fef9e2965e4af2 (patch)
treed3e36383f0501db16b19b2f7f3eded9bd7b14d0f /include/linux/property.h
parente6bff4665c595b5a4aff173848851ed49ac3bfad (diff)
software node: allow embedding of small arrays into property_entry
We should not conflate whether a property data is an array or a single value with where it is stored (embedded into property_entry structure or out-of-line). All single-value properties are in effect 1-element arrays, and we can figure the amount of data stored in a property by examining its length and the data type. And arrays can be as easily stored in property entry instances as single values are, provided that we have enough space (we have up to 8 bytes). We can embed: - up to 8 bytes from U8 arrays - up to 4 words - up to 2 double words - one U64 value - one (on 64 bit architectures) or 2 (on 32 bit) strings. This change also has an effect of switching properties with small amount of data to embed it instead of keeping it separate when copying such properties. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/property.h')
-rw-r--r--include/linux/property.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/include/linux/property.h b/include/linux/property.h
index 6c1ca870a9a9..fc819c6ebf33 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -240,11 +240,11 @@ struct property_entry {
union {
const void *pointer;
union {
- u8 u8_data;
- u16 u16_data;
- u32 u32_data;
- u64 u64_data;
- const char *str;
+ u8 u8_data[sizeof(u64) / sizeof(u8)];
+ u16 u16_data[sizeof(u64) / sizeof(u16)];
+ u32 u32_data[sizeof(u64) / sizeof(u32)];
+ u64 u64_data[sizeof(u64) / sizeof(u64)];
+ const char *str[sizeof(u64) / sizeof(char *)];
} value;
};
};
@@ -256,7 +256,7 @@ struct property_entry {
*/
#define __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_) \
- sizeof(((struct property_entry *)NULL)->value._elem_)
+ sizeof(((struct property_entry *)NULL)->value._elem_[0])
#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)\
(struct property_entry) { \
@@ -294,7 +294,7 @@ struct property_entry {
.length = __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_), \
.is_inline = true, \
.type = DEV_PROP_##_Type_, \
- { .value = { ._elem_ = _val_ } }, \
+ { .value = { ._elem_[0] = _val_ } }, \
}
#define PROPERTY_ENTRY_U8(_name_, _val_) \