diff options
author | Bartosz Golaszewski <brgl@bgdev.pl> | 2018-03-19 10:17:17 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-23 16:25:00 +0100 |
commit | 7c2806642ecf3adabec005cc78ff2bf444d4acba (patch) | |
tree | d8f424cee90fb93b2d039345c931a665210c9d92 /drivers/misc | |
parent | eeprom: at24: move platform data processing into a separate routine (diff) | |
download | linux-7c2806642ecf3adabec005cc78ff2bf444d4acba.tar.xz linux-7c2806642ecf3adabec005cc78ff2bf444d4acba.zip |
eeprom: at24: remove at24_platform_data from at24_data
Not all fields from at24_platform_data are needed in at24_data. Let's
keep just the ones we need and not carry the whole platform_data
structure all the time.
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/eeprom/at24.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index fe0bb5dbcdd7..6895cd276bc4 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -63,8 +63,6 @@ struct at24_client { }; struct at24_data { - struct at24_platform_data chip; - /* * Lock protects against activities from other Linux tasks, * but not from changes by other I2C masters. @@ -75,6 +73,10 @@ struct at24_data { 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; @@ -252,7 +254,7 @@ static struct at24_client *at24_translate_offset(struct at24_data *at24, { unsigned int i; - if (at24->chip.flags & AT24_FLAG_ADDR16) { + if (at24->flags & AT24_FLAG_ADDR16) { i = *offset >> 16; *offset &= 0xffff; } else { @@ -279,8 +281,8 @@ static size_t at24_adjust_read_count(struct at24_data *at24, * 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; @@ -339,7 +341,7 @@ static size_t at24_adjust_write_count(struct at24_data *at24, 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; @@ -384,7 +386,7 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count) 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); @@ -431,7 +433,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) 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); @@ -601,7 +603,9 @@ static int at24_probe(struct i2c_client *client) 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); |