Lines Matching refs:data
203 struct tmp401_data *data) in tmp401_update_device_reg16() argument
206 int num_regs = data->kind == tmp411 ? 6 : 4; in tmp401_update_device_reg16()
207 int num_sensors = data->kind == tmp432 ? 3 : 2; in tmp401_update_device_reg16()
216 regaddr = data->kind == tmp432 ? in tmp401_update_device_reg16()
222 data->temp[j][i] = val << 8; in tmp401_update_device_reg16()
225 regaddr = data->kind == tmp432 ? TMP432_TEMP_LSB[j][i] in tmp401_update_device_reg16()
230 data->temp[j][i] |= val; in tmp401_update_device_reg16()
238 struct tmp401_data *data = dev_get_drvdata(dev); in tmp401_update_device() local
239 struct i2c_client *client = data->client; in tmp401_update_device()
240 struct tmp401_data *ret = data; in tmp401_update_device()
244 mutex_lock(&data->update_lock); in tmp401_update_device()
246 next_update = data->last_updated + in tmp401_update_device()
247 msecs_to_jiffies(data->update_interval); in tmp401_update_device()
248 if (time_after(jiffies, next_update) || !data->valid) { in tmp401_update_device()
249 if (data->kind != tmp432) { in tmp401_update_device()
259 data->status[0] = in tmp401_update_device()
261 data->status[1] = in tmp401_update_device()
264 data->status[2] = in tmp401_update_device()
267 data->status[3] = val & (TMP401_STATUS_LOCAL_CRIT in tmp401_update_device()
270 for (i = 0; i < ARRAY_SIZE(data->status); i++) { in tmp401_update_device()
277 data->status[i] = val; in tmp401_update_device()
286 data->config = val; in tmp401_update_device()
287 val = tmp401_update_device_reg16(client, data); in tmp401_update_device()
297 data->temp_crit_hyst = val; in tmp401_update_device()
299 data->last_updated = jiffies; in tmp401_update_device()
300 data->valid = 1; in tmp401_update_device()
304 mutex_unlock(&data->update_lock); in tmp401_update_device()
313 struct tmp401_data *data = tmp401_update_device(dev); in show_temp() local
315 if (IS_ERR(data)) in show_temp()
316 return PTR_ERR(data); in show_temp()
319 tmp401_register_to_temp(data->temp[nr][index], data->config)); in show_temp()
326 struct tmp401_data *data = tmp401_update_device(dev); in show_temp_crit_hyst() local
328 if (IS_ERR(data)) in show_temp_crit_hyst()
329 return PTR_ERR(data); in show_temp_crit_hyst()
331 mutex_lock(&data->update_lock); in show_temp_crit_hyst()
332 temp = tmp401_register_to_temp(data->temp[3][index], data->config); in show_temp_crit_hyst()
333 temp -= data->temp_crit_hyst * 1000; in show_temp_crit_hyst()
334 mutex_unlock(&data->update_lock); in show_temp_crit_hyst()
344 struct tmp401_data *data = tmp401_update_device(dev); in show_status() local
346 if (IS_ERR(data)) in show_status()
347 return PTR_ERR(data); in show_status()
349 return sprintf(buf, "%d\n", !!(data->status[nr] & mask)); in show_status()
357 struct tmp401_data *data = dev_get_drvdata(dev); in store_temp() local
358 struct i2c_client *client = data->client; in store_temp()
366 reg = tmp401_temp_to_register(val, data->config, nr == 3 ? 8 : 4); in store_temp()
368 mutex_lock(&data->update_lock); in store_temp()
370 regaddr = data->kind == tmp432 ? TMP432_TEMP_MSB_WRITE[nr][index] in store_temp()
374 regaddr = data->kind == tmp432 ? TMP432_TEMP_LSB[nr][index] in store_temp()
378 data->temp[nr][index] = reg; in store_temp()
380 mutex_unlock(&data->update_lock); in store_temp()
389 struct tmp401_data *data = tmp401_update_device(dev); in store_temp_crit_hyst() local
393 if (IS_ERR(data)) in store_temp_crit_hyst()
394 return PTR_ERR(data); in store_temp_crit_hyst()
399 if (data->config & TMP401_CONFIG_RANGE) in store_temp_crit_hyst()
404 mutex_lock(&data->update_lock); in store_temp_crit_hyst()
405 temp = tmp401_register_to_temp(data->temp[3][index], data->config); in store_temp_crit_hyst()
409 i2c_smbus_write_byte_data(data->client, TMP401_TEMP_CRIT_HYST, in store_temp_crit_hyst()
412 data->temp_crit_hyst = reg; in store_temp_crit_hyst()
414 mutex_unlock(&data->update_lock); in store_temp_crit_hyst()
427 struct tmp401_data *data = dev_get_drvdata(dev); in reset_temp_history() local
428 struct i2c_client *client = data->client; in reset_temp_history()
440 mutex_lock(&data->update_lock); in reset_temp_history()
442 data->valid = 0; in reset_temp_history()
443 mutex_unlock(&data->update_lock); in reset_temp_history()
451 struct tmp401_data *data = dev_get_drvdata(dev); in show_update_interval() local
453 return sprintf(buf, "%u\n", data->update_interval); in show_update_interval()
460 struct tmp401_data *data = dev_get_drvdata(dev); in set_update_interval() local
461 struct i2c_client *client = data->client; in set_update_interval()
479 mutex_lock(&data->update_lock); in set_update_interval()
481 data->update_interval = (1 << (7 - rate)) * 125; in set_update_interval()
482 mutex_unlock(&data->update_lock); in set_update_interval()
619 static int tmp401_init_client(struct tmp401_data *data, in tmp401_init_client() argument
626 data->update_interval = 500; in tmp401_init_client()
721 struct tmp401_data *data; in tmp401_probe() local
724 data = devm_kzalloc(dev, sizeof(struct tmp401_data), GFP_KERNEL); in tmp401_probe()
725 if (!data) in tmp401_probe()
728 data->client = client; in tmp401_probe()
729 mutex_init(&data->update_lock); in tmp401_probe()
730 data->kind = id->driver_data; in tmp401_probe()
733 status = tmp401_init_client(data, client); in tmp401_probe()
738 data->groups[groups++] = &tmp401_group; in tmp401_probe()
741 if (data->kind == tmp411) in tmp401_probe()
742 data->groups[groups++] = &tmp411_group; in tmp401_probe()
745 if (data->kind == tmp432) in tmp401_probe()
746 data->groups[groups++] = &tmp432_group; in tmp401_probe()
749 data, data->groups); in tmp401_probe()
753 dev_info(dev, "Detected TI %s chip\n", names[data->kind]); in tmp401_probe()