Lines Matching +full:i2c +full:- +full:retry +full:- +full:count

1 // SPDX-License-Identifier: GPL-2.0-only
32 #include <linux/i2c.h>
35 #include <linux/nvmem-provider.h>
38 #include <linux/hwmon-sysfs.h>
64 dev_dbg(dev, "ds1682_show() called on %s\n", attr->attr.name); in ds1682_show()
67 rc = i2c_smbus_read_i2c_block_data(client, sattr->index, sattr->nr, in ds1682_show()
70 return -EIO; in ds1682_show()
74 if (sattr->index == DS1682_REG_ELAPSED) { in ds1682_show()
77 /* Detect and retry when a tick occurs mid-read */ in ds1682_show()
79 rc = i2c_smbus_read_i2c_block_data(client, sattr->index, in ds1682_show()
80 sattr->nr, in ds1682_show()
83 return -EIO; in ds1682_show()
87 retries--; in ds1682_show()
95 return sprintf(buf, "%llu\n", (sattr->nr == 4) ? (val * 250) : val); in ds1682_show()
99 const char *buf, size_t count) in ds1682_store() argument
107 dev_dbg(dev, "ds1682_store() called on %s\n", attr->attr.name); in ds1682_store()
113 return -EINVAL; in ds1682_store()
117 * resolution, scale input down to quarter-seconds */ in ds1682_store()
118 if (sattr->nr == 4) in ds1682_store()
123 rc = i2c_smbus_write_i2c_block_data(client, sattr->index, sattr->nr, in ds1682_store()
127 sattr->index, sattr->nr); in ds1682_store()
128 return -EIO; in ds1682_store()
131 return count; in ds1682_store()
158 char *buf, loff_t off, size_t count) in ds1682_eeprom_read() argument
163 dev_dbg(&client->dev, "ds1682_eeprom_read(p=%p, off=%lli, c=%zi)\n", in ds1682_eeprom_read()
164 buf, off, count); in ds1682_eeprom_read()
167 count, buf); in ds1682_eeprom_read()
169 return -EIO; in ds1682_eeprom_read()
171 return count; in ds1682_eeprom_read()
176 char *buf, loff_t off, size_t count) in ds1682_eeprom_write() argument
180 dev_dbg(&client->dev, "ds1682_eeprom_write(p=%p, off=%lli, c=%zi)\n", in ds1682_eeprom_write()
181 buf, off, count); in ds1682_eeprom_write()
185 count, buf) < 0) in ds1682_eeprom_write()
186 return -EIO; in ds1682_eeprom_write()
188 return count; in ds1682_eeprom_write()
229 .dev = &client->dev, in ds1682_probe()
240 if (!i2c_check_functionality(client->adapter, in ds1682_probe()
242 dev_err(&client->dev, "i2c bus does not support the ds1682\n"); in ds1682_probe()
243 rc = -ENODEV; in ds1682_probe()
247 nvmem = devm_nvmem_register(&client->dev, &config); in ds1682_probe()
251 rc = sysfs_create_group(&client->dev.kobj, &ds1682_group); in ds1682_probe()
255 rc = sysfs_create_bin_file(&client->dev.kobj, &ds1682_eeprom_attr); in ds1682_probe()
262 sysfs_remove_group(&client->dev.kobj, &ds1682_group); in ds1682_probe()
269 sysfs_remove_bin_file(&client->dev.kobj, &ds1682_eeprom_attr); in ds1682_remove()
270 sysfs_remove_group(&client->dev.kobj, &ds1682_group); in ds1682_remove()
277 MODULE_DEVICE_TABLE(i2c, ds1682_id);