|
820 | 820 | #define DT_STRING_UPPER_TOKEN(node_id, prop) \ |
821 | 821 | DT_CAT4(node_id, _P_, prop, _STRING_UPPER_TOKEN) |
822 | 822 |
|
823 | | -/** |
824 | | - * @brief Get an enumeration property's value as a token. |
825 | | - * |
826 | | - * This allows you to "remove the quotes" from some string-valued |
827 | | - * properties. That can be useful, for example, when pasting the |
828 | | - * values onto some other token to form an enum in C using the @p ## |
829 | | - * preprocessor operator. |
830 | | - * |
831 | | - * DT_ENUM_TOKEN() can only be used for properties with string type |
832 | | - * whose binding has an "enum:". The values in the binding's "enum:" |
833 | | - * list must be unique after converting non-alphanumeric characters to |
834 | | - * underscores. |
835 | | - * |
836 | | - * It is an error to use DT_ENUM_TOKEN() in other circumstances. |
837 | | - * |
838 | | - * Example devicetree fragment: |
839 | | - * |
840 | | - * n1: node-1 { |
841 | | - * prop = "foo"; |
842 | | - * }; |
843 | | - * n2: node-2 { |
844 | | - * prop = "FOO"; |
845 | | - * } |
846 | | - * n3: node-3 { |
847 | | - * prop = "123 foo"; |
848 | | - * }; |
849 | | - * |
850 | | - * Example bindings fragment: |
851 | | - * |
852 | | - * properties: |
853 | | - * prop: |
854 | | - * type: string |
855 | | - * enum: |
856 | | - * - "foo" |
857 | | - * - "FOO" |
858 | | - * - "123 foo" |
859 | | - * |
860 | | - * Example usage: |
861 | | - * |
862 | | - * DT_ENUM_TOKEN(DT_NODELABEL(n1), prop) // foo |
863 | | - * DT_ENUM_TOKEN(DT_NODELABEL(n2), prop) // FOO |
864 | | - * DT_ENUM_TOKEN(DT_NODELABEL(n3), prop) // 123_foo |
865 | | - * |
866 | | - * Notice how: |
867 | | - * |
868 | | - * - Unlike C identifiers, the property values may begin with a |
869 | | - * number. It's the user's responsibility not to use such values as |
870 | | - * the name of a C identifier. |
871 | | - * |
872 | | - * - The uppercased "FOO" in the DTS remains @p FOO as a token. It is |
873 | | - *not* converted to @p foo. |
874 | | - * |
875 | | - * - The whitespace in the DTS "123 foo" string is converted to @p |
876 | | - * 123_foo as a token. |
877 | | - * |
878 | | - * @param node_id node identifier |
879 | | - * @param prop lowercase-and-underscores property name with suitable |
880 | | - * enumeration of values in its binding |
881 | | - * @return the value of @p prop as a token, i.e. without any quotes |
882 | | - * and with special characters converted to underscores |
883 | | - */ |
884 | | -#define DT_ENUM_TOKEN(node_id, prop) \ |
885 | | - __DEPRECATED_MACRO \ |
886 | | - DT_CAT4(node_id, _P_, prop, _ENUM_TOKEN) |
887 | | - |
888 | | -/** |
889 | | - * @brief Like DT_ENUM_TOKEN(), but uppercased |
890 | | - * |
891 | | - * This allows you to "remove the quotes and capitalize" some string-valued |
892 | | - * properties. |
893 | | - * |
894 | | - * DT_ENUM_UPPER_TOKEN() can only be used for properties with string type |
895 | | - * whose binding has an "enum:". The values in the binding's "enum:" |
896 | | - * list must be unique after converting non-alphanumeric characters to |
897 | | - * underscores and capitalizating any letters. |
898 | | - * |
899 | | - * It is an error to use DT_ENUM_UPPER_TOKEN() in other circumstances. |
900 | | - * |
901 | | - * Example devicetree fragment: |
902 | | - * |
903 | | - * n1: node-1 { |
904 | | - * prop = "foo"; |
905 | | - * }; |
906 | | - * n2: node-2 { |
907 | | - * prop = "123 foo"; |
908 | | - * }; |
909 | | - * |
910 | | - * Example bindings fragment: |
911 | | - * |
912 | | - * properties: |
913 | | - * prop: |
914 | | - * type: string |
915 | | - * enum: |
916 | | - * - "foo" |
917 | | - * - "123 foo" |
918 | | - * |
919 | | - * Example usage: |
920 | | - * |
921 | | - * DT_ENUM_TOKEN((DT_NODELABEL(n1), prop) // FOO |
922 | | - * DT_ENUM_TOKEN((DT_NODELABEL(n2), prop) // 123_FOO |
923 | | - * |
924 | | - * Notice how: |
925 | | - * |
926 | | - * - Unlike C identifiers, the property values may begin with a |
927 | | - * number. It's the user's responsibility not to use such values as |
928 | | - * the name of a C identifier. |
929 | | - * |
930 | | - * - The lowercased "foo" in the DTS becomes @p FOO as a token, i.e. |
931 | | - * it is uppercased. |
932 | | - * |
933 | | - * - The whitespace in the DTS "123 foo" string is converted to @p |
934 | | - * 123_FOO as a token, i.e. it is uppercased and whitespace becomes |
935 | | - * an underscore. |
936 | | - * |
937 | | - * @param node_id node identifier |
938 | | - * @param prop lowercase-and-underscores property name with suitable |
939 | | - * enumeration of values in its binding |
940 | | - * @return the value of @p prop as a capitalized token, i.e. upper case, |
941 | | - * without any quotes, and with special characters converted to |
942 | | - * underscores |
943 | | - */ |
944 | | -#define DT_ENUM_UPPER_TOKEN(node_id, prop) \ |
945 | | - __DEPRECATED_MACRO \ |
946 | | - DT_CAT4(node_id, _P_, prop, _ENUM_UPPER_TOKEN) |
947 | | - |
948 | 823 | /* |
949 | 824 | * phandle properties |
950 | 825 | * |
|
0 commit comments