History

Merge tag 'hwmon-for-linus-v4.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fix from Guenter Roeck: "Improve fan type detection for dell-smm to prevent kernel hang" * tag 'hwmon-for-linus-v4.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (dell-smm) Cache fan_type() calls and change fan detection

Linus Torvalds committed 10 years ago

Commit 260eaba2 parents ed13fbb 5ce91711 file · +20 −5Browse files

Unified · Split

drivers/hwmon/dell-smm-hwmon.c+20−5
@@ -238,7 +238,7 @@ static int i8k_get_fan_speed(int fan) · 237 unmodified lines
238238 /*
239239 * Read the fan type.
240240 */
241−static int i8k_get_fan_type(int fan)
241+static int _i8k_get_fan_type(int fan)
242242 {
243243 struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, };
244244
@@ -249,6 +249,17 @@ static int i8k_get_fan_type(int fan) · 4 unmodified lines
249249 return i8k_smm(&regs) ? : regs.eax & 0xff;
250250 }
251251
252+static int i8k_get_fan_type(int fan)
253+{
254+ /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */
255+ static int types[2] = { INT_MIN, INT_MIN };
256+
257+ if (types[fan] == INT_MIN)
258+ types[fan] = _i8k_get_fan_type(fan);
259+
260+ return types[fan];
261+}
262+
252263 /*
253264 * Read the fan nominal rpm for specific fan speed.
254265 */
@@ -782,13 +793,17 @@ static int __init i8k_init_hwmon(void) · 527 unmodified lines
782793 if (err >= 0)
783794 i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4;
784795
785− /* First fan attributes, if fan type is OK */
786− err = i8k_get_fan_type(0);
796+ /* First fan attributes, if fan status or type is OK */
797+ err = i8k_get_fan_status(0);
798+ if (err < 0)
799+ err = i8k_get_fan_type(0);
787800 if (err >= 0)
788801 i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1;
789802
790− /* Second fan attributes, if fan type is OK */
791− err = i8k_get_fan_type(1);
803+ /* Second fan attributes, if fan status or type is OK */
804+ err = i8k_get_fan_status(1);
805+ if (err < 0)
806+ err = i8k_get_fan_type(1);
792807 if (err >= 0)
793808 i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2;
794809

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