Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20536438ybl; Sun, 5 Jan 2020 05:04:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy2GQUxnjyyNhVdxZ78M2Yq2LorpOuB8uJMkwq1Q+191oiIQc+dXekKcU3U8iPTKUSespbi X-Received: by 2002:a05:6830:2110:: with SMTP id i16mr106994328otc.337.1578229492298; Sun, 05 Jan 2020 05:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578229492; cv=none; d=google.com; s=arc-20160816; b=Oh2aSuGumkpTBgLdvYyXwvP16CC5UesILnlgf7ps/6TgVWh8jERtn8D0TQpJEvegKH Kg7up+xKIuvdwHTHP7l3rLVmFfJR7rUbg9sH4WIk41Hs2YMdO1+lDImtYn2EcoWRg8Jj 5xSq65mljfZrG7mcLs+CuWyuEo/ztWTc/FumNj0nokLecj30PIu5Va9Y1pa8Gs+Tl7TA uDxCjIfFQtcDzjR4p+utbfgYpCpZpD/vEj9X+lgf0wyQs0h9nEbNosUgUI6EgiQvuiL4 1VERKRBcb229RN+BkaNnvKr+cmkMR3s36hVL5VnOFjPpyI8LX5oD9rnJ3gKpYjokKmrW wxAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wtj4ycfHH4tNcald6Hu3wfTW6bDI5OTHJjc7dzUfoq0=; b=08qG7IOpBTqKqnE56M6OnV1czmlgJQ5Pzhv4H3JzHkkLYQr2XCMkBUy82Uef2qOOot RHYoQC2RbIxp1WfkDnlXRZ4VBACsBswPzG7IU7qYG03HL1IY6+0EUYKKvNYiBfmKiYGZ basLKGsYAw1+2qqxcxkCl0HXm+q7FpU3o55qp+HUd7rukI2MRy3NSBoQK+brlpyWCbgF TOLlnIje82MDpo/CRktXSxdZR8c6S+eUhX1K6fdTCyH2grQgkYXzKRAxwiGtuv6WvOzz 9wdU2FTtycf7Mbj9K6e69RISiqVc0y8mW0wpVFTSpHWkjbsNG++P28mcXBIe1lEXLg9I nkow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=meOv6Nbx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si29244890oij.125.2020.01.05.05.04.14; Sun, 05 Jan 2020 05:04:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=meOv6Nbx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgAENAq (ORCPT + 99 others); Sun, 5 Jan 2020 08:00:46 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:46143 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726029AbgAENAq (ORCPT ); Sun, 5 Jan 2020 08:00:46 -0500 Received: by mail-lj1-f194.google.com with SMTP id m26so45769600ljc.13; Sun, 05 Jan 2020 05:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wtj4ycfHH4tNcald6Hu3wfTW6bDI5OTHJjc7dzUfoq0=; b=meOv6NbxWkh2QWiN19ICU9RrFOj8sUAIx0weTKNSjxrNhTKdZhtHhN4TVLEDBDqAs3 7KzeubXZ4ueV9A0YSa0gdaBYC7IlB6YgaiYbfwr9IUL3GobCmcnLZHBy8PTUHsDp4B3G ELln8M4CfcVt70mY8YO+yYVtYVsgCDFxJOxSo3ljD15KNsjvdrnrQol7BtXVi8bDJ9F1 ub8M2R0ZQ82ESmbQWq+fw9lH1SL/dV1M1l0yU59c/xT2APU49eZnEru0hMqmxwuH2m2Y 23c25jZB3BiBuxHDk+u1R8ZQrz3ZK2FmEiM6aDsXYWDJTzBAa0Cut7J7bRVqY1HU3G2g AokQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wtj4ycfHH4tNcald6Hu3wfTW6bDI5OTHJjc7dzUfoq0=; b=HGRELdr1HqkM4zO5zCnstcj0VYAy0V2dkLXYgwFj95MWxD5kTeVUmjju62zPemIMBC mjNlKPF2vnItVHl0Gd+NvIdribi13fFs0P8sulyO194dFbjXzwMYXEu+QiJcbZPLRv8t xhQDEkFCVBXLA3YDaScuswaxLMNXw0vk0iaGzm2PscjWF7jIXIUO36zmibjKZBnTbNYu hHETX6Dl+xHVr283kLW5Nr2GS+8NVjFJ6C6fam3LFGqzSv/Qh6LIc/Zj6tQZ97iMgORq VWQ/dOYO59f+b0e7fvW8IOJRmIGgvAqYBYdUUD0NUeDvTNI67Z+pH5WiWciYhFMjNFmk di9A== X-Gm-Message-State: APjAAAUfOi9/XUJjU34DAA5DTDRyrWhyab9tj0ZSLJ+oMwshmraPhqCm aPpBBXTY2OQdkoJbEXhLss5pFOgnCWZ3xHqCu0g= X-Received: by 2002:a2e:8544:: with SMTP id u4mr54341659ljj.70.1578229243841; Sun, 05 Jan 2020 05:00:43 -0800 (PST) MIME-Version: 1.0 References: <20200105012416.23296-1-samuel@sholland.org> <20200105012416.23296-3-samuel@sholland.org> In-Reply-To: <20200105012416.23296-3-samuel@sholland.org> From: Julian Calaby Date: Mon, 6 Jan 2020 00:00:32 +1100 Message-ID: Subject: Re: [linux-sunxi] [PATCH v2 2/9] power: supply: axp20x_ac_power: Fix reporting online status To: samuel@sholland.org Cc: Chen-Yu Tsai , Sebastian Reichel , Lee Jones , Hans de Goede , Oskari Lemmela , Quentin Schulz , linux-pm@vger.kernel.org, LKML , linux-sunxi , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Samuel, On Sun, Jan 5, 2020 at 12:24 PM Samuel Holland 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@vger.kernel.org > Signed-off-by: Samuel Holland > --- > 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@gmail.com Profile: http://www.google.com/profiles/julian.calaby/