diff options
author | Varka Bhadram <varkabhadram@gmail.com> | 2015-03-31 00:19:08 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-04-08 03:54:05 -0400 |
commit | 7898b31ebafbf01d2ad56d251cfc9bfa4e5c644a (patch) | |
tree | 42e9370e7dc2765dad94947021d79fb106c4e92d /drivers/gpio | |
parent | d1e10dc8c104d533547f6e499550fafc36809943 (diff) |
gpio: use devm_kzalloc
We can use devres API for allocating memory. No need of using kfree.
Signed-off-by: Varka Bhadram <varkab@cdac.in>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-adp5588.c | 3 | ||||
-rw-r--r-- | drivers/gpio/gpio-mcp23s08.c | 7 |
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c index 3beed6ea8c65..0de8c7008122 100644 --- a/drivers/gpio/gpio-adp5588.c +++ b/drivers/gpio/gpio-adp5588.c | |||
@@ -378,7 +378,7 @@ static int adp5588_gpio_probe(struct i2c_client *client, | |||
378 | return -EIO; | 378 | return -EIO; |
379 | } | 379 | } |
380 | 380 | ||
381 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 381 | dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); |
382 | if (dev == NULL) | 382 | if (dev == NULL) |
383 | return -ENOMEM; | 383 | return -ENOMEM; |
384 | 384 | ||
@@ -446,7 +446,6 @@ static int adp5588_gpio_probe(struct i2c_client *client, | |||
446 | err_irq: | 446 | err_irq: |
447 | adp5588_irq_teardown(dev); | 447 | adp5588_irq_teardown(dev); |
448 | err: | 448 | err: |
449 | kfree(dev); | ||
450 | return ret; | 449 | return ret; |
451 | } | 450 | } |
452 | 451 | ||
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index eea5d7e578c9..a17b81fea161 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c | |||
@@ -949,10 +949,12 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
949 | if (!chips) | 949 | if (!chips) |
950 | return -ENODEV; | 950 | return -ENODEV; |
951 | 951 | ||
952 | data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08), | 952 | data = devm_kzalloc(&spi->dev, |
953 | GFP_KERNEL); | 953 | sizeof(*data) + chips * sizeof(struct mcp23s08), |
954 | GFP_KERNEL); | ||
954 | if (!data) | 955 | if (!data) |
955 | return -ENOMEM; | 956 | return -ENOMEM; |
957 | |||
956 | spi_set_drvdata(spi, data); | 958 | spi_set_drvdata(spi, data); |
957 | 959 | ||
958 | spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0); | 960 | spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0); |
@@ -989,7 +991,6 @@ fail: | |||
989 | continue; | 991 | continue; |
990 | gpiochip_remove(&data->mcp[addr]->chip); | 992 | gpiochip_remove(&data->mcp[addr]->chip); |
991 | } | 993 | } |
992 | kfree(data); | ||
993 | return status; | 994 | return status; |
994 | } | 995 | } |
995 | 996 | ||