eeprom: ee1004: Improve creating dummy devices

i2c_new_dummy_device() calls i2c_new_client_device() that complains
if it fails to create the device. Therefore we don't have to emit an
error message in case of failure. In addition ensure that
ee1004_set_page is only set if creating the device succeeded.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/d38df5ac-6ecb-7d5f-b5c3-39bfc6a1e8a1@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Heiner Kallweit 2021-05-24 22:13:12 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель 08e5138aa4
Коммит 3c03dad765
1 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -179,15 +179,14 @@ static int ee1004_probe(struct i2c_client *client,
mutex_lock(&ee1004_bus_lock); mutex_lock(&ee1004_bus_lock);
if (++ee1004_dev_count == 1) { if (++ee1004_dev_count == 1) {
for (cnr = 0; cnr < 2; cnr++) { for (cnr = 0; cnr < 2; cnr++) {
ee1004_set_page[cnr] = i2c_new_dummy_device(client->adapter, struct i2c_client *cl;
EE1004_ADDR_SET_PAGE + cnr);
if (IS_ERR(ee1004_set_page[cnr])) { cl = i2c_new_dummy_device(client->adapter, EE1004_ADDR_SET_PAGE + cnr);
dev_err(&client->dev, if (IS_ERR(cl)) {
"address 0x%02x unavailable\n", err = PTR_ERR(cl);
EE1004_ADDR_SET_PAGE + cnr);
err = PTR_ERR(ee1004_set_page[cnr]);
goto err_clients; goto err_clients;
} }
ee1004_set_page[cnr] = cl;
} }
} else if (client->adapter != ee1004_set_page[0]->adapter) { } else if (client->adapter != ee1004_set_page[0]->adapter) {
dev_err(&client->dev, dev_err(&client->dev,