diff options
Diffstat (limited to 'devices/src')
-rw-r--r-- | devices/src/pci/pci_configuration.rs | 7 | ||||
-rw-r--r-- | devices/src/pci/pci_root.rs | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/devices/src/pci/pci_configuration.rs b/devices/src/pci/pci_configuration.rs index e65dd85..5e268fe 100644 --- a/devices/src/pci/pci_configuration.rs +++ b/devices/src/pci/pci_configuration.rs @@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use byteorder::{ByteOrder, LittleEndian}; - +use std::convert::TryInto; use std::fmt::{self, Display}; use crate::pci::PciInterruptPin; @@ -300,8 +299,8 @@ impl PciConfiguration { let reg_offset = reg_idx * 4 + offset as usize; match data.len() { 1 => self.write_byte(reg_offset, data[0]), - 2 => self.write_word(reg_offset, LittleEndian::read_u16(data)), - 4 => self.write_dword(reg_offset, LittleEndian::read_u32(data)), + 2 => self.write_word(reg_offset, u16::from_le_bytes(data.try_into().unwrap())), + 4 => self.write_dword(reg_offset, u32::from_le_bytes(data.try_into().unwrap())), _ => (), } } diff --git a/devices/src/pci/pci_root.rs b/devices/src/pci/pci_root.rs index 300b951..eef642e 100644 --- a/devices/src/pci/pci_root.rs +++ b/devices/src/pci/pci_root.rs @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +use std::convert::TryInto; use std::os::unix::io::RawFd; use std::sync::Arc; -use byteorder::{ByteOrder, LittleEndian}; use sync::Mutex; use crate::pci::pci_configuration::{ @@ -184,9 +184,9 @@ impl PciConfigIo { ), 2 => ( 0x0000_ffff << (offset * 16), - ((data[1] as u32) << 8 | data[0] as u32) << (offset * 16), + u32::from(u16::from_le_bytes(data.try_into().unwrap())) << (offset * 16), ), - 4 => (0xffff_ffff, LittleEndian::read_u32(data)), + 4 => (0xffff_ffff, u32::from_le_bytes(data.try_into().unwrap())), _ => return, }; self.config_address = (self.config_address & !mask) | value; |