Lines Matching refs:at24

141 static struct i2c_client *at24_translate_offset(struct at24_data *at24,  in at24_translate_offset()  argument
146 if (at24->chip.flags & AT24_FLAG_ADDR16) { in at24_translate_offset()
154 return at24->client[i]; in at24_translate_offset()
157 static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf, in at24_eeprom_read() argument
184 client = at24_translate_offset(at24, &offset); in at24_eeprom_read()
189 switch (at24->use_smbus) { in at24_eeprom_read()
210 if (at24->chip.flags & AT24_FLAG_ADDR16) in at24_eeprom_read()
232 switch (at24->use_smbus) { in at24_eeprom_read()
270 static ssize_t at24_read(struct at24_data *at24, in at24_read() argument
282 mutex_lock(&at24->lock); in at24_read()
287 status = at24_eeprom_read(at24, buf, off, count); in at24_read()
299 mutex_unlock(&at24->lock); in at24_read()
308 struct at24_data *at24; in at24_bin_read() local
310 at24 = dev_get_drvdata(container_of(kobj, struct device, kobj)); in at24_bin_read()
311 return at24_read(at24, buf, off, count); in at24_bin_read()
323 static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf, in at24_eeprom_write() argument
333 client = at24_translate_offset(at24, &offset); in at24_eeprom_write()
336 if (count > at24->write_max) in at24_eeprom_write()
337 count = at24->write_max; in at24_eeprom_write()
340 next_page = roundup(offset + 1, at24->chip.page_size); in at24_eeprom_write()
345 if (!at24->use_smbus) { in at24_eeprom_write()
352 msg.buf = at24->writebuf; in at24_eeprom_write()
353 if (at24->chip.flags & AT24_FLAG_ADDR16) in at24_eeprom_write()
369 if (at24->use_smbus_write) { in at24_eeprom_write()
370 switch (at24->use_smbus_write) { in at24_eeprom_write()
401 static ssize_t at24_write(struct at24_data *at24, const char *buf, loff_t off, in at24_write() argument
413 mutex_lock(&at24->lock); in at24_write()
418 status = at24_eeprom_write(at24, buf, off, count); in at24_write()
430 mutex_unlock(&at24->lock); in at24_write()
439 struct at24_data *at24; in at24_bin_write() local
444 at24 = dev_get_drvdata(container_of(kobj, struct device, kobj)); in at24_bin_write()
445 return at24_write(at24, buf, off, count); in at24_bin_write()
459 struct at24_data *at24 = container_of(macc, struct at24_data, macc); in at24_macc_read() local
461 return at24_read(at24, buf, offset, count); in at24_macc_read()
467 struct at24_data *at24 = container_of(macc, struct at24_data, macc); in at24_macc_write() local
469 return at24_write(at24, buf, offset, count); in at24_macc_write()
501 struct at24_data *at24; in at24_probe() local
578 at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) + in at24_probe()
580 if (!at24) in at24_probe()
583 mutex_init(&at24->lock); in at24_probe()
584 at24->use_smbus = use_smbus; in at24_probe()
585 at24->use_smbus_write = use_smbus_write; in at24_probe()
586 at24->chip = chip; in at24_probe()
587 at24->num_addresses = num_addresses; in at24_probe()
593 sysfs_bin_attr_init(&at24->bin); in at24_probe()
594 at24->bin.attr.name = "eeprom"; in at24_probe()
595 at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR; in at24_probe()
596 at24->bin.read = at24_bin_read; in at24_probe()
597 at24->bin.size = chip.byte_len; in at24_probe()
599 at24->macc.read = at24_macc_read; in at24_probe()
607 at24->macc.write = at24_macc_write; in at24_probe()
609 at24->bin.write = at24_bin_write; in at24_probe()
610 at24->bin.attr.mode |= S_IWUSR; in at24_probe()
616 at24->write_max = write_max; in at24_probe()
619 at24->writebuf = devm_kzalloc(&client->dev, in at24_probe()
621 if (!at24->writebuf) in at24_probe()
629 at24->client[0] = client; in at24_probe()
633 at24->client[i] = i2c_new_dummy(client->adapter, in at24_probe()
635 if (!at24->client[i]) { in at24_probe()
643 err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin); in at24_probe()
647 i2c_set_clientdata(client, at24); in at24_probe()
650 at24->bin.size, client->name, in at24_probe()
651 writable ? "writable" : "read-only", at24->write_max); in at24_probe()
661 chip.setup(&at24->macc, chip.context); in at24_probe()
667 if (at24->client[i]) in at24_probe()
668 i2c_unregister_device(at24->client[i]); in at24_probe()
675 struct at24_data *at24; in at24_remove() local
678 at24 = i2c_get_clientdata(client); in at24_remove()
679 sysfs_remove_bin_file(&client->dev.kobj, &at24->bin); in at24_remove()
681 for (i = 1; i < at24->num_addresses; i++) in at24_remove()
682 i2c_unregister_device(at24->client[i]); in at24_remove()