Commit dcdea261 authored by Henrik Rydberg's avatar Henrik Rydberg Committed by Guenter Roeck

hwmon: (applesmc) Handle new temperature format

The recent Macbooks have temperature registers of a new type.
This patch adds the logic to handle them.
Signed-off-by: default avatarHenrik Rydberg <rydberg@euromail.se>
Signed-off-by: default avatarGuenter Roeck <guenter.roeck@ericsson.com>
parent 9792dadf
...@@ -734,13 +734,19 @@ static ssize_t applesmc_show_temperature(struct device *dev, ...@@ -734,13 +734,19 @@ static ssize_t applesmc_show_temperature(struct device *dev,
entry = applesmc_get_entry_by_index(index); entry = applesmc_get_entry_by_index(index);
if (IS_ERR(entry)) if (IS_ERR(entry))
return PTR_ERR(entry); return PTR_ERR(entry);
if (entry->len > 2)
return -EINVAL;
ret = applesmc_read_entry(entry, buffer, 2); ret = applesmc_read_entry(entry, buffer, entry->len);
if (ret) if (ret)
return ret; return ret;
temp = buffer[0]*1000; if (entry->len == 2) {
temp += (buffer[1] >> 6) * 250; temp = buffer[0] * 1000;
temp += (buffer[1] >> 6) * 250;
} else {
temp = buffer[0] * 4000;
}
return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp); return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment