Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2551820rwd; Mon, 15 May 2023 13:21:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hmdxH3WSlV92hLD6zi1f8+Uv2ygk18kZ4DnyRl2aa2+7YNSlO+nv1UMClA99323eHubyb X-Received: by 2002:a05:6a20:8e15:b0:104:6f59:3dc4 with SMTP id y21-20020a056a208e1500b001046f593dc4mr15581709pzj.62.1684182078265; Mon, 15 May 2023 13:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684182078; cv=none; d=google.com; s=arc-20160816; b=FEtE7sJkz2TCFEEjIQCXDCX2651KDZI9cSrQLoBuVoTEck6aP+WcRpL4eruK7vwgcU Av8Zq8wen7R/qKY3vsvw55DuUDBY1gF+SSVf2NyuiLL326Iy6YJdVeUbspqig6iq4+CD EudWLxWeX1ofNw1MNKD0/heWLmnTLjkqLHELnYEHTbXC/z0/L9aNkFiI6uVoIMn1ULjy zZrmK84rXyqtWjgN239I+OdB0v1dOU33qiiGBzYncwC8sBaoJ7F2oTce4VWt2MoHTPdO bxCZArAEYwC0tmVlhkpeVGyflaYS1w5Ep9fz9AvuCkrnvFVlyPFZ4O/ovoypGoRJWlbJ 43ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Orv9xlXl2ys7vR4uDv3BL0KEya+/X55FDQeChcF+Wx8=; b=txxDOq5zp+NgMU916t75xjA6GKlQRd8LMY/QtZ8X1S1pN46e551nHsWLoM68/J6YPD /lf7w32oUjfLwavcbPvQrveEXy3GRfA2vITdKPcCb1fCF6ycippbvtw2fkmBvgOLTAto dFe0ailUJA3fWW7R3HVyirsX4RJDQtmNVRS+OePh40i2hGLqLX5Q3pEaGaE+uo8DtExZ TYzazJx0hoVAlYkI1Z+WN16R7Ll0uBpsBys3R4qGxvuonZ5wsReQwCyQdnN1b+TJJHfR TJaa5N+jlR59j6pCpDLOZ31g1kJvN4I9nYArtJwcOEWOREvDbK7csUukIOIaesP2xRea 9IJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=QC82tEqV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a63b343000000b0051f0bd40bb0si17033266pgt.779.2023.05.15.13.20.41; Mon, 15 May 2023 13:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=QC82tEqV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245299AbjEOUTD (ORCPT + 99 others); Mon, 15 May 2023 16:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245322AbjEOUSg (ORCPT ); Mon, 15 May 2023 16:18:36 -0400 Received: from sonic301-22.consmr.mail.ir2.yahoo.com (sonic301-22.consmr.mail.ir2.yahoo.com [77.238.176.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6512120BC for ; Mon, 15 May 2023 13:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1684181871; bh=Orv9xlXl2ys7vR4uDv3BL0KEya+/X55FDQeChcF+Wx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=QC82tEqVnOdPOLck4AWPS1Oxbuo6+6vUzcLTxSi7UvC74CACKWah3ColkFxUKy/4bLiPzco+s7z3tuwno9GZ5F3av6qnDDLmzqR2cftkWoa4Yl19Pb4GnVuNvRQLEgWR+TH9IDS8OS9ZzZG7FNjiYNXu453NB1RmMYpO5+5rdmeud2CK4xidw2Mtsc2vd+eUEwwTzDLKD9IV2na6TSBayQtQXcTpv9SC8HaX3sF1oW+ufROjMAaKztHamjLILhKIDlvPXLtNhK2hMejkkeOU/gB39xehnz0V3oSDoNrrQKqUd1NfRNRY6KCS3KI0laJIWhJRsn86HQi+cABFMS6zCA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1684181871; bh=K49QPtGjNbriJKMuofqiZphv/NCgNob2jjg+2INQjBi=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=sE2D6Ksk64u23xb7lw8h8pWrtYHQdFrHC6he/ZoVGG+Mkwi3kzyGOaoJhK0Cl5DdPcdpLuSxrKayCV2dnIB1Fq3PBMaksGdFFmsivafRBM762LIcMzpnDeK6CcXIek6nFqmGTCGI7//OAmhweGKezCDQJxlvnPlgXU011DfrmODjwa5s9ds7MIeef5MPKzDShDeXhm0JsKO+oAl8leQbknSxBv9oeaYQjct0i61obbrPvfONn1Lj6m5flQGBe6hdrzqh+4+M7m+6N5gU36uqdWJoBkvs5YYbzQ27HCoD91e1CHNpMcLNSF92SSSPTWjuApTM/l+giPqFlIw8JzKYvQ== X-YMail-OSG: IFxmzi4VM1mO3.iur2nQWy7FV2Opphkfxxw.UOkcA43Lrm9uGwvyDtW4A2kwYX5 OLU8Gv3cMTAUdmhPuRZIwHLUBkuwyBxJmRTbSeAg0.EXJYPWeAM4jqx.YvlUhZTzdh_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ls92hQfWX9VqiDylvw2Cp_jvHTtsovjnFlg.h3NLpyLT.IhHJteq yBQDU0EK3OSCANYV2MU6GIhf5AA-- X-Sonic-MF: X-Sonic-ID: 128f9572-9d09-4333-b790-65a0e522659e Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Mon, 15 May 2023 20:17:51 +0000 Received: by hermes--production-ir2-7867f454fc-8nkq6 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID cb456a1ee9275492b492c35f2e11856e; Mon, 15 May 2023 20:17: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 , Pavel Machek , Axel Lin , ChiYuan Huang , Linus Walleij , Henrik Grimler , Christophe Jaillet , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser , Sebastian Reichel Subject: [PATCH v6 08/10] power: supply: rt5033_battery: Adopt status property from charger Date: Mon, 15 May 2023 22:17:10 +0200 Message-Id: <20230515201712.30124-9-jahau@rocketmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230515201712.30124-7-jahau@rocketmail.com> References: <20230515201712.30124-7-jahau@rocketmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. To get the charger as a "supplier" from the devicetree, the "of_node" needs to be initiated. Additionally, in the probe function replace dev_err() with dev_err_probe(), this will avoid printing an error for -EPROBE_DEFER when the battery driver probes before the charger driver. Signed-off-by: Jakob Hauser Acked-by: Sebastian Reichel --- drivers/power/supply/rt5033_battery.c | 29 +++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c index 91e1efd81f69..94d2dea7ef5e 100644 --- a/drivers/power/supply/rt5033_battery.c +++ b/drivers/power/supply/rt5033_battery.c @@ -19,6 +19,21 @@ struct rt5033_battery { struct power_supply *psy; }; +static int rt5033_battery_get_status(struct i2c_client *client) +{ + struct rt5033_battery *battery = i2c_get_clientdata(client); + union power_supply_propval val; + int ret; + + ret = power_supply_get_property_from_supplier(battery->psy, + POWER_SUPPLY_PROP_STATUS, + &val); + if (ret) + val.intval = POWER_SUPPLY_STATUS_UNKNOWN; + + return val.intval; +} + static int rt5033_battery_get_capacity(struct i2c_client *client) { struct rt5033_battery *battery = i2c_get_clientdata(client); @@ -91,6 +106,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; } @@ -103,6 +121,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 = { @@ -124,7 +143,6 @@ static int rt5033_battery_probe(struct i2c_client *client) struct i2c_adapter *adapter = client->adapter; struct power_supply_config psy_cfg = {}; struct rt5033_battery *battery; - u32 ret; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) return -EIO; @@ -142,15 +160,14 @@ static int rt5033_battery_probe(struct i2c_client *client) } i2c_set_clientdata(client, battery); + psy_cfg.of_node = client->dev.of_node; psy_cfg.drv_data = battery; battery->psy = power_supply_register(&client->dev, &rt5033_battery_desc, &psy_cfg); - if (IS_ERR(battery->psy)) { - dev_err(&client->dev, "Failed to register power supply\n"); - ret = PTR_ERR(battery->psy); - return ret; - } + if (IS_ERR(battery->psy)) + return dev_err_probe(&client->dev, PTR_ERR(battery->psy), + "Failed to register power supply\n"); return 0; } -- 2.39.2