[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ek7w5yd2kvmk7qnu3v776dckyjyvdmfahebqbvzfyckwi2szwz@ytcuz22io2cs>
Date: Tue, 27 Aug 2024 19:14:24 +0200
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Krzysztof Kozlowski <krzk@...nel.org>
Cc: Artur Weber <aweber.kernel@...il.com>,
Chanwoo Choi <cw00.choi@...sung.com>, Rob Herring <robh@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Lee Jones <lee@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Alim Akhtar <alim.akhtar@...sung.com>, linux-pm@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-samsung-soc@...r.kernel.org,
~postmarketos/upstreaming@...ts.sr.ht, Henrik Grimler <henrik@...mler.se>,
Wolfgang Wiedmeyer <wolfgit@...dmeyer.de>, Denis 'GNUtoo' Carikli <GNUtoo@...erdimension.org>
Subject: Re: [PATCH v4 04/10] power: supply: max77693: Set charge current
limits during init
Hi,
On Fri, Aug 16, 2024 at 05:40:37PM GMT, Krzysztof Kozlowski wrote:
> On 16/08/2024 16:25, Artur Weber wrote:
> >
> >
> > On 16.08.2024 11:54, Krzysztof Kozlowski wrote:
> >> On 16/08/2024 10:19, Artur Weber wrote:
> >>> @@ -732,6 +794,15 @@ static int max77693_charger_probe(struct platform_device *pdev)
> >>> chg->dev = &pdev->dev;
> >>> chg->max77693 = max77693;
> >>>
> >>> + psy_cfg.drv_data = chg;
> >>> +
> >>> + chg->charger = devm_power_supply_register(&pdev->dev,
> >>> + &max77693_charger_desc,
> >>> + &psy_cfg);
> >>> + if (IS_ERR(chg->charger))
> >>> + return dev_err_probe(&pdev->dev, PTR_ERR(chg->charger),
> >>> + "failed: power supply register\n");
> >>
> >> This code move is not explained in the commit msg. At least I could not
> >> find it. Please explain why you need it in the commit msg.
> >
> > This is done because the call to power_supply_get_battery_info in
> > max77693_dt_init requires chg->charger to be set. (I was considering
> > putting this in the commit message, can't remember why I didn't do it.
> > I'll add it in the next version.)
>
> I think that's wrong. Power supply is being available to the system
> before it is being configured.
It's a known limitation of the power_supply_get_battery_info API.
I think it would be best to add an register_init() hook to struct
power_supply_desc, which would be called from __power_supply_register()
directly before it calls device_add(). At that point the power_supply
struct is initialized far enough for getting the battery info, but not
yet exposed to the remaining system.
As a nice side effect the register writes happen after checking the
supplies, so the registers are not written if the probe errors out
with a probe defer anyways.
Greetings,
-- Sebastian
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists