26 #include <linux/module.h>
28 #include <linux/slab.h>
29 #include <linux/i2c.h>
34 #include <linux/device.h>
61 static inline int hih6130_temp_ticks_to_millicelsius(
int ticks)
77 static inline int hih6130_rh_ticks_to_per_cent_mille(
int ticks)
136 if ((tmp[0] & 0xC0) != 0) {
137 dev_err(&client->
dev,
"Error while reading measurement result\n");
142 t = (tmp[0] << 8) + tmp[1];
143 hih6130->
humidity = hih6130_rh_ticks_to_per_cent_mille(t);
145 t = (tmp[2] << 8) + tmp[3];
146 hih6130->
temperature = hih6130_temp_ticks_to_millicelsius(t);
149 hih6130->
valid =
true;
154 return ret >= 0 ? 0 :
ret;
171 struct hih6130 *hih6130 = i2c_get_clientdata(client);
172 int ret = hih6130_update_measurements(client);
191 struct hih6130 *hih6130 = i2c_get_clientdata(client);
192 int ret = hih6130_update_measurements(client);
204 static struct attribute *hih6130_attributes[] = {
205 &sensor_dev_attr_temp1_input.dev_attr.attr,
206 &sensor_dev_attr_humidity1_input.dev_attr.attr,
211 .attrs = hih6130_attributes,
226 struct hih6130 *hih6130;
230 dev_err(&client->
dev,
"adapter does not support true I2C\n");
238 i2c_set_clientdata(client, hih6130);
244 dev_dbg(&client->
dev,
"could not create sysfs files\n");
250 dev_dbg(&client->
dev,
"unable to register hwmon device\n");
252 goto fail_remove_sysfs;
268 struct hih6130 *hih6130 = i2c_get_clientdata(client);
284 .driver.name =
"hih6130",
285 .probe = hih6130_probe,
287 .id_table = hih6130_id,