static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sch5627_data *data = sch5627_update_device(dev); int val; if (IS_ERR(data)) return PTR_ERR(data); val = reg_to_temp(data->temp[attr->index]); return snprintf(buf, PAGE_SIZE, "%d\n", val); }
static s32 tmon_read_critical_limit(struct i2c_client *client, s32 *ptemp, enum temp_type typ) { u8 config; u8 tmp; int err; u16 temperature = 0; struct tmon_info *data = i2c_get_clientdata(client); TMON_RD(client, REG_CFG_READ, &config); TMON_RD(client, REG_TEMP_CRIT_LIMIT[typ], &tmp); temperature = ((u16)tmp) << 8; *ptemp = reg_to_temp(temperature, config); if (typ == REMOTE) *ptemp = *ptemp + data->pdata->remote_offset; return 0; }
static s32 tmon_read_local_temp(struct i2c_client *client, int *ptemp) { u8 config; u8 tmp; int err; u16 temperature = 0; TMON_RD(client, REG_CFG_READ, &config); TMON_RD(client, REG_TEMP_MSB[0], &tmp); temperature = ((u16)tmp) << 8; if (tmon_device == TMP411) { TMON_RD(client, REG_TEMP_LSB[0], &tmp); temperature |= tmp; } *ptemp = reg_to_temp(temperature, config); return 0; }
static s32 tmon_read_remote_temp(struct i2c_client *client, s32 *ptemp) { u8 config; u8 tmp; int err; u16 temperature = 0; struct tmon_info *data = i2c_get_clientdata(client); TMON_RD(client, REG_CFG_READ, &config); TMON_RD(client, REG_TEMP_MSB[1], &tmp); temperature = ((u16)tmp) << 8; TMON_RD(client, REG_TEMP_LSB[1], &tmp); temperature |= tmp; *ptemp = reg_to_temp(temperature, config) + data->pdata->remote_offset; return 0; }
static s32 tmon_read_high_limit(struct i2c_client *client, s32 *ptemp, enum temp_type typ) { u8 config; u8 tmp; int err; u16 temperature = 0; struct tmon_info *data = i2c_get_clientdata(client); TMON_RD(client, REG_CFG_READ, &config); TMON_RD(client, REG_TEMP_HIGH_LIMIT_MSB_RD[typ], &tmp); temperature = ((u16)tmp) << 8; if ((typ == REMOTE) || (typ == LOCAL && tmon_device == TMP411)) { TMON_RD(client, REG_TEMP_HIGH_LIMIT_LSB[typ], &tmp); temperature |= tmp; } *ptemp = reg_to_temp(temperature, config); if (typ == REMOTE) *ptemp = *ptemp + data->pdata->remote_offset; return 0; }