Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275401 > unrolled thread

[PATCH] power: bq27xxx_battery: avoid unused function warnings

Started byArnd Bergmann <arnd@arndb.de>
First post2015-11-23 14:50 +0100
Last post2015-11-23 17:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] power: bq27xxx_battery: avoid unused function warnings Arnd Bergmann <arnd@arndb.de> - 2015-11-23 14:50 +0100
    Re: [PATCH] power: bq27xxx_battery: avoid unused function warnings "Andrew F. Davis" <afd@ti.com> - 2015-11-23 17:50 +0100

#1275401 — [PATCH] power: bq27xxx_battery: avoid unused function warnings

FromArnd Bergmann <arnd@arndb.de>
Date2015-11-23 14:50 +0100
Subject[PATCH] power: bq27xxx_battery: avoid unused function warnings
Message-ID<qxZFg-2qN-5@gated-at.bofh.it>
We can configure the bq27xxx_battery driver with neither the I2C
nor the platform driver backends, which leaves out all references
to some of the symbols, causing a couple of warnings in many
randconfig builds:

drivers/power/bq27xxx_battery.c:288:12: warning: 'bq27xxx_regs' defined but not used [-Wunused-variable]
drivers/power/bq27xxx_battery.c:994:12: warning: 'bq27xxx_powersupply_init' defined but not used [-Wunused-function]
drivers/power/bq27xxx_battery.c:1029:13: warning: 'bq27xxx_powersupply_unregister' defined but not used [-Wunused-function]

I first tried replacing the existing #ifdefs with if(IS_ENABLED()
statements, but that failed because the i2c framework does not
declare functions when they are left out of the kernel.

This just marks the unused functions as __maybe_unused, which is
a correct description here. A better fix would be to restructure
the driver into separate files and only build the common parts
if at least one of the two bus specific drivers is enabled, but
that requires much more work and testing on real hardware.

For the time being, my simpler change at least avoids the warnings.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---

diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/bq27xxx_battery.c
index 880233ce9343..6c3a447f378b 100644
--- a/drivers/power/bq27xxx_battery.c
+++ b/drivers/power/bq27xxx_battery.c
@@ -285,7 +285,7 @@ static u8 bq27421_regs[] = {
 	0x18,	/* AP		*/
 };
 
-static u8 *bq27xxx_regs[] = {
+static u8 *bq27xxx_regs[] __maybe_unused = {
 	[BQ27000] = bq27000_regs,
 	[BQ27010] = bq27010_regs,
 	[BQ27500] = bq27500_regs,
@@ -991,7 +991,7 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)
 	schedule_delayed_work(&di->work, 0);
 }
 
-static int bq27xxx_powersupply_init(struct bq27xxx_device_info *di,
+static int __maybe_unused bq27xxx_powersupply_init(struct bq27xxx_device_info *di,
 				    const char *name)
 {
 	int ret;
@@ -1026,7 +1026,7 @@ static int bq27xxx_powersupply_init(struct bq27xxx_device_info *di,
 	return 0;
 }
 
-static void bq27xxx_powersupply_unregister(struct bq27xxx_device_info *di)
+static void __maybe_unused bq27xxx_powersupply_unregister(struct bq27xxx_device_info *di)
 {
 	/*
 	 * power_supply_unregister call bq27xxx_battery_get_property which

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1275626

From"Andrew F. Davis" <afd@ti.com>
Date2015-11-23 17:50 +0100
Message-ID<qy2ts-4pB-35@gated-at.bofh.it>
In reply to#1275401
On 11/23/2015 07:42 AM, Arnd Bergmann wrote:
> We can configure the bq27xxx_battery driver with neither the I2C
> nor the platform driver backends, which leaves out all references
> to some of the symbols, causing a couple of warnings in many
> randconfig builds:
>
> drivers/power/bq27xxx_battery.c:288:12: warning: 'bq27xxx_regs' defined but not used [-Wunused-variable]
> drivers/power/bq27xxx_battery.c:994:12: warning: 'bq27xxx_powersupply_init' defined but not used [-Wunused-function]
> drivers/power/bq27xxx_battery.c:1029:13: warning: 'bq27xxx_powersupply_unregister' defined but not used [-Wunused-function]
>
> I first tried replacing the existing #ifdefs with if(IS_ENABLED()
> statements, but that failed because the i2c framework does not
> declare functions when they are left out of the kernel.
>
> This just marks the unused functions as __maybe_unused, which is
> a correct description here. A better fix would be to restructure
> the driver into separate files and only build the common parts
> if at least one of the two bus specific drivers is enabled, but
> that requires much more work and testing on real hardware.
>
> For the time being, my simpler change at least avoids the warnings.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>
> diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/bq27xxx_battery.c
> index 880233ce9343..6c3a447f378b 100644
> --- a/drivers/power/bq27xxx_battery.c
> +++ b/drivers/power/bq27xxx_battery.c
> @@ -285,7 +285,7 @@ static u8 bq27421_regs[] = {
>   	0x18,	/* AP		*/
>   };
>
> -static u8 *bq27xxx_regs[] = {
> +static u8 *bq27xxx_regs[] __maybe_unused = {
>   	[BQ27000] = bq27000_regs,
>   	[BQ27010] = bq27010_regs,
>   	[BQ27500] = bq27500_regs,
> @@ -991,7 +991,7 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)
>   	schedule_delayed_work(&di->work, 0);
>   }
>
> -static int bq27xxx_powersupply_init(struct bq27xxx_device_info *di,
> +static int __maybe_unused bq27xxx_powersupply_init(struct bq27xxx_device_info *di,
>   				    const char *name)
>   {
>   	int ret;
> @@ -1026,7 +1026,7 @@ static int bq27xxx_powersupply_init(struct bq27xxx_device_info *di,
>   	return 0;
>   }
>
> -static void bq27xxx_powersupply_unregister(struct bq27xxx_device_info *di)
> +static void __maybe_unused bq27xxx_powersupply_unregister(struct bq27xxx_device_info *di)
>   {
>   	/*
>   	 * power_supply_unregister call bq27xxx_battery_get_property which
>

The current organization of this driver has caused a lot of problems like this,
it has been discussed that it should just be re-organized before. I went ahead
and finally did this, I'll push the patch here in a bit, should take care of this and
several other issues.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web