From: Jakob Hauser <jahau@rocketmail.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: Lee Jones <lee@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Beomho Seo <beomho.seo@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Stephan Gerhold <stephan@gerhold.net>,
Raymond Hackley <raymondhackley@protonmail.com>,
Pavel Machek <pavel@ucw.cz>, Axel Lin <axel.lin@ingics.com>,
ChiYuan Huang <cy_huang@richtek.com>,
Linus Walleij <linus.walleij@linaro.org>,
Henrik Grimler <henrik@grimler.se>,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v5 05/10] power: supply: rt5033_charger: Add RT5033 charger device driver
Date: Sun, 14 May 2023 14:54:57 +0200 [thread overview]
Message-ID: <200945d3-f4ca-9a73-f101-4fda96ab8b2c@rocketmail.com> (raw)
In-Reply-To: <20230514123130.41172-6-jahau@rocketmail.com>
Hi Sebastian,
On 14.05.23 14:31, Jakob Hauser wrote:
...
> +static struct rt5033_charger_data *rt5033_charger_dt_init(
> + struct rt5033_charger *charger)
> +{
> + struct rt5033_charger_data *chg;
> + struct power_supply_battery_info *info;
> + int ret;
> +
> + chg = devm_kzalloc(charger->dev, sizeof(*chg), GFP_KERNEL);
> + if (!chg)
> + return ERR_PTR(-ENOMEM);
> +
> + ret = power_supply_get_battery_info(charger->psy, &info);
> + if (ret)
> + return ERR_PTR(dev_err_probe(charger->dev, -EINVAL,
> + "missing battery info\n"));
Here you suggested to use: "info = charger->psy->battery_info;". This
didn't work.
The supply type of the rt5033-charger is set as POWER_SUPPLY_TYPE_USB.
The one of rt5033-battery is POWER_SUPPLY_TYPE_BATTERY. Which makes
sense because if both of them are POWER_SUPPLY_TYPE_BATTERY, userspace
sees two batteries reported, one of which with 0% capacity (the charger
doesn't report capacity).
The ...->psy->battery_info, however, gets populated only for a power
supply device that is supply type POWER_SUPPLY_TYPE_BATTERY [1].
[1]
https://github.com/torvalds/linux/blob/v6.4-rc1/drivers/power/supply/power_supply_core.c#L1390-L1399
> +
> + /* Assign data. Validity will be checked in the init functions. */
> + chg->pre_uamp = info->precharge_current_ua;
> + chg->fast_uamp = info->constant_charge_current_max_ua;
> + chg->eoc_uamp = info->charge_term_current_ua;
> + chg->pre_uvolt = info->precharge_voltage_max_uv;
> + chg->const_uvolt = info->constant_charge_voltage_max_uv;
> +
> + return chg;
> +}
...
Kind regards,
Jakob
next prev parent reply other threads:[~2023-05-14 12:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230514123130.41172-1-jahau.ref@rocketmail.com>
2023-05-14 12:31 ` [PATCH v5 00/10] Add RT5033 charger device driver Jakob Hauser
2023-05-14 12:31 ` [PATCH v5 01/10] mfd: rt5033: Drop rt5033-battery sub-device Jakob Hauser
2023-05-14 12:31 ` [PATCH v5 02/10] mfd: rt5033: Fix chip revision readout Jakob Hauser
2023-05-14 12:31 ` [PATCH v5 03/10] mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines Jakob Hauser
2023-05-14 12:31 ` [PATCH v5 04/10] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver Jakob Hauser
2023-05-14 12:31 ` [PATCH v5 05/10] power: supply: rt5033_charger: Add RT5033 charger device driver Jakob Hauser
2023-05-14 12:54 ` Jakob Hauser [this message]
2023-05-14 14:31 ` Christophe JAILLET
2023-05-14 17:03 ` Jakob Hauser
2023-05-14 22:51 ` Sebastian Reichel
2023-05-14 12:31 ` [PATCH v5 06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply Jakob Hauser
2023-05-14 22:47 ` Sebastian Reichel
2023-05-14 12:31 ` [PATCH v5 07/10] power: supply: rt5033_battery: Move struct rt5033_battery to battery driver Jakob Hauser
2023-05-14 22:47 ` Sebastian Reichel
2023-05-14 12:31 ` [PATCH v5 08/10] power: supply: rt5033_battery: Adopt status property from charger Jakob Hauser
2023-05-14 22:48 ` Sebastian Reichel
2023-05-14 12:31 ` [PATCH v5 09/10] dt-bindings: power: supply: rt5033-battery: Add power-supplies as a property Jakob Hauser
2023-05-14 16:43 ` Krzysztof Kozlowski
2023-05-14 12:31 ` [PATCH v5 10/10] dt-bindings: Add rt5033 mfd, regulator and charger Jakob Hauser
2023-05-14 16:44 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200945d3-f4ca-9a73-f101-4fda96ab8b2c@rocketmail.com \
--to=jahau@rocketmail.com \
--cc=axel.lin@ingics.com \
--cc=beomho.seo@samsung.com \
--cc=broonie@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=cy_huang@richtek.com \
--cc=devicetree@vger.kernel.org \
--cc=henrik@grimler.se \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=phone-devel@vger.kernel.org \
--cc=raymondhackley@protonmail.com \
--cc=robh+dt@kernel.org \
--cc=sre@kernel.org \
--cc=stephan@gerhold.net \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox