Re: [PATCH 1/2] swap led_brightness from enum to typedef

From: Pavel Machek
Date: Mon Jul 19 2021 - 08:08:36 EST


Hi!

> This commit changes how led_brightness, declared in header file
> include/linux/leds.h, works throughout the kernel, and updates other
> files in accordance.
>
> The TODO located at drivers/leds/TODO requests:
>
> * Get rid of led_brightness
>
> It is really an integer, as maximum is configurable. Get rid of it, or
> make it into typedef or something.
>
> This patch changes the declaration of led_brightness from an enum to a
> typedef. In order to hold the currently existing enum values, macro
> definitions are provided. Files which use led_brightness are updated to
> conform to the new types.

Hmm... thanks.

But I can't really pull this through the LED tree as it touches other
people's code.


> index bfa60fa1d812..e1d771513b98 100644
> --- a/drivers/leds/TODO
> +++ b/drivers/leds/TODO
> @@ -1,7 +1,7 @@
> -*- org -*-
>
> * On/off LEDs should have max_brightness of 1
> -* Get rid of enum led_brightness
> +* Get rid of led_brightness
>
> It is really an integer, as maximum is configurable. Get rid of it, or
> make it into typedef or something.

You can delete this.

Probably new type should be called led_brightness_t. And probably it
should be typedef for the enum _for now_, so that we can switch users
gradually.

It should also be more than u8, I believe someone has more than 255
levels at this point.

> +++ b/include/linux/leds.h
> @@ -26,12 +26,11 @@ struct device_node;
> */
>
> /* This is obsolete/useless. We now support variable maximum brightness. */
> -enum led_brightness {
> - LED_OFF = 0,
> - LED_ON = 1,
> - LED_HALF = 127,
> - LED_FULL = 255,
> -};
> +typedef u8 led_brightness;
> +#define LED_OFF 0
> +#define LED_ON 1
> +#define LED_HALF 127
> +#define LED_FULL 255
>

Best regards,
Pavel

--
http://www.livejournal.com/~pavelmachek

Attachment: signature.asc
Description: PGP signature