[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <hggfy3pwu4du7msmeg2hz6y5i4kvogpbwzw33lcubhso7angob@q7llvdyz4x2b>
Date: Fri, 31 May 2024 03:58:57 +0300
From: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc: Sebastian Reichel <sre@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Bjorn Andersson <andersson@...nel.org>, Hans de Goede <hdegoede@...hat.com>,
Bryan O'Donoghue <bryan.odonoghue@...aro.org>, Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Konrad Dybcio <konrad.dybcio@...aro.org>,
linux-pm@...r.kernel.org, devicetree@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
platform-driver-x86@...r.kernel.org, linux-usb@...r.kernel.org, linux-arm-msm@...r.kernel.org,
Nikita Travkin <nikita@...n.ru>
Subject: Re: [PATCH v4 4/6] power: supply: lenovo_yoga_c630_battery: add
Lenovo C630 driver
On Wed, May 29, 2024 at 06:41:36PM +0300, Ilpo Järvinen wrote:
> On Tue, 28 May 2024, Dmitry Baryshkov wrote:
>
> > On the Lenovo Yoga C630 WOS laptop the EC provides access to the adapter
> > and battery status. Add the driver to read power supply status on the
> > laptop.
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
> > ---
> > drivers/power/supply/Kconfig | 9 +
> > drivers/power/supply/Makefile | 1 +
> > drivers/power/supply/lenovo_yoga_c630_battery.c | 479 ++++++++++++++++++++++++
> > 3 files changed, 489 insertions(+)
> >
> > +
> > + val = yoga_c630_ec_read16(ec, LENOVO_EC_BAT_DESIGN_CAPACITY);
> > + if (val < 0)
> > + return val;
> > + ecbat->design_capacity = val * 1000;
>
> Check linux/units.h if some WATT related one matches to that literal 1000.
I'd rather not do that. The capacity might be either in microWatt-hours
or in microAmp-hours. Using WATT will be confusing in the second case.
> > + msleep(50);
> > +
> > + val = yoga_c630_ec_read16(ec, LENOVO_EC_BAT_VOLTAGE);
> > + if (val < 0)
> > + return val;
> > + ecbat->voltage_now = val * 1000;
>
> Ditto.
No, Volts and Amps don't have units in <linux/units.h>
>
> > + msleep(50);
> > +
> > + val = yoga_c630_ec_read16(ec, LENOVO_EC_BAT_CURRENT);
> > + if (val < 0)
> > + return val;
> > + current_mA = sign_extend32(val, 15);
> > + ecbat->current_now = current_mA * 1000;
> > + ecbat->rate_now = current_mA * (ecbat->voltage_now / 1000);
>
> Ditto.
The same
>
> > + msleep(50);
> > +
> > + if (!ecbat->unit_mA)
> > + ecbat->capacity_now *= 10;
> > +
> > + ecbat->last_status_update = jiffies;
--
With best wishes
Dmitry
Powered by blists - more mailing lists