software node: introduce PROPERTY_ENTRY_XXX_ARRAY_LEN()
Sometimes we want to initialize property entry array from a regular pointer, when we can't determine length automatically via ARRAY_SIZE. Let's introduce PROPERTY_ENTRY_XXX_ARRAY_LEN macros that take explicit "len" argument. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
a00351687f
commit
1741cfacfa
|
@ -261,33 +261,44 @@ struct property_entry {
|
||||||
* and structs.
|
* and structs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _Type_, _val_) \
|
#define PROPERTY_ENTRY_ARRAY_LEN(_name_, _type_, _Type_, _val_, _len_) \
|
||||||
(struct property_entry) { \
|
(struct property_entry) { \
|
||||||
.name = _name_, \
|
.name = _name_, \
|
||||||
.length = ARRAY_SIZE(_val_) * sizeof(_type_), \
|
.length = (_len_) * sizeof(_type_), \
|
||||||
.is_array = true, \
|
.is_array = true, \
|
||||||
.type = DEV_PROP_##_Type_, \
|
.type = DEV_PROP_##_Type_, \
|
||||||
{ .pointer = { ._type_##_data = _val_ } }, \
|
{ .pointer = { ._type_##_data = _val_ } }, \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \
|
#define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_) \
|
||||||
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u8, U8, _val_)
|
PROPERTY_ENTRY_ARRAY_LEN(_name_, u8, U8, _val_, _len_)
|
||||||
#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_) \
|
#define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_) \
|
||||||
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u16, U16, _val_)
|
PROPERTY_ENTRY_ARRAY_LEN(_name_, u16, U16, _val_, _len_)
|
||||||
#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_) \
|
#define PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, _len_) \
|
||||||
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u32, U32, _val_)
|
PROPERTY_ENTRY_ARRAY_LEN(_name_, u32, U32, _val_, _len_)
|
||||||
#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_) \
|
#define PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, _len_) \
|
||||||
PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, U64, _val_)
|
PROPERTY_ENTRY_ARRAY_LEN(_name_, u64, U64, _val_, _len_)
|
||||||
|
|
||||||
#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \
|
#define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_) \
|
||||||
(struct property_entry) { \
|
(struct property_entry) { \
|
||||||
.name = _name_, \
|
.name = _name_, \
|
||||||
.length = ARRAY_SIZE(_val_) * sizeof(const char *), \
|
.length = (_len_) * sizeof(const char *), \
|
||||||
.is_array = true, \
|
.is_array = true, \
|
||||||
.type = DEV_PROP_STRING, \
|
.type = DEV_PROP_STRING, \
|
||||||
{ .pointer = { .str = _val_ } }, \
|
{ .pointer = { .str = _val_ } }, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_) \
|
||||||
|
PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
||||||
|
#define PROPERTY_ENTRY_U16_ARRAY(_name_, _val_) \
|
||||||
|
PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
||||||
|
#define PROPERTY_ENTRY_U32_ARRAY(_name_, _val_) \
|
||||||
|
PROPERTY_ENTRY_U32_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
||||||
|
#define PROPERTY_ENTRY_U64_ARRAY(_name_, _val_) \
|
||||||
|
PROPERTY_ENTRY_U64_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
||||||
|
#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \
|
||||||
|
PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
|
||||||
|
|
||||||
#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _Type_, _val_) \
|
#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _Type_, _val_) \
|
||||||
(struct property_entry) { \
|
(struct property_entry) { \
|
||||||
.name = _name_, \
|
.name = _name_, \
|
||||||
|
|
Loading…
Reference in New Issue