Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] hwmon: Add Razer PWM PC Fan Controller driver
@ 2026-12-05 19:13 Victor Chernyakin
  2026-12-05 19:36 ` sashiko-bot
  2026-12-05 19:37 ` Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: Victor Chernyakin @ 2026-12-05 19:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, Victor Chernyakin,
	Jiri Kosina, Benjamin Tissoires, linux-hwmon, linux-doc,
	linux-kernel, linux-input

This is a USB fan controller (VID 0x1532, PID 0x0F3C) that supports
up to 8 connected fans. The driver exposes their RPM readings and allows
setting their PWM duty cycles.

The controller can report which of its ports actually have fans connected,
and whether those fans are 3-wire or 4-wire. The driver uses this
information to limit the exposed sysfs attributes to meaningful ones.

Although the controller supports hotplugging fans (it can generate an event
when this happens), I've chosen to not implement this in the driver,
because it seems like a big headache (manually tracking and dynamically
adding/removing all those sysfs files) for little gain (is anyone actually
hotplugging their fans?). Instead the driver just queries which fans are
present once at startup and goes with that.

Signed-off-by: Victor Chernyakin <chernyakin.victor.j@outlook.com>
---

I've included two nonstandard sysfs files that expose the controller's
firmware version and serial number. I know the contributing guidelines
discourage nonstandard attributes, but this seems like a reasonable use,
for this kind of extra info? If not I can remove them.

Tested by manually poking sysfs attributes, and in CoolerControl.

---
 Documentation/hwmon/index.rst                 |   1 +
 .../hwmon/razer_pwm_pc_fan_controller.rst     |  39 ++
 MAINTAINERS                                   |   7 +
 drivers/hid/hid-quirks.c                      |   1 +
 drivers/hwmon/Kconfig                         |  10 +
 drivers/hwmon/Makefile                        |   1 +
 drivers/hwmon/razer_pwm_pc_fan_controller.c   | 472 ++++++++++++++++++
 7 files changed, 531 insertions(+)
 create mode 100644 Documentation/hwmon/razer_pwm_pc_fan_controller.rst
 create mode 100644 drivers/hwmon/razer_pwm_pc_fan_controller.c

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 9955a525436a..ebe686e9547f 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -235,6 +235,7 @@ Hardware Monitoring Kernel Drivers
    q54sj108a2
    qnap-mcu-hwmon
    raspberrypi-hwmon
+   razer_pwm_pc_fan_controller
    sbrmi
    sbtsi_temp
    sch5627
diff --git a/Documentation/hwmon/razer_pwm_pc_fan_controller.rst b/Documentation/hwmon/razer_pwm_pc_fan_controller.rst
new file mode 100644
index 000000000000..c90da5df1bfa
--- /dev/null
+++ b/Documentation/hwmon/razer_pwm_pc_fan_controller.rst
@@ -0,0 +1,39 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver razer_pwm_pc_fan_controller
+=========================================
+
+Supported devices:
+
+* Razer PWM PC Fan Controller (USB, VID 0x1532, PID 0x0F3C)
+
+Author: Victor Chernyakin <chernyakin.victor.j@outlook.com>
+
+Description
+-----------
+
+This driver provides hwmon support for the Razer PWM PC Fan Controller, a USB
+fan controller that supports up to 8 3-wire or 4-wire fans.
+
+At startup, the driver queries which of the controller's ports have fans
+connected, and doesn't query this again. This means that if a fan is hotplugged,
+the change will not be detected until the controller itself is disconnected
+and reconnected, or the system is rebooted.
+
+Sysfs entries
+-------------
+
+================= ==== ========================================================
+fan[1-8]_input    RO   Fan speed in RPM. Only exposed for those ports that
+                       have a fan connected (whether 3-wire or 4-wire).
+pwm[1-8]          RW   PWM duty cycle (0-255). Reads returns the last
+                       successfully written value. Initialized to 127.
+                       Only exposed for those ports that have a 4-wire fan
+		       connected. Because the controller's firmware doesn't
+		       allow setting a duty cycle less than 33%, any values
+		       below 85 are rounded up to 85 (expect for 0, which
+		       disables the fan).
+firmware_version  RO   The controller's firmware version in the format
+                       "%u.%u.%u.%u".
+serial_number     RO   The controller's serial number as an ASCII string.
+================= ==== ========================================================
diff --git a/MAINTAINERS b/MAINTAINERS
index 4d926c47ad8d..4483023994e1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22834,6 +22834,13 @@ F:	drivers/clk/clk-rp1.c
 F:	drivers/misc/rp1/
 F:	drivers/pinctrl/pinctrl-rp1.c
 
