21 #include <linux/module.h>
23 #include <linux/slab.h>
25 #include <linux/i2c.h>
57 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
62 #define LM75_REG_CONF 0x01
63 static const u8 LM75_REG_TEMP[3] = {
101 LM75_TEMP_FROM_REG(data->
temp[attr->
index]));
105 const char *buf,
size_t count)
109 struct lm75_data *data = i2c_get_clientdata(client);
114 error = kstrtol(buf, 10, &temp);
119 data->
temp[
nr] = LM75_TEMP_TO_REG(temp);
120 lm75_write_value(client, LM75_REG_TEMP[nr], data->
temp[nr]);
131 static struct attribute *lm75_attributes[] = {
132 &sensor_dev_attr_temp1_input.dev_attr.attr,
133 &sensor_dev_attr_temp1_max.dev_attr.attr,
134 &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
140 .attrs = lm75_attributes,
152 u8 set_mask, clr_mask;
155 if (!i2c_check_functionality(client->
adapter,
163 i2c_set_clientdata(client, data);
171 | (1 << 6) | (1 << 5);
176 dev_dbg(&client->
dev,
"Can't read config? %d\n", status);
180 new = status & ~clr_mask;
207 static int lm75_remove(
struct i2c_client *client)
209 struct lm75_data *data = i2c_get_clientdata(client);
238 #define LM75A_ID 0xA1
241 static int lm75_detect(
struct i2c_client *new_client,
311 for (i = 8; i <= 248; i += 40) {
327 static int lm75_suspend(
struct device *dev)
333 dev_dbg(&client->
dev,
"Can't read config? %d\n", status);
341 static int lm75_resume(
struct device *dev)
347 dev_dbg(&client->
dev,
"Can't read config? %d\n", status);
355 static const struct dev_pm_ops lm75_dev_pm_ops = {
357 .resume = lm75_resume,
359 #define LM75_DEV_PM_OPS (&lm75_dev_pm_ops)
361 #define LM75_DEV_PM_OPS NULL
371 .remove = lm75_remove,
372 .id_table = lm75_ids,
373 .detect = lm75_detect,
374 .address_list = normal_i2c,
391 return i2c_smbus_read_word_swapped(client, reg);
399 return i2c_smbus_write_word_swapped(client, reg, value);
405 struct lm75_data *data = i2c_get_clientdata(client);
413 dev_dbg(&client->
dev,
"Starting lm75 update\n");
418 status = lm75_read_value(client, LM75_REG_TEMP[i]);
421 "LM75: Failed to read value: reg %d, error %d\n",
422 LM75_REG_TEMP[i], status);
423 ret = ERR_PTR(status);