at24 244 drivers/misc/eeprom/at24.c static struct at24_client *at24_translate_offset(struct at24_data *at24, at24 249 drivers/misc/eeprom/at24.c if (at24->flags & AT24_FLAG_ADDR16) { at24 257 drivers/misc/eeprom/at24.c return &at24->client[i]; at24 260 drivers/misc/eeprom/at24.c static struct device *at24_base_client_dev(struct at24_data *at24) at24 262 drivers/misc/eeprom/at24.c return &at24->client[0].client->dev; at24 265 drivers/misc/eeprom/at24.c static size_t at24_adjust_read_count(struct at24_data *at24, at24 276 drivers/misc/eeprom/at24.c if (at24->flags & AT24_FLAG_NO_RDROL) { at24 277 drivers/misc/eeprom/at24.c bits = (at24->flags & AT24_FLAG_ADDR16) ? 16 : 8; at24 289 drivers/misc/eeprom/at24.c static ssize_t at24_regmap_read(struct at24_data *at24, char *buf, at24 298 drivers/misc/eeprom/at24.c at24_client = at24_translate_offset(at24, &offset); at24 301 drivers/misc/eeprom/at24.c count = at24_adjust_read_count(at24, offset, count); at24 304 drivers/misc/eeprom/at24.c offset += at24->offset_adj; at24 335 drivers/misc/eeprom/at24.c static size_t at24_adjust_write_count(struct at24_data *at24, at24 341 drivers/misc/eeprom/at24.c if (count > at24->write_max) at24 342 drivers/misc/eeprom/at24.c count = at24->write_max; at24 345 drivers/misc/eeprom/at24.c next_page = roundup(offset + 1, at24->page_size); at24 352 drivers/misc/eeprom/at24.c static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf, at24 361 drivers/misc/eeprom/at24.c at24_client = at24_translate_offset(at24, &offset); at24 364 drivers/misc/eeprom/at24.c count = at24_adjust_write_count(at24, offset, count); at24 388 drivers/misc/eeprom/at24.c struct at24_data *at24; at24 393 drivers/misc/eeprom/at24.c at24 = priv; at24 394 drivers/misc/eeprom/at24.c dev = at24_base_client_dev(at24); at24 399 drivers/misc/eeprom/at24.c if (off + count > at24->byte_len) at24 412 drivers/misc/eeprom/at24.c mutex_lock(&at24->lock); at24 415 drivers/misc/eeprom/at24.c ret = at24_regmap_read(at24, buf, off, count); at24 417 drivers/misc/eeprom/at24.c mutex_unlock(&at24->lock); at24 426 drivers/misc/eeprom/at24.c mutex_unlock(&at24->lock); at24 435 drivers/misc/eeprom/at24.c struct at24_data *at24; at24 440 drivers/misc/eeprom/at24.c at24 = priv; at24 441 drivers/misc/eeprom/at24.c dev = at24_base_client_dev(at24); at24 446 drivers/misc/eeprom/at24.c if (off + count > at24->byte_len) at24 459 drivers/misc/eeprom/at24.c mutex_lock(&at24->lock); at24 460 drivers/misc/eeprom/at24.c gpiod_set_value_cansleep(at24->wp_gpio, 0); at24 463 drivers/misc/eeprom/at24.c ret = at24_regmap_write(at24, buf, off, count); at24 465 drivers/misc/eeprom/at24.c gpiod_set_value_cansleep(at24->wp_gpio, 1); at24 466 drivers/misc/eeprom/at24.c mutex_unlock(&at24->lock); at24 475 drivers/misc/eeprom/at24.c gpiod_set_value_cansleep(at24->wp_gpio, 1); at24 476 drivers/misc/eeprom/at24.c mutex_unlock(&at24->lock); at24 509 drivers/misc/eeprom/at24.c static int at24_make_dummy_client(struct at24_data *at24, unsigned int index, at24 516 drivers/misc/eeprom/at24.c base_client = at24->client[0].client; at24 528 drivers/misc/eeprom/at24.c at24->client[index].client = dummy_client; at24 529 drivers/misc/eeprom/at24.c at24->client[index].regmap = regmap; at24 566 drivers/misc/eeprom/at24.c struct at24_data *at24; at24 651 drivers/misc/eeprom/at24.c at24 = devm_kzalloc(dev, struct_size(at24, client, num_addresses), at24 653 drivers/misc/eeprom/at24.c if (!at24) at24 656 drivers/misc/eeprom/at24.c mutex_init(&at24->lock); at24 657 drivers/misc/eeprom/at24.c at24->byte_len = byte_len; at24 658 drivers/misc/eeprom/at24.c at24->page_size = page_size; at24 659 drivers/misc/eeprom/at24.c at24->flags = flags; at24 660 drivers/misc/eeprom/at24.c at24->num_addresses = num_addresses; at24 661 drivers/misc/eeprom/at24.c at24->offset_adj = at24_get_offset_adj(flags, byte_len); at24 662 drivers/misc/eeprom/at24.c at24->client[0].client = client; at24 663 drivers/misc/eeprom/at24.c at24->client[0].regmap = regmap; at24 665 drivers/misc/eeprom/at24.c at24->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_HIGH); at24 666 drivers/misc/eeprom/at24.c if (IS_ERR(at24->wp_gpio)) at24 667 drivers/misc/eeprom/at24.c return PTR_ERR(at24->wp_gpio); at24 671 drivers/misc/eeprom/at24.c at24->write_max = min_t(unsigned int, at24 673 drivers/misc/eeprom/at24.c if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX) at24 674 drivers/misc/eeprom/at24.c at24->write_max = I2C_SMBUS_BLOCK_MAX; at24 679 drivers/misc/eeprom/at24.c err = at24_make_dummy_client(at24, i, ®map_config); at24 693 drivers/misc/eeprom/at24.c nvmem_config.priv = at24; at24 698 drivers/misc/eeprom/at24.c at24->nvmem = devm_nvmem_register(dev, &nvmem_config); at24 699 drivers/misc/eeprom/at24.c if (IS_ERR(at24->nvmem)) at24 700 drivers/misc/eeprom/at24.c return PTR_ERR(at24->nvmem); at24 702 drivers/misc/eeprom/at24.c i2c_set_clientdata(client, at24); at24 712 drivers/misc/eeprom/at24.c err = at24_read(at24, 0, &test_byte, 1); at24 721 drivers/misc/eeprom/at24.c writable ? "writable" : "read-only", at24->write_max);