34 #include <linux/module.h>
36 #include <linux/i2c.h>
37 #include <linux/string.h>
38 #include <linux/list.h>
40 #include <linux/ctype.h>
44 #define DS1682_REG_CONFIG 0x00
45 #define DS1682_REG_ALARM 0x01
46 #define DS1682_REG_ELAPSED 0x05
47 #define DS1682_REG_EVT_CNTR 0x09
48 #define DS1682_REG_EEPROM 0x0b
49 #define DS1682_REG_RESET 0x1d
50 #define DS1682_REG_WRITE_DISABLE 0x1e
51 #define DS1682_REG_WRITE_MEM_DISABLE 0x1f
53 #define DS1682_EEPROM_SIZE 10
66 dev_dbg(dev,
"ds1682_show() called on %s\n", attr->
attr.name);
94 dev_dbg(dev,
"ds1682_store() called on %s\n", attr->
attr.name);
99 dev_dbg(dev,
"input string not a number\n");
113 dev_err(dev,
"register write failed; reg=0x%x, size=%i\n",
133 &sensor_dev_attr_elapsed_time.dev_attr.attr,
134 &sensor_dev_attr_alarm_time.dev_attr.attr,
135 &sensor_dev_attr_event_count.dev_attr.attr,
145 char *buf, loff_t off,
size_t count)
147 struct i2c_client *client = kobj_to_i2c_client(kobj);
150 dev_dbg(&client->
dev,
"ds1682_eeprom_read(p=%p, off=%lli, c=%zi)\n",
169 char *buf, loff_t off,
size_t count)
171 struct i2c_client *client = kobj_to_i2c_client(kobj);
173 dev_dbg(&client->
dev,
"ds1682_eeprom_write(p=%p, off=%lli, c=%zi)\n",
196 .read = ds1682_eeprom_read,
197 .write = ds1682_eeprom_write,
203 static int ds1682_probe(
struct i2c_client *client,
208 if (!i2c_check_functionality(client->
adapter,
210 dev_err(&client->
dev,
"i2c bus does not support the ds1682\n");
231 static int ds1682_remove(
struct i2c_client *client)
248 .probe = ds1682_probe,
249 .remove = ds1682_remove,
250 .id_table = ds1682_id,