gpio: pcf857x: use devm_kzalloc()
authorJingoo Han <jg1.han@samsung.com>
Fri, 15 Mar 2013 09:16:11 +0000 (18:16 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 27 Mar 2013 15:05:12 +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-pcf857x.c

index a965620..e8faf53 100644 (file)
@@ -268,7 +268,7 @@ static int pcf857x_probe(struct i2c_client *client,
        }
 
        /* Allocate, initialize, and register this gpio_chip. */
-       gpio = kzalloc(sizeof *gpio, GFP_KERNEL);
+       gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
        if (!gpio)
                return -ENOMEM;
 
@@ -391,7 +391,6 @@ fail:
        if (pdata && client->irq)
                pcf857x_irq_domain_cleanup(gpio);
 
-       kfree(gpio);
        return status;
 }
 
@@ -416,9 +415,7 @@ static int pcf857x_remove(struct i2c_client *client)
                pcf857x_irq_domain_cleanup(gpio);
 
        status = gpiochip_remove(&gpio->chip);
-       if (status == 0)
-               kfree(gpio);
-       else
+       if (status)
                dev_err(&client->dev, "%s --> %d\n", "remove", status);
        return status;
 }