Lines Matching refs:data
91 struct thmc50_data *data = dev_get_drvdata(dev); in thmc50_update_device() local
92 struct i2c_client *client = data->client; in thmc50_update_device()
93 int timeout = HZ / 5 + (data->type == thmc50 ? HZ : 0); in thmc50_update_device()
95 mutex_lock(&data->update_lock); in thmc50_update_device()
97 if (time_after(jiffies, data->last_updated + timeout) in thmc50_update_device()
98 || !data->valid) { in thmc50_update_device()
100 int temps = data->has_temp3 ? 3 : 2; in thmc50_update_device()
107 data->temp_input[i] = i2c_smbus_read_byte_data(client, in thmc50_update_device()
109 data->temp_max[i] = i2c_smbus_read_byte_data(client, in thmc50_update_device()
111 data->temp_min[i] = i2c_smbus_read_byte_data(client, in thmc50_update_device()
113 data->temp_critical[i] = in thmc50_update_device()
118 data->analog_out = in thmc50_update_device()
120 data->alarms = in thmc50_update_device()
122 data->last_updated = jiffies; in thmc50_update_device()
123 data->valid = 1; in thmc50_update_device()
126 mutex_unlock(&data->update_lock); in thmc50_update_device()
128 return data; in thmc50_update_device()
134 struct thmc50_data *data = thmc50_update_device(dev); in show_analog_out() local
135 return sprintf(buf, "%d\n", data->analog_out); in show_analog_out()
142 struct thmc50_data *data = dev_get_drvdata(dev); in set_analog_out() local
143 struct i2c_client *client = data->client; in set_analog_out()
152 mutex_lock(&data->update_lock); in set_analog_out()
153 data->analog_out = clamp_val(tmp, 0, 255); in set_analog_out()
155 data->analog_out); in set_analog_out()
158 if (data->analog_out == 0) in set_analog_out()
164 mutex_unlock(&data->update_lock); in set_analog_out()
180 struct thmc50_data *data = thmc50_update_device(dev); in show_temp() local
181 return sprintf(buf, "%d\n", data->temp_input[nr] * 1000); in show_temp()
188 struct thmc50_data *data = thmc50_update_device(dev); in show_temp_min() local
189 return sprintf(buf, "%d\n", data->temp_min[nr] * 1000); in show_temp_min()
196 struct thmc50_data *data = dev_get_drvdata(dev); in set_temp_min() local
197 struct i2c_client *client = data->client; in set_temp_min()
205 mutex_lock(&data->update_lock); in set_temp_min()
206 data->temp_min[nr] = clamp_val(val / 1000, -128, 127); in set_temp_min()
208 data->temp_min[nr]); in set_temp_min()
209 mutex_unlock(&data->update_lock); in set_temp_min()
217 struct thmc50_data *data = thmc50_update_device(dev); in show_temp_max() local
218 return sprintf(buf, "%d\n", data->temp_max[nr] * 1000); in show_temp_max()
225 struct thmc50_data *data = dev_get_drvdata(dev); in set_temp_max() local
226 struct i2c_client *client = data->client; in set_temp_max()
234 mutex_lock(&data->update_lock); in set_temp_max()
235 data->temp_max[nr] = clamp_val(val / 1000, -128, 127); in set_temp_max()
237 data->temp_max[nr]); in set_temp_max()
238 mutex_unlock(&data->update_lock); in set_temp_max()
247 struct thmc50_data *data = thmc50_update_device(dev); in show_temp_critical() local
248 return sprintf(buf, "%d\n", data->temp_critical[nr] * 1000); in show_temp_critical()
255 struct thmc50_data *data = thmc50_update_device(dev); in show_alarm() local
257 return sprintf(buf, "%u\n", (data->alarms >> index) & 1); in show_alarm()
374 static void thmc50_init_client(struct thmc50_data *data) in thmc50_init_client() argument
376 struct i2c_client *client = data->client; in thmc50_init_client()
379 data->analog_out = i2c_smbus_read_byte_data(client, in thmc50_init_client()
382 if (data->analog_out == 0) { in thmc50_init_client()
383 data->analog_out = 1; in thmc50_init_client()
385 data->analog_out); in thmc50_init_client()
389 if (data->type == adm1022 && (config & (1 << 7))) in thmc50_init_client()
390 data->has_temp3 = 1; in thmc50_init_client()
398 struct thmc50_data *data; in thmc50_probe() local
402 data = devm_kzalloc(dev, sizeof(struct thmc50_data), GFP_KERNEL); in thmc50_probe()
403 if (!data) in thmc50_probe()
406 data->client = client; in thmc50_probe()
407 data->type = id->driver_data; in thmc50_probe()
408 mutex_init(&data->update_lock); in thmc50_probe()
410 thmc50_init_client(data); in thmc50_probe()
413 data->groups[idx++] = &thmc50_group; in thmc50_probe()
416 if (data->has_temp3) in thmc50_probe()
417 data->groups[idx++] = &temp3_group; in thmc50_probe()
420 data, data->groups); in thmc50_probe()