+RAZER PWM PC FAN CONTROLLER DRIVER
+M:	Victor Chernyakin <chernyakin.victor.j@outlook.com>
+L:	linux-hwmon@vger.kernel.org
+S:	Maintained
+F:	Documentation/hwmon/razer_pwm_pc_fan_controller.rst
+F:	drivers/hwmon/razer_pwm_pc_fan_controller.c
+
 RC-CORE / LIRC FRAMEWORK
 M:	Sean Young <sean@mess.org>
 L:	linux-media@vger.kernel.org
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 96a36c5ba04f..641582a5005c 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -973,6 +973,7 @@ static const struct hid_device_id hid_ignore_list[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PETZL, USB_DEVICE_ID_PETZL_HEADLAMP) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) },
+	{ HID_USB_DEVICE(USB_VENDOR_ID_RAZER, 0x0F3C) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SAI, USB_DEVICE_ID_CYPRESS_HIDCOM) },
 #if IS_ENABLED(CONFIG_MOUSE_SYNAPTICS_USB)
 	{ HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP) },
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index fecff8610ea8..79093c48781f 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1981,6 +1981,16 @@ config SENSORS_RASPBERRYPI_HWMON
 	  This driver can also be built as a module. If so, the module
 	  will be called raspberrypi-hwmon.
 
+config SENSORS_RAZER_PWM_PC_FAN_CONTROLLER
+	tristate "Razer PWM PC Fan Controller"
+	depends on USB
+	help
+	  This driver provides support for the 8-channel Razer PWM PC Fan
+	  Controller.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called razer_pwm_pc_fan_controller.
+
 config SENSORS_SL28CPLD
 	tristate "Kontron sl28cpld hardware monitoring driver"
 	depends on MFD_SL28CPLD || COMPILE_TEST
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 1229b6b3996d..abf23654a3a5 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -207,6 +207,7 @@ obj-$(CONFIG_SENSORS_PT5161L)	+= pt5161l.o
 obj-$(CONFIG_SENSORS_PWM_FAN)	+= pwm-fan.o
 obj-$(CONFIG_SENSORS_QNAP_MCU_HWMON)	+= qnap-mcu-hwmon.o
 obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON)	+= raspberrypi-hwmon.o
+obj-$(CONFIG_SENSORS_RAZER_PWM_PC_FAN_CONTROLLER) += razer_pwm_pc_fan_controller.o
 obj-$(CONFIG_SENSORS_SBTSI)	+= sbtsi_temp.o
 obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
 obj-$(CONFIG_SENSORS_SCH5627)	+= sch5627.o
