Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Varka Bhadram and committed by
Linus Walleij
7898b31e d1e10dc8

+5 -5
+1 -2
drivers/gpio/gpio-adp5588.c
··· 378 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 382 if (dev == NULL) 383 383 return -ENOMEM; 384 384 ··· 446 446 err_irq: 447 447 adp5588_irq_teardown(dev); 448 448 err: 449 - kfree(dev); 450 449 return ret; 451 450 } 452 451
+4 -3
drivers/gpio/gpio-mcp23s08.c
··· 949 949 if (!chips) 950 950 return -ENODEV; 951 951 952 - data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08), 953 - GFP_KERNEL); 952 + data = devm_kzalloc(&spi->dev, 953 + sizeof(*data) + chips * sizeof(struct mcp23s08), 954 + GFP_KERNEL); 954 955 if (!data) 955 956 return -ENOMEM; 957 + 956 958 spi_set_drvdata(spi, data); 957 959 958 960 spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0); ··· 991 989 continue; 992 990 gpiochip_remove(&data->mcp[addr]->chip); 993 991 } 994 - kfree(data); 995 992 return status; 996 993 } 997 994