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
37Description:37Description:
38 Resume on lid open. 1 means on, 0 means off.38 Resume on lid open. 1 means on, 0 means off.
39 39
40What: /sys/devices/platform/<platform>/fan_mode40What: /sys/devices/platform/<platform>/fan_boost_mode
41Date: Apr 201941Date: Sep 2019
42KernelVersion: 5.242KernelVersion: 5.3
43Contact: "Yurii Pavlovskyi" <yurii.pavlovskyi@gmail.com>43Contact: "Yurii Pavlovskyi" <yurii.pavlovskyi@gmail.com>
44Description:44Description:
45 Fan boost mode:45 Fan boost mode:
drivers/platform/x86/asus-wmi.c+62−56
@@ -68,12 +68,12 @@ MODULE_LICENSE("GPL"); · 67 unmodified lines
68#define ASUS_FAN_CTRL_MANUAL 168#define ASUS_FAN_CTRL_MANUAL 1
69#define ASUS_FAN_CTRL_AUTO 269#define ASUS_FAN_CTRL_AUTO 2
70 70
71#define ASUS_FAN_MODE_NORMAL 071#define ASUS_FAN_BOOST_MODE_NORMAL 0
72#define ASUS_FAN_MODE_OVERBOOST 172#define ASUS_FAN_BOOST_MODE_OVERBOOST 1
73#define ASUS_FAN_MODE_OVERBOOST_MASK 0x0173#define ASUS_FAN_BOOST_MODE_OVERBOOST_MASK 0x01
74#define ASUS_FAN_MODE_SILENT 274#define ASUS_FAN_BOOST_MODE_SILENT 2
75#define ASUS_FAN_MODE_SILENT_MASK 0x0275#define ASUS_FAN_BOOST_MODE_SILENT_MASK 0x02
76#define ASUS_FAN_MODES_MASK 0x0376#define ASUS_FAN_BOOST_MODES_MASK 0x03
77 77
78#define USB_INTEL_XUSB2PR 0xD078#define USB_INTEL_XUSB2PR 0xD0
79#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c3179#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
@@ -182,9 +182,9 @@ struct asus_wmi { · 102 unmodified lines
182 int asus_hwmon_num_fans;182 int asus_hwmon_num_fans;
183 int asus_hwmon_pwm;183 int asus_hwmon_pwm;
184 184
185 bool fan_mode_available;185 bool fan_boost_mode_available;
186 u8 fan_mode_mask;186 u8 fan_boost_mode_mask;
187 u8 fan_mode;187 u8 fan_boost_mode;
188 188
189 struct hotplug_slot hotplug_slot;189 struct hotplug_slot hotplug_slot;
190 struct mutex hotplug_lock;190 struct mutex hotplug_lock;
@@ -1487,14 +1487,15 @@ static int asus_wmi_fan_init(struct asus_wmi *asus) · 1296 unmodified lines
1487 1487
1488/* Fan mode *******************************************************************/1488/* Fan mode *******************************************************************/
1489 1489
1490static int fan_mode_check_present(struct asus_wmi *asus)1490static int fan_boost_mode_check_present(struct asus_wmi *asus)
1491{1491{
1492 u32 result;1492 u32 result;
1493 int err;1493 int err;
1494 1494
1495 asus->fan_mode_available = false;1495 asus->fan_boost_mode_available = false;
1496 1496
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);
1498 if (err) {1499 if (err) {
1499 if (err == -ENODEV)1500 if (err == -ENODEV)
1500 return 0;1501 return 0;
@@ -1503,72 +1504,77 @@ static int fan_mode_check_present(struct asus_wmi *asus) · 2 unmodified lines
1503 }1504 }
1504 1505
1505 if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) &&1506 if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
1506 (result & ASUS_FAN_MODES_MASK)) {1507 (result & ASUS_FAN_BOOST_MODES_MASK)) {
1507 asus->fan_mode_available = true;1508 asus->fan_boost_mode_available = true;
1508 asus->fan_mode_mask = result & ASUS_FAN_MODES_MASK;1509 asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
1509 }1510 }
1510 1511
1511 return 0;1512 return 0;
1512}1513}
1513 1514
1514static int fan_mode_write(struct asus_wmi *asus)1515static int fan_boost_mode_write(struct asus_wmi *asus)
1515{1516{
1516 int err;1517 int err;
1517 u8 value;1518 u8 value;
1518 u32 retval;1519 u32 retval;
1519 1520
1520 value = asus->fan_mode;1521 value = asus->fan_boost_mode;
1521 1522
1522 pr_info("Set fan mode: %u\n", value);1523 pr_info("Set fan boost mode: %u\n", value);
1523 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_MODE, value, &retval);1524 err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_BOOST_MODE, value,
1525 &retval);
1524 1526
1525 if (err) {1527 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);
1527 return err;1529 return err;
1528 }1530 }
1529 1531
1530 if (retval != 1) {1532 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);
1532 return -EIO;1535 return -EIO;
1533 }1536 }
1534 1537
1535 return 0;1538 return 0;
1536}1539}
1537 1540
1538static int fan_mode_switch_next(struct asus_wmi *asus)1541static int fan_boost_mode_switch_next(struct asus_wmi *asus)
1539{1542{
1540 if (asus->fan_mode == ASUS_FAN_MODE_NORMAL) {1543 u8 mask = asus->fan_boost_mode_mask;
1541 if (asus->fan_mode_mask & ASUS_FAN_MODE_OVERBOOST_MASK)1544
1542 asus->fan_mode = ASUS_FAN_MODE_OVERBOOST;1545 if (asus->fan_boost_mode == ASUS_FAN_BOOST_MODE_NORMAL) {
1543 else if (asus->fan_mode_mask & ASUS_FAN_MODE_SILENT_MASK)1546 if (mask & ASUS_FAN_BOOST_MODE_OVERBOOST_MASK)
1544 asus->fan_mode = ASUS_FAN_MODE_SILENT;1547 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_OVERBOOST;
1545 } else if (asus->fan_mode == ASUS_FAN_MODE_OVERBOOST) {1548 else if (mask & ASUS_FAN_BOOST_MODE_SILENT_MASK)
1546 if (asus->fan_mode_mask & ASUS_FAN_MODE_SILENT_MASK)1549 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_SILENT;
1547 asus->fan_mode = ASUS_FAN_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;
1548 else1553 else
1549 asus->fan_mode = ASUS_FAN_MODE_NORMAL;1554 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL;
1550 } else {1555 } else {
1551 asus->fan_mode = ASUS_FAN_MODE_NORMAL;1556 asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL;
1552 }1557 }
1553 1558
1554 return fan_mode_write(asus);1559 return fan_boost_mode_write(asus);
1555}1560}
1556 1561
1557static ssize_t fan_mode_show(struct device *dev,1562static ssize_t fan_boost_mode_show(struct device *dev,
1558 struct device_attribute *attr, char *buf)1563 struct device_attribute *attr, char *buf)
1559{1564{
1560 struct asus_wmi *asus = dev_get_drvdata(dev);1565 struct asus_wmi *asus = dev_get_drvdata(dev);
1561 1566
1562 return scnprintf(buf, PAGE_SIZE, "%d\n", asus->fan_mode);1567 return scnprintf(buf, PAGE_SIZE, "%d\n", asus->fan_boost_mode);
1563}1568}
1564 1569
1565static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr,1570static ssize_t fan_boost_mode_store(struct device *dev,
1566 const char *buf, size_t count)1571 struct device_attribute *attr,
1572 const char *buf, size_t count)
1567{1573{
1568 int result;1574 int result;
1569 u8 new_mode;1575 u8 new_mode;
1570
1571 struct asus_wmi *asus = dev_get_drvdata(dev);1576 struct asus_wmi *asus = dev_get_drvdata(dev);
1577 u8 mask = asus->fan_boost_mode_mask;
1572 1578
1573 result = kstrtou8(buf, 10, &new_mode);1579 result = kstrtou8(buf, 10, &new_mode);
1574 if (result < 0) {1580 if (result < 0) {
@@ -1576,24 +1582,24 @@ static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr, · 1 unmodified line
1576 return result;1582 return result;
1577 }1583 }
1578 1584
1579 if (new_mode == ASUS_FAN_MODE_OVERBOOST) {1585 if (new_mode == ASUS_FAN_BOOST_MODE_OVERBOOST) {
1580 if (!(asus->fan_mode_mask & ASUS_FAN_MODE_OVERBOOST_MASK))1586 if (!(mask & ASUS_FAN_BOOST_MODE_OVERBOOST_MASK))
1581 return -EINVAL;1587 return -EINVAL;
1582 } else if (new_mode == ASUS_FAN_MODE_SILENT) {1588 } else if (new_mode == ASUS_FAN_BOOST_MODE_SILENT) {
1583 if (!(asus->fan_mode_mask & ASUS_FAN_MODE_SILENT_MASK))1589 if (!(mask & ASUS_FAN_BOOST_MODE_SILENT_MASK))
1584 return -EINVAL;1590 return -EINVAL;
1585 } else if (new_mode != ASUS_FAN_MODE_NORMAL) {1591 } else if (new_mode != ASUS_FAN_BOOST_MODE_NORMAL) {
1586 return -EINVAL;1592 return -EINVAL;
1587 }1593 }
1588 1594
1589 asus->fan_mode = new_mode;1595 asus->fan_boost_mode = new_mode;
1590 fan_mode_write(asus);1596 fan_boost_mode_write(asus);
1591 1597
1592 return result;1598 return result;
1593}1599}
1594 1600
1595// Fan mode: 0 - normal, 1 - overboost, 2 - silent1601// Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
1596static DEVICE_ATTR_RW(fan_mode);1602static DEVICE_ATTR_RW(fan_boost_mode);
1597 1603
1598/* Backlight ******************************************************************/1604/* Backlight ******************************************************************/
1599 1605
@@ -1873,8 +1879,8 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) · 273 unmodified lines
1873 return;1879 return;
1874 }1880 }
1875 1881
1876 if (asus->fan_mode_available && code == NOTIFY_KBD_FBM) {1882 if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) {
1877 fan_mode_switch_next(asus);1883 fan_boost_mode_switch_next(asus);
1878 return;1884 return;
1879 }1885 }
1880 1886
@@ -2034,7 +2040,7 @@ static struct attribute *platform_attributes[] = { · 153 unmodified lines
2034 &dev_attr_touchpad.attr,2040 &dev_attr_touchpad.attr,
2035 &dev_attr_lid_resume.attr,2041 &dev_attr_lid_resume.attr,
2036 &dev_attr_als_enable.attr,2042 &dev_attr_als_enable.attr,
2037 &dev_attr_fan_mode.attr,2043 &dev_attr_fan_boost_mode.attr,
2038 NULL2044 NULL
2039};2045};
2040 2046
@@ -2056,8 +2062,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, · 15 unmodified lines
2056 devid = ASUS_WMI_DEVID_LID_RESUME;2062 devid = ASUS_WMI_DEVID_LID_RESUME;
2057 else if (attr == &dev_attr_als_enable.attr)2063 else if (attr == &dev_attr_als_enable.attr)
2058 devid = ASUS_WMI_DEVID_ALS_ENABLE;2064 devid = ASUS_WMI_DEVID_ALS_ENABLE;
2059 else if (attr == &dev_attr_fan_mode.attr)2065 else if (attr == &dev_attr_fan_boost_mode.attr)
2060 ok = asus->fan_mode_available;2066 ok = asus->fan_boost_mode_available;
2061 2067
2062 if (devid != -1)2068 if (devid != -1)
2063 ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);2069 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
2315 if (err)2321 if (err)
2316 goto fail_platform;2322 goto fail_platform;
2317 2323
2318 err = fan_mode_check_present(asus);2324 err = fan_boost_mode_check_present(asus);
2319 if (err)2325 if (err)
2320 goto fail_fan_mode;2326 goto fail_fan_boost_mode;
2321 2327
2322 err = asus_wmi_sysfs_init(asus->platform_device);2328 err = asus_wmi_sysfs_init(asus->platform_device);
2323 if (err)2329 if (err)
@@ -2402,7 +2408,7 @@ fail_hwmon: · 78 unmodified lines
2402fail_input:2408fail_input:
2403 asus_wmi_sysfs_exit(asus->platform_device);2409 asus_wmi_sysfs_exit(asus->platform_device);
2404fail_sysfs:2410fail_sysfs:
2405fail_fan_mode:2411fail_fan_boost_mode:
2406fail_platform:2412fail_platform:
2407 kfree(asus);2413 kfree(asus);
2408 return err;2414 return err;
include/linux/platform_data/x86/asus-wmi.h+1−1
@@ -57,7 +57,7 @@ · 56 unmodified lines
57#define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x0005002157#define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021
58#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */58#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */
59#define ASUS_WMI_DEVID_LIGHTBAR 0x0005002559#define ASUS_WMI_DEVID_LIGHTBAR 0x00050025
60#define ASUS_WMI_DEVID_FAN_MODE 0x0011001860#define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018
61 61
62/* Misc */62/* Misc */
63#define ASUS_WMI_DEVID_CAMERA 0x0006001363#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