Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp748181rwd; Sun, 14 May 2023 06:02:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+aZBKZcPGCvaDMX5Vga1dBc+8p4EppPC9pWw7f0qsSQ5XEQdfXQWmVDLSW/uZ2xmw1kko X-Received: by 2002:a9d:6d85:0:b0:6ab:1447:8817 with SMTP id x5-20020a9d6d85000000b006ab14478817mr10775656otp.17.1684069359043; Sun, 14 May 2023 06:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684069359; cv=none; d=google.com; s=arc-20160816; b=wCMvnjnmSRBCQbnFCwelTb5m0bSUQ5LWSJwc5bSC8sX+5I+t0mXxKaqOWHa3xT+3KP k9PNHDJpiiC5zLfKrGn43H93yU52ggiPQwD1EbJo8+pB20+tqMz1i7epQmJn3BIHP4kh 9mSjFFtX0g2Xca1O5CMeTbdM83ZZCguWrBt8kBtYwnbw4UMex6s2OiNegcdEWUbyyxy4 OtvrZODneEvlYStGxEnII1APItxwlUUoH4lV00KzcxI3vcn5dfVEydwrLvxGMjbVNEuw oDiIEMMfwS8Z9eJCImL4kzdUr1MkMuzbWV/c2bQjvyi9Y2RPj5exFFyRLkno1TqMp+WT 1gOA== 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=iR6f3XRVOHcEpdjcnFCif4nNa1shR7J/nAlLWRT5R4w=; b=B3Yt+h3TSK21OaOgfnnDPv2QZWdXhRLytrGptgWdR/PVtfqavEJedoqIC3r+iZrVHJ S3Z1d5mUadLS4J8OZQwfgC6tjAvLO/P/6kHXVrel2Wpc5o7v9UYvMnPaYzZfiOYEV+Nx Kdcc09dpg4BIxyhyijH1w0YoM23KRg+T+QEgJGePUoXaZ5L5UOSZKAkDFQ1Nru/H7qKJ DBlchs+tqR9T8+Eb5jyBr6Af8IzrNIL9KfVaMII+T50UEeaXKtHB7oWjQuoSyM1Byxtj pLEUwoPyVtTofg85+BgKXy3nzBC7d5ZXiBLpO/5aqKxZPyZCUQSaBKQbUjkKLd6TdpJ8 +ddg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=aNDwZkDh; 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 ca25-20020a056830611900b006aaefd292d7si2323214otb.137.2023.05.14.06.02.17; Sun, 14 May 2023 06:02:39 -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=aNDwZkDh; 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 S229611AbjENMhd (ORCPT + 99 others); Sun, 14 May 2023 08:37:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234058AbjENMh3 (ORCPT ); Sun, 14 May 2023 08:37:29 -0400 Received: from sonic314-19.consmr.mail.ir2.yahoo.com (sonic314-19.consmr.mail.ir2.yahoo.com [77.238.177.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 933D726BB for ; Sun, 14 May 2023 05:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1684067845; bh=iR6f3XRVOHcEpdjcnFCif4nNa1shR7J/nAlLWRT5R4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=aNDwZkDhIJzo4X4lCijZaF803UlbasjNKxdPtFrPJjSswTHmICKbz4nGPtmZeMGWBDQfbp+luEfFb6rjlqb59sKKJsLfhCrm4GFuF4shK6rNeIBY751vV5L27gukt7acQyNjIfE7ThqHjH9zs56cE3zw2LHv4zjpox+M5eIPbBTJ0baEFLQA1n/Qd+ITibYbDZ8FJyIKGGxK3oaTds9jXKvRKu7LZoHufuXwhitmHZmAkCIj5lDXiMO9uTGIyneRPKd4jma+H15ZGzUazW8fuHHamtlKD4uhd+SohMW33rI7fbUPqgm05OqXkkx7cx35zfkp9eujLKricCVpHhWYTA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1684067845; bh=RjpbhSDHhQw1UtHbfXMZI6CGElLiocD+Lb9tXb5dZ0m=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=FCvemGMKBWTvJyxVJTyJ3zgb9IT7hTBRsbA+jhZlGN9B4/pTtPGjRjuDHqEoZSK84DKnCUcyNDSpzZiQYjM+/h/7N+FAsdubR/ToMwxn86WCZNWvOp4Zzr9wWGRpfuBXxQ52O2mUUGQ5HlaTNFQ+3xrmhsM4/tUHvn+kidv0XvTQ5EHUL4SChttBU0cFK5RhMFfNo7Do8l+jk3mo9x4XDA7biSWPhNMCd0oyzVdsoZRaXBwteBB7XrwIlwb6Gy8+yoaeJT9aCquw3fYNLeTj+TiHtQE13AsxtDlV3gKo5mxqjRs0uDDQjAIco4sKQWVO8VBtB4pIOGN10faC7RMiyA== X-YMail-OSG: mWsgP6UVM1lqWsEsYFxpseFHRosMBuMe61n_Ji4lNO7ELZZRKOqBAc7GPpU2lDU JYVFs1WYQ7FmkCnhPHeOEBtAn5KAcE9cr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widhmqeMju3pYMB1Rin6ALl3jMn8004p KcV_EFqxSYwTxa7di1P6wehSrapEXM2r17Rz8Z5iuZKjOSFKl_ie41GZuqBwGFGkotQMGMoKvZeB CXls_ki6QIi98d3w27Ns9tXyVu.ih5w-- X-Sonic-MF: X-Sonic-ID: 877ba4c0-0451-46bb-a1c2-970c7ffcb540 Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.ir2.yahoo.com with HTTP; Sun, 14 May 2023 12:37:25 +0000 Received: by hermes--production-ir2-7867f454fc-tvsct (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID ec262f708c8ca7d1990bed607fb68ca2; Sun, 14 May 2023 12:37:22 +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 , 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 Subject: [PATCH v5 08/10] power: supply: rt5033_battery: Adopt status property from charger Date: Sun, 14 May 2023 14:31:28 +0200 Message-Id: <20230514123130.41172-9-jahau@rocketmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230514123130.41172-1-jahau@rocketmail.com> References: <20230514123130.41172-1-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,RCVD_IN_MSPIKE_H2,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 --- 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