Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bradjc committed Nov 30, 2018
1 parent 37ce55c commit 3c00c39
Show file tree
Hide file tree
Showing 36 changed files with 204 additions and 155 deletions.
22 changes: 11 additions & 11 deletions arch/cortex-m3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,17 @@ pub unsafe extern "C" fn hard_fault_handler() {
let kernel_stack: bool;

asm!(
"mov r1, 0 \n\
tst lr, #4 \n\
itte eq \n\
mrseq r0, msp \n\
addeq r1, 1 \n\
mrsne r0, psp "
: "={r0}"(faulting_stack), "={r1}"(kernel_stack)
:
: "r0", "r1"
: "volatile"
);
"mov r1, 0 \n\
tst lr, #4 \n\
itte eq \n\
mrseq r0, msp \n\
addeq r1, 1 \n\
mrsne r0, psp "
: "={r0}"(faulting_stack), "={r1}"(kernel_stack)
:
: "r0", "r1"
: "volatile"
);

if kernel_stack {
kernel_hardfault(faulting_stack);
Expand Down
22 changes: 11 additions & 11 deletions arch/cortex-m4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,17 @@ pub unsafe extern "C" fn hard_fault_handler() {
let kernel_stack: bool;

asm!(
"mov r1, 0 \n\
tst lr, #4 \n\
itte eq \n\
mrseq r0, msp \n\
addeq r1, 1 \n\
mrsne r0, psp "
: "={r0}"(faulting_stack), "={r1}"(kernel_stack)
:
: "r0", "r1"
: "volatile"
);
"mov r1, 0 \n\
tst lr, #4 \n\
itte eq \n\
mrseq r0, msp \n\
addeq r1, 1 \n\
mrsne r0, psp "
: "={r0}"(faulting_stack), "={r1}"(kernel_stack)
:
: "r0", "r1"
: "volatile"
);

if kernel_stack {
kernel_hardfault(faulting_stack);
Expand Down
6 changes: 4 additions & 2 deletions boards/imix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ pub unsafe fn reset_handler() {
&sam4l::gpio::PA[08], // irq
&sam4l::gpio::PA[08],
RADIO_CHANNEL,
).finalize();
)
.finalize();

let adc = AdcComponent::new().finalize();
let gpio = GpioComponent::new().finalize();
Expand Down Expand Up @@ -418,7 +419,8 @@ pub unsafe fn reset_handler() {
src_mac_from_serial_num,
local_ip_ifaces,
mux_alarm,
).finalize();
)
.finalize();

let imix = Imix {
pconsole,
Expand Down
2 changes: 1 addition & 1 deletion boards/launchxl/src/pin_mapping_cc1312r.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use enum_primitive::cast::FromPrimitive;

enum_from_primitive!{
enum_from_primitive! {
pub enum PIN_FN {
UART0_RX = 2,
UART0_TX = 3,
Expand Down
8 changes: 1 addition & 7 deletions boards/nordic/nrf51dk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@

extern crate capsules;
#[allow(unused_imports)]
#[macro_use(
create_capability,
debug,
debug_verbose,
debug_gpio,
static_init
)]
#[macro_use(create_capability, debug, debug_verbose, debug_gpio, static_init)]
extern crate kernel;
extern crate cortexm0;
extern crate nrf51;
Expand Down
8 changes: 1 addition & 7 deletions boards/nordic/nrf52dk_base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
extern crate capsules;
extern crate cortexm4;
#[allow(unused_imports)]
#[macro_use(
create_capability,
debug,
debug_verbose,
debug_gpio,
static_init
)]
#[macro_use(create_capability, debug, debug_verbose, debug_gpio, static_init)]
extern crate kernel;
extern crate nrf52;
extern crate nrf5x;
Expand Down
6 changes: 4 additions & 2 deletions capsules/src/alarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ impl<A: Alarm> Driver for AlarmDriver<'a, A> {
.enter(app_id, |td, _allocator| {
td.callback = callback;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
}

/// Setup and read the alarm.
Expand Down Expand Up @@ -152,7 +153,8 @@ impl<A: Alarm> Driver for AlarmDriver<'a, A> {
self.reset_active_alarm(now);
}
return_code
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
}
}

Expand Down
6 changes: 4 additions & 2 deletions capsules/src/ambient_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ impl AmbientLight<'a> {
}
ReturnCode::SUCCESS
}
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
}
}

Expand All @@ -76,7 +77,8 @@ impl Driver for AmbientLight<'a> {
.enter(app_id, |app, _| {
app.callback = callback;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand Down
9 changes: 6 additions & 3 deletions capsules/src/app_flash_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ impl AppFlash<'a> {
ReturnCode::SUCCESS
}
}
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
}
}

Expand Down Expand Up @@ -175,7 +176,8 @@ impl Driver for AppFlash<'a> {
.enter(appid, |app, _| {
app.buffer = slice;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand All @@ -197,7 +199,8 @@ impl Driver for AppFlash<'a> {
.enter(app_id, |app, _| {
app.callback = callback;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand Down
30 changes: 20 additions & 10 deletions capsules/src/ble_advertising_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,10 @@ impl App {
.transmit_advertisement(kernel_tx, total_len, channel);
ble.kernel_tx.replace(result);
ReturnCode::SUCCESS
}).unwrap_or(ReturnCode::FAIL)
}).unwrap_or(ReturnCode::FAIL)
})
.unwrap_or(ReturnCode::FAIL)
})
.unwrap_or(ReturnCode::FAIL)
}

