gpio: mc9s08dz60: Use devm_kzalloc API
authorAxel Lin <axel.lin@gmail.com>
Wed, 29 Aug 2012 01:36:54 +0000 (09:36 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 31 Aug 2012 23:02:27 +0000 (01:02 +0200)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-mc9s08dz60.c

index 2738cc44d636b06b55836176992430ad006906a9..0ab700046a23eec7f5e6446ea05dc6382ff28e86 100644 (file)
@@ -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[] = {