summaryrefslogtreecommitdiffstats
path: root/rust/syn/macros.rs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-24 08:46:03 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-24 08:46:03 -0700
commitcf9610f9116d55c5a66ef9f1faecacabd93a9322 (patch)
tree757a3d280760c654767631cab5ad8af2d86d1848 /rust/syn/macros.rs
downloadlinux-stable-cf9610f9116d55c5a66ef9f1faecacabd93a9322.tar.gz
linux-stable-cf9610f9116d55c5a66ef9f1faecacabd93a9322.zip
Merge tag 'pinctrl-v7.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrlgrafted
Pull pin control updates from Linus Walleij: "Core changes: - Use the non-blocking mux_state_try_select() in the generic MUX pin control back-end - Free pin maps on pinctrl_generic_to_map() failure in the core helpers New hardware pin control: - Qualcomm Maili TLMM SoC, PMG1110 PMIC, and Eliza LPASS LPI TLMM SoC (this is for the low power audio, LPASS = Low Power Audio SubSystem portions) - Upboard support on top of the Intel pin controller - Apple T6030 and T6031 support (just compatible strings) - Samsung Exynos 8855 SoC - Mediatek MT6858 SoC - Rockchip RK3308B and RV1106 SoCs - Airoha EN7523 and AN7563 SoCs Improvements: - Qualcomm TLMM GPIOs are unconditionally marked as wakeup capable - Qualcomm improvements on top of the Qualcomm PDC (power domain controller) irqchip improvements from tglx:s tree - Qualcomm IPQ806x and IPQ9650 non-urgent pin grop fixups - The NPCM8xx driver has been put into shape fixing many pin and group definitions - Some non-urgent Tegra 264 pin assignments are fixed up - Some non-urgent fixups to Airoha AN7581 and AN7583 registers and pin assignments, missing features etc" * tag 'pinctrl-v7.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl: (130 commits) dt-bindings: pinctrl: Convert TI DA850 pupd to DT schema pinctrl: meson: sync some modify from A4 pinctrl: meson: a4: Add input enable pin configuration pinctrl: realtek: rtd1625: remove unused group name spdif_sel pinctrl: realtek: rtd1625: fix base_bit for VE4 GPIO 13 dt-bindings: pinctrl: microchip,pic32mzda-pinctrl: Convert to DT schema Revert "Merge branch 'ib-rsk7204' into devel" pinctrl: rockchip: Add RV1106 pinctrl support dt-bindings: pinctrl: rockchip: Add RV1106 compatible pinctrl: rockchip: Decode drive strength in the get function pinctrl: fix PINCTRL_GENERIC_MUX not always being selectable pinctrl: airoha: add support of an7563 SoC dt-bindings: pinctrl: airoha: add support of an7563 pin controller pinctrl: airoha: try to find chip scu node by phandle first pinctrl: airoha: add support of en7523 SoC dt-bindings: pinctrl: airoha: add support of en7523 pin controller pinctrl: airoha: an7583: add support for olt pinmux pinctrl: airoha: an7583: add support for pon_alt pinmux pinctrl: airoha: an7583: add support for npu_uart pinmux dt-bindings: pinctrl: airoha: an7583: add missed features ...
Diffstat (limited to 'rust/syn/macros.rs')
-rw-r--r--rust/syn/macros.rs184
1 files changed, 184 insertions, 0 deletions
diff --git a/rust/syn/macros.rs b/rust/syn/macros.rs
new file mode 100644
index 000000000..8676f6492
--- /dev/null
+++ b/rust/syn/macros.rs
@@ -0,0 +1,184 @@
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+
+#[cfg_attr(
+ not(any(feature = "full", feature = "derive")),
+ allow(unknown_lints, unused_macro_rules)
+)]
+macro_rules! ast_struct {
+ (
+ $(#[$attr:meta])*
+ $pub:ident $struct:ident $name:ident #full $body:tt
+ ) => {
+ check_keyword_matches!(pub $pub);
+ check_keyword_matches!(struct $struct);
+
+ #[cfg(feature = "full")]
+ $(#[$attr])* $pub $struct $name $body
+
+ #[cfg(not(feature = "full"))]
+ $(#[$attr])* $pub $struct $name {
+ _noconstruct: ::std::marker::PhantomData<::proc_macro2::Span>,
+ }
+
+ #[cfg(all(not(feature = "full"), feature = "printing"))]
+ impl ::quote::ToTokens for $name {
+ fn to_tokens(&self, _: &mut ::proc_macro2::TokenStream) {
+ unreachable!()
+ }
+ }
+ };
+
+ (
+ $(#[$attr:meta])*
+ $pub:ident $struct:ident $name:ident $body:tt
+ ) => {
+ check_keyword_matches!(pub $pub);
+ check_keyword_matches!(struct $struct);
+
+ $(#[$attr])* $pub $struct $name $body
+ };
+}
+
+#[cfg(any(feature = "full", feature = "derive"))]
+macro_rules! ast_enum {
+ (
+ $(#[$enum_attr:meta])*
+ $pub:ident $enum:ident $name:ident $body:tt
+ ) => {
+ check_keyword_matches!(pub $pub);
+ check_keyword_matches!(enum $enum);
+
+ $(#[$enum_attr])* $pub $enum $name $body
+ };
+}
+
+macro_rules! ast_enum_of_structs {
+ (
+ $(#[$enum_attr:meta])*
+ $pub:ident $enum:ident $name:ident $body:tt
+ ) => {
+ check_keyword_matches!(pub $pub);
+ check_keyword_matches!(enum $enum);
+
+ $(#[$enum_attr])* $pub $enum $name $body
+
+ ast_enum_of_structs_impl!($name $body);
+
+ #[cfg(feature = "printing")]
+ generate_to_tokens!(() tokens $name $body);
+ };
+}
+
+macro_rules! ast_enum_of_structs_impl {
+ (
+ $name:ident {
+ $(
+ $(#[cfg $cfg_attr:tt])*
+ $(#[doc $($doc_attr:tt)*])*
+ $variant:ident $( ($member:ident) )*,
+ )*
+ }
+ ) => {
+ $($(
+ ast_enum_from_struct!($name::$variant, $member);
+ )*)*
+ };
+}
+
+macro_rules! ast_enum_from_struct {
+ // No From<TokenStream> for verbatim variants.
+ ($name:ident::Verbatim, $member:ident) => {};
+
+ ($name:ident::$variant:ident, $member:ident) => {
+ impl From<$member> for $name {
+ fn from(e: $member) -> $name {
+ $name::$variant(e)
+ }
+ }
+ };
+}
+
+#[cfg(feature = "printing")]
+macro_rules! generate_to_tokens {
+ (
+ ($($arms:tt)*) $tokens:ident $name:ident {
+ $(#[cfg $cfg_attr:tt])*
+ $(#[doc $($doc_attr:tt)*])*
+ $variant:ident,
+ $($next:tt)*
+ }
+ ) => {
+ generate_to_tokens!(
+ ($($arms)* $(#[cfg $cfg_attr])* $name::$variant => {})
+ $tokens $name { $($next)* }
+ );
+ };
+
+ (
+ ($($arms:tt)*) $tokens:ident $name:ident {
+ $(#[cfg $cfg_attr:tt])*
+ $(#[doc $($doc_attr:tt)*])*
+ $variant:ident($member:ident),
+ $($next:tt)*
+ }
+ ) => {
+ generate_to_tokens!(
+ ($($arms)* $(#[cfg $cfg_attr])* $name::$variant(_e) => _e.to_tokens($tokens),)
+ $tokens $name { $($next)* }
+ );
+ };
+
+ (($($arms:tt)*) $tokens:ident $name:ident {}) => {
+ #[cfg_attr(docsrs, doc(cfg(feature = "printing")))]
+ impl ::quote::ToTokens for $name {
+ fn to_tokens(&self, $tokens: &mut ::proc_macro2::TokenStream) {
+ match self {
+ $($arms)*
+ }
+ }
+ }
+ };
+}
+
+// Rustdoc bug: does not respect the doc(hidden) on some items.
+#[cfg(all(doc, feature = "parsing"))]
+macro_rules! pub_if_not_doc {
+ ($(#[$m:meta])* $pub:ident $($item:tt)*) => {
+ check_keyword_matches!(pub $pub);
+
+ $(#[$m])*
+ $pub(crate) $($item)*
+ };
+}
+
+#[cfg(all(not(doc), feature = "parsing"))]
+macro_rules! pub_if_not_doc {
+ ($(#[$m:meta])* $pub:ident $($item:tt)*) => {
+ check_keyword_matches!(pub $pub);
+
+ $(#[$m])*
+ $pub $($item)*
+ };
+}
+
+macro_rules! check_keyword_matches {
+ (enum enum) => {};
+ (pub pub) => {};
+ (struct struct) => {};
+}
+
+#[cfg(any(feature = "full", feature = "derive"))]
+macro_rules! return_impl_trait {
+ (
+ $(#[$attr:meta])*
+ $vis:vis fn $name:ident $args:tt -> $impl_trait:ty [$concrete:ty] $body:block
+ ) => {
+ #[cfg(not(docsrs))]
+ $(#[$attr])*
+ $vis fn $name $args -> $concrete $body
+
+ #[cfg(docsrs)]
+ $(#[$attr])*
+ $vis fn $name $args -> $impl_trait $body
+ };
+}