File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -149,14 +149,22 @@ pub struct KParamGuard<'a> {
149
149
this_module : & ' a ThisModule ,
150
150
}
151
151
152
- #[ cfg( CONFIG_SYSFS ) ]
153
152
impl < ' a > Drop for KParamGuard < ' a > {
153
+ #[ cfg( CONFIG_SYSFS ) ]
154
154
fn drop ( & mut self ) {
155
155
// SAFETY: `kernel_param_lock` will check if the pointer is null and
156
156
// use the built-in mutex in that case. The existance of `self`
157
157
// guarantees that the lock is held.
158
158
unsafe { bindings:: kernel_param_unlock ( self . this_module . 0 ) }
159
159
}
160
+
161
+ // This "empty" `Drop` implementation is kept so that the behavior remains
162
+ // the same with and without `CONFIG_SYSFS` with respect to `dropck`.
163
+ #[ cfg( not( CONFIG_SYSFS ) ) ]
164
+ fn drop ( & mut self ) {
165
+ // Touches the `this_module` field, to prevent dead_code warnings.
166
+ let _ = self . this_module ;
167
+ }
160
168
}
161
169
162
170
/// 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