eeprom: at24: remove at24_platform_data from at24_data
authorBartosz Golaszewski <brgl@bgdev.pl>
Mon, 19 Mar 2018 09:17:17 +0000 (10:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Mar 2018 15:25:00 +0000 (16:25 +0100)
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>
drivers/misc/eeprom/at24.c

index fe0bb5d..6895cd2 100644 (file)
@@ -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);