xref: /openbmc/linux/rust/bindings/lib.rs (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
18326ac05SMiguel Ojeda // SPDX-License-Identifier: GPL-2.0
28326ac05SMiguel Ojeda 
38326ac05SMiguel Ojeda //! Bindings.
48326ac05SMiguel Ojeda //!
58326ac05SMiguel Ojeda //! Imports the generated bindings by `bindgen`.
68326ac05SMiguel Ojeda //!
78326ac05SMiguel Ojeda //! This crate may not be directly used. If you need a kernel C API that is
88326ac05SMiguel Ojeda //! not ported or wrapped in the `kernel` crate, then do so first instead of
98326ac05SMiguel Ojeda //! using this crate.
108326ac05SMiguel Ojeda 
118326ac05SMiguel Ojeda #![no_std]
128326ac05SMiguel Ojeda // See <https://github.com/rust-lang/rust-bindgen/issues/1651>.
138326ac05SMiguel Ojeda #![cfg_attr(test, allow(deref_nullptr))]
148326ac05SMiguel Ojeda #![cfg_attr(test, allow(unaligned_references))]
158326ac05SMiguel Ojeda #![cfg_attr(test, allow(unsafe_op_in_unsafe_fn))]
168326ac05SMiguel Ojeda #![allow(
178326ac05SMiguel Ojeda     clippy::all,
188326ac05SMiguel Ojeda     missing_docs,
198326ac05SMiguel Ojeda     non_camel_case_types,
208326ac05SMiguel Ojeda     non_upper_case_globals,
218326ac05SMiguel Ojeda     non_snake_case,
228326ac05SMiguel Ojeda     improper_ctypes,
238326ac05SMiguel Ojeda     unreachable_pub,
248326ac05SMiguel Ojeda     unsafe_op_in_unsafe_fn
258326ac05SMiguel Ojeda )]
268326ac05SMiguel Ojeda 
278326ac05SMiguel Ojeda mod bindings_raw {
288326ac05SMiguel Ojeda     // Use glob import here to expose all helpers.
298326ac05SMiguel Ojeda     // Symbols defined within the module will take precedence to the glob import.
308326ac05SMiguel Ojeda     pub use super::bindings_helper::*;
318326ac05SMiguel Ojeda     include!(concat!(
328326ac05SMiguel Ojeda         env!("OBJTREE"),
338326ac05SMiguel Ojeda         "/rust/bindings/bindings_generated.rs"
348326ac05SMiguel Ojeda     ));
358326ac05SMiguel Ojeda }
368326ac05SMiguel Ojeda 
378326ac05SMiguel Ojeda // When both a directly exposed symbol and a helper exists for the same function,
388326ac05SMiguel Ojeda // the directly exposed symbol is preferred and the helper becomes dead code, so
398326ac05SMiguel Ojeda // ignore the warning here.
408326ac05SMiguel Ojeda #[allow(dead_code)]
418326ac05SMiguel Ojeda mod bindings_helper {
428326ac05SMiguel Ojeda     // Import the generated bindings for types.
43*9dc04365SWedson Almeida Filho     use super::bindings_raw::*;
448326ac05SMiguel Ojeda     include!(concat!(
458326ac05SMiguel Ojeda         env!("OBJTREE"),
468326ac05SMiguel Ojeda         "/rust/bindings/bindings_helpers_generated.rs"
478326ac05SMiguel Ojeda     ));
488326ac05SMiguel Ojeda }
498326ac05SMiguel Ojeda 
508326ac05SMiguel Ojeda pub use bindings_raw::*;
518326ac05SMiguel Ojeda 
528326ac05SMiguel Ojeda pub const GFP_KERNEL: gfp_t = BINDINGS_GFP_KERNEL;
538326ac05SMiguel Ojeda pub const __GFP_ZERO: gfp_t = BINDINGS___GFP_ZERO;
54