diff --git a/drivers/hwmon/razer_pwm_pc_fan_controller.c b/drivers/hwmon/razer_pwm_pc_fan_controller.c
new file mode 100644
index 000000000000..dc6dbe096e11
--- /dev/null
+++ b/drivers/hwmon/razer_pwm_pc_fan_controller.c
@@ -0,0 +1,472 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Razer PWM PC Fan Controller driver
+ *
+ * Based on a userspace C# driver by Evan Mulawski, a kernel driver
+ * derived from it by SlimRG, and partly on code from the OpenRazer project.
+ *
+ * Copyright (C) 2026 Victor Chernyakin <chernyakin.victor.j@outlook.com>
+ *
+ * As with all Razer device drivers, this driver was developed by reverse
+ * engineering Razer's config program Synapse. The controller's protocol
+ * is still not 100% understood, hence some fields here have funny
+ * names like "always_1".
+ *
+ * This driver was developed against firmware version 1.1.0.0. If you're seeing
+ * issues, one thing to check is whether your firmware version differs.
+ */
+
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/hid.h>
+#include <linux/hwmon.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/sysfs.h>
+#include <linux/usb.h>
+
+#define RAZER_PWM_CHANNEL_COUNT		8
+
+#define RAZER_PWM_STATUS_BUSY		0x01
+#define RAZER_PWM_STATUS_SUCCESS	0x02
+#define RAZER_PWM_STATUS_ERROR		0x03
+#define RAZER_PWM_STATUS_TIMEDOUT	0x04
+#define RAZER_PWM_STATUS_INVALID	0x05
+
+#define RAZER_PWM_CMD(_command, _payload_len)	\
+	.command = cpu_to_be16(_command),	\
+	.payload_len = (_payload_len)
+
+#define RAZER_PWM_CMD_GET_SERIAL_NUMBER		RAZER_PWM_CMD(0x0082, 16)
+#define RAZER_PWM_CMD_GET_FIRMWARE_VERSION	RAZER_PWM_CMD(0x0087,  4)
+#define RAZER_PWM_CMD_GET_FAN_INFO		RAZER_PWM_CMD(0x00B5, 80)
+#define RAZER_PWM_CMD_SET_CHANNEL_MODE		RAZER_PWM_CMD(0x0D02,  4)
+#define RAZER_PWM_CMD_SET_DUTY_CYCLE		RAZER_PWM_CMD(0x0D0D,  3)
+#define RAZER_PWM_CMD_GET_RPM			RAZER_PWM_CMD(0x0D81,  6)
+
+#define RAZER_PWM_CHANNEL_MODE_MANUAL		0x04
+#define RAZER_PWM_CHANNEL_MODE_QUIET		0x05
+#define RAZER_PWM_CHANNEL_MODE_NORMAL		0x06
+#define RAZER_PWM_CHANNEL_MODE_PERFORMANCE	0x07
+
+#define RAZER_PWM_FAN_TYPE_NOT_PRESENT	0
+#define RAZER_PWM_FAN_TYPE_4WIRE	1
+#define RAZER_PWM_FAN_TYPE_3WIRE	2
+
+struct __packed razer_pwm_report {
+	u8 status;
+	u8 sequence_number;
+	__be16 remaining_count;
+	u8 protocol_type;
+	u8 payload_len;
+	__be16 command;
+	union {
+		u8 payload[80];
+
+		char serial_number[16]; /* ASCII string, null terminated. */
+
+		struct __packed {
+			u8 major;
+			u8 minor;
+			u8 patch;
+			u8 hotfix;
+		} firmware_version;
+
+		struct __packed {
+			u8 always_5; /* Is this why the channels below are + 5? */
+			u8 always_8; /* The number of channels? */
+			u8 fan_type[RAZER_PWM_CHANNEL_COUNT];
+		} fan_info;
+
+		struct __packed {
+			u8 always_1;
+			u8 channel_plus_5;
+			u8 percent;
+		} set_duty_cycle;
+
+		struct __packed {
+			u8 always_1;
+			u8 channel_plus_5;
+			u8 mode;
+		} set_channel_mode;
+
+		struct __packed {
+			u8 always_1;
+			u8 channel_plus_5;
+			__be32 rpm;
+		} get_rpm;
+	};
+	u8 checksum;
+	u8 reserved;
+};
+static_assert(sizeof(struct razer_pwm_report) == 90);
+
+struct razer_pwm_dev {
+	__dma_from_device_group_begin();
+	struct razer_pwm_report report;
+	__dma_from_device_group_end();
+	struct usb_device *usbdev;
+	u8 cached_pwm[RAZER_PWM_CHANNEL_COUNT]; /* [0, 255] */
+	bool cached_pwm_might_be_stale[RAZER_PWM_CHANNEL_COUNT];
+	u8 fan_type[RAZER_PWM_CHANNEL_COUNT];
+	u8 current_sequence_number;
+};
+
+static u8 razer_pwm_compute_checksum(const struct razer_pwm_report *report)
+{
+	u8 checksum = 0;
+
+	/* Not all the report's bytes participate in the checksum. */
+	for (int i = 2; i < 88; i++)
+		checksum ^= ((const u8 *)report)[i];
+
+	return checksum;
+}
+
+static int razer_pwm_send_report(struct razer_pwm_dev *d)
+{
+	unsigned long timeout;
+	int ret;
+
+	++d->current_sequence_number;
+	d->current_sequence_number %= 31; /* Synapse also wraps around after 31. */
+
+	d->report.sequence_number = d->current_sequence_number;
+	d->report.checksum = razer_pwm_compute_checksum(&d->report);
+
+	ret = usb_control_msg(d->usbdev, usb_sndctrlpipe(d->usbdev, 0),
+			      HID_REQ_SET_REPORT,
+			      USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
+			      0x300, 0, &d->report, sizeof(d->report),
+			      USB_CTRL_SET_TIMEOUT);
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(d->report))
+		return -EIO;
+
+	timeout = jiffies + msecs_to_jiffies(500);
+	for (;;) {
+		msleep(10); /* Synapse seems to use approximately this delay. */
+
+		ret = usb_control_msg(d->usbdev, usb_rcvctrlpipe(d->usbdev, 0),
+				      HID_REQ_GET_REPORT,
+				      USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
+				      0x300, 0, &d->report, sizeof(d->report),
+				      USB_CTRL_GET_TIMEOUT);
+		if (ret < 0)
+			return ret;
+		if (ret != sizeof(d->report))
+			return -EIO;
+
+		if (d->report.checksum != razer_pwm_compute_checksum(&d->report))
+			return -EIO;
+
+		if (d->report.sequence_number != d->current_sequence_number ||
+		    d->report.status == RAZER_PWM_STATUS_BUSY) {
+			if (time_after(jiffies, timeout))
+				return -ETIMEDOUT;
+
+			continue;
+		}
+
+		switch (d->report.status) {
+		case RAZER_PWM_STATUS_SUCCESS:
+			return 0;
+		case RAZER_PWM_STATUS_TIMEDOUT:
+			return -ETIMEDOUT;
+		case RAZER_PWM_STATUS_INVALID:
+			return -EINVAL;
+		default:
+			return -EIO;
+		}
+	}
+}
+
+static int razer_pwm_set_pwm(struct razer_pwm_dev *d, u8 channel, u8 val)
+{
+	int ret;
+
+	d->report = (struct razer_pwm_report) {
+		RAZER_PWM_CMD_SET_CHANNEL_MODE,
+		.set_channel_mode = {
+			.always_1 = 1,
+			.channel_plus_5 = channel + 5,
+			.mode = RAZER_PWM_CHANNEL_MODE_MANUAL,
+		},
+	};
+	ret = razer_pwm_send_report(d);
+	if (ret)
+		return ret;
+
+	/*
+	 * The controller's firmware refuses to set any duty cycle lower
+	 * than 33% (it rounds up any lower values to 33%, expect of course for
+	 * the value 0, which disables the fan). Reflect that behaviour here.
+	 */
+	if (val != 0)
+		val = umax(val, 255 / 3);
+
+	d->report = (struct razer_pwm_report) {
+		RAZER_PWM_CMD_SET_DUTY_CYCLE,
+		.set_duty_cycle = {
+			.always_1 = 1,
+			.channel_plus_5 = channel + 5,
+			.percent = DIV_ROUND_CLOSEST(val * 100, 255),
+		},
+	};
+	ret = razer_pwm_send_report(d);
+	d->cached_pwm_might_be_stale[channel] = !!ret;
+	if (ret)
+		return ret;
+
+	d->cached_pwm[channel] = val;
+	return 0;
+}
+
+static int razer_pwm_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
+				u32 attr, int channel, long *val)
+{
+	struct razer_pwm_dev *d = dev_get_drvdata(dev);
+	int ret;
+
+	switch (type) {
+	case hwmon_fan:
+		switch (attr) {
+		case hwmon_fan_input:
+			d->report = (struct razer_pwm_report) {
+				RAZER_PWM_CMD_GET_RPM,
+				.get_rpm = {
+					.always_1 = 1,
+					.channel_plus_5 = channel + 5,
+				},
+			};
+			ret = razer_pwm_send_report(d);
+			if (ret)
+				return ret;
+
+			*val = be32_to_cpu(d->report.get_rpm.rpm);
+			return 0;
+		default:
+			return -EOPNOTSUPP;
+		}
+	case hwmon_pwm:
+		switch (attr) {
+		case hwmon_pwm_input:
+			if (d->cached_pwm_might_be_stale[channel])
+				return -ENODATA;
+
+			*val = d->cached_pwm[channel];
+			return 0;
+		default:
+			return -EOPNOTSUPP;
+		}
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int razer_pwm_hwmon_write(struct device *dev, enum hwmon_sensor_types type,
+				 u32 attr, int channel, long val)
+{
+	struct razer_pwm_dev *d = dev_get_drvdata(dev);
+
+	switch (type) {
+	case hwmon_pwm:
+		switch (attr) {
+		case hwmon_pwm_input:
+			if (val < 0 || val > 255)
+				return -EINVAL;
+
+			return razer_pwm_set_pwm(d, channel, val);
+		default:
+			return -EOPNOTSUPP;
+		}
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static umode_t razer_pwm_hwmon_is_visible(const void *drvdata,
+					  enum hwmon_sensor_types type,
+					  u32 attr, int channel)
+{
+	const struct razer_pwm_dev *d = drvdata;
+
+	switch (type) {
+	case hwmon_fan:
+		switch (attr) {
+		case hwmon_fan_input:
+			switch (d->fan_type[channel]) {
+			case RAZER_PWM_FAN_TYPE_3WIRE:
+			case RAZER_PWM_FAN_TYPE_4WIRE:
+				return 0444;
+			default:
+				return 0;
+			}
+		default:
+			return 0;
+		}
+	case hwmon_pwm:
+		switch (attr) {
+		case hwmon_pwm_input:
+			switch (d->fan_type[channel]) {
+			case RAZER_PWM_FAN_TYPE_4WIRE:
+				return 0644;
+			default:
+				return 0;
+			}
+		default:
+			return 0;
+		}
+	default:
+		return 0;
+	}
+}
+
+static ssize_t firmware_version_show(struct device *dev,
+				     struct device_attribute *attr, char *buf)
+{
+	struct razer_pwm_dev *d = dev_get_drvdata(dev);
+	int ret;
+
+	d->report = (struct razer_pwm_report) {
+		RAZER_PWM_CMD_GET_FIRMWARE_VERSION,
+	};
+	ret = razer_pwm_send_report(d);
+	if (ret)
+		return ret;
+
+	return sysfs_emit(buf, "%u.%u.%u.%u\n",
+			  d->report.firmware_version.major,
+			  d->report.firmware_version.minor,
+			  d->report.firmware_version.patch,
+			  d->report.firmware_version.hotfix);
+}
+
+static ssize_t serial_number_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	struct razer_pwm_dev *d = dev_get_drvdata(dev);
+	int ret;
+
+	d->report = (struct razer_pwm_report) {
+		RAZER_PWM_CMD_GET_SERIAL_NUMBER,
+	};
+	ret = razer_pwm_send_report(d);
+	if (ret)
+		return ret;
+
+	return sysfs_emit(buf, "%.*s\n",
+			  (int)sizeof(d->report.serial_number),
+			  d->report.serial_number);
+}
+
+static const DEVICE_ATTR_RO(firmware_version);
+static const DEVICE_ATTR_RO(serial_number);
+
+static const struct attribute *const razer_pwm_attrs[] = {
+	&dev_attr_firmware_version.attr,
+	&dev_attr_serial_number.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(razer_pwm);
+
+static const struct hwmon_ops razer_pwm_hwmon_ops = {
+	.is_visible = razer_pwm_hwmon_is_visible,
+	.read = razer_pwm_hwmon_read,
+	.write = razer_pwm_hwmon_write,
+};
+
+static const struct hwmon_channel_info *const razer_pwm_hwmon_info[] = {
+	HWMON_CHANNEL_INFO(fan,
+			   HWMON_F_INPUT, HWMON_F_INPUT,
+			   HWMON_F_INPUT, HWMON_F_INPUT,
+			   HWMON_F_INPUT, HWMON_F_INPUT,
+			   HWMON_F_INPUT, HWMON_F_INPUT),
+	HWMON_CHANNEL_INFO(pwm,
+			   HWMON_PWM_INPUT, HWMON_PWM_INPUT,
+			   HWMON_PWM_INPUT, HWMON_PWM_INPUT,
+			   HWMON_PWM_INPUT, HWMON_PWM_INPUT,
+			   HWMON_PWM_INPUT, HWMON_PWM_INPUT),
+	NULL
+};
+
+static const struct hwmon_chip_info razer_pwm_chip_info = {
+	.ops = &razer_pwm_hwmon_ops,
+	.info = razer_pwm_hwmon_info,
+};
+
+static int razer_pwm_suspend(struct usb_interface *intf, pm_message_t message)
+{
+	return 0;
+}
+
+static int razer_pwm_resume(struct usb_interface *intf)
+{
+	struct razer_pwm_dev *d = usb_get_intfdata(intf);
+
+	for (int channel = 0; channel < RAZER_PWM_CHANNEL_COUNT; channel++) {
+		if (d->fan_type[channel] == RAZER_PWM_FAN_TYPE_4WIRE)
+			(void)razer_pwm_set_pwm(d, channel, d->cached_pwm[channel]);
+	}
+
+	return 0;
+}
+
+static int razer_pwm_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+	struct device *hwmon_dev;
+	struct razer_pwm_dev *d;
+	int ret;
+
+	d = devm_kzalloc(&intf->dev, sizeof(*d), GFP_KERNEL);
+	if (!d)
+		return -ENOMEM;
+
+	d->usbdev = interface_to_usbdev(intf);
+	usb_set_intfdata(intf, d);
+
+	d->report = (struct razer_pwm_report) {
+		RAZER_PWM_CMD_GET_FAN_INFO,
+	};
+	ret = razer_pwm_send_report(d);
+	if (ret)
+		return ret;
+
+	memcpy(d->fan_type, d->report.fan_info.fan_type, sizeof(d->fan_type));
+
+	/* Set fans to 50% by default. */
+	memset(d->cached_pwm, 127, sizeof(d->cached_pwm));
+	razer_pwm_resume(intf);
+
+	hwmon_dev = devm_hwmon_device_register_with_info(&intf->dev,
+							 "razer_pwm_pc_fan_controller",
+							 d,
+							 &razer_pwm_chip_info,
+							 razer_pwm_groups);
+	return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static void razer_pwm_disconnect(struct usb_interface *intf) {}
+
+static const struct usb_device_id razer_pwm_table[] = {
+	{ USB_DEVICE_INTERFACE_NUMBER(0x1532, 0x0F3C, 0x00) },
+	{ }
+};
+MODULE_DEVICE_TABLE(usb, razer_pwm_table);
+
+static struct usb_driver razer_pwm_driver = {
+	.name = "razer_pwm_pc_fan_controller",
+	.id_table = razer_pwm_table,
+	.probe = razer_pwm_probe,
+	.disconnect = razer_pwm_disconnect,
+	.suspend = razer_pwm_suspend,
+	.resume = razer_pwm_resume,
+};
+module_usb_driver(razer_pwm_driver);
+
+MODULE_AUTHOR("Victor Chernyakin <chernyakin.victor.j@outlook.com>");
+MODULE_DESCRIPTION("Razer PWM PC Fan Controller driver");
+MODULE_LICENSE("GPL");
-- 
2.53.0


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

end of thread, other threads:[~2026-12-05 19:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 19:13 [PATCH] hwmon: Add Razer PWM PC Fan Controller driver Victor Chernyakin
2026-12-05 19:36 ` sashiko-bot
2026-12-05 19:40   ` Guenter Roeck
2026-12-05 19:37 ` Guenter Roeck

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