提交 50ebec09 编写于 作者: H Henrique de Moraes Holschuh 提交者: Len Brown

ACPI: thinkpad-acpi: add poll() support to some sysfs attributes

Implement poll()/select() support through sysfs_notify() for some key
attributes which userspace might want to poll() or select() on.

In order to let userspace know poll()/select() support is available for an
attribute, the thinkpad-acpi sysfs interface version is also bumped up.
Further changes that add poll()/select() capabilities to any pre-existing
attributes will also increment the sysfs interface version.
Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 013c40e4
...@@ -311,6 +311,8 @@ sysfs notes: ...@@ -311,6 +311,8 @@ sysfs notes:
disabled" postition, and 1 if the switch is in the disabled" postition, and 1 if the switch is in the
"radios enabled" position. "radios enabled" position.
This attribute has poll()/select() support.
hotkey_report_mode: hotkey_report_mode:
Returns the state of the procfs ACPI event report mode Returns the state of the procfs ACPI event report mode
filter for hot keys. If it is set to 1 (the default), filter for hot keys. If it is set to 1 (the default),
...@@ -332,6 +334,8 @@ sysfs notes: ...@@ -332,6 +334,8 @@ sysfs notes:
undock. Set to zero for normal wake-ups or wake-ups undock. Set to zero for normal wake-ups or wake-ups
due to unknown reasons. due to unknown reasons.
This attribute has poll()/select() support.
wakeup_hotunplug_complete: wakeup_hotunplug_complete:
Set to 1 if the system was waken up because of an Set to 1 if the system was waken up because of an
undock or bay ejection request, and that request undock or bay ejection request, and that request
...@@ -340,6 +344,8 @@ sysfs notes: ...@@ -340,6 +344,8 @@ sysfs notes:
user's choice. Refer to HKEY events 0x4003 and user's choice. Refer to HKEY events 0x4003 and
0x3003, below. 0x3003, below.
This attribute has poll()/select() support.
input layer notes: input layer notes:
A Hot key is mapped to a single input layer EV_KEY event, possibly A Hot key is mapped to a single input layer EV_KEY event, possibly
...@@ -1354,3 +1360,6 @@ Sysfs interface changelog: ...@@ -1354,3 +1360,6 @@ Sysfs interface changelog:
NVRAM polling patch). Some development snapshots of NVRAM polling patch). Some development snapshots of
0.18 had an earlier version that did strange things 0.18 had an earlier version that did strange things
to hotkey_mask. to hotkey_mask.
0x020200: Add poll()/select() support to the following attributes:
hotkey_radio_sw, wakeup_hotunplug_complete, wakeup_reason
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
#define TPACPI_VERSION "0.18" #define TPACPI_VERSION "0.18"
#define TPACPI_SYSFS_VERSION 0x020101 #define TPACPI_SYSFS_VERSION 0x020200
/* /*
* Changelog: * Changelog:
...@@ -1643,7 +1643,7 @@ static struct device_attribute dev_attr_hotkey_poll_freq = ...@@ -1643,7 +1643,7 @@ static struct device_attribute dev_attr_hotkey_poll_freq =
#endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */
/* sysfs hotkey radio_sw ----------------------------------------------- */ /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
static ssize_t hotkey_radio_sw_show(struct device *dev, static ssize_t hotkey_radio_sw_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -1659,6 +1659,13 @@ static ssize_t hotkey_radio_sw_show(struct device *dev, ...@@ -1659,6 +1659,13 @@ static ssize_t hotkey_radio_sw_show(struct device *dev,
static struct device_attribute dev_attr_hotkey_radio_sw = static struct device_attribute dev_attr_hotkey_radio_sw =
__ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL); __ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL);
static void hotkey_radio_sw_notify_change(void)
{
if (tp_features.hotkey_wlsw)
sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
"hotkey_radio_sw");
}
/* sysfs hotkey report_mode -------------------------------------------- */ /* sysfs hotkey report_mode -------------------------------------------- */
static ssize_t hotkey_report_mode_show(struct device *dev, static ssize_t hotkey_report_mode_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
...@@ -1671,7 +1678,7 @@ static ssize_t hotkey_report_mode_show(struct device *dev, ...@@ -1671,7 +1678,7 @@ static ssize_t hotkey_report_mode_show(struct device *dev,
static struct device_attribute dev_attr_hotkey_report_mode = static struct device_attribute dev_attr_hotkey_report_mode =
__ATTR(hotkey_report_mode, S_IRUGO, hotkey_report_mode_show, NULL); __ATTR(hotkey_report_mode, S_IRUGO, hotkey_report_mode_show, NULL);
/* sysfs wakeup reason ------------------------------------------------- */ /* sysfs wakeup reason (pollable) -------------------------------------- */
static ssize_t hotkey_wakeup_reason_show(struct device *dev, static ssize_t hotkey_wakeup_reason_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -1682,7 +1689,14 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev, ...@@ -1682,7 +1689,14 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev,
static struct device_attribute dev_attr_hotkey_wakeup_reason = static struct device_attribute dev_attr_hotkey_wakeup_reason =
__ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL); __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL);
/* sysfs wakeup hotunplug_complete ------------------------------------- */ void hotkey_wakeup_reason_notify_change(void)
{
if (tp_features.hotkey_mask)
sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
"wakeup_reason");
}
/* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
static ssize_t hotkey_wakeup_hotunplug_complete_show(struct device *dev, static ssize_t hotkey_wakeup_hotunplug_complete_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
...@@ -1694,6 +1708,13 @@ static struct device_attribute dev_attr_hotkey_wakeup_hotunplug_complete = ...@@ -1694,6 +1708,13 @@ static struct device_attribute dev_attr_hotkey_wakeup_hotunplug_complete =
__ATTR(wakeup_hotunplug_complete, S_IRUGO, __ATTR(wakeup_hotunplug_complete, S_IRUGO,
hotkey_wakeup_hotunplug_complete_show, NULL); hotkey_wakeup_hotunplug_complete_show, NULL);
void hotkey_wakeup_hotunplug_complete_notify_change(void)
{
if (tp_features.hotkey_mask)
sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
"wakeup_hotunplug_complete");
}
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
static struct attribute *hotkey_attributes[] __initdata = { static struct attribute *hotkey_attributes[] __initdata = {
...@@ -2106,6 +2127,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) ...@@ -2106,6 +2127,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
printk(TPACPI_INFO printk(TPACPI_INFO
"woke up due to a hot-unplug " "woke up due to a hot-unplug "
"request...\n"); "request...\n");
hotkey_wakeup_reason_notify_change();
} }
break; break;
case 3: case 3:
...@@ -2114,6 +2136,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) ...@@ -2114,6 +2136,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
hotkey_autosleep_ack = 1; hotkey_autosleep_ack = 1;
printk(TPACPI_INFO printk(TPACPI_INFO
"bay ejected\n"); "bay ejected\n");
hotkey_wakeup_hotunplug_complete_notify_change();
} else { } else {
unk_ev = 1; unk_ev = 1;
} }
...@@ -2124,6 +2147,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) ...@@ -2124,6 +2147,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
hotkey_autosleep_ack = 1; hotkey_autosleep_ack = 1;
printk(TPACPI_INFO printk(TPACPI_INFO
"undocked\n"); "undocked\n");
hotkey_wakeup_hotunplug_complete_notify_change();
} else { } else {
unk_ev = 1; unk_ev = 1;
} }
...@@ -2150,6 +2174,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) ...@@ -2150,6 +2174,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
/* 0x7000-0x7FFF: misc */ /* 0x7000-0x7FFF: misc */
if (tp_features.hotkey_wlsw && hkey == 0x7000) { if (tp_features.hotkey_wlsw && hkey == 0x7000) {
tpacpi_input_send_radiosw(); tpacpi_input_send_radiosw();
hotkey_radio_sw_notify_change();
send_acpi_ev = 0; send_acpi_ev = 0;
break; break;
} }
...@@ -2193,6 +2218,9 @@ static void hotkey_resume(void) ...@@ -2193,6 +2218,9 @@ static void hotkey_resume(void)
"error while trying to read hot key mask " "error while trying to read hot key mask "
"from firmware\n"); "from firmware\n");
tpacpi_input_send_radiosw(); tpacpi_input_send_radiosw();
hotkey_radio_sw_notify_change();
hotkey_wakeup_reason_notify_change();
hotkey_wakeup_hotunplug_complete_notify_change();
#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
hotkey_poll_setup_safe(0); hotkey_poll_setup_safe(0);
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册