Skip to content

Commit 77a1a8c

Browse files
committed
rust: kernel: apply rustfmt to from_kernel_result! blocks
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent d955157 commit 77a1a8c

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

rust/kernel/amba.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ unsafe extern "C" fn probe_callback<T: Driver>(
120120
} else {
121121
// SAFETY: The offset comes from a previous call to `offset_from` in `IdArray::new`,
122122
// which guarantees that the resulting pointer is within the table.
123-
let ptr = unsafe { aid.cast::<u8>().offset(offset as _).cast::<Option<T::IdInfo>>() };
123+
let ptr = unsafe {
124+
aid.cast::<u8>()
125+
.offset(offset as _)
126+
.cast::<Option<T::IdInfo>>()
127+
};
124128
// SAFETY: The id table has a static lifetime, so `ptr` is guaranteed to be valid for
125129
// read.
126130
unsafe { (&*ptr).as_ref() }

rust/kernel/file.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,12 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
361361
// references to `file` have been released, so we know it can't be called while this
362362
// function is running.
363363
let f = unsafe { T::Data::borrow((*file).private_data) };
364-
let read =
365-
T::read(f, unsafe { File::from_ptr(file) }, &mut iter, offset.try_into()?)?;
364+
let read = T::read(
365+
f,
366+
unsafe { File::from_ptr(file) },
367+
&mut iter,
368+
offset.try_into()?,
369+
)?;
366370
unsafe { (*iocb).ki_pos += bindings::loff_t::try_from(read).unwrap() };
367371
Ok(read as _)
368372
}
@@ -389,7 +393,7 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
389393
f,
390394
unsafe { File::from_ptr(file) },
391395
&mut data,
392-
unsafe { *offset }.try_into()?
396+
unsafe { *offset }.try_into()?,
393397
)?;
394398
unsafe { (*offset) += bindings::loff_t::try_from(written).unwrap() };
395399
Ok(written as _)
@@ -410,8 +414,12 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
410414
// references to `file` have been released, so we know it can't be called while this
411415
// function is running.
412416
let f = unsafe { T::Data::borrow((*file).private_data) };
413-
let written =
414-
T::write(f, unsafe { File::from_ptr(file) }, &mut iter, offset.try_into()?)?;
417+
let written = T::write(
418+
f,
419+
unsafe { File::from_ptr(file) },
420+
&mut iter,
421+
offset.try_into()?,
422+
)?;
415423
unsafe { (*iocb).ki_pos += bindings::loff_t::try_from(written).unwrap() };
416424
Ok(written as _)
417425
}

rust/kernel/fs.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ impl<T: Type + ?Sized> Tables<T> {
166166
// SAFETY: The callback contract guarantees the parameter key to be valid and last at
167167
// least the duration of the callback.
168168
T::Context::parse_unknown_param(
169-
&mut data, unsafe { CStr::from_char_ptr(param.key) }, val)?;
169+
&mut data,
170+
unsafe { CStr::from_char_ptr(param.key) },
171+
val,
172+
)?;
170173
Ok(0)
171174
}
172175
}
@@ -291,8 +294,9 @@ impl<T: Type + ?Sized> Tables<T> {
291294
// SAFETY: Both `fc` and `buf` are guaranteed to be valid; the former because the
292295
// callback is still ongoing and the latter because its lifefime is tied to that of
293296
// `page`, which is also valid for the duration of the callback.
294-
to_result(
295-
unsafe { bindings::generic_parse_monolithic(fc, buf.as_mut_ptr().cast()) })?;
297+
to_result(unsafe {
298+
bindings::generic_parse_monolithic(fc, buf.as_mut_ptr().cast())
299+
})?;
296300
}
297301
Ok(0)
298302
}

rust/kernel/irq.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ unsafe extern "C" fn irq_set_type_callback<T: Chip>(
213213

214214
// SAFETY: The value returned by `IrqData` is only valid until the end of this function, and
215215
// `irq_data` is guaranteed to be valid until then (by the contract with C code).
216-
let ret = T::set_type(data, &mut LockedIrqData(unsafe { IrqData::from_ptr(irq_data) }), flow_type)?;
216+
let ret = T::set_type(
217+
data,
218+
&mut LockedIrqData(unsafe { IrqData::from_ptr(irq_data) }),
219+
flow_type,
220+
)?;
217221
Ok(ret as _)
218222
}
219223
}

0 commit comments

Comments
 (0)