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

gpio: tpic2810: 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
2148a7ac 6c19974d

+4 -21
+4 -21
drivers/gpio/gpio-tpic2810.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 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 7 7 #include <linux/gpio/driver.h> ··· 101 101 static int tpic2810_probe(struct i2c_client *client) 102 102 { 103 103 struct tpic2810 *gpio; 104 - int ret; 105 104 106 105 gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL); 107 106 if (!gpio) 108 107 return -ENOMEM; 109 - 110 - i2c_set_clientdata(client, gpio); 111 108 112 109 gpio->chip = template_chip; 113 110 gpio->chip.parent = &client->dev; ··· 113 116 114 117 mutex_init(&gpio->lock); 115 118 116 - ret = gpiochip_add_data(&gpio->chip, gpio); 117 - if (ret < 0) { 118 - dev_err(&client->dev, "Unable to register gpiochip\n"); 119 - return ret; 120 - } 121 - 122 - return 0; 123 - } 124 - 125 - static void tpic2810_remove(struct i2c_client *client) 126 - { 127 - struct tpic2810 *gpio = i2c_get_clientdata(client); 128 - 129 - gpiochip_remove(&gpio->chip); 119 + return devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio); 130 120 } 131 121 132 122 static const struct i2c_device_id tpic2810_id_table[] = { ··· 128 144 .of_match_table = tpic2810_of_match_table, 129 145 }, 130 146 .probe_new = tpic2810_probe, 131 - .remove = tpic2810_remove, 132 147 .id_table = tpic2810_id_table, 133 148 }; 134 149 module_i2c_driver(tpic2810_driver); 135 150 136 - MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>"); 151 + MODULE_AUTHOR("Andrew Davis <afd@ti.com>"); 137 152 MODULE_DESCRIPTION("TPIC2810 8-Bit LED Driver GPIO Driver"); 138 153 MODULE_LICENSE("GPL v2");