// Returns a new pseudo-random number and updates the randomness state.
Expand Down Expand Up @@ -459,7 +461,8 @@ where
for (dst, src) in userland.iter_mut().zip(buf[0..len as usize].iter()) {
*dst = *src;
}
}).is_some();
})
.is_some();

if success {
app.scan_callback.map(|mut cb| {
Expand Down Expand Up @@ -574,7 +577,8 @@ where
} else {
ReturnCode::EBUSY
}
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),

// Stop periodic advertisements or passive scanning
1 => self
Expand All @@ -585,7 +589,8 @@ where
ReturnCode::SUCCESS
}
_ => ReturnCode::EBUSY,
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),

// Configure transmitted power
// BLUETOOTH SPECIFICATION Version 4.2 [Vol 6, Part A], section 3
Expand Down Expand Up @@ -614,7 +619,8 @@ where
} else {
ReturnCode::EBUSY
}
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
}

// Passive scanning mode
Expand All @@ -629,7 +635,8 @@ where
} else {
ReturnCode::EBUSY
}
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),

_ => ReturnCode::ENOSUPPORT,
}
Expand All @@ -653,7 +660,8 @@ where
} else {
ReturnCode::FAIL
}
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),

// Passive scanning buffer
1 => self
Expand All @@ -665,7 +673,8 @@ where
ReturnCode::SUCCESS
}
_ => ReturnCode::EINVAL,
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),

// Operation not supported
_ => ReturnCode::ENOSUPPORT,
Expand All @@ -688,7 +697,8 @@ where
ReturnCode::SUCCESS
}
_ => ReturnCode::EINVAL,
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand Down
9 changes: 6 additions & 3 deletions capsules/src/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ impl<G: hil::gpio::Pin + hil::gpio::PinCtl> Driver for Button<'a, G> {
.enter(app_id, |cntr, _| {
cntr.0 = callback;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),

// default
_ => ReturnCode::ENOSUPPORT,
Expand Down Expand Up @@ -179,7 +180,8 @@ impl<G: hil::gpio::Pin + hil::gpio::PinCtl> Driver for Button<'a, G> {
.0
.enable_interrupt(data, InterruptMode::EitherEdge);
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
} else {
ReturnCode::EINVAL /* impossible button */
}
Expand All @@ -195,7 +197,8 @@ impl<G: hil::gpio::Pin + hil::gpio::PinCtl> Driver for Button<'a, G> {
.enter(appid, |cntr, _| {
cntr.1 &= !(1 << data);
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into());
})
.unwrap_or_else(|err| err.into());

// are any processes waiting for this button?
let interrupt_count = Cell::new(0);
Expand Down
12 changes: 8 additions & 4 deletions capsules/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,15 @@ impl<U: UART> Driver for Console<'a, U> {
.enter(appid, |app, _| {
app.write_buffer = slice;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
2 => self
.apps
.enter(appid, |app, _| {
app.read_buffer = slice;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand Down Expand Up @@ -384,8 +386,10 @@ impl<U: UART> Client for Console<'a, U> {
}
}
});
}).unwrap_or_default();
}).unwrap_or_default();
})
.unwrap_or_default();
})
.unwrap_or_default();

// Whatever happens, we want to make sure to replace the rx_buffer for future transactions
self.rx_buffer.replace(buffer);
Expand Down
12 changes: 8 additions & 4 deletions capsules/src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ impl<C: hil::crc::CRC> Driver for Crc<'a, C> {
.enter(appid, |app, _| {
app.buffer = slice;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand Down Expand Up @@ -218,7 +219,8 @@ impl<C: hil::crc::CRC> Driver for Crc<'a, C> {
.enter(app_id, |app, _| {
app.callback = callback;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into()),
})
.unwrap_or_else(|err| err.into()),
_ => ReturnCode::ENOSUPPORT,
}
}
Expand Down Expand Up @@ -303,7 +305,8 @@ impl<C: hil::crc::CRC> Driver for Crc<'a, C> {
ReturnCode::EINVAL
}
}
}).unwrap_or_else(|err| err.into())
})
.unwrap_or_else(|err| err.into())
} else {
ReturnCode::EINVAL
};
Expand All @@ -329,7 +332,8 @@ impl<C: hil::crc::CRC> hil::crc::Client for Crc<'a, C> {
}
app.waiting = None;
ReturnCode::SUCCESS
}).unwrap_or_else(|err| err.into());
})
.unwrap_or_else(|err| err.into());
self.serve_waiting_apps();
});
}
Expand Down
2 changes: 1 addition & 1 deletion capsules/src/driver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use enum_primitive::cast::FromPrimitive;

enum_from_primitive!{
enum_from_primitive! {
#[derive(Debug, PartialEq)]
// syscall driver numbers
pub enum NUM {
Expand Down
Loading

0 comments on commit 3c00c39

Please sign in to comment.