Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316034
b: refs/heads/master
c: b6e5122
h: refs/heads/master
v: v3
  • Loading branch information
Henrik Rydberg authored and Guenter Roeck committed Jul 22, 2012
1 parent c7d1fa8 commit b56c649
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 41bf870e6db130c6e467c70b6da96398066b8be7
refs/heads/master: b6e5122f09272cb30c2e1fc1d80a40bfa6e87757
19 changes: 8 additions & 11 deletions trunk/drivers/hwmon/applesmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#define FANS_MANUAL "FS! " /* r-w ui16 */
#define FAN_ID_FMT "F%dID" /* r-o char[16] */

#define TEMP_SENSOR_TYPE "sp78"

/* List of keys used to read/write fan speeds */
static const char *const fan_speed_fmt[] = {
"F%dAc", /* actual speed */
Expand Down Expand Up @@ -720,27 +722,22 @@ static ssize_t applesmc_show_temperature(struct device *dev,
int index = smcreg.temp_begin + to_index(devattr);
const struct applesmc_entry *entry;
int ret;
u8 buffer[2];
unsigned int temp;
s16 value;
int temp;

entry = applesmc_get_entry_by_index(index);
if (IS_ERR(entry))
return PTR_ERR(entry);
if (entry->len > 2)
if (strcmp(entry->type, TEMP_SENSOR_TYPE))
return -EINVAL;

ret = applesmc_read_entry(entry, buffer, entry->len);
ret = applesmc_read_s16(entry->key, &value);
if (ret)
return ret;

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

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

static ssize_t applesmc_show_fan_speed(struct device *dev,
Expand Down

0 comments on commit b56c649

Please sign in to comment.