Skip to content

Commit cf08967

Browse files
committed
zephyr: Run cargo fmt
Format the source according to the default rules. This provides a baseline for future changes to require well-formatted source. Signed-off-by: David Brown <[email protected]>
1 parent 98000a2 commit cf08967

File tree

22 files changed

+207
-229
lines changed

22 files changed

+207
-229
lines changed

zephyr/src/align.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ impl_alignas!(1, 2, 4, 8, 16, 32, 64, 128, 256);
3434
/// member of the struct.
3535
#[repr(transparent)]
3636
pub struct AlignAs<const N: usize>([<AlignAsStruct as AlignAsTrait<N>>::Aligned; 0])
37-
where
37+
where
3838
AlignAsStruct: AlignAsTrait<N>;
3939

4040
impl<const N: usize> AlignAs<N>
41-
where AlignAsStruct: AlignAsTrait<N>
41+
where
42+
AlignAsStruct: AlignAsTrait<N>,
4243
{
4344
/// Construct a new AlignAs.
4445
///

zephyr/src/device.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
use crate::sync::atomic::{AtomicBool, Ordering};
1212

13-
pub mod gpio;
1413
pub mod flash;
14+
pub mod gpio;
1515

1616
// Allow dead code, because it isn't required for a given build to have any devices.
1717
/// Device uniqueness.

zephyr/src/device/flash.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Note that currently, the flash partition shares the controller, so the underlying operations
44
// are not actually safe. Need to rethink how to manage this.
55

6-
use crate::raw;
76
use super::Unique;
7+
use crate::raw;
88

99
/// A flash controller
1010
///
@@ -20,7 +20,10 @@ pub struct FlashController {
2020
impl FlashController {
2121
/// Constructor, intended to be called by devicetree generated code.
2222
#[allow(dead_code)]
23-
pub(crate) unsafe fn new(unique: &Unique, device: *const raw::device) -> Option<FlashController> {
23+
pub(crate) unsafe fn new(
24+
unique: &Unique,
25+
device: *const raw::device,
26+
) -> Option<FlashController> {
2427
if !unique.once() {
2528
return None;
2629
}
@@ -45,7 +48,12 @@ pub struct FlashPartition {
4548
impl FlashPartition {
4649
/// Constructor, intended to be called by devicetree generated code.
4750
#[allow(dead_code)]
48-
pub(crate) unsafe fn new(unique: &Unique, device: *const raw::device, offset: u32, size: u32) -> Option<FlashPartition> {
51+
pub(crate) unsafe fn new(
52+
unique: &Unique,
53+
device: *const raw::device,
54+
offset: u32,
55+
size: u32,
56+
) -> Option<FlashPartition> {
4957
if !unique.once() {
5058
return None;
5159
}
@@ -54,6 +62,10 @@ impl FlashPartition {
5462
// but in this case, we need one for each device, so just construct it here.
5563
// TODO: This is not actually safe.
5664
let controller = FlashController { device };
57-
Some(FlashPartition { controller, offset, size })
65+
Some(FlashPartition {
66+
controller,
67+
offset,
68+
size,
69+
})
5870
}
5971
}

zephyr/src/device/gpio.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//! pervasively throughout Zephyr device drivers. As such, most of the calls in this module are
88
//! unsafe.
99
10-
use crate::raw;
1110
use super::Unique;
11+
use crate::raw;
1212

1313
/// Global instance to help make gpio in Rust slightly safer.
1414
///
@@ -60,9 +60,7 @@ impl Gpio {
6060
/// Verify that the device is ready for use. At a minimum, this means the device has been
6161
/// successfully initialized.
6262
pub fn is_ready(&self) -> bool {
63-
unsafe {
64-
raw::device_is_ready(self.device)
65-
}
63+
unsafe { raw::device_is_ready(self.device) }
6664
}
6765
}
6866

@@ -82,7 +80,12 @@ unsafe impl Send for GpioPin {}
8280
impl GpioPin {
8381
/// Constructor, used by the devicetree generated code.
8482
#[allow(dead_code)]
85-
pub(crate) unsafe fn new(unique: &Unique, device: *const raw::device, pin: u32, dt_flags: u32) -> Option<GpioPin> {
83+
pub(crate) unsafe fn new(
84+
unique: &Unique,
85+
device: *const raw::device,
86+
pin: u32,
87+
dt_flags: u32,
88+
) -> Option<GpioPin> {
8689
if !unique.once() {
8790
return None;
8891
}
@@ -91,7 +94,7 @@ impl GpioPin {
9194
port: device,
9295
pin: pin as raw::gpio_pin_t,
9396
dt_flags: dt_flags as raw::gpio_dt_flags_t,
94-
}
97+
},
9598
})
9699
}
97100

@@ -112,9 +115,11 @@ impl GpioPin {
112115
pub unsafe fn configure(&mut self, _token: &mut GpioToken, extra_flags: raw::gpio_flags_t) {
113116
// TODO: Error?
114117
unsafe {
115-
raw::gpio_pin_configure(self.pin.port,
118+
raw::gpio_pin_configure(
119+
self.pin.port,
116120
self.pin.pin,
117-
self.pin.dt_flags as raw::gpio_flags_t | extra_flags);
121+
self.pin.dt_flags as raw::gpio_flags_t | extra_flags,
122+
);
118123
}
119124
}
120125

zephyr/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use core::panic::PanicInfo;
7272

7373
/// Override rust's panic. This simplistic initial version just hangs in a loop.
7474
#[panic_handler]
75-
fn panic(info :&PanicInfo) -> ! {
75+
fn panic(info: &PanicInfo) -> ! {
7676
#[cfg(CONFIG_PRINTK)]
7777
{
7878
printkln!("panic: {}", info);

zephyr/src/logging/impl_printk.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ impl Log for PrintkLogger {
2424
// printing will be racy. Otherwise, the message will be broken into small chunks that are each
2525
// printed atomically.
2626
fn log(&self, record: &Record<'_>) {
27-
printkln!("{}:{}: {}",
28-
record.level(),
29-
record.target(),
30-
record.args());
27+
printkln!("{}:{}: {}", record.level(), record.target(), record.args());
3128
}
3229

3330
// Flush is not needed.
34-
fn flush(&self) {
35-
}
31+
fn flush(&self) {}
3632
}
3733

3834
static PRINTK_LOGGER: PrintkLogger = PrintkLogger;

zephyr/src/logging/impl_zlog.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ impl Log for ZlogLogger {
3535
// Zephyr doesn't have a separate trace, so fold that into debug.
3636
Level::Trace => raw::LOG_LEVEL_DBG,
3737
};
38-
let mut msg = format!("{}: {}",
39-
record.target(),
40-
record.args());
38+
let mut msg = format!("{}: {}", record.target(), record.args());
4139
// Append a null so this is a valid C string. This lets us avoid an additional allocation
4240
// and copying.
4341
msg.push('\x00');
@@ -47,8 +45,7 @@ impl Log for ZlogLogger {
4745
}
4846

4947
// Flush not needed.
50-
fn flush(&self) {
51-
}
48+
fn flush(&self) {}
5249
}
5350

5451
extern "C" {

zephyr/src/object.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ where
188188
KOBJ_UNINITIALIZED,
189189
KOBJ_INITING,
190190
Ordering::AcqRel,
191-
Ordering::Acquire)
192-
{
191+
Ordering::Acquire,
192+
) {
193193
return None;
194194
}
195195
let result = self.get_wrapped(args);
@@ -401,7 +401,7 @@ macro_rules! _kobj_stack {
401401
[$crate::sys::thread::RealStaticThreadStack<{$crate::sys::thread::stack_len($size)}>; $asize] =
402402
unsafe { ::core::mem::zeroed() };
403403

404-
$v static $name:
404+
$v static $name:
405405
[$crate::_export::KStaticThreadStack; $asize] =
406406
$crate::_export::KStaticThreadStack::new_from_array(&[< $name _REAL >]);
407407
}

zephyr/src/printk.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
//!
66
//! This uses the `k_str_out` syscall, which is part of printk to output to the console.
77
8-
use core::fmt::{
9-
Arguments,
10-
Result,
11-
Write,
12-
write,
13-
};
8+
use core::fmt::{write, Arguments, Result, Write};
149

1510
/// Print to Zephyr's console, without a newline.
1611
///

zephyr/src/sync.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,8 @@ pub use portable_atomic_util::Arc;
3030

3131
mod mutex;
3232

33-
pub use mutex::{
34-
Mutex,
35-
MutexGuard,
36-
Condvar,
37-
LockResult,
38-
TryLockResult,
39-
};
33+
pub use mutex::{Condvar, LockResult, Mutex, MutexGuard, TryLockResult};
4034

4135
mod spinmutex;
4236

43-
pub use spinmutex::{
44-
SpinMutex,
45-
SpinMutexGuard,
46-
};
37+
pub use spinmutex::{SpinMutex, SpinMutexGuard};

0 commit comments

Comments
 (0)