Skip to content

Commit

Permalink
Add debug method node
Browse files Browse the repository at this point in the history
  • Loading branch information
tangalbert919 committed Feb 1, 2025
1 parent beea748 commit 1472902
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions aorus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct gigabyte_laptop_wmi {
u8 fan_silent_method;
struct fan_curve_data fan_curve;
int fan_curve_index;
u8 debug_method;
};

static struct platform_device *platform_device;
Expand Down Expand Up @@ -648,6 +649,32 @@ static ssize_t battery_cycle_show(struct device *dev, struct device_attribute *a
return sysfs_emit(buf, "%d\n", max(cyc1, cyc2));
}

static ssize_t debug_method_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
int ret;
u8 data;
struct gigabyte_laptop_wmi *gigabyte;

ret = kstrtou8(buf, 0, &data);
if (ret)
return ret;

gigabyte = dev_get_drvdata(dev);
gigabyte->debug_method = data;
return count;
}

static ssize_t debug_method_show(struct device *dev, struct device_attribute *attr, char *buf)
{
int ret, output;
struct gigabyte_laptop_wmi *gigabyte = dev_get_drvdata(dev);

ret = gigabyte_laptop_get_devstate(gigabyte->debug_method, &output);
if (ret)
return ret;
return sysfs_emit(buf, "%d, %d\n", gigabyte->debug_method, output);
}

#define TOGGLE_DEVICE(_device, _id) \
static ssize_t _device##_toggle_show(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
Expand All @@ -669,6 +696,7 @@ static DEVICE_ATTR_RW(gpu_boost);
static DEVICE_ATTR_RW(fan_curve_index);
static DEVICE_ATTR_RW(fan_curve_data);
static DEVICE_ATTR_RO(battery_cycle);
static DEVICE_ATTR_RW(debug_method);

static struct attribute *gigabyte_laptop_attributes[] = {
&dev_attr_fan_mode.attr,
Expand All @@ -681,6 +709,7 @@ static struct attribute *gigabyte_laptop_attributes[] = {
&dev_attr_fan_curve_index.attr,
&dev_attr_fan_curve_data.attr,
&dev_attr_battery_cycle.attr,
&dev_attr_debug_method.attr,
NULL
};

Expand Down

0 comments on commit 1472902

Please sign in to comment.