aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/applesmc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 03c24b7c9cbd..1d7f8aff9982 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -734,13 +734,19 @@ static ssize_t applesmc_show_temperature(struct device *dev,
734 entry = applesmc_get_entry_by_index(index); 734 entry = applesmc_get_entry_by_index(index);
735 if (IS_ERR(entry)) 735 if (IS_ERR(entry))
736 return PTR_ERR(entry); 736 return PTR_ERR(entry);
737 if (entry->len > 2)
738 return -EINVAL;
737 739
738 ret = applesmc_read_entry(entry, buffer, 2); 740 ret = applesmc_read_entry(entry, buffer, entry->len);
739 if (ret) 741 if (ret)
740 return ret; 742 return ret;
741 743
742 temp = buffer[0]*1000; 744 if (entry->len == 2) {
743 temp += (buffer[1] >> 6) * 250; 745 temp = buffer[0] * 1000;
746 temp += (buffer[1] >> 6) * 250;
747 } else {
748 temp = buffer[0] * 4000;
749 }
744 750
745 return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp); 751 return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", temp);
746} 752}