From: Konrad Dybcio <konrad.dybcio@linaro.org>
To: Nikita Travkin <nikita@trvn.ru>,
Sebastian Reichel <sre@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
cros-qcom-dts-watchers@chromium.org,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 2/3] power: supply: Add Acer Aspire 1 embedded controller driver
Date: Thu, 7 Dec 2023 20:24:53 +0100 [thread overview]
Message-ID: <71459bab-05b9-41f6-bb32-2b744736487d@linaro.org> (raw)
In-Reply-To: <20231207-aspire1-ec-v1-2-ba9e1c227007@trvn.ru>
On 12/7/23 12:20, Nikita Travkin wrote:
> Acer Aspire 1 is a Snapdragon 7c based laptop. It uses an embedded
> controller to control the charging and battery management, as well as to
> perform a set of misc functions.
>
> Unfortunately, while all this functionality is implemented in ACPI, it's
> currently not possible to use ACPI to boot Linux on such Qualcomm
> devices. To allow Linux to still support the features provided by EC,
> this driver reimplments the relevant ACPI parts. This allows us to boot
> the laptop with Device Tree and retain all the features.
>
> Signed-off-by: Nikita Travkin <nikita@trvn.ru>
> ---
[...]
> + case POWER_SUPPLY_PROP_CAPACITY:
> + val->intval = le16_to_cpu(ddat.capacity_now) * 100
> + / le16_to_cpu(sdat.capacity_full);
It may be just my OCD and im not the maintainer here, but I'd do
/= here
[...]
> + case POWER_SUPPLY_PROP_MODEL_NAME:
> + if (sdat.model_id - 1 < ARRAY_SIZE(aspire_ec_psy_battery_model))
> + val->strval = aspire_ec_psy_battery_model[sdat.model_id - 1];
> + else
> + val->strval = "Unknown";
Would it make sense to print the model_id that's absent from the LUT
here and similarly below?
> + break;
> +
> + case POWER_SUPPLY_PROP_MANUFACTURER:
> + if (sdat.vendor_id - 3 < ARRAY_SIZE(aspire_ec_psy_battery_vendor))
> + val->strval = aspire_ec_psy_battery_vendor[sdat.vendor_id - 3];
> + else
> + val->strval = "Unknown";
> + break;
> +
> + default:
> + return -EINVAL;
> + }
Another ocd trip, i'd add a newline before return
> + return 0;
> +}
[...]
> + /*
> + * The original ACPI firmware actually has a small sleep in the handler.
> + *
> + * It seems like in most cases it's not needed but when the device
> + * just exits suspend, our i2c driver has a brief time where data
> + * transfer is not possible yet. So this delay allows us to suppress
> + * quite a bunch of spurious error messages in dmesg. Thus it's kept.
Ouch.. do you think i2c-geni needs fixing on this part?
[...]
> + switch (id) {
> + case 0x0: /* No event */
> + break;
Is this a NOP/watchdog sort of thing?
[...]
> +
> +static struct i2c_driver aspire_ec_driver = {
> + .driver = {
> + .name = "aspire-ec",
> + .of_match_table = aspire_ec_of_match,
> + .pm = pm_sleep_ptr(&aspire_ec_pm_ops),
> + },
> + .probe = aspire_ec_probe,
> + .id_table = aspire_ec_id,
Since it's tristate, I'd expect an entry for .remove_new here
Konrad
next prev parent reply other threads:[~2023-12-07 19:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 11:20 [PATCH 0/3] power: supply: Acer Aspire 1 embedded controller Nikita Travkin
2023-12-07 11:20 ` [PATCH 1/3] dt-bindings: power: supply: Add Acer Aspire 1 EC Nikita Travkin
2023-12-07 16:56 ` Krzysztof Kozlowski
2023-12-07 17:21 ` Nikita Travkin
2023-12-07 11:20 ` [PATCH 2/3] power: supply: Add Acer Aspire 1 embedded controller driver Nikita Travkin
2023-12-07 19:24 ` Konrad Dybcio [this message]
2023-12-08 10:31 ` Nikita Travkin
2023-12-07 11:20 ` [PATCH 3/3] arm64: dts: qcom: acer-aspire1: Add embedded controller Nikita Travkin
2023-12-07 19:25 ` Konrad Dybcio
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=71459bab-05b9-41f6-bb32-2b744736487d@linaro.org \
--to=konrad.dybcio@linaro.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=cros-qcom-dts-watchers@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nikita@trvn.ru \
--cc=robh+dt@kernel.org \
--cc=sre@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).