Skip to content

Commit

Permalink
hwmon: (applesmc) Handle new temperature format
Browse files Browse the repository at this point in the history
The recent Macbooks have temperature registers of a new type.
This patch adds the logic to handle them.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
  • Loading branch information
Henrik Rydberg authored and Guenter Roeck committed Jan 8, 2011
1 parent 9792dad commit dcdea26
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/hwmon/applesmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,13 +734,19 @@ static ssize_t applesmc_show_temperature(struct device *dev,
entry = applesmc_get_entry_by_index(index);
if (IS_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)
return ret;

temp = buffer[0]*1000;
temp += (buffer[1] >> 6) * 250;
if (entry->len == 2) {
temp = buffer[0] * 1000;
temp += (buffer[1] >> 6) * 250;
} else {
temp = buffer[0] * 4000;
}

return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp);
}
Expand Down

0 comments on commit dcdea26

Please sign in to comment.