History

platform/x86: asus: Rename "fan mode" to "fan boost mode"

The Asus WMI spec indicates that the function being controlled here is called "Fan Boost Mode". The user-facing documentation also calls it this. The spec uses the term "fan mode" is used to refer to other things, including functionality expected to appear on future products. We missed this before as we are not dealing with the most readable of specs, and didn't forsee any confusion around shortening the name. Rename "fan mode" to "fan boost mode" to improve consistency with the spec and to avoid a future naming conflict. There is no interface breakage here since this has yet to be included in an official kernel release. I also updated the kernel version listed under ABI accordingly.

Daniel Drake committed 7 years ago

Commit 9af93db1 parent 0a8ad0f3 files · +66 −60Browse files

Unified · Split

3 files
  1. Documentation/ABI/testing/sysfs-platform-asus-wmi +3 −3
  2. drivers/platform/x86/asus-wmi.c +62 −56
  3. include/linux/platform_data/x86/asus-wmi.h +1 −1
Documentation/ABI/testing/sysfs-platform-asus-wmi+3−3
@@ -37,9 +37,9 @@ Contact: "AceLan Kao" <acelan.kao@canonical.com> · 36 unmodified lines
3737 Description:
3838 Resume on lid open. 1 means on, 0 means off.
3939
40−What: /sys/devices/platform/<platform>/fan_mode
41−Date: Apr 2019
42−KernelVersion: 5.2
40+What: /sys/devices/platform/<platform>/fan_boost_mode
41+Date: Sep 2019
42+KernelVersion: 5.3
4343 Contact: "Yurii Pavlovskyi" <yurii.pavlovskyi@gmail.com>
4444 Description:
4545 Fan boost mode:
drivers/platform/x86/asus-wmi.c+62−56
@@ -68,12 +68,12 @@ MODULE_LICENSE("GPL"); · 67 unmodified lines
6868 #define ASUS_FAN_CTRL_MANUAL 1
6969 #define ASUS_FAN_CTRL_AUTO 2
7070
71−#define ASUS_FAN_MODE_NORMAL 0
72−#define ASUS_FAN_MODE_OVERBOOST 1
73−#define ASUS_FAN_MODE_OVERBOOST_MASK 0x01
74−#define ASUS_FAN_MODE_SILENT 2
75−#define ASUS_FAN_MODE_SILENT_MASK 0x02
76−#define ASUS_FAN_MODES_MASK 0x03
71+#define ASUS_FAN_BOOST_MODE_NORMAL 0
72+#define ASUS_FAN_BOOST_MODE_OVERBOOST 1
73+#define ASUS_FAN_BOOST_MODE_OVERBOOST_MASK 0x01
74+#define ASUS_FAN_BOOST_MODE_SILENT 2
75+#define ASUS_FAN_BOOST_MODE_SILENT_MASK 0x02
76+#define ASUS_FAN_BOOST_MODES_MASK 0x03
7777
7878 #define USB_INTEL_XUSB2PR 0xD0
7979 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
@@ -182,9 +182,9 @@ struct asus_wmi { · 102 unmodified lines
182182 int asus_hwmon_num_fans;
183183 int asus_hwmon_pwm;
184184
185− bool fan_mode_available;
186− u8 fan_mode_mask;
187− u8 fan_mode;
185+ bool fan_boost_mode_available;
186+ u8 fan_boost_mode_mask;
187+ u8 fan_boost_mode;
188188
189189 struct hotplug_slot hotplug_slot;
190190 struct mutex hotplug_lock;
@@ -1487,14 +1487,15 @@ static int asus_wmi_fan_init(struct asus_wmi *asus) · 1296 unmodified lines
14871487
14881488 /* Fan mode *******************************************************************/
14891489
1490−static int fan_mode_check_present(struct asus_wmi *asus)
1490+static int fan_boost_mode_check_present(struct asus_wmi *asus)
14911491 {
14921492 u32 result;
14931493 int err;
14941494
1495− asus->fan_mode_available = false;
1495+ asus->fan_boost_mode_available = false;
14961496
1497− err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_MODE, &result);
1497+ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE,
1498+ &result);
14981499 if (err) {
14991500 if (err == -ENODEV)
15001501 return 0;
@@ -1503,72 +1504,77 @@ static int fan_mode_check_present(struct asus_wmi *asus) · 2 unmodified lines
15031504 }
15041505
15051506 if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
1506− (result & ASUS_FAN_MODES_MASK)) {
1507− asus->fan_mode_available = true;
1508− asus->fan_mode_mask = result & ASUS_FAN_MODES_MASK;
1507+ (result & ASUS_FAN_BOOST_MODES_MASK)) {
1508+ asus->fan_boost_mode_available = true;
1509+ asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
15091510 }
15101511
15111512 return 0;
15121513 }
15131514
1514−static int fan_mode_write(struct asus_wmi *asus)
1515+static int fan_boost_mode_write(struct asus_wmi *asus)
15151516 {
15161517 int err;
15171518 u8 value;
15181519 u32 retval;
15191520
1520− value = asus->fan_mode;
1521+ value = asus->fan_boost_mode;
15211522
1522− pr_info("Set fan mode: %u\n", value);
1523− err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_MODE, value, &retval);
1523+ pr_info("Set fan boost mode: %u\n", value);
1524+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_BOOST_MODE, value,
1525+ &retval);
15241526
15251527 if (err) {
1526− pr_warn("Failed to set fan mode: %d\n", err);
1528+ pr_warn("Failed to set fan boost mode: %d\n", err);
15271529 return err;
15281530 }
15291531
15301532 if (retval != 1) {
1531− pr_warn("Failed to set fan mode (retval): 0x%x\n", retval);
1533+ pr_warn("Failed to set fan boost mode (retval): 0x%x\n",
1534+ retval);
15321535 return -EIO;
15331536 }
15341537
15351538 return 0;
15361539 }
15371540
1538−static int fan_mode_switch_next(struct asus_wmi *asus)
1541+static int fan_boost_mode_switch_next(struct asus_wmi *asus)
15391542 {
1540− if (asus->fan_mode == ASUS_FAN_MODE_NORMAL) {
1541− if (asus->fan_mode_mask & ASUS_FAN_MODE_OVERBOOST_MASK)
1542− asus->fan_mode = ASUS_FAN_MODE_OVERBOOST;
1543− else if (asus->fan_mode_mask & ASUS_FAN_MODE_SILENT_MASK)
1544− asus->fan_mode = ASUS_FAN_MODE_SILENT;
1545− } else if (asus->fan_mode == ASUS_FAN_MODE_OVERBOOST) {
1546− if (asus->fan_mode_mask & ASUS_FAN_MODE_SILENT_MASK)
1547− asus->fan_mode = ASUS_FAN_MODE_SILENT;
1543+ u8 mask = asus->fan_boost_mode_mask;
1544+
1545+ if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_NORMAL) {
1546+ if (mask & ASUS_FAN_BOOST_MODE_OVERBOOST_MASK)
1547+ asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_OVERBOOST;
1548+ else if (mask & ASUS_FAN_BOOST_MODE_SILENT_MASK)
1549+ asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT;
1550+ } else if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) {
1551+ if (mask & ASUS_FAN_BOOST_MODE_SILENT_MASK)
1552+ asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT;
15481553 else
1549− asus->fan_mode = ASUS_FAN_MODE_NORMAL;
1554+ asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL;
15501555 } else {
1551− asus->fan_mode = ASUS_FAN_MODE_NORMAL;
1556+ asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL;
15521557 }
15531558
1554− return fan_mode_write(asus);
1559+ return fan_boost_mode_write(asus);
15551560 }
15561561
1557−static ssize_t fan_mode_show(struct device *dev,
1558− struct device_attribute *attr, char *buf)
1562+static ssize_t fan_boost_mode_show(struct device *dev,
1563+ struct device_attribute *attr, char *buf)
15591564 {
15601565 struct asus_wmi *asus = dev_get_drvdata(dev);
15611566
1562− return scnprintf(buf, PAGE_SIZE, "%d\n", asus->fan_mode);
1567+ return scnprintf(buf, PAGE_SIZE, "%d\n", asus->fan_boost_mode);
15631568 }
15641569
1565−static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr,
1566− const char *buf, size_t count)
1570+static ssize_t fan_boost_mode_store(struct device *dev,
1571+ struct device_attribute *attr,
1572+ const char *buf, size_t count)
15671573 {
15681574 int result;
15691575 u8 new_mode;
1570−
15711576 struct asus_wmi *asus = dev_get_drvdata(dev);
1577+ u8 mask = asus->fan_boost_mode_mask;
15721578
15731579 result = kstrtou8(buf, 10, &new_mode);
15741580 if (result < 0) {
@@ -1576,24 +1582,24 @@ static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr, · 1 unmodified line
15761582 return result;
15771583 }
15781584
1579− if (new_mode == ASUS_FAN_MODE_OVERBOOST) {
1580− if (!(asus->fan_mode_mask & ASUS_FAN_MODE_OVERBOOST_MASK))
1585+ if (new_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) {
1586+ if (!(mask & ASUS_FAN_BOOST_MODE_OVERBOOST_MASK))
15811587 return -EINVAL;
1582− } else if (new_mode == ASUS_FAN_MODE_SILENT) {
1583− if (!(asus->fan_mode_mask & ASUS_FAN_MODE_SILENT_MASK))
1588+ } else if (new_mode == ASUS_FAN_BOOST_MODE_SILENT) {
1589+ if (!(mask & ASUS_FAN_BOOST_MODE_SILENT_MASK))
15841590 return -EINVAL;
1585− } else if (new_mode != ASUS_FAN_MODE_NORMAL) {
1591+ } else if (new_mode != ASUS_FAN_BOOST_MODE_NORMAL) {
15861592 return -EINVAL;
15871593 }
15881594
1589− asus->fan_mode = new_mode;
1590− fan_mode_write(asus);
1595+ asus->fan_boost_mode = new_mode;
1596+ fan_boost_mode_write(asus);
15911597
15921598 return result;
15931599 }
15941600
1595−// Fan mode: 0 - normal, 1 - overboost, 2 - silent
1596−static DEVICE_ATTR_RW(fan_mode);
1601+// Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
1602+static DEVICE_ATTR_RW(fan_boost_mode);
15971603
15981604 /* Backlight ******************************************************************/
15991605
@@ -1873,8 +1879,8 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) · 273 unmodified lines
18731879 return;
18741880 }
18751881
1876− if (asus->fan_mode_available && code == NOTIFY_KBD_FBM) {
1877− fan_mode_switch_next(asus);
1882+ if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) {
1883+ fan_boost_mode_switch_next(asus);
18781884 return;
18791885 }
18801886
@@ -2034,7 +2040,7 @@ static struct attribute *platform_attributes[] = { · 153 unmodified lines
20342040 &dev_attr_touchpad.attr,
20352041 &dev_attr_lid_resume.attr,
20362042 &dev_attr_als_enable.attr,
2037− &dev_attr_fan_mode.attr,
2043+ &dev_attr_fan_boost_mode.attr,
20382044 NULL
20392045 };
20402046
@@ -2056,8 +2062,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, · 15 unmodified lines
20562062 devid = ASUS_WMI_DEVID_LID_RESUME;
20572063 else if (attr == &dev_attr_als_enable.attr)
20582064 devid = ASUS_WMI_DEVID_ALS_ENABLE;
2059− else if (attr == &dev_attr_fan_mode.attr)
2060− ok = asus->fan_mode_available;
2065+ else if (attr == &dev_attr_fan_boost_mode.attr)
2066+ ok = asus->fan_boost_mode_available;
20612067
20622068 if (devid != -1)
20632069 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
@@ -2315,9 +2321,9 @@ static int asus_wmi_add(struct platform_device *pdev) · 251 unmodified lines
23152321 if (err)
23162322 goto fail_platform;
23172323
2318− err = fan_mode_check_present(asus);
2324+ err = fan_boost_mode_check_present(asus);
23192325 if (err)
2320− goto fail_fan_mode;
2326+ goto fail_fan_boost_mode;
23212327
23222328 err = asus_wmi_sysfs_init(asus->platform_device);
23232329 if (err)
@@ -2402,7 +2408,7 @@ fail_hwmon: · 78 unmodified lines
24022408 fail_input:
24032409 asus_wmi_sysfs_exit(asus->platform_device);
24042410 fail_sysfs:
2405−fail_fan_mode:
2411+fail_fan_boost_mode:
24062412 fail_platform:
24072413 kfree(asus);
24082414 return err;
include/linux/platform_data/x86/asus-wmi.h+1−1
@@ -57,7 +57,7 @@ · 56 unmodified lines
5757 #define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021
5858 #define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */
5959 #define ASUS_WMI_DEVID_LIGHTBAR 0x00050025
60−#define ASUS_WMI_DEVID_FAN_MODE 0x00110018
60+#define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018
6161
6262 /* Misc */
6363 #define ASUS_WMI_DEVID_CAMERA 0x00060013

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t