* [PATCH] power: supply: move power_supply_attr_group into #ifdef block
@ 2024-02-28 13:46 Ricardo B. Marliere
2024-02-28 17:10 ` Nathan Chancellor
2024-02-28 22:08 ` Sebastian Reichel
0 siblings, 2 replies; 3+ messages in thread
From: Ricardo B. Marliere @ 2024-02-28 13:46 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Sebastian Reichel, linux-pm, linux-kernel, Greg Kroah-Hartman,
Nathan Chancellor, Ricardo B. Marliere
When building with CONFIG_SYSFS=n, the build error below is triggered:
ld: drivers/power/supply/power_supply_core.o:(.data+0x0): undefined
reference to `power_supply_attr_group'
The problem is that power_supply_attr_group is needed in
power_supply_core.c but defined in power_supply_sysfs.c, which is only
targeted with CONFIG_SYSFS=y. Therefore, move the extern declaration into
the #ifdef block that checks for CONFIG_SYSFS, and define an empty static
const struct otherwise. This is safe because the macro __ATRIBUTE_GROUPS in
power_supply_core.c will expand into an empty attribute_group array.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/all/20240227214916.GA3699076@dev-arch.thelio-3990X/
Fixes: 7b46b60944d7 ("power: supply: core: constify the struct device_type usage")
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
This patch depends on [1].
[1]: 20240227-fix-power_supply_init_attrs-stub-v1-1-43365e68d4b3@kernel.org
---
drivers/power/supply/power_supply.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
index 7d05756398b9..06749a534db4 100644
--- a/drivers/power/supply/power_supply.h
+++ b/drivers/power/supply/power_supply.h
@@ -13,16 +13,16 @@ struct device;
struct device_type;
struct power_supply;
-extern const struct attribute_group power_supply_attr_group;
-
#ifdef CONFIG_SYSFS
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;
#else
static inline void power_supply_init_attrs(void) {}
+static const struct attribute_group power_supply_attr_group;
#define power_supply_uevent NULL
#endif /* CONFIG_SYSFS */
---
base-commit: 837af6b0cdb2b8df56d2df35db0444cfa1ea47c2
change-id: 20240228-device_cleanup-power-2dcfaa7b7f2b
Best regards,
--
Ricardo B. Marliere <ricardo@marliere.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: move power_supply_attr_group into #ifdef block
2024-02-28 13:46 [PATCH] power: supply: move power_supply_attr_group into #ifdef block Ricardo B. Marliere
@ 2024-02-28 17:10 ` Nathan Chancellor
2024-02-28 22:08 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2024-02-28 17:10 UTC (permalink / raw)
To: Ricardo B. Marliere
Cc: Sebastian Reichel, Sebastian Reichel, linux-pm, linux-kernel,
Greg Kroah-Hartman
On Wed, Feb 28, 2024 at 10:46:28AM -0300, Ricardo B. Marliere wrote:
> When building with CONFIG_SYSFS=n, the build error below is triggered:
>
> ld: drivers/power/supply/power_supply_core.o:(.data+0x0): undefined
> reference to `power_supply_attr_group'
>
> The problem is that power_supply_attr_group is needed in
> power_supply_core.c but defined in power_supply_sysfs.c, which is only
> targeted with CONFIG_SYSFS=y. Therefore, move the extern declaration into
> the #ifdef block that checks for CONFIG_SYSFS, and define an empty static
> const struct otherwise. This is safe because the macro __ATRIBUTE_GROUPS in
> power_supply_core.c will expand into an empty attribute_group array.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Link: https://lore.kernel.org/all/20240227214916.GA3699076@dev-arch.thelio-3990X/
> Fixes: 7b46b60944d7 ("power: supply: core: constify the struct device_type usage")
> Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Tested-by: Nathan Chancellor <nathan@kernel.org> # build
Thanks for the quick fix!
> ---
> This patch depends on [1].
> [1]: 20240227-fix-power_supply_init_attrs-stub-v1-1-43365e68d4b3@kernel.org
> ---
> drivers/power/supply/power_supply.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h
> index 7d05756398b9..06749a534db4 100644
> --- a/drivers/power/supply/power_supply.h
> +++ b/drivers/power/supply/power_supply.h
> @@ -13,16 +13,16 @@ struct device;
> struct device_type;
> struct power_supply;
>
> -extern const struct attribute_group power_supply_attr_group;
> -
> #ifdef CONFIG_SYSFS
>
> 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;
>
> #else
>
> static inline void power_supply_init_attrs(void) {}
> +static const struct attribute_group power_supply_attr_group;
> #define power_supply_uevent NULL
>
> #endif /* CONFIG_SYSFS */
>
> ---
> base-commit: 837af6b0cdb2b8df56d2df35db0444cfa1ea47c2
> change-id: 20240228-device_cleanup-power-2dcfaa7b7f2b
>
> Best regards,
> --
> Ricardo B. Marliere <ricardo@marliere.net>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: supply: move power_supply_attr_group into #ifdef block
2024-02-28 13:46 [PATCH] power: supply: move power_supply_attr_group into #ifdef block Ricardo B. Marliere
2024-02-28 17:10 ` Nathan Chancellor
@ 2024-02-28 22:08 ` Sebastian Reichel
1 sibling, 0 replies; 3+ messages in thread
From: Sebastian Reichel @ 2024-02-28 22:08 UTC (permalink / raw)
To: Sebastian Reichel, Ricardo B. Marliere
Cc: linux-pm, linux-kernel, Greg Kroah-Hartman, Nathan Chancellor
On Wed, 28 Feb 2024 10:46:28 -0300, Ricardo B. Marliere wrote:
> When building with CONFIG_SYSFS=n, the build error below is triggered:
>
> ld: drivers/power/supply/power_supply_core.o:(.data+0x0): undefined
> reference to `power_supply_attr_group'
>
> The problem is that power_supply_attr_group is needed in
> power_supply_core.c but defined in power_supply_sysfs.c, which is only
> targeted with CONFIG_SYSFS=y. Therefore, move the extern declaration into
> the #ifdef block that checks for CONFIG_SYSFS, and define an empty static
> const struct otherwise. This is safe because the macro __ATRIBUTE_GROUPS in
> power_supply_core.c will expand into an empty attribute_group array.
>
> [...]
Applied, thanks!
[1/1] power: supply: move power_supply_attr_group into #ifdef block
commit: ea4367c40c79a5f16cb0de8a94a6b72697d37f06
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-28 22:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28 13:46 [PATCH] power: supply: move power_supply_attr_group into #ifdef block Ricardo B. Marliere
2024-02-28 17:10 ` Nathan Chancellor
2024-02-28 22:08 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®