diff options
author | NeilBrown <neil@brown.name> | 2015-08-07 13:45:25 +1000 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-08-07 07:04:56 +0200 |
commit | b49d15d138aa4632f35a2db93dee775d920f3653 (patch) | |
tree | f273623e7839667c5de84ecb36406d5a85d34f60 /drivers/power/twl4030_charger.c | |
parent | c9f85a90d41476aca2d3b60f98ab87d7ae1b8612 (diff) | |
download | lwn-b49d15d138aa4632f35a2db93dee775d920f3653.tar.gz lwn-b49d15d138aa4632f35a2db93dee775d920f3653.zip |
twl4030_charger: fix compile error when TWL4030_MADC not available.
We can only use the madc to check for 'ac' availability if the madc has
been compiled in. If not: assume always using USB.
Reported-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: NeilBrown <neil@brown.name>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/twl4030_charger.c')
-rw-r--r-- | drivers/power/twl4030_charger.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index 2c537ee11bbe..f4f2c1f76c32 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c @@ -91,6 +91,21 @@ #define TWL4030_MSTATEC_COMPLETE1 0x0b #define TWL4030_MSTATEC_COMPLETE4 0x0e +#if IS_ENABLED(CONFIG_TWL4030_MADC) +/* + * If AC (Accessory Charger) voltage exceeds 4.5V (MADC 11) + * then AC is available. + */ +static inline int ac_available(void) +{ + return twl4030_get_madc_conversion(11) > 4500; +} +#else +static inline int ac_available(void) +{ + return 0; +} +#endif static bool allow_usb; module_param(allow_usb, bool, 0644); MODULE_PARM_DESC(allow_usb, "Allow USB charge drawing default current"); @@ -263,7 +278,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci) * If AC (Accessory Charger) voltage exceeds 4.5V (MADC 11) * and AC is enabled, set current for 'ac' */ - if (twl4030_get_madc_conversion(11) > 4500) { + if (ac_available()) { cur = bci->ac_cur; bci->ac_is_active = true; } else { |