All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pengyu Luo <mitltlatltl@gmail.com>
To: ilpo.jarvinen@linux.intel.com
Cc: andersson@kernel.org, bryan.odonoghue@linaro.org,
	conor+dt@kernel.org, devicetree@vger.kernel.org,
	dmitry.baryshkov@linaro.org, gregkh@linuxfoundation.org,
	hdegoede@redhat.com, heikki.krogerus@linux.intel.com,
	konradybcio@kernel.org, krzk+dt@kernel.org,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-usb@vger.kernel.org,
	mitltlatltl@gmail.com, nikita@trvn.ru,
	platform-driver-x86@vger.kernel.org, robh@kernel.org,
	sre@kernel.org
Subject: Re: [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver
Date: Sun, 29 Dec 2024 23:55:51 +0800	[thread overview]
Message-ID: <20241229155551.92070-1-mitltlatltl@gmail.com> (raw)
In-Reply-To: <41e8cc85-6978-49b0-7216-3ce715d48101@linux.intel.com>

On Sun, Dec 29, 2024 at 11:33 PM Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote:
> On Sat, 28 Dec 2024, Pengyu Luo wrote:
> > On Sat, Dec 28, 2024 at 8:33 PM Bryan O'Donoghue <bryan.odonoghue@linaro.org> wrote:
> > > On 27/12/2024 17:13, Pengyu Luo wrote:
> > > > There are 3 variants, Huawei released first 2 at the same time.
> > >
> > > There are three variants of which Huawei released the first two
> > > simultaneously.

[skipped]

> > > > +/* Thermal Zone */
> > > > +/* Range from 0 to 0x2C, partial valid */
> > > > +static const u8 temp_reg[] = {0x05, 0x07, 0x08, 0x0E, 0x0F, 0x12, 0x15, 0x1E,
> > > > +                           0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26,
> > > > +                           0x27, 0x28, 0x29, 0x2A};
> > > > +
> > > > +int gaokun_ec_wmi_get_temp(struct gaokun_ec *ec, s16 temp[GAOKUN_TZ_REG_NUM])
> > >
> > > int gaokun_ec_wmi_get_temp(struct gaokun_ec *ec, s16 *temp, size_t
> > > temp_reg_num)
> > >
> > >
> > > > +{
> > > > +     /* GTMP */
> > > > +     u8 req[REQ_HDR_SIZE] = {0x02, 0x61, 1,};
> > > > +     u8 resp[RESP_HDR_SIZE + sizeof(s16)];
> > > > +     int ret, i = 0;
> > > > +
> > > > +     while (i < GAOKUN_TZ_REG_NUM) {
> > > while (i < temp_reg_num)
> > >
> >
> > It is a constant. But later, as Krzysztof suggested, I will use interfaces
> > from hwmon, then reading one at a time.
> >
> > > > +             req[INPUT_DATA_OFFSET] = temp_reg[i];
> > > > +             ret = gaokun_ec_read(ec, req, sizeof(resp), resp);
> > > > +             if (ret)
> > > > +                     return -EIO;
> > > > +             temp[i++] = *(s16 *)(resp + DATA_OFFSET);
> > >
> > > What's the point of the casting here ?
> > >
> > > memcpy(temp, resp, sizeof(s16));
> > > temp++;
> >
> > A 2Bytes symbol number in little endian, ec return it like this, so
> > casting.
>
> You should use __le16 and proper endianess conversion function then.
>

Agree

> It's bit confusing that in the declaration you used RESP_HDR_SIZE and here
> you do it with DATA_OFFSET instead. It feels DATA_OFFSET is unnecessary
> duplicate of RESP_HDR_SIZE and will easily lead confusing variation such
> as above.
>

I totally agree with you, it is duplicated.
In declaration, u8 resp[RESP_HDR_SIZE]; RESP_HDR_SIZE indicates the size.
When assigning, val = resp[DATA_OFFSET]; let us know we are extracting a
data from a response without thinking, so I added an alias. Removing it
is also fine for me.

Best wishes,
Pengyu

  reply	other threads:[~2024-12-29 15:57 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-27 17:13 [PATCH 0/5] platform: arm64: Huawei Matebook E Go embedded controller Pengyu Luo
2024-12-27 17:13 ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Pengyu Luo
2024-12-27 18:18   ` Rob Herring (Arm)
2024-12-28  9:54   ` Krzysztof Kozlowski
2024-12-28 10:50     ` Pengyu Luo
2024-12-29  9:50       ` Krzysztof Kozlowski
2024-12-29 10:12         ` Pengyu Luo
2024-12-30  7:28           ` Aiqun(Maria) Yu
2024-12-30  7:35             ` Krzysztof Kozlowski
2024-12-30  9:10               ` Aiqun(Maria) Yu
2024-12-30  8:00             ` Pengyu Luo
2025-01-01  5:57             ` Pengyu Luo
2024-12-27 17:13 ` [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver Pengyu Luo
2024-12-27 18:21   ` Maya Matuszczyk
2024-12-28  5:42     ` Pengyu Luo
2024-12-28  9:58   ` Krzysztof Kozlowski
2024-12-28 11:34     ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Pengyu Luo
2024-12-29  4:08       ` Dmitry Baryshkov
2024-12-29  9:04         ` [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver Pengyu Luo
2024-12-29  9:44           ` Krzysztof Kozlowski
2024-12-29  9:43       ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Krzysztof Kozlowski
2024-12-29 10:28         ` Pengyu Luo
2024-12-29 21:45           ` Krzysztof Kozlowski
2024-12-28 12:33   ` [PATCH 2/5] platform: arm64: add Huawei Matebook E Go (sc8280xp) EC driver Bryan O'Donoghue
2024-12-28 13:51     ` Pengyu Luo
2024-12-29 15:32       ` Ilpo Järvinen
2024-12-29 15:55         ` Pengyu Luo [this message]
2024-12-29 14:49   ` Markus Elfring
2024-12-30  9:04   ` Aiqun(Maria) Yu
2024-12-30 10:44     ` Pengyu Luo
2024-12-31  5:00       ` Aiqun(Maria) Yu
2024-12-31  7:44         ` Pengyu Luo
2024-12-31 11:09           ` Bryan O'Donoghue
2025-01-03  5:38           ` Dmitry Baryshkov
2025-01-03  7:19             ` Pengyu Luo
2025-01-01 11:27         ` Pengyu Luo
2024-12-27 17:13 ` [PATCH 3/5] usb: typec: ucsi: add Huawei Matebook E Go (sc8280xp) ucsi driver Pengyu Luo
2024-12-28 13:06   ` Bryan O'Donoghue
2024-12-28 14:38     ` Pengyu Luo
2024-12-29 14:51       ` Bryan O'Donoghue
2024-12-29 16:25         ` Pengyu Luo
2024-12-29  4:40   ` Dmitry Baryshkov
2024-12-29  9:05     ` Pengyu Luo
2025-01-06  3:33       ` Dmitry Baryshkov
2025-01-06  9:20         ` [PATCH 1/5] dt-bindings: platform: Add Huawei Matebook E Go EC Pengyu Luo
2025-01-06  9:22         ` [PATCH 3/5] usb: typec: ucsi: add Huawei Matebook E Go (sc8280xp) ucsi driver Pengyu Luo
2024-12-29 16:15   ` Markus Elfring
2024-12-27 17:13 ` [PATCH 4/5] power: supply: add Huawei Matebook E Go (sc8280xp) psy driver Pengyu Luo
2024-12-27 17:13 ` [PATCH 5/5] arm64: dts: qcom: gaokun3: Add Embedded Controller node Pengyu Luo
2024-12-30 14:53   ` Konrad Dybcio
2024-12-30 16:22     ` Pengyu Luo

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=20241229155551.92070-1-mitltlatltl@gmail.com \
    --to=mitltlatltl@gmail.com \
    --cc=andersson@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nikita@trvn.ru \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.