Commit 130199ec authored by Andrew Davis's avatar Andrew Davis Committed by Lee Jones

leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path

Use devm version of gpiochip add function to handle removal for us.
Signed-off-by: default avatarAndrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20231116224121.302150-1-afd@ti.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 804073f5
...@@ -638,19 +638,13 @@ static int tca6507_probe_gpios(struct device *dev, ...@@ -638,19 +638,13 @@ static int tca6507_probe_gpios(struct device *dev,
tca->gpio.direction_output = tca6507_gpio_direction_output; tca->gpio.direction_output = tca6507_gpio_direction_output;
tca->gpio.set = tca6507_gpio_set_value; tca->gpio.set = tca6507_gpio_set_value;
tca->gpio.parent = dev; tca->gpio.parent = dev;
err = gpiochip_add_data(&tca->gpio, tca); err = devm_gpiochip_add_data(dev, &tca->gpio, tca);
if (err) { if (err) {
tca->gpio.ngpio = 0; tca->gpio.ngpio = 0;
return err; return err;
} }
return 0; return 0;
} }
static void tca6507_remove_gpio(struct tca6507_chip *tca)
{
if (tca->gpio.ngpio)
gpiochip_remove(&tca->gpio);
}
#else /* CONFIG_GPIOLIB */ #else /* CONFIG_GPIOLIB */
static int tca6507_probe_gpios(struct device *dev, static int tca6507_probe_gpios(struct device *dev,
struct tca6507_chip *tca, struct tca6507_chip *tca,
...@@ -658,9 +652,6 @@ static int tca6507_probe_gpios(struct device *dev, ...@@ -658,9 +652,6 @@ static int tca6507_probe_gpios(struct device *dev,
{ {
return 0; return 0;
} }
static void tca6507_remove_gpio(struct tca6507_chip *tca)
{
}
#endif /* CONFIG_GPIOLIB */ #endif /* CONFIG_GPIOLIB */
static struct tca6507_platform_data * static struct tca6507_platform_data *
...@@ -793,7 +784,6 @@ static void tca6507_remove(struct i2c_client *client) ...@@ -793,7 +784,6 @@ static void tca6507_remove(struct i2c_client *client)
if (tca_leds[i].led_cdev.name) if (tca_leds[i].led_cdev.name)
led_classdev_unregister(&tca_leds[i].led_cdev); led_classdev_unregister(&tca_leds[i].led_cdev);
} }
tca6507_remove_gpio(tca);
cancel_work_sync(&tca->work); cancel_work_sync(&tca->work);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment