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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07F45C64EC7 for ; Tue, 28 Feb 2023 22:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjB1WjF (ORCPT ); Tue, 28 Feb 2023 17:39:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbjB1WjA (ORCPT ); Tue, 28 Feb 2023 17:39:00 -0500 Received: from sonic302-21.consmr.mail.ir2.yahoo.com (sonic302-21.consmr.mail.ir2.yahoo.com [87.248.110.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6E7321954 for ; Tue, 28 Feb 2023 14:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1677623932; bh=s32HUPwCKOshIyB3RzDVkjP0uF49xcWO2+tOArORygE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=VigrbbD8aKFhzR97hZhIck1i/JZoKmjNuqqlIYkdawxgM2bALYrg5XHv3kzjLy+MFdth/ams8RdUG62fNEZbh3VND51wJMYty5O9oN2eD1xr40d5cIJ0qbZXFHKxDnNBi4tC3UfvCahYeR84sWbkTyJKzgHQgB0TqF/1ejM1LTqcBD0pHwlhaP4XjG9ENjDAtGSwyD2+llN5RrdJI/Zhcs5usM09h7036wpRrCJ9F1GdxjZJbfJVeJJDchySTTs2fmvqmooncMtH8WTTg51zts2RA0d/t95BTNA1MsX/tPcHVKM5Ig1gBco8u/Mj40BBVBlWc8zJDqut68XCMMQMVg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1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qzQkssUerkkLFP DS7vLmc3YPIH28xcWDLFzoSXs61P7aPa61UocBGLmvfePMM27THFHeiT1FlmbaWZ.ToJ1SSqCJid _X19uXAA3k86dFpglIyq6VEmDEQ0wdOOx3CcjC38SiNR3k7i.ReRQS5LlbOShmJWUZRBBVb6u5T_ c0.Dt9AGhLgOqHlgStN8y9tS8u.A4bMnMuXrdMCjOMFV527a9pkoTjhTIC2Xn9.XaVCTJ8iw4LzF n3Jb1MYBHf_F7qyzqDETlTPTlUJ6KfCy.Vjl9xc8Xw9jYgfh80w9gjbSwJKI7gF.2BSWrT7Z4y0a ZrzdN2PR94kHl4xh57K.iUjvFwISpPYQGgWF07iNF3SecIqx3wsSkM87Fx9AAaEph44uVMCWZa8g SwWlY3Eq3ADySg3Ctc48RTDoNFrJsHkS1iWvipBnUyi43Eli6eDNGdAewM4ytQ8A8q1jDj3EZUuu 17Ix4KHfPohq_PsdZIVfcOPqrIWJFyYKWCxHlkTA7n08cuwq4xGU2UiR6vwNJaNTE_Iv4H29x7Xz 3brrE4wy0mZCnZ_SnDZdk2grj6NxkUla0oAHGvhsT8.K7h1kletjiinZnzDT5PxNRllXIjeo2Dtt pfE2d6CMD.4vswlI4CDvjA.kQxKC3186sgWnCWM0qT1NLjBVvow-- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ir2.yahoo.com with HTTP; Tue, 28 Feb 2023 22:38:52 +0000 Received: by hermes--production-ir2-65c64dfd66-svnc4 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1052c26ec2388683ab738a7f87fce466; Tue, 28 Feb 2023 22:38:50 +0000 (UTC) From: Jakob Hauser To: Sebastian Reichel , Lee Jones , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: Beomho Seo , Chanwoo Choi , Stephan Gerhold , Raymond Hackley , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser Subject: [PATCH 09/10] power: supply: rt5033_battery: Adopt status property from charger Date: Tue, 28 Feb 2023 23:32:26 +0100 Message-Id: <768faa5609bcf52a97f1f1f71dea6518237b04a0.1677620677.git.jahau@rocketmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rt5033-battery fuelgauge can't get a status by itself. The rt5033-charger can, let's get this value. Tested-by: Raymond Hackley Signed-off-by: Jakob Hauser --- drivers/power/supply/rt5033_battery.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c index 5c04cf305219..48d4cccce4f6 100644 --- a/drivers/power/supply/rt5033_battery.c +++ b/drivers/power/supply/rt5033_battery.c @@ -12,6 +12,26 @@ #include #include +static int rt5033_battery_get_status(struct i2c_client *client) +{ + struct power_supply *charger; + union power_supply_propval val; + int ret; + + charger = power_supply_get_by_name("rt5033-charger"); + if (!charger) + return -ENODEV; + + ret = power_supply_get_property(charger, POWER_SUPPLY_PROP_STATUS, &val); + if (ret) { + power_supply_put(charger); + return POWER_SUPPLY_STATUS_UNKNOWN; + } + + power_supply_put(charger); + return val.intval; +} + static int rt5033_battery_get_capacity(struct i2c_client *client) { struct rt5033_battery *battery = i2c_get_clientdata(client); @@ -84,6 +104,9 @@ static int rt5033_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CAPACITY: val->intval = rt5033_battery_get_capacity(battery->client); break; + case POWER_SUPPLY_PROP_STATUS: + val->intval = rt5033_battery_get_status(battery->client); + break; default: return -EINVAL; } @@ -96,6 +119,7 @@ static enum power_supply_property rt5033_battery_props[] = { POWER_SUPPLY_PROP_VOLTAGE_OCV, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_CAPACITY, + POWER_SUPPLY_PROP_STATUS, }; static const struct regmap_config rt5033_battery_regmap_config = { -- 2.39.1