[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGRGNgXeenNYMNXY0dewQaeG2QecUPgE_MOofURg7HzcND782w@mail.gmail.com>
Date: Mon, 6 Jan 2020 00:00:32 +1100
From: Julian Calaby <julian.calaby@...il.com>
To: samuel@...lland.org
Cc: Chen-Yu Tsai <wens@...e.org>, Sebastian Reichel <sre@...nel.org>,
Lee Jones <lee.jones@...aro.org>,
Hans de Goede <hdegoede@...hat.com>,
Oskari Lemmela <oskari@...mela.net>,
Quentin Schulz <quentin.schulz@...tlin.com>,
linux-pm@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
linux-sunxi <linux-sunxi@...glegroups.com>,
stable@...r.kernel.org
Subject: Re: [linux-sunxi] [PATCH v2 2/9] power: supply: axp20x_ac_power: Fix
reporting online status
Hi Samuel,
On Sun, Jan 5, 2020 at 12:24 PM Samuel Holland <samuel@...lland.org> wrote:
>
> AXP803/AXP813 have a flag that enables/disables the AC power supply
> input. This flag does not affect the status bits in PWR_INPUT_STATUS.
> Its effect can be verified by checking the battery charge/discharge
> state (bit 2 of PWR_INPUT_STATUS), or by examining the current draw on
> the AC input.
>
> Take this flag into account when getting the ONLINE property of the AC
> input, on PMICs where this flag is present.
>
> Fixes: 7693b5643fd2 ("power: supply: add AC power supply driver for AXP813")
> Cc: stable@...r.kernel.org
> Signed-off-by: Samuel Holland <samuel@...lland.org>
> ---
> drivers/power/supply/axp20x_ac_power.c | 31 +++++++++++++++++++++-----
> 1 file changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/axp20x_ac_power.c
> index 0d34a932b6d5..ca0a28f72a27 100644
> --- a/drivers/power/supply/axp20x_ac_power.c
> +++ b/drivers/power/supply/axp20x_ac_power.c
> @@ -23,6 +23,8 @@
> #define AXP20X_PWR_STATUS_ACIN_PRESENT BIT(7)
> #define AXP20X_PWR_STATUS_ACIN_AVAIL BIT(6)
>
> +#define AXP813_ACIN_PATH_SEL BIT(7)
> +
> #define AXP813_VHOLD_MASK GENMASK(5, 3)
> #define AXP813_VHOLD_UV_TO_BIT(x) ((((x) / 100000) - 40) << 3)
> #define AXP813_VHOLD_REG_TO_UV(x) \
> @@ -40,6 +42,7 @@ struct axp20x_ac_power {
> struct power_supply *supply;
> struct iio_channel *acin_v;
> struct iio_channel *acin_i;
> + bool has_acin_path_sel;
> };
>
> static irqreturn_t axp20x_ac_power_irq(int irq, void *devid)
> @@ -86,6 +89,17 @@ static int axp20x_ac_power_get_property(struct power_supply *psy,
> return ret;
>
> val->intval = !!(reg & AXP20X_PWR_STATUS_ACIN_AVAIL);
> +
> + /* ACIN_PATH_SEL disables ACIN even if ACIN_AVAIL is set. */
> + if (power->has_acin_path_sel) {
Do we need to check this bit if ACIN_AVAIL is not set?
> + ret = regmap_read(power->regmap, AXP813_ACIN_PATH_CTRL,
> + ®);
> + if (ret)
> + return ret;
> +
> + val->intval &= !!(reg & AXP813_ACIN_PATH_SEL);
If we only check this bit if ACIN_AVAIL is set, then we don't need the
"&" in the "&=". (I'm assuming that val->intval is an int, not a bool,
otherwise this is the wrong operator)
Thanks,
--
Julian Calaby
Email: julian.calaby@...il.com
Profile: http://www.google.com/profiles/julian.calaby/
Powered by blists - more mailing lists