};
struct at24_data {
- struct at24_platform_data chip;
-
/*
* Lock protects against activities from other Linux tasks,
* but not from changes by other I2C masters.
unsigned int num_addresses;
unsigned int offset_adj;
+ u32 byte_len;
+ u16 page_size;
+ u8 flags;
+
struct nvmem_device *nvmem;
struct gpio_desc *wp_gpio;
{
unsigned int i;
- if (at24->chip.flags & AT24_FLAG_ADDR16) {
+ if (at24->flags & AT24_FLAG_ADDR16) {
i = *offset >> 16;
*offset &= 0xffff;
} else {
* the next slave address: truncate the count to the slave boundary,
* so that the read never straddles slaves.
*/
- if (at24->chip.flags & AT24_FLAG_NO_RDROL) {
- bits = (at24->chip.flags & AT24_FLAG_ADDR16) ? 16 : 8;
+ if (at24->flags & AT24_FLAG_NO_RDROL) {
+ bits = (at24->flags & AT24_FLAG_ADDR16) ? 16 : 8;
remainder = BIT(bits) - offset;
if (count > remainder)
count = remainder;
count = at24->write_max;
/* Never roll over backwards, to the start of this page */
- next_page = roundup(offset + 1, at24->chip.page_size);
+ next_page = roundup(offset + 1, at24->page_size);
if (offset + count > next_page)
count = next_page - offset;
if (unlikely(!count))
return count;
- if (off + count > at24->chip.byte_len)
+ if (off + count > at24->byte_len)
return -EINVAL;
ret = pm_runtime_get_sync(dev);
if (unlikely(!count))
return -EINVAL;
- if (off + count > at24->chip.byte_len)
+ if (off + count > at24->byte_len)
return -EINVAL;
ret = pm_runtime_get_sync(dev);
return -ENOMEM;
mutex_init(&at24->lock);
- at24->chip = pdata;
+ at24->byte_len = pdata.byte_len;
+ at24->page_size = pdata.page_size;
+ at24->flags = pdata.flags;
at24->num_addresses = num_addresses;
at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len);