From fd7be13e06ca440c8f7ac03dcf696c8d1c15d0c5 Mon Sep 17 00:00:00 2001 From: Louis Kemp Date: Mon, 13 May 2019 08:50:29 +0200 Subject: [PATCH 1/5] Allow override of rpm check for some cases --- asus_fan.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/asus_fan.c b/asus_fan.c index 654de73..41daf46 100644 --- a/asus_fan.c +++ b/asus_fan.c @@ -124,12 +124,12 @@ struct asus_fan_data { static struct asus_fan_data asus_data = { - NULL, - {-1, -1}, - {false, false}, - false, false, + NULL, + {-1, -1}, + {false, false}, + false, false, 255, 255, - 10, 10, + 10, 10, "CPU Fan", "GFX Fan", ASUS_FAN_HW_DEFAULT }; @@ -143,6 +143,9 @@ static struct acpi_object_list params; // force loading i.e., skip device existance check static short force_load = false; +// allow checking but override rpm check +static short force_rpm_override = false; + // housekeeping structs static struct asus_fan_driver asus_fan_driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, @@ -160,6 +163,9 @@ static struct attribute_group platform_attribute_group = { module_param(force_load, short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); MODULE_PARM_DESC(force_load, "Force loading of module---omit device existance check"); +module_param(force_rpm_override, short, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); +MODULE_PARM_DESC(force_rpm_override, + "Force loading of module---still do device existance check"); ////// ////// FUNCTION PROTOTYPES @@ -494,9 +500,9 @@ static ssize_t _fan_set_mode(int fan, const char* buf, size_t count) { fan_set_auto(); } else if (strncmp(buf, fan_mode_manual_string, strlen(fan_mode_manual_string)) == 0) __fan_set_cur_state(0, (255 - asus_data.fan_minimum) >> 1); - else - err_msg("set mode", "fan id: %d | setting mode to '%s', use 'auto' or 'manual'", fan+1, buf); - + else + err_msg("set mode", "fan id: %d | setting mode to '%s', use 'auto' or 'manual'", fan+1, buf); + return count; } @@ -808,7 +814,7 @@ __ATTRIBUTE_GROUPS(hwmon_attr); static int asus_fan_hwmon_init(struct asus_fan *asus) { dbg_msg("init hwmon device"); - + asus->hwmon_dev = hwmon_device_register_with_groups( &asus->platform_device->dev, "asus_fan", asus, hwmon_attr_groups); @@ -924,13 +930,13 @@ static int __init fan_init(void) { "ASUSTeK COMPUTER INC.")) { // step by step probe available functionalities and insert into attrib grp - // @TODO TODO TODO TODO - + // @TODO TODO TODO TODO + size_t temp = AE_OK; // USE this for idx in hwmon_attrs size_t idx = 0; // try to get RPM for first fan rpm = __fan_rpm(0); - if (rpm == -1) { + if (rpm == -1 && !force_rpm_override) { asus_data.has_fan = false; err_msg("init", "fan-id: 1 | failed to get rpm"); } else { @@ -946,7 +952,7 @@ static int __init fan_init(void) { } // try to get RPM for second fan rpm = __fan_rpm(1); - if (rpm == -1) { + if (rpm == -1 && !force_rpm_override) { err_msg("init", "fan-id: 2 | failed to get rpm"); asus_data.has_gfx_fan = false; } else { From 2484583fb8ce3db8bf879a76c300f0e329f07f43 Mon Sep 17 00:00:00 2001 From: Louis Kemp Date: Tue, 14 May 2019 06:55:20 +0200 Subject: [PATCH 2/5] Added message to dmesg if override is set --- asus_fan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/asus_fan.c b/asus_fan.c index 41daf46..ddfdabc 100644 --- a/asus_fan.c +++ b/asus_fan.c @@ -936,6 +936,9 @@ static int __init fan_init(void) { // USE this for idx in hwmon_attrs size_t idx = 0; // try to get RPM for first fan rpm = __fan_rpm(0); + if (force_rpm_override){ + info_mesg("init", "overriding rpm check: USE WITH CARE"); + } if (rpm == -1 && !force_rpm_override) { asus_data.has_fan = false; err_msg("init", "fan-id: 1 | failed to get rpm"); From 3b731d483df410479822570cc28f516638a2a3a2 Mon Sep 17 00:00:00 2001 From: Louis Kemp Date: Tue, 14 May 2019 07:01:15 +0200 Subject: [PATCH 3/5] spelling mistake in previous commit info_mesg > info_msg --- asus_fan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asus_fan.c b/asus_fan.c index ddfdabc..7867f54 100644 --- a/asus_fan.c +++ b/asus_fan.c @@ -937,7 +937,7 @@ static int __init fan_init(void) { // try to get RPM for first fan rpm = __fan_rpm(0); if (force_rpm_override){ - info_mesg("init", "overriding rpm check: USE WITH CARE"); + info_msg("init", "overriding rpm check: USE WITH CARE"); } if (rpm == -1 && !force_rpm_override) { asus_data.has_fan = false; From a92203cce245c9862d19bf2ff21af148272f5fae Mon Sep 17 00:00:00 2001 From: Louis Kemp Date: Wed, 22 May 2019 21:05:20 +0200 Subject: [PATCH 4/5] Added string output of acpi status codes --- asus_fan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/asus_fan.c b/asus_fan.c index 7867f54..509f80b 100644 --- a/asus_fan.c +++ b/asus_fan.c @@ -446,8 +446,7 @@ static int __fan_rpm(int fan) { // acpi call ret = acpi_evaluate_integer(NULL, "\\_SB.PCI0.LPCB.EC0.TACH", ¶ms, &value); - - dbg_msg("|--> acpi request returned: %d", (unsigned int)ret); + dbg_msg("|--> acpi request returned: %s", acpi_format_exception(ret)); if (ret != AE_OK) return -1; } @@ -995,22 +994,24 @@ static int __init fan_init(void) { return -ENODEV; } - dbg_msg("fan_set_max_speed() call succeeded, ret: %d", (unsigned int)ret); + dbg_msg("fan_set_max_speed() call succeeded, ret: %s", + acpi_format_exception(ret)); // force sane enviroment / init with automatic fan controlling if ((ret = fan_set_auto()) != AE_OK) { - err_msg("init", "set auto-mode speed to active, failed! errcode: %d", - ret); + err_msg("init", "set auto-mode speed to active, failed! errcode: %s", + acpi_format_exception(ret)); return -ENODEV; } - dbg_msg("fan_set_auto() call succeeded, ret: %d", (unsigned int)ret); + dbg_msg("fan_set_auto() call succeeded, ret: %s", + acpi_format_exception(ret)); } ret = asus_fan_register_driver(&asus_fan_driver); if (ret != AE_OK) { - err_msg("init", "set max speed to: '%d' failed! errcode: %d", - asus_data.max_fan_speed_default, ret); + err_msg("init", "set max speed to: '%d' failed! errcode: %s", + asus_data.max_fan_speed_default, acpi_format_exception(ret)); return ret; } From ac98011e1aeede14648577d5f11c12e1e7a2548c Mon Sep 17 00:00:00 2001 From: Louis Kemp Date: Wed, 22 May 2019 21:12:30 +0200 Subject: [PATCH 5/5] Missed some for the string error codes --- asus_fan.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/asus_fan.c b/asus_fan.c index 509f80b..cef4c02 100644 --- a/asus_fan.c +++ b/asus_fan.c @@ -616,7 +616,8 @@ static int fan_set_max_speed(unsigned long state, bool reset) { ret = acpi_evaluate_integer(NULL, "\\_SB.ATKD.QMOD", ¶ms, &value); if (ret != AE_OK) { err_msg("set_max_speed", - "set max fan speed(s) failed (force reset)! errcode: %d", ret); + "set max fan speed(s) failed (force reset)! errcode: %s", + acpi_format_exception(ret)); return ret; } @@ -637,7 +638,8 @@ static int fan_set_max_speed(unsigned long state, bool reset) { &value); if (ret != AE_OK) { err_msg("set_max_speed", - "set max fan speed(s) failed (no reset) errcoded", ret); + "set max fan speed(s) failed (no reset) errcode: %s", + acpi_format_exception(ret)); return ret; } @@ -680,8 +682,8 @@ static int fan_set_auto() { if (ret != AE_OK) { err_msg("set_auto", "failed reseting fan(s) to auto-mode! " - "errcode: %d - DANGER! OVERHEAT? DANGER!", - ret); + "errcode: %s - DANGER! OVERHEAT? DANGER!", + acpi_format_exception(ret)); return ret; } @@ -737,7 +739,8 @@ static ssize_t temp1_input(struct device *dev, struct device_attribute *attr, // acpi call ret = acpi_evaluate_integer(NULL, "\\_SB.PCI0.LPCB.EC0.TH1R", NULL, &value); if (ret != AE_OK) { - err_msg("read_temp", "failed reading temperature, errcode: %d", ret); + err_msg("read_temp", "failed reading temperature, errcode: %s", + acpi_format_exception(ret)); return ret; } size = sprintf((char *)&buf, "%llu\n", value); @@ -989,8 +992,8 @@ static int __init fan_init(void) { // check if reseting fan speeds works ret = fan_set_max_speed(asus_data.max_fan_speed_default, false); if (ret != AE_OK) { - err_msg("init", "set max speed to: '%d' failed! errcode: %d", - asus_data.max_fan_speed_default, ret); + err_msg("init", "set max speed to: '%d' failed! errcode: %s", + asus_data.max_fan_speed_default, acpi_format_exception(ret)); return -ENODEV; }