From patchwork Mon Oct 18 13:50:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12566539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6060C433EF for ; Mon, 18 Oct 2021 13:53:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F8FD60F25 for ; Mon, 18 Oct 2021 13:53:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232705AbhJRNzJ (ORCPT ); Mon, 18 Oct 2021 09:55:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43034 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233200AbhJRNxP (ORCPT ); Mon, 18 Oct 2021 09:53:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634565063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=axZ9Ln7q8QDt70Z8kWYCwfszQULRroHPak977G8hWws=; b=h63CSWRzE/lx7H1H0RpzTcNz4pt/S8LWKsSAPv0NXb11v7nzHFcogyXu8pTtfqTfVfbny2 pcOYBsxv8z4nL0IulKwjoMpIdWQUaE3Ig0QIfXjsUILswgyuBYlaJb4fwT6ukuKQwIZsjd LT4Z7v1BTVsEOj7f/FHu/DOiGuhtqUM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-214-fKIb7zDaP32i9q8-jYExhA-1; Mon, 18 Oct 2021 09:51:00 -0400 X-MC-Unique: fKIb7zDaP32i9q8-jYExhA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30FE11006AA2; Mon, 18 Oct 2021 13:50:59 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id B768C22719; Mon, 18 Oct 2021 13:50:57 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel Cc: Hans de Goede , Kate Hsuan , linux-pm@vger.kernel.org, kernel test robot Subject: [PATCH 1/3] power: supply: axp288-charger: Add depends on IOSF_MBIO to Kconfig Date: Mon, 18 Oct 2021 15:50:51 +0200 Message-Id: <20211018135053.213310-2-hdegoede@redhat.com> In-Reply-To: <20211018135053.213310-1-hdegoede@redhat.com> References: <20211018135053.213310-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add "depends on IOSF_MBI" to CONFIG_AXP288_CHARGER as the changes from commit ed229454856e ("power: supply: axp288-charger: Optimize register reading method") use symbols which are only defined when IOSF_MBI support is enabled. Depending on this is ok since IOSF_MBI support should always be enabled on devices which use the AXP288 PMIC. Fixes: ed229454856e ("power: supply: axp288-charger: Optimize register reading method") Reported-by: kernel test robot Signed-off-by: Hans de Goede --- drivers/power/supply/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index fcc7534edcb2..2366b785abd9 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -351,7 +351,7 @@ config AXP20X_POWER config AXP288_CHARGER tristate "X-Powers AXP288 Charger" - depends on MFD_AXP20X && EXTCON_AXP288 + depends on MFD_AXP20X && EXTCON_AXP288 && IOSF_MBI help Say yes here to have support X-Power AXP288 power management IC (PMIC) integrated charger. From patchwork Mon Oct 18 13:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12566543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DFB0C433FE for ; Mon, 18 Oct 2021 13:53:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11CCC60F11 for ; Mon, 18 Oct 2021 13:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233326AbhJRNzP (ORCPT ); Mon, 18 Oct 2021 09:55:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23669 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234169AbhJRNxQ (ORCPT ); Mon, 18 Oct 2021 09:53:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634565065; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dbjaDHTrTLCbvIh14r9ttu+A+qP55yZcf8yXCeCOYQs=; b=Y3DzwgDznSBS9Fffoy1gMMb3ALDRqwQabFrvCkLrcSDEp0Mk0k8jiU4V0BmVg76JqJAftv o7wY5a33GKOdDvMaHQ1j08X6nGbRdEfabeESbSTuYkRID1VsVdCKdzqw2/AnMWkcN4rJ+L 1Yg65Sj5+IcbC70bMS1UBg2y6csaYHg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-X8dXCel_NsasXEs7kSIpow-1; Mon, 18 Oct 2021 09:51:01 -0400 X-MC-Unique: X8dXCel_NsasXEs7kSIpow-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B65A1362F8; Mon, 18 Oct 2021 13:51:00 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81B39708E0; Mon, 18 Oct 2021 13:50:59 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel Cc: Hans de Goede , Kate Hsuan , linux-pm@vger.kernel.org Subject: [PATCH 2/3] power: supply: axp288-charger: Remove unnecessary is_present and is_online helpers Date: Mon, 18 Oct 2021 15:50:52 +0200 Message-Id: <20211018135053.213310-3-hdegoede@redhat.com> In-Reply-To: <20211018135053.213310-1-hdegoede@redhat.com> References: <20211018135053.213310-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that axp288_charger_usb_update_property() reads and caches all relevant registers, the axp288_charger_is_present() and axp288_charger_is_online() helpers are not necessary anymore. Directly check the cached input_status instead, allowing the removal of these 2 helpers. Signed-off-by: Hans de Goede --- drivers/power/supply/axp288_charger.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c index 058e2cd4b4aa..d09c8f36b73a 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -302,24 +302,6 @@ static int axp288_charger_enable_charger(struct axp288_chrg_info *info, return ret; } -static int axp288_charger_is_present(struct axp288_chrg_info *info) -{ - int present = 0; - - if (info->input_status & PS_STAT_VBUS_PRESENT) - present = 1; - return present; -} - -static int axp288_charger_is_online(struct axp288_chrg_info *info) -{ - int online = 0; - - if (info->input_status & PS_STAT_VBUS_VALID) - online = 1; - return online; -} - static int axp288_get_charger_health(struct axp288_chrg_info *info) { int health = POWER_SUPPLY_HEALTH_UNKNOWN; @@ -447,7 +429,7 @@ static int axp288_charger_usb_get_property(struct power_supply *psy, val->intval = 0; break; } - val->intval = axp288_charger_is_present(info); + val->intval = (info->input_status & PS_STAT_VBUS_PRESENT) ? 1 : 0; break; case POWER_SUPPLY_PROP_ONLINE: /* Check for OTG case first */ @@ -455,7 +437,7 @@ static int axp288_charger_usb_get_property(struct power_supply *psy, val->intval = 0; break; } - val->intval = axp288_charger_is_online(info); + val->intval = (info->input_status & PS_STAT_VBUS_VALID) ? 1 : 0; break; case POWER_SUPPLY_PROP_HEALTH: val->intval = axp288_get_charger_health(info); From patchwork Mon Oct 18 13:50:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 12566541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7564FC4332F for ; Mon, 18 Oct 2021 13:53:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C62B61361 for ; Mon, 18 Oct 2021 13:53:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234161AbhJRNzO (ORCPT ); Mon, 18 Oct 2021 09:55:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29135 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234138AbhJRNxQ (ORCPT ); Mon, 18 Oct 2021 09:53:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634565064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mWw0K7RgUOjSJJ1WfQxi7QXCSVGoMY40WVLfY8ZdmWQ=; b=jD1JyF1MrCoStwDtA7TQ3yW2zQXEvQAtXKBG1aBck/IFpZRpu77xT5+LXPtIy51+ZHZhsj nfw1LFxPyBYlzzqIUPskoFX/LCdA+3hK4NHHyYalEhOGDz39SUxRjMX4DAeuBlbs3EG7Wt tQLWcFjPpBSTlycfBNLoR9SZH9kNpBc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-603-rINODGhkMpCUDQLBS95_ZA-1; Mon, 18 Oct 2021 09:51:03 -0400 X-MC-Unique: rINODGhkMpCUDQLBS95_ZA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4397D1006AA4; Mon, 18 Oct 2021 13:51:02 +0000 (UTC) Received: from x1.localdomain (unknown [10.39.192.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 229A422719; Mon, 18 Oct 2021 13:51:00 +0000 (UTC) From: Hans de Goede To: Sebastian Reichel Cc: Hans de Goede , Kate Hsuan , linux-pm@vger.kernel.org Subject: [PATCH 3/3] power: supply: axp288-charger: Simplify axp288_get_charger_health() Date: Mon, 18 Oct 2021 15:50:53 +0200 Message-Id: <20211018135053.213310-4-hdegoede@redhat.com> In-Reply-To: <20211018135053.213310-1-hdegoede@redhat.com> References: <20211018135053.213310-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that axp288_charger_usb_update_property() reads and caches all relevant registers, axp288_get_charger_health() can be simplified by directly returning the health. Signed-off-by: Hans de Goede --- drivers/power/supply/axp288_charger.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c index d09c8f36b73a..ed058b598223 100644 --- a/drivers/power/supply/axp288_charger.c +++ b/drivers/power/supply/axp288_charger.c @@ -304,22 +304,17 @@ static int axp288_charger_enable_charger(struct axp288_chrg_info *info, static int axp288_get_charger_health(struct axp288_chrg_info *info) { - int health = POWER_SUPPLY_HEALTH_UNKNOWN; - if (!(info->input_status & PS_STAT_VBUS_PRESENT)) - goto health_read_fail; + return POWER_SUPPLY_HEALTH_UNKNOWN; if (!(info->input_status & PS_STAT_VBUS_VALID)) - health = POWER_SUPPLY_HEALTH_DEAD; + return POWER_SUPPLY_HEALTH_DEAD; else if (info->op_mode & CHRG_STAT_PMIC_OTP) - health = POWER_SUPPLY_HEALTH_OVERHEAT; + return POWER_SUPPLY_HEALTH_OVERHEAT; else if (info->op_mode & CHRG_STAT_BAT_SAFE_MODE) - health = POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE; + return POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE; else - health = POWER_SUPPLY_HEALTH_GOOD; - -health_read_fail: - return health; + return POWER_SUPPLY_HEALTH_GOOD; } static int axp288_charger_usb_set_property(struct power_supply *psy,