Message ID | 20240303-class_cleanup-power-v2-1-e248b7128519@marliere.net (mailing list archive) |
---|---|
State | Handled Elsewhere, archived |
Headers | show |
Series | [v2] power: supply: move power_supply_attr_groups definition back to sysfs | expand |
On Sun, 03 Mar 2024 13:30:50 -0300, Ricardo B. Marliere wrote: > As reported by the kernel test robot, 'power_supply_attr_group' is defined > but not used when CONFIG_SYSFS is not set. Sebastian suggested that the > correct fix implemented by this patch, instead of my attempt in commit > ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef > block"), is to define power_supply_attr_groups in power_supply_sysfs.c and > expose it in the power_supply.h header. For the case where CONFIG_SYSFS=n, > define it as NULL. > > [...] Applied, thanks! [1/1] power: supply: move power_supply_attr_groups definition back to sysfs commit: f107e6b82392a4d64507e219c57235d3fe09e9d7 Best regards,
diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h index 06749a534db4..3cbafc58bdad 100644 --- a/drivers/power/supply/power_supply.h +++ b/drivers/power/supply/power_supply.h @@ -17,12 +17,12 @@ struct power_supply; extern void power_supply_init_attrs(void); extern int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env); -extern const struct attribute_group power_supply_attr_group; +extern const struct attribute_group *power_supply_attr_groups[]; #else static inline void power_supply_init_attrs(void) {} -static const struct attribute_group power_supply_attr_group; +#define power_supply_attr_groups NULL #define power_supply_uevent NULL #endif /* CONFIG_SYSFS */ diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 4f27f17f8741..0a716cc0f164 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -34,7 +34,6 @@ EXPORT_SYMBOL_GPL(power_supply_class); static BLOCKING_NOTIFIER_HEAD(power_supply_notifier); -__ATTRIBUTE_GROUPS(power_supply_attr); static const struct device_type power_supply_dev_type = { .name = "power_supply", .groups = power_supply_attr_groups, diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index edb240450e38..bf725cbb0d86 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -389,11 +389,16 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj, return 0; } -const struct attribute_group power_supply_attr_group = { +static const struct attribute_group power_supply_attr_group = { .attrs = __power_supply_attrs, .is_visible = power_supply_attr_is_visible, }; +const struct attribute_group *power_supply_attr_groups[] = { + &power_supply_attr_group, + NULL +}; + void power_supply_init_attrs(void) { int i;
As reported by the kernel test robot, 'power_supply_attr_group' is defined but not used when CONFIG_SYSFS is not set. Sebastian suggested that the correct fix implemented by this patch, instead of my attempt in commit ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef block"), is to define power_supply_attr_groups in power_supply_sysfs.c and expose it in the power_supply.h header. For the case where CONFIG_SYSFS=n, define it as NULL. Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.com> Fixes: ea4367c40c79 ("power: supply: core: move power_supply_attr_group into #ifdef block") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202403021518.SUQzk3oA-lkp@intel.com/ Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net> --- Changes in v2: - Fixed typo in commit title - Link to v1: https://lore.kernel.org/r/20240303-class_cleanup-power-v1-1-6a3abb5b15ad@marliere.net --- drivers/power/supply/power_supply.h | 4 ++-- drivers/power/supply/power_supply_core.c | 1 - drivers/power/supply/power_supply_sysfs.c | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) --- base-commit: 71c2cc5cbf686c2397f43cbcb51a31589bdcee7b change-id: 20240303-class_cleanup-power-7e25046623fc Best regards,