From: Guenter Roeck <linux@roeck-us.net>
To: Morduan Zang <zhangdandan@uniontech.com>,
devnull+cryolitia.gmail.com@kernel.org
Cc: CoelacanthusHex@gmail.com, Cryolitia@gmail.com, corbet@lwn.net,
jdelvare@suse.com, linux-doc@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
marcin@stragowski.com
Subject: Re: [PATCH] hwmon: gpd-fan: replace custom EC I/O with kernel ec_read/ec_write
Date: Thu, 26 Feb 2026 20:35:33 -0800 [thread overview]
Message-ID: <501be986-17b4-4fca-99bd-25c669f2b39c@roeck-us.net> (raw)
In-Reply-To: <53C09CAECC90EB98+20260227024945.151198-1-zhangdandan@uniontech.com>
On 2/26/26 18:49, Morduan Zang wrote:
> Replace the custom gpd_ecram_read() and gpd_ecram_write() functions that
> use direct I/O port access (inb/outb) with the kernel's standard ec_read()
> and ec_write() functions. This provides better abstraction, improves code
> maintainability, and ensures compatibility across different kernel
> versions.
>
It also adds dependency on ACPI. On top of that, it is quite obviously
buggy (see below).
> Signed-off-by: Morduan Zang <zhangdandan@uniontech.com>
> ---
> drivers/hwmon/gpd-fan.c | 37 +++----------------------------------
> 1 file changed, 3 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/hwmon/gpd-fan.c b/drivers/hwmon/gpd-fan.c
> index 1729729b135f..c44957b7fd91 100644
> --- a/drivers/hwmon/gpd-fan.c
> +++ b/drivers/hwmon/gpd-fan.c
> @@ -19,6 +19,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> +#include <linux/acpi.h>
>
> #define DRIVER_NAME "gpdfan"
> #define GPD_PWM_CTR_OFFSET 0x1841
> @@ -243,44 +244,12 @@ static const struct gpd_fan_drvdata *gpd_module_drvdata[] = {
> // Helper functions to handle EC read/write
> static void gpd_ecram_read(u16 offset, u8 *val)
> {
> - u16 addr_port = gpd_driver_priv.drvdata->addr_port;
> - u16 data_port = gpd_driver_priv.drvdata->data_port;
> -
> - outb(0x2E, addr_port);
> - outb(0x11, data_port);
> - outb(0x2F, addr_port);
> - outb((u8)((offset >> 8) & 0xFF), data_port);
> -
> - outb(0x2E, addr_port);
> - outb(0x10, data_port);
> - outb(0x2F, addr_port);
> - outb((u8)(offset & 0xFF), data_port);
> -
> - outb(0x2E, addr_port);
> - outb(0x12, data_port);
> - outb(0x2F, addr_port);
> - *val = inb(data_port);
> + *val = ec_read(offset, val);
ec_read() writes the return value into val, and returns an error code.
So this now returns the lower 8 bit of the error code as "value".
... which of course means that this code was not tested, and who knows
what the ec_read() and ec_write() functions actually do.
This code is so bad that I won't trust any subsequent versions. NACK.
Guenter
next prev parent reply other threads:[~2026-02-27 4:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 2:49 Morduan Zang
2026-02-27 3:03 ` Cryolitia PukNgae
2026-02-27 4:35 ` Guenter Roeck [this message]
2026-02-27 6:55 ` kernel test robot
2026-02-27 10:58 ` kernel test robot
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=501be986-17b4-4fca-99bd-25c669f2b39c@roeck-us.net \
--to=linux@roeck-us.net \
--cc=CoelacanthusHex@gmail.com \
--cc=Cryolitia@gmail.com \
--cc=corbet@lwn.net \
--cc=devnull+cryolitia.gmail.com@kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcin@stragowski.com \
--cc=zhangdandan@uniontech.com \
/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
all inboxes | Powered by JetHome®