提交 f39f54af 编写于 作者: J Jingoo Han 提交者: Linus Walleij

gpio: pcf857x: use devm_kzalloc()

Use devm_kzalloc() to make cleanup paths simpler.
Signed-off-by: NJingoo Han <jg1.han@samsung.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 632d8e55
...@@ -268,7 +268,7 @@ static int pcf857x_probe(struct i2c_client *client, ...@@ -268,7 +268,7 @@ static int pcf857x_probe(struct i2c_client *client,
} }
/* Allocate, initialize, and register this gpio_chip. */ /* Allocate, initialize, and register this gpio_chip. */
gpio = kzalloc(sizeof *gpio, GFP_KERNEL); gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
if (!gpio) if (!gpio)
return -ENOMEM; return -ENOMEM;
...@@ -391,7 +391,6 @@ static int pcf857x_probe(struct i2c_client *client, ...@@ -391,7 +391,6 @@ static int pcf857x_probe(struct i2c_client *client,
if (pdata && client->irq) if (pdata && client->irq)
pcf857x_irq_domain_cleanup(gpio); pcf857x_irq_domain_cleanup(gpio);
kfree(gpio);
return status; return status;
} }
...@@ -416,9 +415,7 @@ static int pcf857x_remove(struct i2c_client *client) ...@@ -416,9 +415,7 @@ static int pcf857x_remove(struct i2c_client *client)
pcf857x_irq_domain_cleanup(gpio); pcf857x_irq_domain_cleanup(gpio);
status = gpiochip_remove(&gpio->chip); status = gpiochip_remove(&gpio->chip);
if (status == 0) if (status)
kfree(gpio);
else
dev_err(&client->dev, "%s --> %d\n", "remove", status); dev_err(&client->dev, "%s --> %d\n", "remove", status);
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册