aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2007-10-30 15:46:24 -0400
committerLen Brown <len.brown@intel.com>2007-11-05 13:07:11 -0500
commitfc589a3ce5f38db6239c147da4f9172a25575ecc (patch)
tree3732f557e21ef93787a0ebfcad4323ec00165dea /drivers/misc
parentb856f5b8c022b75bb0504a8c1ce16a5f1656e08b (diff)
ACPI: thinkpad-acpi: allow for syscall restart in sysfs handlers
Map an mutex_lock_interruptible() error return into ERESTARTSYS, as the only possible error from mutex_lock_interruptible is EINTR, and that will only happen if signal_pending() causes the mutex lock attempt to abort. This still allows signals to be delivered ASAP, which is much nicer than just doing mutex_lock, and still shadows userspace from EINTR when SA_RESTART is active. Problem reported by Peter Jordan. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> Cc: Jean Delvare <khali@linux-fr.org> Cc: Peter Jordan <usernetwork@gmx.info> Cc: Richard Neill <rn214@hermes.cam.ac.uk> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/thinkpad_acpi.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 251110d0ec80..306daa524c03 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1342,9 +1342,8 @@ static int hotkey_read(char *p)
1342 return len; 1342 return len;
1343 } 1343 }
1344 1344
1345 res = mutex_lock_interruptible(&hotkey_mutex); 1345 if (mutex_lock_interruptible(&hotkey_mutex))
1346 if (res < 0) 1346 return -ERESTARTSYS;
1347 return res;
1348 res = hotkey_get(&status, &mask); 1347 res = hotkey_get(&status, &mask);
1349 mutex_unlock(&hotkey_mutex); 1348 mutex_unlock(&hotkey_mutex);
1350 if (res) 1349 if (res)
@@ -1373,9 +1372,8 @@ static int hotkey_write(char *buf)
1373 if (!tp_features.hotkey) 1372 if (!tp_features.hotkey)
1374 return -ENODEV; 1373 return -ENODEV;
1375 1374
1376 res = mutex_lock_interruptible(&hotkey_mutex); 1375 if (mutex_lock_interruptible(&hotkey_mutex))
1377 if (res < 0) 1376 return -ERESTARTSYS;
1378 return res;
1379 1377
1380 res = hotkey_get(&status, &mask); 1378 res = hotkey_get(&status, &mask);
1381 if (res) 1379 if (res)
@@ -3768,9 +3766,8 @@ static ssize_t fan_pwm1_store(struct device *dev,
3768 /* scale down from 0-255 to 0-7 */ 3766 /* scale down from 0-255 to 0-7 */
3769 newlevel = (s >> 5) & 0x07; 3767 newlevel = (s >> 5) & 0x07;
3770 3768
3771 rc = mutex_lock_interruptible(&fan_mutex); 3769 if (mutex_lock_interruptible(&fan_mutex))
3772 if (rc < 0) 3770 return -ERESTARTSYS;
3773 return rc;
3774 3771
3775 rc = fan_get_status(&status); 3772 rc = fan_get_status(&status);
3776 if (!rc && (status & 3773 if (!rc && (status &
@@ -4020,9 +4017,8 @@ static int fan_get_status_safe(u8 *status)
4020 int rc; 4017 int rc;
4021 u8 s; 4018 u8 s;
4022 4019
4023 rc = mutex_lock_interruptible(&fan_mutex); 4020 if (mutex_lock_interruptible(&fan_mutex))
4024 if (rc < 0) 4021 return -ERESTARTSYS;
4025 return rc;
4026 rc = fan_get_status(&s); 4022 rc = fan_get_status(&s);
4027 if (!rc) 4023 if (!rc)
4028 fan_update_desired_level(s); 4024 fan_update_desired_level(s);
@@ -4156,9 +4152,8 @@ static int fan_set_level_safe(int level)
4156 if (!fan_control_allowed) 4152 if (!fan_control_allowed)
4157 return -EPERM; 4153 return -EPERM;
4158 4154
4159 rc = mutex_lock_interruptible(&fan_mutex); 4155 if (mutex_lock_interruptible(&fan_mutex))
4160 if (rc < 0) 4156 return -ERESTARTSYS;
4161 return rc;
4162 4157
4163 if (level == TPACPI_FAN_LAST_LEVEL) 4158 if (level == TPACPI_FAN_LAST_LEVEL)
4164 level = fan_control_desired_level; 4159 level = fan_control_desired_level;
@@ -4179,9 +4174,8 @@ static int fan_set_enable(void)
4179 if (!fan_control_allowed) 4174 if (!fan_control_allowed)
4180 return -EPERM; 4175 return -EPERM;
4181 4176
4182 rc = mutex_lock_interruptible(&fan_mutex); 4177 if (mutex_lock_interruptible(&fan_mutex))
4183 if (rc < 0) 4178 return -ERESTARTSYS;
4184 return rc;
4185 4179
4186 switch (fan_control_access_mode) { 4180 switch (fan_control_access_mode) {
4187 case TPACPI_FAN_WR_ACPI_FANS: 4181 case TPACPI_FAN_WR_ACPI_FANS:
@@ -4235,9 +4229,8 @@ static int fan_set_disable(void)
4235 if (!fan_control_allowed) 4229 if (!fan_control_allowed)
4236 return -EPERM; 4230 return -EPERM;
4237 4231
4238 rc = mutex_lock_interruptible(&fan_mutex); 4232 if (mutex_lock_interruptible(&fan_mutex))
4239 if (rc < 0) 4233 return -ERESTARTSYS;
4240 return rc;
4241 4234
4242 rc = 0; 4235 rc = 0;
4243 switch (fan_control_access_mode) { 4236 switch (fan_control_access_mode) {
@@ -4274,9 +4267,8 @@ static int fan_set_speed(int speed)
4274 if (!fan_control_allowed) 4267 if (!fan_control_allowed)
4275 return -EPERM; 4268 return -EPERM;
4276 4269
4277 rc = mutex_lock_interruptible(&fan_mutex); 4270 if (mutex_lock_interruptible(&fan_mutex))
4278 if (rc < 0) 4271 return -ERESTARTSYS;
4279 return rc;
4280 4272
4281 rc = 0; 4273 rc = 0;
4282 switch (fan_control_access_mode) { 4274 switch (fan_control_access_mode) {