eeprom: at24: rename chip to pdata in at24_probe()
Reflect the purpose of this variable: it contains platform data so name it such. 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>
This commit is contained in:
parent
1f77d1859c
commit
f2adff6660
|
@ -519,7 +519,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
struct regmap_config regmap_config = { };
|
struct regmap_config regmap_config = { };
|
||||||
struct nvmem_config nvmem_config = { };
|
struct nvmem_config nvmem_config = { };
|
||||||
const struct at24_chip_data *cd = NULL;
|
const struct at24_chip_data *cd = NULL;
|
||||||
struct at24_platform_data chip = { };
|
struct at24_platform_data pdata = { };
|
||||||
unsigned int i, num_addresses;
|
unsigned int i, num_addresses;
|
||||||
struct at24_data *at24;
|
struct at24_data *at24;
|
||||||
bool writable;
|
bool writable;
|
||||||
|
@ -527,7 +527,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (client->dev.platform_data) {
|
if (client->dev.platform_data) {
|
||||||
chip = *(struct at24_platform_data *)client->dev.platform_data;
|
pdata = *(struct at24_platform_data *)client->dev.platform_data;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* The I2C core allows OF nodes compatibles to match against the
|
* The I2C core allows OF nodes compatibles to match against the
|
||||||
|
@ -549,32 +549,32 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
if (!cd)
|
if (!cd)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
chip.byte_len = cd->byte_len;
|
pdata.byte_len = cd->byte_len;
|
||||||
chip.flags = cd->flags;
|
pdata.flags = cd->flags;
|
||||||
at24_properties_to_pdata(&client->dev, &chip);
|
at24_properties_to_pdata(&client->dev, &pdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chip.page_size) {
|
if (!pdata.page_size) {
|
||||||
dev_err(&client->dev, "page_size must not be 0!\n");
|
dev_err(&client->dev, "page_size must not be 0!\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (!is_power_of_2(chip.page_size))
|
if (!is_power_of_2(pdata.page_size))
|
||||||
dev_warn(&client->dev,
|
dev_warn(&client->dev,
|
||||||
"page_size looks suspicious (no power of 2)!\n");
|
"page_size looks suspicious (no power of 2)!\n");
|
||||||
|
|
||||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) &&
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) &&
|
||||||
!i2c_check_functionality(client->adapter,
|
!i2c_check_functionality(client->adapter,
|
||||||
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK))
|
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK))
|
||||||
chip.page_size = 1;
|
pdata.page_size = 1;
|
||||||
|
|
||||||
if (chip.flags & AT24_FLAG_TAKE8ADDR)
|
if (pdata.flags & AT24_FLAG_TAKE8ADDR)
|
||||||
num_addresses = 8;
|
num_addresses = 8;
|
||||||
else
|
else
|
||||||
num_addresses = DIV_ROUND_UP(chip.byte_len,
|
num_addresses = DIV_ROUND_UP(pdata.byte_len,
|
||||||
(chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
(pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
|
||||||
|
|
||||||
regmap_config.val_bits = 8;
|
regmap_config.val_bits = 8;
|
||||||
regmap_config.reg_bits = (chip.flags & AT24_FLAG_ADDR16) ? 16 : 8;
|
regmap_config.reg_bits = (pdata.flags & AT24_FLAG_ADDR16) ? 16 : 8;
|
||||||
regmap_config.disable_locking = true;
|
regmap_config.disable_locking = true;
|
||||||
|
|
||||||
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
|
at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) +
|
||||||
|
@ -583,9 +583,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
mutex_init(&at24->lock);
|
mutex_init(&at24->lock);
|
||||||
at24->chip = chip;
|
at24->chip = pdata;
|
||||||
at24->num_addresses = num_addresses;
|
at24->num_addresses = num_addresses;
|
||||||
at24->offset_adj = at24_get_offset_adj(chip.flags, chip.byte_len);
|
at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len);
|
||||||
|
|
||||||
at24->wp_gpio = devm_gpiod_get_optional(&client->dev,
|
at24->wp_gpio = devm_gpiod_get_optional(&client->dev,
|
||||||
"wp", GPIOD_OUT_HIGH);
|
"wp", GPIOD_OUT_HIGH);
|
||||||
|
@ -597,16 +597,16 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
if (IS_ERR(at24->client[0].regmap))
|
if (IS_ERR(at24->client[0].regmap))
|
||||||
return PTR_ERR(at24->client[0].regmap);
|
return PTR_ERR(at24->client[0].regmap);
|
||||||
|
|
||||||
if ((chip.flags & AT24_FLAG_SERIAL) && (chip.flags & AT24_FLAG_MAC)) {
|
if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) {
|
||||||
dev_err(&client->dev,
|
dev_err(&client->dev,
|
||||||
"invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
|
"invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
writable = !(chip.flags & AT24_FLAG_READONLY);
|
writable = !(pdata.flags & AT24_FLAG_READONLY);
|
||||||
if (writable) {
|
if (writable) {
|
||||||
at24->write_max = min_t(unsigned int,
|
at24->write_max = min_t(unsigned int,
|
||||||
chip.page_size, at24_io_limit);
|
pdata.page_size, at24_io_limit);
|
||||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) &&
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) &&
|
||||||
at24->write_max > I2C_SMBUS_BLOCK_MAX)
|
at24->write_max > I2C_SMBUS_BLOCK_MAX)
|
||||||
at24->write_max = I2C_SMBUS_BLOCK_MAX;
|
at24->write_max = I2C_SMBUS_BLOCK_MAX;
|
||||||
|
@ -660,7 +660,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
nvmem_config.priv = at24;
|
nvmem_config.priv = at24;
|
||||||
nvmem_config.stride = 1;
|
nvmem_config.stride = 1;
|
||||||
nvmem_config.word_size = 1;
|
nvmem_config.word_size = 1;
|
||||||
nvmem_config.size = chip.byte_len;
|
nvmem_config.size = pdata.byte_len;
|
||||||
|
|
||||||
at24->nvmem = nvmem_register(&nvmem_config);
|
at24->nvmem = nvmem_register(&nvmem_config);
|
||||||
|
|
||||||
|
@ -670,12 +670,12 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_info(&client->dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
|
dev_info(&client->dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
|
||||||
chip.byte_len, client->name,
|
pdata.byte_len, client->name,
|
||||||
writable ? "writable" : "read-only", at24->write_max);
|
writable ? "writable" : "read-only", at24->write_max);
|
||||||
|
|
||||||
/* export data to kernel code */
|
/* export data to kernel code */
|
||||||
if (chip.setup)
|
if (pdata.setup)
|
||||||
chip.setup(at24->nvmem, chip.context);
|
pdata.setup(at24->nvmem, pdata.context);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue