public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: gpd-fan: replace custom EC I/O with kernel ec_read/ec_write
@ 2026-02-27  2:49 Morduan Zang
  2026-02-27  3:03 ` Cryolitia PukNgae
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Morduan Zang @ 2026-02-27  2:49 UTC (permalink / raw)
  To: devnull+cryolitia.gmail.com
  Cc: CoelacanthusHex, Cryolitia, corbet, jdelvare, linux-doc,
	linux-hwmon, linux-kernel, linux, marcin, Morduan Zang

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.

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);
 }
 
 static void gpd_ecram_write(u16 offset, u8 value)
 {
-	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);
-	outb(value, data_port);
+	ec_write(offset, value);
 }
 
 static int gpd_generic_read_rpm(void)
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-27 11:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27  2:49 [PATCH] hwmon: gpd-fan: replace custom EC I/O with kernel ec_read/ec_write Morduan Zang
2026-02-27  3:03 ` Cryolitia PukNgae
2026-02-27  4:35 ` Guenter Roeck
2026-02-27  6:55 ` kernel test robot
2026-02-27 10:58 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox