gpio: max732x: use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Fri, 15 Mar 2013 09:15:28 +0000 (18:15 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 27 Mar 2013 15:05:11 +0000 (16:05 +0100)
Use devm_kzalloc() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-max732x.c

index 1e0467c..d4b51b1 100644 (file)
@@ -589,7 +589,8 @@ static int max732x_probe(struct i2c_client *client,
                return -EINVAL;
        }
 
-       chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL);
+       chip = devm_kzalloc(&client->dev, sizeof(struct max732x_chip),
+                       GFP_KERNEL);
        if (chip == NULL)
                return -ENOMEM;
        chip->client = client;
@@ -647,7 +648,6 @@ static int max732x_probe(struct i2c_client *client,
 
 out_failed:
        max732x_irq_teardown(chip);
-       kfree(chip);
        return ret;
 }
 
@@ -680,7 +680,6 @@ static int max732x_remove(struct i2c_client *client)
        if (chip->client_dummy)
                i2c_unregister_device(chip->client_dummy);
 
-       kfree(chip);
        return 0;
 }