Re: [PATCH v3] power: supply: sbs-battery: Handle unsupported PROP_TIME_TO_EMPTY_NOW

From: AngeloGioacchino Del Regno
Date: Fri Apr 19 2024 - 03:26:52 EST


Il 18/04/24 19:34, Nícolas F. R. A. Prado ha scritto:
Despite the RunTimeToEmpty() (0x11) function being defined in the SBS
specification as required, it seems that not all batteries implement it.
On platforms with such batteries, reading the property will cause an
error to be printed:

power_supply sbs-8-000b: driver failed to report `time_to_empty_now' property: -5

This not only pollutes the log, distracting from real problems on the
device, but also prevents the uevent file from being read since it
contains all properties, including the faulty one.

The following table summarizes the findings for a handful of platforms:

Platform Status Manufacturer Model
------------------------------------------------------------------------
mt8186-corsola-steelix-sku131072 OK BYD L22B3PG0
mt8195-cherry-tomato-r2 NOT OK PANASON AP16L5J
mt8192-asurada-spherion-r0 NOT OK PANASON AP15O5L
mt8183-kukui-jacuzzi-juniper-sku16 NOT OK LGC KT0 AP16L8J
mt8173-elm-hana OK Sunwoda L18D3PG1
sc7180-trogdor-lazor-limozeen-nots-r5 NOT OK Murata AP18C4K
sc7180-trogdor-kingoftown NOT OK 333-AC-0D-A GG02047XL
rk3399-gru-kevin OK SDI 4352D51

Detect if this is one of the quirky batteries during presence update, so
that hot-plugging works as expected, and if so report -ENODATA for
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, which removes it from uevent and
prevents throwing errors.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@xxxxxxxxxxxxx>

Nícolas, please, I think that sending this commit to stable for backporting
makes a lot of sense since you're actually fixing laptops (that does not
really require a Fixes tag) that are supported upstream since .. lots of time
ago.

In any case, this LGTM.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>