Skip to contentSkip to conversation

device property: Define type of PROPERTY_ENRTY_*() macros

PATCH Superseded Andy Shevchenko 2 participants 2 messages Jan 22, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/1 device property: Define type of PROPERTY_ENRTY_*() macros

Some of the drivers may use the macro at runtime flow, like

struct property_entry p[10];
...
p[index++] = PROPERTY_ENTRY_U8("u8 property", u8_data);

In that case and absence of the data type compiler fails the build:

drivers/char/ipmi/ipmi_dmi.c:79:29: error: Expected ; at end of statement drivers/char/ipmi/ipmi_dmi.c:79:29: error: got {

---
 include/linux/property.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/property.h +5 -5
index 7eefaf2f22b9..f144be4f99e0 100644
@@ -204,7 +204,7 @@ struct property_entry {
  */
 
 #define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _Type_, _val_)	\
-{									\
+(struct property_entry) {						\
 	.name = _name_,							\
 	.length = ARRAY_SIZE(_val_) * sizeof(_type_),			\
 	.is_array = true,						\
@@ -222,7 +222,7 @@ struct property_entry {
 	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, U64, _val_)
 
 #define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_)		\
-{								\
+(struct property_entry) {					\
 	.name = _name_,						\
 	.length = ARRAY_SIZE(_val_) * sizeof(const char *),	\
 	.is_array = true,					\
@@ -231,7 +231,7 @@ struct property_entry {
 }
 
 #define PROPERTY_ENTRY_INTEGER(_name_, _type_, _Type_, _val_)	\
-{								\
+(struct property_entry) {					\
 	.name = _name_,						\
 	.length = sizeof(_type_),				\
 	.type = DEV_PROP_##_Type_,				\
@@ -248,7 +248,7 @@ struct property_entry {
 	PROPERTY_ENTRY_INTEGER(_name_, u64, U64, _val_)
 
 #define PROPERTY_ENTRY_STRING(_name_, _val_)		\
-{							\
+(struct property_entry) {				\
 	.name = _name_,					\
 	.length = sizeof(_val_),			\
 	.type = DEV_PROP_STRING,			\
@@ -256,7 +256,7 @@ struct property_entry {
 }
 
 #define PROPERTY_ENTRY_BOOL(_name_)		\
-{						\
+(struct property_entry) {			\
 	.name = _name_,				\
 }
 
Signature · 1 line
2.15.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Andy Shevchenko

Some of the drivers may use the macro at runtime flow, like

   struct property_entry p[10];

...
p[index++] = PROPERTY_ENTRY_U8("u8 property", u8_data);

Quoted 7 lines

In that case and absence of the data type compiler fails the build:

drivers/char/ipmi/ipmi_dmi.c:79:29: error: Expected ; at end of statement drivers/char/ipmi/ipmi_dmi.c:79:29: error: got {

This looks good to me.

Quoted 53 lines
---
  include/linux/property.h | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/property.h +5 -5
index 7eefaf2f22b9..f144be4f99e0 100644
@@ -204,7 +204,7 @@ struct property_entry {
   */
 
  #define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _Type_, _val_)	\
-{									\
+(struct property_entry) {						\
  	.name = _name_,							\
  	.length = ARRAY_SIZE(_val_) * sizeof(_type_),			\
  	.is_array = true,						\
@@ -222,7 +222,7 @@ struct property_entry {
  	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, U64, _val_)
 
  #define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_)		\
-{								\
+(struct property_entry) {					\
  	.name = _name_,						\
  	.length = ARRAY_SIZE(_val_) * sizeof(const char *),	\
  	.is_array = true,					\
@@ -231,7 +231,7 @@ struct property_entry {
  }
 
  #define PROPERTY_ENTRY_INTEGER(_name_, _type_, _Type_, _val_)	\
-{								\
+(struct property_entry) {					\
  	.name = _name_,						\
  	.length = sizeof(_type_),				\
  	.type = DEV_PROP_##_Type_,				\
@@ -248,7 +248,7 @@ struct property_entry {
  	PROPERTY_ENTRY_INTEGER(_name_, u64, U64, _val_)
 
  #define PROPERTY_ENTRY_STRING(_name_, _val_)		\
-{							\
+(struct property_entry) {				\
  	.name = _name_,					\
  	.length = sizeof(_val_),			\
  	.type = DEV_PROP_STRING,			\
@@ -256,7 +256,7 @@ struct property_entry {
  }
 
  #define PROPERTY_ENTRY_BOOL(_name_)		\
-{						\
+(struct property_entry) {			\
  	.name = _name_,				\
  }