Skip to content

Commit

Permalink
leds: tca6507: Use devm_gpiochip_add_data() to simplify remove path
Browse files Browse the repository at this point in the history
Use devm version of gpiochip add function to handle removal for us.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20231116224121.302150-1-afd@ti.com
Signed-off-by: Lee Jones <lee@kernel.org>
  • Loading branch information
glneo authored and lag-linaro committed Dec 13, 2023
1 parent 804073f commit 130199e
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions drivers/leds/leds-tca6507.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,29 +638,20 @@ static int tca6507_probe_gpios(struct device *dev,
tca->gpio.direction_output = tca6507_gpio_direction_output;
tca->gpio.set = tca6507_gpio_set_value;
tca->gpio.parent = dev;
err = gpiochip_add_data(&tca->gpio, tca);
err = devm_gpiochip_add_data(dev, &tca->gpio, tca);
if (err) {
tca->gpio.ngpio = 0;
return err;
}
return 0;
}

static void tca6507_remove_gpio(struct tca6507_chip *tca)
{
if (tca->gpio.ngpio)
gpiochip_remove(&tca->gpio);
}
#else /* CONFIG_GPIOLIB */
static int tca6507_probe_gpios(struct device *dev,
struct tca6507_chip *tca,
struct tca6507_platform_data *pdata)
{
return 0;
}
static void tca6507_remove_gpio(struct tca6507_chip *tca)
{
}
#endif /* CONFIG_GPIOLIB */

static struct tca6507_platform_data *
Expand Down Expand Up @@ -793,7 +784,6 @@ static void tca6507_remove(struct i2c_client *client)
if (tca_leds[i].led_cdev.name)
led_classdev_unregister(&tca_leds[i].led_cdev);
}
tca6507_remove_gpio(tca);
cancel_work_sync(&tca->work);
}

Expand Down

0 comments on commit 130199e

Please sign in to comment.