88use crate :: { clk:: Clk , error:: from_kernel_err_ptr} ;
99
1010use crate :: {
11- bindings, c_str , c_types ,
11+ bindings,
1212 revocable:: { Revocable , RevocableGuard } ,
1313 str:: CStr ,
1414 sync:: { NeedsLockClass , RevocableMutex , RevocableMutexGuard , UniqueRef } ,
@@ -20,6 +20,9 @@ use core::{
2020 pin:: Pin ,
2121} ;
2222
23+ #[ cfg( CONFIG_PRINTK ) ]
24+ use crate :: { c_str, c_types} ;
25+
2326/// A raw device.
2427///
2528/// # Safety
@@ -138,10 +141,12 @@ pub unsafe trait RawDevice {
138141 ///
139142 /// Callers must ensure that `klevel` is null-terminated; in particular, one of the
140143 /// `KERN_*`constants, for example, `KERN_CRIT`, `KERN_ALERT`, etc.
144+ #[ cfg_attr( not( CONFIG_PRINTK ) , allow( unused_variables) ) ]
141145 unsafe fn printk ( & self , klevel : & [ u8 ] , msg : fmt:: Arguments < ' _ > ) {
142146 // SAFETY: `klevel` is null-terminated and one of the kernel constants. `self.raw_device`
143147 // is valid because `self` is valid. The "%pA" format string expects a pointer to
144148 // `fmt::Arguments`, which is what we're passing as the last argument.
149+ #[ cfg( CONFIG_PRINTK ) ]
145150 unsafe {
146151 bindings:: _dev_printk (
147152 klevel as * const _ as * const c_types:: c_char ,
0 commit comments