You need to sign in or sign up before continuing.
提交 34d43faf 编写于 作者: B Bartosz Golaszewski 提交者: Greg Kroah-Hartman

eeprom: at24: simplify the i2c functionality checking

Save one call and make code prettier by checking the i2c functionality
in the beginning of at24_probe(), saving the relevant values and
reusing them later.
Signed-off-by: NBartosz Golaszewski <brgl@bgdev.pl>
Tested-by: NAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 df3da615
...@@ -564,6 +564,7 @@ static int at24_probe(struct i2c_client *client) ...@@ -564,6 +564,7 @@ static int at24_probe(struct i2c_client *client)
struct nvmem_config nvmem_config = { }; struct nvmem_config nvmem_config = { };
struct at24_platform_data pdata = { }; struct at24_platform_data pdata = { };
struct device *dev = &client->dev; struct device *dev = &client->dev;
bool i2c_fn_i2c, i2c_fn_block;
unsigned int i, num_addresses; unsigned int i, num_addresses;
struct at24_data *at24; struct at24_data *at24;
struct regmap *regmap; struct regmap *regmap;
...@@ -572,13 +573,15 @@ static int at24_probe(struct i2c_client *client) ...@@ -572,13 +573,15 @@ static int at24_probe(struct i2c_client *client)
u8 test_byte; u8 test_byte;
int err; int err;
i2c_fn_i2c = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
i2c_fn_block = i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
err = at24_get_pdata(dev, &pdata); err = at24_get_pdata(dev, &pdata);
if (err) if (err)
return err; return err;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) && if (!i2c_fn_i2c && !i2c_fn_block)
!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK))
pdata.page_size = 1; pdata.page_size = 1;
if (!pdata.page_size) { if (!pdata.page_size) {
...@@ -631,8 +634,7 @@ static int at24_probe(struct i2c_client *client) ...@@ -631,8 +634,7 @@ static int at24_probe(struct i2c_client *client)
if (writable) { if (writable) {
at24->write_max = min_t(unsigned int, at24->write_max = min_t(unsigned int,
pdata.page_size, at24_io_limit); pdata.page_size, at24_io_limit);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) && if (!i2c_fn_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;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册