Benno Lossin
2025-Aug-14 07:54 UTC
[PATCH v3 9/9] rust: device: use `kernel::{fmt,prelude::fmt!}`
On Wed Aug 13, 2025 at 5:39 PM CEST, Tamir Duberstein wrote:> Reduce coupling to implementation details of the formatting machinery by > avoiding direct use for `core`'s formatting traits and macros. > > Signed-off-by: Tamir Duberstein <tamird at gmail.com>Reviewed-by: Benno Lossin <lossin at kernel.org>> --- > rust/kernel/device/property.rs | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-)> @@ -413,9 +414,9 @@ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { > // SAFETY: `fwnode_get_name_prefix` returns null or a > // valid C string. > let prefix = unsafe { CStr::from_char_ptr(prefix) }; > - write!(f, "{prefix}")?; > + fmt::Display::fmt(prefix, f)?; > } > - write!(f, "{}", fwnode.display_name())?;So we're not able to use `write!` with our `Display` or did you also write a `FmtAdapter` wrapper for that? (don't think we need it now, just wanted to know if we have this issue possibly in the future) --- Cheers, Benno> + fmt::Display::fmt(&fwnode.display_name(), f)?; > } > > Ok(())