Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions capsules/core/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>
let mut app_buf_length = 0;
let exists = self.processid.map_or(false, |id| {
self.apps
.enter(*id, |_, kernel_data| {
.enter(id, |_, kernel_data| {
app_buf_length = kernel_data
.get_readwrite_processbuffer(0)
.map(|b| b.len())
Expand All @@ -361,7 +361,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>
self.mode.set(AdcMode::SingleBuffer);
let ret = self.processid.map_or(Err(ErrorCode::NOMEM), |id| {
self.apps
.enter(*id, |app, _| {
.enter(id, |app, _| {
app.app_buf_offset.set(0);
self.channel.set(channel);
// start a continuous sample
Expand Down Expand Up @@ -418,7 +418,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>
self.mode.set(AdcMode::NoMode);
self.processid.map(|id| {
self.apps
.enter(*id, |app, _| {
.enter(id, |app, _| {
app.samples_remaining.set(0);
app.samples_outstanding.set(0);
})
Expand Down Expand Up @@ -459,7 +459,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>
let mut next_app_buf_length = 0;
let exists = self.processid.map_or(false, |id| {
self.apps
.enter(*id, |_, kernel_data| {
.enter(id, |_, kernel_data| {
app_buf_length = kernel_data
.get_readwrite_processbuffer(0)
.map(|b| b.len())
Expand Down Expand Up @@ -489,7 +489,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>

let ret = self.processid.map_or(Err(ErrorCode::NOMEM), |id| {
self.apps
.enter(*id, |app, _| {
.enter(id, |app, _| {
app.app_buf_offset.set(0);
self.channel.set(channel);
// start a continuous sample
Expand Down Expand Up @@ -559,7 +559,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>
self.mode.set(AdcMode::NoMode);
self.processid.map(|id| {
self.apps
.enter(*id, |app, _| {
.enter(id, |app, _| {
app.samples_remaining.set(0);
app.samples_outstanding.set(0);
})
Expand Down Expand Up @@ -588,7 +588,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> AdcDedicated<'a, A>
// clean up state
self.processid.map_or(Err(ErrorCode::FAIL), |id| {
self.apps
.enter(*id, |app, _| {
.enter(id, |app, _| {
self.active.set(false);
self.mode.set(AdcMode::NoMode);
app.app_buf_offset.set(0);
Expand Down Expand Up @@ -749,7 +749,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> hil::adc::Client

self.processid.map(|id| {
self.apps
.enter(*id, |_app, upcalls| {
.enter(id, |_app, upcalls| {
calledback = true;
upcalls
.schedule_upcall(
Expand All @@ -776,7 +776,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> hil::adc::Client
// perform callback
self.processid.map(|id| {
self.apps
.enter(*id, |_app, upcalls| {
.enter(id, |_app, upcalls| {
calledback = true;
upcalls
.schedule_upcall(
Expand Down Expand Up @@ -841,7 +841,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> hil::adc::HighSpeedC
// we did expect a buffer. Determine the current application state
self.processid.map(|id| {
self.apps
.enter(*id, |app, kernel_data| {
.enter(id, |app, kernel_data| {
// Get both buffers, this shouldn't ever fail since the grant was created
// with enough space. The buffer still may be empty though
let app_buf0 = match kernel_data.get_readwrite_processbuffer(0) {
Expand Down Expand Up @@ -1116,7 +1116,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> hil::adc::HighSpeedC
self.mode.set(AdcMode::NoMode);
self.processid.map(|id| {
self.apps
.enter(*id, |app, _| {
.enter(id, |app, _| {
app.app_buf_offset.set(0);
})
.map_err(|err| {
Expand Down Expand Up @@ -1171,7 +1171,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> SyscallDriver for Ad
// we need to verify that that application still exists, and remove
// it as owner if not.
if self.active.get() {
owning_app == &processid
owning_app == processid
} else {
// Check the app still exists.
//
Expand All @@ -1181,7 +1181,7 @@ impl<'a, A: hil::adc::Adc<'a> + hil::adc::AdcHighSpeed<'a>> SyscallDriver for Ad
// longer exists and we return `true` to signify the
// "or_nonexistant" case.
self.apps
.enter(*owning_app, |_, _| owning_app == &processid)
.enter(owning_app, |_, _| owning_app == processid)
.unwrap_or(true)
}
});
Expand Down
14 changes: 7 additions & 7 deletions capsules/core/src/i2c_master_slave_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ impl<'a, I: hil::i2c::I2CMasterSlave<'a>> hil::i2c::I2CHwMasterClient
self.master_buffer.replace(buffer);

self.app.map(|app| {
let _ = self.apps.enter(*app, |_, kernel_data| {
let _ = self.apps.enter(app, |_, kernel_data| {
kernel_data.schedule_upcall(0, (0, status, 0)).ok();
});
});
}

MasterAction::Read(read_len) => {
self.app.map(|app| {
let _ = self.apps.enter(*app, |_, kernel_data| {
let _ = self.apps.enter(app, |_, kernel_data| {
// Because this (somewhat incorrectly) doesn't report
// back how many bytes were read, the result of mut_enter
// is ignored. Note that this requires userspace to keep
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<'a, I: hil::i2c::I2CMasterSlave<'a>> hil::i2c::I2CHwMasterClient

MasterAction::WriteRead(read_len) => {
self.app.map(|app| {
let _ = self.apps.enter(*app, |_, kernel_data| {
let _ = self.apps.enter(app, |_, kernel_data| {
// Because this (somewhat incorrectly) doesn't report
// back how many bytes were read, the result of mut_enter
// is ignored. Note that this requires userspace to keep
Expand Down Expand Up @@ -206,7 +206,7 @@ impl<'a, I: hil::i2c::I2CMasterSlave<'a>> hil::i2c::I2CHwSlaveClient
match transmission_type {
hil::i2c::SlaveTransmissionType::Write => {
self.app.map(|app| {
let _ = self.apps.enter(*app, |_, kernel_data| {
let _ = self.apps.enter(app, |_, kernel_data| {
kernel_data
.get_readwrite_processbuffer(rw_allow::SLAVE_RX)
.and_then(|slave_rx| {
Expand Down Expand Up @@ -242,7 +242,7 @@ impl<'a, I: hil::i2c::I2CMasterSlave<'a>> hil::i2c::I2CHwSlaveClient

// Notify the app that the read finished
self.app.map(|app| {
let _ = self.apps.enter(*app, |_, kernel_data| {
let _ = self.apps.enter(app, |_, kernel_data| {
kernel_data.schedule_upcall(0, (4, length as usize, 0)).ok();
});
});
Expand All @@ -254,7 +254,7 @@ impl<'a, I: hil::i2c::I2CMasterSlave<'a>> hil::i2c::I2CHwSlaveClient
// Pass this up to the client. Not much we can do until the application
// has setup a buffer to read from.
self.app.map(|app| {
let _ = self.apps.enter(*app, |_, kernel_data| {
let _ = self.apps.enter(app, |_, kernel_data| {
// Ask the app to setup a read buffer. The app must call
// command 3 after it has setup the shared read buffer with
// the correct bytes.
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<'a, I: hil::i2c::I2CMasterSlave<'a>> SyscallDriver for I2CMasterSlaveDriver
// some (alive) process
let match_or_empty_or_nonexistant = self.app.map_or(true, |current_process| {
self.apps
.enter(*current_process, |_, _| current_process == &process_id)
.enter(current_process, |_, _| current_process == process_id)
.unwrap_or(true)
});
if match_or_empty_or_nonexistant {
Expand Down
4 changes: 2 additions & 2 deletions capsules/core/src/spi_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a, S: SpiMasterDevice<'a>> SyscallDriver for Spi<'a, S> {
// Check if this driver is free, or already dedicated to this process.
let match_or_empty_or_nonexistant = self.current_process.map_or(true, |current_process| {
self.grants
.enter(*current_process, |_, _| current_process == &process_id)
.enter(current_process, |_, _| current_process == process_id)
.unwrap_or(true)
});
if match_or_empty_or_nonexistant {
Expand Down Expand Up @@ -310,7 +310,7 @@ impl<'a, S: SpiMasterDevice<'a>> SpiMasterClient for Spi<'a, S> {
_status: Result<(), ErrorCode>,
) {
self.current_process.map(|process_id| {
let _ = self.grants.enter(*process_id, move |app, kernel_data| {
let _ = self.grants.enter(process_id, move |app, kernel_data| {
let rbuf = readbuf.map(|src| {
let index = app.index;
let _ = kernel_data
Expand Down
6 changes: 3 additions & 3 deletions capsules/core/src/spi_peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'a, S: SpiSlaveDevice<'a>> SyscallDriver for SpiPeripheral<'a, S> {
// Check if this driver is free, or already dedicated to this process.
let match_or_empty_or_nonexistant = self.current_process.map_or(true, |current_process| {
self.grants
.enter(*current_process, |_, _| current_process == &process_id)
.enter(current_process, |_, _| current_process == process_id)
.unwrap_or(true)
});
if match_or_empty_or_nonexistant {
Expand Down Expand Up @@ -272,7 +272,7 @@ impl<'a, S: SpiSlaveDevice<'a>> SpiSlaveClient for SpiPeripheral<'a, S> {
_status: Result<(), ErrorCode>,
) {
self.current_process.map(|process_id| {
let _ = self.grants.enter(*process_id, move |app, kernel_data| {
let _ = self.grants.enter(process_id, move |app, kernel_data| {
let rbuf = readbuf.map(|src| {
let index = app.index;
let _ = kernel_data
Expand Down Expand Up @@ -325,7 +325,7 @@ impl<'a, S: SpiSlaveDevice<'a>> SpiSlaveClient for SpiPeripheral<'a, S> {
// Simple callback for when chip has been selected
fn chip_selected(&self) {
self.current_process.map(|process_id| {
let _ = self.grants.enter(*process_id, move |app, kernel_data| {
let _ = self.grants.enter(process_id, move |app, kernel_data| {
let len = app.len;
kernel_data.schedule_upcall(1, (len, 0, 0)).ok();
});
Expand Down
2 changes: 1 addition & 1 deletion capsules/core/src/virtualizers/virtual_rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a> Rng<'a> for VirtualRngMasterDevice<'a> {
},
|current_node| {
// Find if current device is the one in flight or not
if *current_node == self {
if current_node == self {
self.mux.rng.cancel()
} else {
Ok(())
Expand Down
17 changes: 9 additions & 8 deletions capsules/core/src/virtualizers/virtual_uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,18 @@ impl<'a> MuxUart<'a> {
node.tx_buffer.take().map(|buf| {
node.operation.map(move |op| match op {
Operation::Transmit { len } => {
let _ = self.uart.transmit_buffer(buf, *len).map_err(
move |(ecode, buf)| {
node.tx_client.map(move |client| {
node.transmitting.set(false);
client.transmitted_buffer(buf, 0, Err(ecode));
let _ =
self.uart
.transmit_buffer(buf, len)
.map_err(move |(ecode, buf)| {
node.tx_client.map(move |client| {
node.transmitting.set(false);
client.transmitted_buffer(buf, 0, Err(ecode));
});
});
},
);
}
Operation::TransmitWord { word } => {
let rcode = self.uart.transmit_word(*word);
let rcode = self.uart.transmit_word(word);
if rcode != Ok(()) {
node.tx_client.map(|client| {
node.transmitting.set(false);
Expand Down
4 changes: 2 additions & 2 deletions capsules/extra/src/analog_comparator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a, A: hil::analog_comparator::AnalogComparator<'a>> SyscallDriver
// Check if this driver is free, or already dedicated to this process.
let match_or_empty_or_nonexistant = self.current_process.map_or(true, |current_process| {
self.grants
.enter(*current_process, |_, _| current_process == &processid)
.enter(current_process, |_, _| current_process == processid)
.unwrap_or(true)
});
if match_or_empty_or_nonexistant {
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<'a, A: hil::analog_comparator::AnalogComparator<'a>> hil::analog_comparator
/// Upcall to userland, signaling the application
fn fired(&self, channel: usize) {
self.current_process.map(|processid| {
let _ = self.grants.enter(*processid, |_app, upcalls| {
let _ = self.grants.enter(processid, |_app, upcalls| {
upcalls.schedule_upcall(0, (channel, 0, 0)).ok();
});
});
Expand Down
16 changes: 8 additions & 8 deletions capsules/extra/src/ble_advertising_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ where
{
fn receive_event(&self, buf: &'static mut [u8], len: u8, result: Result<(), ErrorCode>) {
self.receiving_app.map(|processid| {
let _ = self.app.enter(*processid, |app, kernel_data| {
let _ = self.app.enter(processid, |app, kernel_data| {
// Validate the received data, because ordinary BLE packets can be bigger than 39
// bytes. Thus, we need to check for that!
// Moreover, we use the packet header to find size but the radio reads maximum
Expand Down Expand Up @@ -521,15 +521,15 @@ where
Some(BLEState::Scanning(RadioChannel::AdvertisingChannel37)) => {
app.process_status =
Some(BLEState::Scanning(RadioChannel::AdvertisingChannel38));
self.receiving_app.set(*processid);
self.receiving_app.set(processid);
let _ = self.radio.set_tx_power(app.tx_power);
self.radio
.receive_advertisement(RadioChannel::AdvertisingChannel38);
}
Some(BLEState::Scanning(RadioChannel::AdvertisingChannel38)) => {
app.process_status =
Some(BLEState::Scanning(RadioChannel::AdvertisingChannel39));
self.receiving_app.set(*processid);
self.receiving_app.set(processid);
self.radio
.receive_advertisement(RadioChannel::AdvertisingChannel39);
}
Expand Down Expand Up @@ -558,15 +558,15 @@ where
fn transmit_event(&self, buf: &'static mut [u8], _crc_ok: Result<(), ErrorCode>) {
self.kernel_tx.replace(buf);
self.sending_app.map(|processid| {
let _ = self.app.enter(*processid, |app, kernel_data| {
let _ = self.app.enter(processid, |app, kernel_data| {
match app.process_status {
Some(BLEState::Advertising(RadioChannel::AdvertisingChannel37)) => {
app.process_status =
Some(BLEState::Advertising(RadioChannel::AdvertisingChannel38));
self.sending_app.set(*processid);
self.sending_app.set(processid);
let _ = self.radio.set_tx_power(app.tx_power);
let _ = app.send_advertisement(
*processid,
processid,
kernel_data,
&self,
RadioChannel::AdvertisingChannel38,
Expand All @@ -576,9 +576,9 @@ where
Some(BLEState::Advertising(RadioChannel::AdvertisingChannel38)) => {
app.process_status =
Some(BLEState::Advertising(RadioChannel::AdvertisingChannel39));
self.sending_app.set(*processid);
self.sending_app.set(processid);
let _ = app.send_advertisement(
*processid,
processid,
kernel_data,
&self,
RadioChannel::AdvertisingChannel39,
Expand Down
17 changes: 10 additions & 7 deletions capsules/extra/src/buzzer_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,16 @@ impl<'a, B: hil::buzzer::Buzzer<'a>> Buzzer<'a, B> {
/// to the current active_app. Otherwise, a different app is trying to
/// use the driver while it is already in use, therefore it is not valid.
pub fn is_valid_app(&self, processid: ProcessId) -> bool {
self.active_app.map_or(true, |owning_app| {
if owning_app == &processid {
true
} else {
false
}
})
self.active_app.map_or(
true,
|owning_app| {
if owning_app == processid {
true
} else {
false
}
},
)
}
}

Expand Down
Loading