lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <200945d3-f4ca-9a73-f101-4fda96ab8b2c@rocketmail.com>
Date:   Sun, 14 May 2023 14:54:57 +0200
From:   Jakob Hauser <jahau@...ketmail.com>
To:     Sebastian Reichel <sre@...nel.org>
Cc:     Lee Jones <lee@...nel.org>, Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Beomho Seo <beomho.seo@...sung.com>,
        Chanwoo Choi <cw00.choi@...sung.com>,
        Stephan Gerhold <stephan@...hold.net>,
        Raymond Hackley <raymondhackley@...tonmail.com>,
        Pavel Machek <pavel@....cz>, Axel Lin <axel.lin@...ics.com>,
        ChiYuan Huang <cy_huang@...htek.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Henrik Grimler <henrik@...mler.se>, linux-pm@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        phone-devel@...r.kernel.org, ~postmarketos/upstreaming@...ts.sr.ht
Subject: Re: [PATCH v5 05/10] power: supply: rt5033_charger: Add RT5033
 charger device driver

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