Commit 3c7051d7 authored by Axel Lin's avatar Axel Lin Committed by Linus Walleij

gpio: mc9s08dz60: Use devm_kzalloc API

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 6e20a0a4
...@@ -91,10 +91,9 @@ static int mc9s08dz60_direction_output(struct gpio_chip *gc, ...@@ -91,10 +91,9 @@ static int mc9s08dz60_direction_output(struct gpio_chip *gc,
static int mc9s08dz60_probe(struct i2c_client *client, static int mc9s08dz60_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
int ret = 0;
struct mc9s08dz60 *mc9s; struct mc9s08dz60 *mc9s;
mc9s = kzalloc(sizeof(*mc9s), GFP_KERNEL); mc9s = devm_kzalloc(&client->dev, sizeof(*mc9s), GFP_KERNEL);
if (!mc9s) if (!mc9s)
return -ENOMEM; return -ENOMEM;
...@@ -110,30 +109,16 @@ static int mc9s08dz60_probe(struct i2c_client *client, ...@@ -110,30 +109,16 @@ static int mc9s08dz60_probe(struct i2c_client *client,
mc9s->client = client; mc9s->client = client;
i2c_set_clientdata(client, mc9s); i2c_set_clientdata(client, mc9s);
ret = gpiochip_add(&mc9s->chip); return gpiochip_add(&mc9s->chip);
if (ret)
goto error;
return 0;
error:
kfree(mc9s);
return ret;
} }
static int mc9s08dz60_remove(struct i2c_client *client) static int mc9s08dz60_remove(struct i2c_client *client)
{ {
struct mc9s08dz60 *mc9s; struct mc9s08dz60 *mc9s;
int ret;
mc9s = i2c_get_clientdata(client); mc9s = i2c_get_clientdata(client);
ret = gpiochip_remove(&mc9s->chip); return gpiochip_remove(&mc9s->chip);
if (!ret)
kfree(mc9s);
return ret;
} }
static const struct i2c_device_id mc9s08dz60_id[] = { static const struct i2c_device_id mc9s08dz60_id[] = {
......
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