File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -138,18 +138,25 @@ impl ThisModule {
138
138
/// Scoped lock on the kernel parameters of [`ThisModule`].
139
139
///
140
140
/// Lock will be released when this struct is dropped.
141
+ #[ repr( transparent) ]
141
142
pub struct KParamGuard < ' a > {
142
143
this_module : & ' a ThisModule ,
143
144
}
144
145
145
- #[ cfg( CONFIG_SYSFS ) ]
146
146
impl < ' a > Drop for KParamGuard < ' a > {
147
+ #[ cfg( CONFIG_SYSFS ) ]
147
148
fn drop ( & mut self ) {
148
149
// SAFETY: `kernel_param_lock` will check if the pointer is null and
149
150
// use the built-in mutex in that case. The existance of `self`
150
151
// guarantees that the lock is held.
151
152
unsafe { bindings:: kernel_param_unlock ( self . this_module . 0 ) }
152
153
}
154
+
155
+ #[ cfg( not( CONFIG_SYSFS ) ) ]
156
+ fn drop ( & mut self ) {
157
+ // This just touches the `this_module` field, to prevent dead_code warnings.
158
+ let _ = self . this_module ;
159
+ }
153
160
}
154
161
155
162
/// Calculates the offset of a field from the beginning of the struct it belongs to.
You can’t perform that action at this time.
0 commit comments