diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-08-29 05:36:54 +0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-09-01 03:02:27 +0400 |
commit | 3c7051d7cc136a6b0293f8e6960f7c61afd6ae08 (patch) | |
tree | 7c5de63ed6794b650fc92485d3667e4e9bce795f /drivers/gpio/gpio-mc9s08dz60.c | |
parent | 6e20a0a429bd4dc07d6de16d9c247270e04e4aa0 (diff) | |
download | linux-3c7051d7cc136a6b0293f8e6960f7c61afd6ae08.tar.xz |
gpio: mc9s08dz60: Use devm_kzalloc API
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-mc9s08dz60.c')
-rw-r--r-- | drivers/gpio/gpio-mc9s08dz60.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/drivers/gpio/gpio-mc9s08dz60.c b/drivers/gpio/gpio-mc9s08dz60.c index 2738cc44d636..0ab700046a23 100644 --- a/drivers/gpio/gpio-mc9s08dz60.c +++ b/drivers/gpio/gpio-mc9s08dz60.c @@ -91,10 +91,9 @@ static int mc9s08dz60_direction_output(struct gpio_chip *gc, static int mc9s08dz60_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret = 0; struct mc9s08dz60 *mc9s; - mc9s = kzalloc(sizeof(*mc9s), GFP_KERNEL); + mc9s = devm_kzalloc(&client->dev, sizeof(*mc9s), GFP_KERNEL); if (!mc9s) return -ENOMEM; @@ -110,30 +109,16 @@ static int mc9s08dz60_probe(struct i2c_client *client, mc9s->client = client; i2c_set_clientdata(client, mc9s); - ret = gpiochip_add(&mc9s->chip); - if (ret) - goto error; - - return 0; - - error: - kfree(mc9s); - return ret; + return gpiochip_add(&mc9s->chip); } static int mc9s08dz60_remove(struct i2c_client *client) { struct mc9s08dz60 *mc9s; - int ret; mc9s = i2c_get_clientdata(client); - ret = gpiochip_remove(&mc9s->chip); - if (!ret) - kfree(mc9s); - - return ret; - + return gpiochip_remove(&mc9s->chip); } static const struct i2c_device_id mc9s08dz60_id[] = { |