drivers/hwmon/nzxt-kraken3.c

Source file repositories/reference/linux-study-clean/drivers/hwmon/nzxt-kraken3.c

File Facts

System
Linux kernel
Corpus path
drivers/hwmon/nzxt-kraken3.c
Extension
.c
Size
33868 bytes
Lines
1029
Domain
Driver Families
Bucket
drivers/hwmon
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct kraken3_channel_info {
	enum pwm_enable mode;

	/* Both values are PWM */
	u16 reported_duty;
	u16 fixed_duty;		/* Manually set fixed duty */

	u8 pwm_points[CUSTOM_CURVE_POINTS];
};

struct kraken3_data {
	struct hid_device *hdev;
	struct device *hwmon_dev;
	struct dentry *debugfs;
	struct mutex buffer_lock;	/* For locking access to buffer */
	struct mutex z53_status_request_lock;
	struct completion fw_version_processed;
	/*
	 * For X53 devices, tracks whether an initial (one) sensor report was received to
	 * make fancontrol not bail outright. For Z53 devices, whether a status report
	 * was processed after requesting one.
	 */
	struct completion status_report_processed;
	/* For locking the above completion */
	spinlock_t status_completion_lock;

	u8 *buffer;
	struct kraken3_channel_info channel_info[2];	/* Pump and fan */
	bool is_device_faulty;

	/* Sensor values */
	s32 temp_input[1];
	u16 fan_input[2];

	enum kinds kind;
	u8 firmware_version[3];

	unsigned long updated;	/* jiffies */
};

static umode_t kraken3_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,
				  int channel)
{
	const struct kraken3_data *priv = data;

	switch (type) {
	case hwmon_temp:
		if (channel < 1)
			return 0444;
		break;
	case hwmon_fan:
		switch (priv->kind) {
		case X53:
			/* Just the pump */
			if (channel < 1)
				return 0444;
			break;
		case Z53:
		case KRAKEN2023:
			/* Pump and fan */
			if (channel < 2)
				return 0444;
			break;
		default:
			break;
		}
		break;
	case hwmon_pwm:
		switch (attr) {
		case hwmon_pwm_enable:
		case hwmon_pwm_input:
			switch (priv->kind) {
			case X53:
				/* Just the pump */
				if (channel < 1)
					return 0644;
				break;
			case Z53:
			case KRAKEN2023:
				/* Pump and fan */
				if (channel < 2)
					return 0644;
				break;
			default:
				break;
			}
			break;
		default:
			break;
		}

Annotation

Implementation Notes