Commit 7898b31e authored by Varka Bhadram's avatar Varka Bhadram Committed by Linus Walleij

gpio: use devm_kzalloc

We can use devres API for allocating memory. No need of using kfree.
Signed-off-by: default avatarVarka Bhadram <varkab@cdac.in>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent d1e10dc8
...@@ -378,7 +378,7 @@ static int adp5588_gpio_probe(struct i2c_client *client, ...@@ -378,7 +378,7 @@ static int adp5588_gpio_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
if (dev == NULL) if (dev == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -446,7 +446,6 @@ static int adp5588_gpio_probe(struct i2c_client *client, ...@@ -446,7 +446,6 @@ static int adp5588_gpio_probe(struct i2c_client *client,
err_irq: err_irq:
adp5588_irq_teardown(dev); adp5588_irq_teardown(dev);
err: err:
kfree(dev);
return ret; return ret;
} }
......
...@@ -949,10 +949,12 @@ static int mcp23s08_probe(struct spi_device *spi) ...@@ -949,10 +949,12 @@ static int mcp23s08_probe(struct spi_device *spi)
if (!chips) if (!chips)
return -ENODEV; return -ENODEV;
data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08), data = devm_kzalloc(&spi->dev,
GFP_KERNEL); sizeof(*data) + chips * sizeof(struct mcp23s08),
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
spi_set_drvdata(spi, data); spi_set_drvdata(spi, data);
spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0); spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0);
...@@ -989,7 +991,6 @@ static int mcp23s08_probe(struct spi_device *spi) ...@@ -989,7 +991,6 @@ static int mcp23s08_probe(struct spi_device *spi)
continue; continue;
gpiochip_remove(&data->mcp[addr]->chip); gpiochip_remove(&data->mcp[addr]->chip);
} }
kfree(data);
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment