Skip to content

Commit b7774de

Browse files
committed
Run rustfmt
Fix up various formatting issues that have crept in. Signed-off-by: David Brown <[email protected]>
1 parent 94e0ecd commit b7774de

File tree

3 files changed

+49
-17
lines changed

3 files changed

+49
-17
lines changed

tests/drivers/gpio-async/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
extern crate alloc;
77

8-
use zephyr::{embassy::Executor, raw::{GPIO_INPUT, GPIO_OUTPUT_ACTIVE, GPIO_PULL_DOWN}};
8+
use zephyr::{
9+
embassy::Executor,
10+
raw::{GPIO_INPUT, GPIO_OUTPUT_ACTIVE, GPIO_PULL_DOWN},
11+
};
912

1013
use embassy_executor::Spawner;
1114
use log::info;

zephyr-build/src/devicetree/augment.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ pub enum Action {
140140
impl Action {
141141
fn generate(&self, _name: &Ident, node: &Node, tree: &DeviceTree) -> TokenStream {
142142
match self {
143-
Action::Instance { raw, device, static_type } => raw.generate(node, device, static_type.as_deref()),
143+
Action::Instance {
144+
raw,
145+
device,
146+
static_type,
147+
} => raw.generate(node, device, static_type.as_deref()),
144148
Action::Labels => {
145149
let nodes = tree.labels.iter().map(|(k, v)| {
146150
let name = dt_to_lower_id(k);

zephyr/src/device/gpio.rs

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ mod async_io {
2020
//! the largest number currently used, although this might change with 64-bit targest in the
2121
//! future.
2222
23-
use core::{cell::UnsafeCell, ffi::c_int, future::Future, mem, sync::atomic::Ordering, task::{Poll, Waker}};
23+
use core::{
24+
cell::UnsafeCell,
25+
ffi::c_int,
26+
future::Future,
27+
mem,
28+
sync::atomic::Ordering,
29+
task::{Poll, Waker},
30+
};
2431

2532
use embassy_sync::waitqueue::AtomicWaker;
2633
use portable_atomic::AtomicBool;
27-
use zephyr_sys::{device, gpio_add_callback, gpio_callback, gpio_init_callback, gpio_pin_get, gpio_pin_interrupt_configure, gpio_pin_interrupt_configure_dt, gpio_port_pins_t, GPIO_INT_LEVEL_HIGH, GPIO_INT_LEVEL_LOW, ZR_GPIO_INT_MODE_DISABLE_ONLY};
34+
use zephyr_sys::{
35+
device, gpio_add_callback, gpio_callback, gpio_init_callback, gpio_pin_get,
36+
gpio_pin_interrupt_configure, gpio_pin_interrupt_configure_dt, gpio_port_pins_t,
37+
GPIO_INT_LEVEL_HIGH, GPIO_INT_LEVEL_LOW, ZR_GPIO_INT_MODE_DISABLE_ONLY,
38+
};
2839

2940
use crate::printkln;
3041

@@ -94,11 +105,15 @@ mod async_io {
94105
}
95106
}
96107

97-
extern "C" fn callback_handler(port: *const device, cb: *mut gpio_callback, mut pins: gpio_port_pins_t) {
98-
let data = unsafe { cb
99-
.cast::<u8>()
100-
.sub(mem::offset_of!(Self, callback))
101-
.cast::<Self>()
108+
extern "C" fn callback_handler(
109+
port: *const device,
110+
cb: *mut gpio_callback,
111+
mut pins: gpio_port_pins_t,
112+
) {
113+
let data = unsafe {
114+
cb.cast::<u8>()
115+
.sub(mem::offset_of!(Self, callback))
116+
.cast::<Self>()
102117
};
103118

104119
// printkln!("CB called: pins: {pins:#x}");
@@ -136,7 +151,10 @@ mod async_io {
136151
/// The `_token` enforces single use of gpios. Note that this makes it impossible to wait for
137152
/// more than one GPIO.
138153
///
139-
pub unsafe fn wait_for_high(&mut self, _token: &mut GpioToken) -> impl Future<Output = ()> + use<'_> {
154+
pub unsafe fn wait_for_high(
155+
&mut self,
156+
_token: &mut GpioToken,
157+
) -> impl Future<Output = ()> + use<'_> {
140158
GpioWait::new(self, 1)
141159
}
142160

@@ -146,7 +164,10 @@ mod async_io {
146164
///
147165
/// The `_token` enforces single use of gpios. Note that this makes it impossible to wait
148166
/// for more than one GPIO.
149-
pub unsafe fn wait_for_low(&mut self, _token: &mut GpioToken) -> impl Future<Output = ()> + use<'_> {
167+
pub unsafe fn wait_for_low(
168+
&mut self,
169+
_token: &mut GpioToken,
170+
) -> impl Future<Output = ()> + use<'_> {
150171
GpioWait::new(self, 0)
151172
}
152173
}
@@ -159,17 +180,17 @@ mod async_io {
159180

160181
impl<'a> GpioWait<'a> {
161182
fn new(pin: &'a mut GpioPin, level: u8) -> Self {
162-
Self {
163-
pin,
164-
level,
165-
}
183+
Self { pin, level }
166184
}
167185
}
168186

169187
impl<'a> Future for GpioWait<'a> {
170188
type Output = ();
171189

172-
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut core::task::Context<'_>) -> core::task::Poll<Self::Output> {
190+
fn poll(
191+
self: core::pin::Pin<&mut Self>,
192+
cx: &mut core::task::Context<'_>,
193+
) -> core::task::Poll<Self::Output> {
173194
self.pin.data.fast_install(self.pin.pin.port);
174195

175196
self.pin.data.register(self.pin.pin.pin, cx.waker());
@@ -256,7 +277,11 @@ impl Gpio {
256277
///
257278
/// TODO: Guarantee single instancing.
258279
#[allow(dead_code)]
259-
pub(crate) unsafe fn new(unique: &Unique, data: &'static GpioStatic, device: *const raw::device) -> Option<Gpio> {
280+
pub(crate) unsafe fn new(
281+
unique: &Unique,
282+
data: &'static GpioStatic,
283+
device: *const raw::device,
284+
) -> Option<Gpio> {
260285
if !unique.once() {
261286
return None;
262287
}

0 commit comments

Comments
 (0)