[PATCH 3/7] LED: Add gpio LED support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat Dec 18 11:41:48 EST 2010


> +
> +/**
> + * led_gpio_unregister - remove a gpio controlled LED from the framework
> + * @param led	The gpio LED
> + */
> +void led_gpio_unregister(struct gpio_led *led)
> +{
> +	led_unregister(&led->led);
> +}
> +
how abaout make the rgb support optional?
> +static void led_gpio_rgb_set(struct led *led, unsigned int value)
> +{
> +	struct gpio_rgb_led *rgb = container_of(led, struct gpio_rgb_led, led);
> +	int al = rgb->active_low;
> +
> +	gpio_direction_output(rgb->gpio_r, !!(value & 4) ^ al);
> +	gpio_direction_output(rgb->gpio_g, !!(value & 2) ^ al);
> +	gpio_direction_output(rgb->gpio_b, !!(value & 1) ^ al);
> +}
> +
> +/**
> + * led_gpio_rgb_register - register three gpios as a rgb LED
> + * @param led	The gpio rg LED
> + *
> + * This function registers three gpios as a rgb LED. led->gpio[rgb]
> + * should be initialized to the gpios to control.
> + */
> +int led_gpio_rgb_register(struct gpio_rgb_led *led)
no safe check?
> +{
> +	led->led.set = led_gpio_rgb_set;
> +	led->led.max_value = 7;
> +
> +	return led_register(&led->led);
> +}
> +
> +/**
> + * led_gpio_rgb_unregister - remove a gpio controlled rgb LED from the framework
> + * @param led	The gpio LED
> + */
> +void led_gpio_rgb_unregister(struct gpio_led *led)
> +{
> +	led_unregister(&led->led);
> +}
> +
Best Regards,
J.



More information about the barebox mailing list