Message ID | 20220105064239.2689-2-linux@weissschuh.net (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | Warning since "power: supply: add charge_behaviour attributes" | expand |
Hi Sebastian, Hans, On 2022-01-05 07:42+0100, Thomas Weißschuh wrote: > For each member of enum power_supply_property a matching entry in > power_supply_attrs is needed. > Add a basic test at compiletime to validate this in addition to the > existing runtime testing. > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > --- > drivers/power/supply/power_supply_sysfs.c | 2 ++ > include/linux/power_supply.h | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c > index 491ffec7bf47..2565052a7a8c 100644 > --- a/drivers/power/supply/power_supply_sysfs.c > +++ b/drivers/power/supply/power_supply_sysfs.c > @@ -403,6 +403,8 @@ void power_supply_init_attrs(struct device_type *dev_type) > { > int i; > > + BUILD_BUG_ON(ARRAY_SIZE(power_supply_attrs) != __POWER_SUPPLY_PROP_CNT); > + > dev_type->groups = power_supply_attr_groups; > > for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++) { > diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h > index 71f0379c2af8..60853f26e25f 100644 > --- a/include/linux/power_supply.h > +++ b/include/linux/power_supply.h > @@ -172,6 +172,8 @@ enum power_supply_property { > POWER_SUPPLY_PROP_MODEL_NAME, > POWER_SUPPLY_PROP_MANUFACTURER, > POWER_SUPPLY_PROP_SERIAL_NUMBER, > + > + __POWER_SUPPLY_PROP_CNT > }; > > enum power_supply_type { > -- > 2.34.1 > Please ignore this patch. It does not do what is tries to do. Sorry for the noise. Thomas
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 491ffec7bf47..2565052a7a8c 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -403,6 +403,8 @@ void power_supply_init_attrs(struct device_type *dev_type) { int i; + BUILD_BUG_ON(ARRAY_SIZE(power_supply_attrs) != __POWER_SUPPLY_PROP_CNT); + dev_type->groups = power_supply_attr_groups; for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++) { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 71f0379c2af8..60853f26e25f 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -172,6 +172,8 @@ enum power_supply_property { POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_SERIAL_NUMBER, + + __POWER_SUPPLY_PROP_CNT }; enum power_supply_type {
For each member of enum power_supply_property a matching entry in power_supply_attrs is needed. Add a basic test at compiletime to validate this in addition to the existing runtime testing. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> --- drivers/power/supply/power_supply_sysfs.c | 2 ++ include/linux/power_supply.h | 2 ++ 2 files changed, 4 insertions(+)