drivers/hwmon/asus_rog_ryujin.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/asus_rog_ryujin.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/asus_rog_ryujin.c- Extension
.c- Size
- 16121 bytes
- Lines
- 580
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/hid.hlinux/hwmon.hlinux/jiffies.hlinux/module.hlinux/spinlock.hlinux/unaligned.h
Detected Declarations
struct rog_ryujin_datafunction rog_ryujin_percent_to_pwmfunction rog_ryujin_pwm_to_percentfunction rog_ryujin_is_visiblefunction rog_ryujin_write_expandedfunction rog_ryujin_execute_cmdfunction rog_ryujin_get_statusfunction rog_ryujin_readfunction rog_ryujin_read_stringfunction rog_ryujin_write_fixed_dutyfunction rog_ryujin_writefunction rog_ryujin_raw_eventfunction rog_ryujin_probefunction rog_ryujin_removefunction rog_ryujin_initfunction rog_ryujin_exit
Annotated Snippet
struct rog_ryujin_data {
struct hid_device *hdev;
struct device *hwmon_dev;
/* For reinitializing the completions below */
spinlock_t status_report_request_lock;
struct completion cooler_status_received;
struct completion controller_status_received;
struct completion cooler_duty_received;
struct completion controller_duty_received;
struct completion cooler_duty_set;
struct completion controller_duty_set;
/* Sensor data */
s32 temp_input[1];
u16 speed_input[6]; /* Pump, internal fan and four controller fan speeds in RPM */
u8 duty_input[3]; /* Pump, internal fan and controller fan duty in PWM */
u8 *buffer;
unsigned long updated; /* jiffies */
};
static int rog_ryujin_percent_to_pwm(u16 val)
{
return DIV_ROUND_CLOSEST(val * 255, 100);
}
static int rog_ryujin_pwm_to_percent(long val)
{
return DIV_ROUND_CLOSEST(val * 100, 255);
}
static umode_t rog_ryujin_is_visible(const void *data,
enum hwmon_sensor_types type, u32 attr, int channel)
{
switch (type) {
case hwmon_temp:
switch (attr) {
case hwmon_temp_label:
case hwmon_temp_input:
return 0444;
default:
break;
}
break;
case hwmon_fan:
switch (attr) {
case hwmon_fan_label:
case hwmon_fan_input:
return 0444;
default:
break;
}
break;
case hwmon_pwm:
switch (attr) {
case hwmon_pwm_input:
return 0644;
default:
break;
}
break;
default:
break;
}
return 0;
}
/* Writes the command to the device with the rest of the report filled with zeroes */
static int rog_ryujin_write_expanded(struct rog_ryujin_data *priv, const u8 *cmd, int cmd_length)
{
memcpy_and_pad(priv->buffer, MAX_REPORT_LENGTH, cmd, cmd_length, 0x00);
return hid_hw_output_report(priv->hdev, priv->buffer, MAX_REPORT_LENGTH);
}
static int rog_ryujin_execute_cmd(struct rog_ryujin_data *priv, const u8 *cmd, int cmd_length,
struct completion *status_completion)
{
int ret;
/*
* Disable raw event parsing for a moment to safely reinitialize the
* completion. Reinit is done because hidraw could have triggered
* the raw event parsing and marked the passed in completion as done.
*/
spin_lock_bh(&priv->status_report_request_lock);
reinit_completion(status_completion);
spin_unlock_bh(&priv->status_report_request_lock);
/* Send command for getting data */
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/hid.h`, `linux/hwmon.h`, `linux/jiffies.h`, `linux/module.h`, `linux/spinlock.h`, `linux/unaligned.h`.
- Detected declarations: `struct rog_ryujin_data`, `function rog_ryujin_percent_to_pwm`, `function rog_ryujin_pwm_to_percent`, `function rog_ryujin_is_visible`, `function rog_ryujin_write_expanded`, `function rog_ryujin_execute_cmd`, `function rog_ryujin_get_status`, `function rog_ryujin_read`, `function rog_ryujin_read_string`, `function rog_ryujin_write_fixed_duty`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.