Commit f3a049e7 authored by Zhouyang Jia's avatar Zhouyang Jia Committed by Linus Walleij

gpio: max732x: add error handling for i2c_new_dummy

When i2c_new_dummy fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling i2c_new_dummy.
Signed-off-by: default avatarZhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent eb3744a2
...@@ -653,6 +653,12 @@ static int max732x_probe(struct i2c_client *client, ...@@ -653,6 +653,12 @@ static int max732x_probe(struct i2c_client *client,
chip->client_group_a = client; chip->client_group_a = client;
if (nr_port > 8) { if (nr_port > 8) {
c = i2c_new_dummy(client->adapter, addr_b); c = i2c_new_dummy(client->adapter, addr_b);
if (!c) {
dev_err(&client->dev,
"Failed to allocate I2C device\n");
ret = -ENODEV;
goto out_failed;
}
chip->client_group_b = chip->client_dummy = c; chip->client_group_b = chip->client_dummy = c;
} }
break; break;
...@@ -660,6 +666,12 @@ static int max732x_probe(struct i2c_client *client, ...@@ -660,6 +666,12 @@ static int max732x_probe(struct i2c_client *client,
chip->client_group_b = client; chip->client_group_b = client;
if (nr_port > 8) { if (nr_port > 8) {
c = i2c_new_dummy(client->adapter, addr_a); c = i2c_new_dummy(client->adapter, addr_a);
if (!c) {
dev_err(&client->dev,
"Failed to allocate I2C device\n");
ret = -ENODEV;
goto out_failed;
}
chip->client_group_a = chip->client_dummy = c; chip->client_group_a = chip->client_dummy = c;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment