On Tue 2020-03-03 18:43:51, Greg Kroah-Hartman wrote: > From: Peter Chen <peter.chen@xxxxxxx> > > commit ca4b43c14cd88d28cfc6467d2fa075aad6818f1d upstream. > > To work properly on every architectures and compilers, the enum value > needs to be specific numbers. All compilers are expected to handle this in the same way, as this is in C standard. This patch is not neccessary, and should not be in mainline, either. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf 6.7.2.2 Enumeration specifiers Syntax ... 3 The identifiers in an enumerator list are declared as constants that have type int and may appear wherever such are permitted.107) An enumerator with = defines its enumeration constant as the value of the constant expression. If the first enumerator has no =, the value of its enumeration constant is 0. Each subsequent enumerator with no = defines its enumeration constant as the value of the constant expression obtained by adding 1 to the value of the previous enumeration constant. (The use of enumerators with = may produce enumeration constants with values that duplicate other values in the same enumeration.) The enumerators of an enumeration are also known as its members. Best regards, Pavel > enum usb_charger_type { > - UNKNOWN_TYPE, > - SDP_TYPE, > - DCP_TYPE, > - CDP_TYPE, > - ACA_TYPE, > + UNKNOWN_TYPE = 0, > + SDP_TYPE = 1, > + DCP_TYPE = 2, > + CDP_TYPE = 3, > + ACA_TYPE = 4, > }; > > /* USB charger state */ > enum usb_charger_state { > - USB_CHARGER_DEFAULT, > - USB_CHARGER_PRESENT, > - USB_CHARGER_ABSENT, > + USB_CHARGER_DEFAULT = 0, > + USB_CHARGER_PRESENT = 1, > + USB_CHARGER_ABSENT = 2, > }; > > #endif /* _UAPI__LINUX_USB_CHARGER_H */ > -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Attachment:
signature.asc
Description: PGP signature