mirror of
https://xff.cz/git/u-boot/
synced 2025-10-18 08:23:24 +02:00
dm: led: Adjust the LED uclass
At present this is very simple, supporting only on and off. We want to also support toggling and blinking. As a first step, change the name of the main method and use an enum to indicate the state. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ziping Chen <techping.chan@gmail.com>
This commit is contained in:
@@ -32,14 +32,14 @@ int led_get_by_label(const char *label, struct udevice **devp)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int led_set_on(struct udevice *dev, int on)
|
||||
int led_set_state(struct udevice *dev, enum led_state_t state)
|
||||
{
|
||||
struct led_ops *ops = led_get_ops(dev);
|
||||
|
||||
if (!ops->set_on)
|
||||
if (!ops->set_state)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->set_on(dev, on);
|
||||
return ops->set_state(dev, state);
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(led) = {
|
||||
|
@@ -18,14 +18,14 @@ struct led_gpio_priv {
|
||||
struct gpio_desc gpio;
|
||||
};
|
||||
|
||||
static int gpio_led_set_on(struct udevice *dev, int on)
|
||||
static int gpio_led_set_state(struct udevice *dev, enum led_state_t state)
|
||||
{
|
||||
struct led_gpio_priv *priv = dev_get_priv(dev);
|
||||
|
||||
if (!dm_gpio_is_valid(&priv->gpio))
|
||||
return -EREMOTEIO;
|
||||
|
||||
return dm_gpio_set_value(&priv->gpio, on);
|
||||
return dm_gpio_set_value(&priv->gpio, state);
|
||||
}
|
||||
|
||||
static int led_gpio_probe(struct udevice *dev)
|
||||
@@ -87,7 +87,7 @@ static int led_gpio_bind(struct udevice *parent)
|
||||
}
|
||||
|
||||
static const struct led_ops gpio_led_ops = {
|
||||
.set_on = gpio_led_set_on,
|
||||
.set_state = gpio_led_set_state,
|
||||
};
|
||||
|
||||
static const struct udevice_id led_gpio_ids[] = {
|
||||
|
Reference in New Issue
Block a user