1 From fc589a3ce5f38db6239c147da4f9172a25575ecc Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Tue, 30 Oct 2007 17:46:24 -0200
4 Subject: [PATCH 21/23] ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers
6 Map an mutex_lock_interruptible() error return into ERESTARTSYS, as the
7 only possible error from mutex_lock_interruptible is EINTR, and that will
8 only happen if signal_pending() causes the mutex lock attempt to abort.
10 This still allows signals to be delivered ASAP, which is much nicer than
11 just doing mutex_lock, and still shadows userspace from EINTR when
14 Problem reported by Peter Jordan.
16 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
17 Cc: Jean Delvare <khali@linux-fr.org>
18 Cc: Peter Jordan <usernetwork@gmx.info>
19 Cc: Richard Neill <rn214@hermes.cam.ac.uk>
20 Signed-off-by: Len Brown <len.brown@intel.com>
22 drivers/misc/thinkpad_acpi.c | 40 ++++++++++++++++------------------------
23 1 files changed, 16 insertions(+), 24 deletions(-)
25 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
26 index 251110d..306daa5 100644
27 --- a/drivers/misc/thinkpad_acpi.c
28 +++ b/drivers/misc/thinkpad_acpi.c
29 @@ -1342,9 +1342,8 @@ static int hotkey_read(char *p)
33 - res = mutex_lock_interruptible(&hotkey_mutex);
36 + if (mutex_lock_interruptible(&hotkey_mutex))
37 + return -ERESTARTSYS;
38 res = hotkey_get(&status, &mask);
39 mutex_unlock(&hotkey_mutex);
41 @@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf)
42 if (!tp_features.hotkey)
45 - res = mutex_lock_interruptible(&hotkey_mutex);
48 + if (mutex_lock_interruptible(&hotkey_mutex))
49 + return -ERESTARTSYS;
51 res = hotkey_get(&status, &mask);
53 @@ -3768,9 +3766,8 @@ static ssize_t fan_pwm1_store(struct device *dev,
54 /* scale down from 0-255 to 0-7 */
55 newlevel = (s >> 5) & 0x07;
57 - rc = mutex_lock_interruptible(&fan_mutex);
60 + if (mutex_lock_interruptible(&fan_mutex))
61 + return -ERESTARTSYS;
63 rc = fan_get_status(&status);
65 @@ -4020,9 +4017,8 @@ static int fan_get_status_safe(u8 *status)
69 - rc = mutex_lock_interruptible(&fan_mutex);
72 + if (mutex_lock_interruptible(&fan_mutex))
73 + return -ERESTARTSYS;
74 rc = fan_get_status(&s);
76 fan_update_desired_level(s);
77 @@ -4156,9 +4152,8 @@ static int fan_set_level_safe(int level)
78 if (!fan_control_allowed)
81 - rc = mutex_lock_interruptible(&fan_mutex);
84 + if (mutex_lock_interruptible(&fan_mutex))
85 + return -ERESTARTSYS;
87 if (level == TPACPI_FAN_LAST_LEVEL)
88 level = fan_control_desired_level;
89 @@ -4179,9 +4174,8 @@ static int fan_set_enable(void)
90 if (!fan_control_allowed)
93 - rc = mutex_lock_interruptible(&fan_mutex);
96 + if (mutex_lock_interruptible(&fan_mutex))
97 + return -ERESTARTSYS;
99 switch (fan_control_access_mode) {
100 case TPACPI_FAN_WR_ACPI_FANS:
101 @@ -4235,9 +4229,8 @@ static int fan_set_disable(void)
102 if (!fan_control_allowed)
105 - rc = mutex_lock_interruptible(&fan_mutex);
108 + if (mutex_lock_interruptible(&fan_mutex))
109 + return -ERESTARTSYS;
112 switch (fan_control_access_mode) {
113 @@ -4274,9 +4267,8 @@ static int fan_set_speed(int speed)
114 if (!fan_control_allowed)
117 - rc = mutex_lock_interruptible(&fan_mutex);
120 + if (mutex_lock_interruptible(&fan_mutex))
121 + return -ERESTARTSYS;
124 switch (fan_control_access_mode) {