Skip to content

Commit

Permalink
gpio: use devm_kzalloc
Browse files Browse the repository at this point in the history
We can use devres API for allocating memory. No need of using kfree.

Signed-off-by: Varka Bhadram <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
bhadram authored and linusw committed Apr 8, 2015
1 parent d1e10dc commit 7898b31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions drivers/gpio/gpio-adp5588.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static int adp5588_gpio_probe(struct i2c_client *client,
return -EIO;
}

dev = kzalloc(sizeof(*dev), GFP_KERNEL);
dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL);
if (dev == NULL)
return -ENOMEM;

Expand Down Expand Up @@ -446,7 +446,6 @@ static int adp5588_gpio_probe(struct i2c_client *client,
err_irq:
adp5588_irq_teardown(dev);
err:
kfree(dev);
return ret;
}

Expand Down
7 changes: 4 additions & 3 deletions drivers/gpio/gpio-mcp23s08.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,12 @@ static int mcp23s08_probe(struct spi_device *spi)
if (!chips)
return -ENODEV;

data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08),
GFP_KERNEL);
data = devm_kzalloc(&spi->dev,
sizeof(*data) + chips * sizeof(struct mcp23s08),
GFP_KERNEL);
if (!data)
return -ENOMEM;

spi_set_drvdata(spi, data);

spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0);
Expand Down Expand Up @@ -989,7 +991,6 @@ static int mcp23s08_probe(struct spi_device *spi)
continue;
gpiochip_remove(&data->mcp[addr]->chip);
}
kfree(data);
return status;
}

Expand Down

0 comments on commit 7898b31

Please sign in to comment.