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

gpio: tps65086: Use devm_gpiochip_add_data() to simplify remove path

Use devm version of gpiochip add function to handle removal for us.

While here update copyright and module author.

Signed-off-by: Andrew Davis <afd@ti.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Andrew Davis and committed by
Bartosz Golaszewski
81b01099 fbc8ab2c

+4 -23
+4 -23
drivers/gpio/gpio-tps65086.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 4 - * Andrew F. Davis <afd@ti.com> 3 + * Copyright (C) 2015-2023 Texas Instruments Incorporated - https://www.ti.com/ 4 + * Andrew Davis <afd@ti.com> 5 5 * 6 6 * Based on the TPS65912 driver 7 7 */ ··· 80 80 static int tps65086_gpio_probe(struct platform_device *pdev) 81 81 { 82 82 struct tps65086_gpio *gpio; 83 - int ret; 84 83 85 84 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 86 85 if (!gpio) 87 86 return -ENOMEM; 88 87 89 - platform_set_drvdata(pdev, gpio); 90 - 91 88 gpio->tps = dev_get_drvdata(pdev->dev.parent); 92 89 gpio->chip = template_chip; 93 90 gpio->chip.parent = gpio->tps->dev; 94 91 95 - ret = gpiochip_add_data(&gpio->chip, gpio); 96 - if (ret < 0) { 97 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 98 - return ret; 99 - } 100 - 101 - return 0; 102 - } 103 - 104 - static int tps65086_gpio_remove(struct platform_device *pdev) 105 - { 106 - struct tps65086_gpio *gpio = platform_get_drvdata(pdev); 107 - 108 - gpiochip_remove(&gpio->chip); 109 - 110 - return 0; 92 + return devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 111 93 } 112 94 113 95 static const struct platform_device_id tps65086_gpio_id_table[] = { ··· 103 121 .name = "tps65086-gpio", 104 122 }, 105 123 .probe = tps65086_gpio_probe, 106 - .remove = tps65086_gpio_remove, 107 124 .id_table = tps65086_gpio_id_table, 108 125 }; 109 126 module_platform_driver(tps65086_gpio_driver); 110 127 111 - MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>"); 128 + MODULE_AUTHOR("Andrew Davis <afd@ti.com>"); 112 129 MODULE_DESCRIPTION("TPS65086 GPIO driver"); 113 130 MODULE_LICENSE("GPL v2");