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

1 // SPDX-License-Identifier: GPL-2.0-only
32 #include <linux/i2c.h>
37 #include <linux/hwmon-sysfs.h>
63 dev_dbg(dev, "ds1682_show() called on %s\n", attr->attr.name); in ds1682_show()
66 rc = i2c_smbus_read_i2c_block_data(client, sattr->index, sattr->nr, in ds1682_show()
69 return -EIO; in ds1682_show()
73 if (sattr->index == DS1682_REG_ELAPSED) { in ds1682_show()
76 /* Detect and retry when a tick occurs mid-read */ in ds1682_show()
78 rc = i2c_smbus_read_i2c_block_data(client, sattr->index, in ds1682_show()
79 sattr->nr, in ds1682_show()
82 return -EIO; in ds1682_show()
86 retries--; in ds1682_show()
94 return sprintf(buf, "%llu\n", (sattr->nr == 4) ? (val * 250) : val); in ds1682_show()
98 const char *buf, size_t count) in ds1682_store() argument
106 dev_dbg(dev, "ds1682_store() called on %s\n", attr->attr.name); in ds1682_store()
112 return -EINVAL; in ds1682_store()
116 * resolution, scale input down to quarter-seconds */ in ds1682_store()
117 if (sattr->nr == 4) in ds1682_store()
122 rc = i2c_smbus_write_i2c_block_data(client, sattr->index, sattr->nr, in ds1682_store()
126 sattr->index, sattr->nr); in ds1682_store()
127 return -EIO; in ds1682_store()
130 return count; in ds1682_store()
157 char *buf, loff_t off, size_t count) in ds1682_eeprom_read() argument
162 dev_dbg(&client->dev, "ds1682_eeprom_read(p=%p, off=%lli, c=%zi)\n", in ds1682_eeprom_read()
163 buf, off, count); in ds1682_eeprom_read()
166 count, buf); in ds1682_eeprom_read()
168 return -EIO; in ds1682_eeprom_read()
170 return count; in ds1682_eeprom_read()
175 char *buf, loff_t off, size_t count) in ds1682_eeprom_write() argument
179 dev_dbg(&client->dev, "ds1682_eeprom_write(p=%p, off=%lli, c=%zi)\n", in ds1682_eeprom_write()
180 buf, off, count); in ds1682_eeprom_write()
184 count, buf) < 0) in ds1682_eeprom_write()
185 return -EIO; in ds1682_eeprom_write()
187 return count; in ds1682_eeprom_write()
208 if (!i2c_check_functionality(client->adapter, in ds1682_probe()
210 dev_err(&client->dev, "i2c bus does not support the ds1682\n"); in ds1682_probe()
211 rc = -ENODEV; in ds1682_probe()
215 rc = sysfs_create_group(&client->dev.kobj, &ds1682_group); in ds1682_probe()
219 rc = sysfs_create_bin_file(&client->dev.kobj, &ds1682_eeprom_attr); in ds1682_probe()
226 sysfs_remove_group(&client->dev.kobj, &ds1682_group); in ds1682_probe()
233 sysfs_remove_bin_file(&client->dev.kobj, &ds1682_eeprom_attr); in ds1682_remove()
234 sysfs_remove_group(&client->dev.kobj, &ds1682_group); in ds1682_remove()
242 MODULE_DEVICE_TABLE(i2c, ds1682_id);