File tree Expand file tree Collapse file tree 4 files changed +13
-27
lines changed Expand file tree Collapse file tree 4 files changed +13
-27
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ bitflags = "2"
120120build-time = " 0.1.3"
121121cfg-if = " 1"
122122crossbeam-utils = { version = " 0.8" , default-features = false }
123- embedded-io = " 0.7"
123+ embedded-io = { version = " 0.7" , features = [ " alloc " ] }
124124enum_dispatch = " 0.3"
125125fdt = { version = " 0.1" , features = [" pretty-printing" ] }
126126free-list = " 0.3"
Original file line number Diff line number Diff line change @@ -59,25 +59,13 @@ impl ErrorType for SerialDevice {
5959
6060impl Read for SerialDevice {
6161 fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > {
62- let mut guard = UART_DEVICE . lock ( ) ;
63-
64- if guard. buffer . is_empty ( ) {
65- Ok ( 0 )
66- } else {
67- let min = buf. len ( ) . min ( guard. buffer . len ( ) ) ;
68-
69- for ( dst, src) in buf[ ..min] . iter_mut ( ) . zip ( guard. buffer . drain ( ..min) ) {
70- * dst = src;
71- }
72-
73- Ok ( min)
74- }
62+ Ok ( UART_DEVICE . lock ( ) . buffer . read ( buf) ?)
7563 }
7664}
7765
7866impl ReadReady for SerialDevice {
7967 fn read_ready ( & mut self ) -> Result < bool , Self :: Error > {
80- Ok ( ! UART_DEVICE . lock ( ) . buffer . is_empty ( ) )
68+ Ok ( UART_DEVICE . lock ( ) . buffer . read_ready ( ) ? )
8169 }
8270}
8371
Original file line number Diff line number Diff line change 11use alloc:: collections:: VecDeque ;
2- use alloc:: vec:: Vec ;
32
43use embedded_io:: { ErrorType , Read , ReadReady , Write } ;
54use hermit_sync:: { InterruptTicketMutex , Lazy } ;
@@ -52,22 +51,13 @@ impl ErrorType for SerialDevice {
5251
5352impl Read for SerialDevice {
5453 fn read ( & mut self , buf : & mut [ u8 ] ) -> Result < usize , Self :: Error > {
55- let mut guard = UART_DEVICE . lock ( ) ;
56- if guard. buffer . is_empty ( ) {
57- Ok ( 0 )
58- } else {
59- let min = core:: cmp:: min ( buf. len ( ) , guard. buffer . len ( ) ) ;
60- let drained = guard. buffer . drain ( ..min) . collect :: < Vec < _ > > ( ) ;
61- buf[ ..min] . copy_from_slice ( drained. as_slice ( ) ) ;
62- Ok ( min)
63- }
54+ Ok ( UART_DEVICE . lock ( ) . buffer . read ( buf) ?)
6455 }
6556}
6657
6758impl ReadReady for SerialDevice {
6859 fn read_ready ( & mut self ) -> Result < bool , Self :: Error > {
69- let read_ready = !UART_DEVICE . lock ( ) . buffer . is_empty ( ) ;
70- Ok ( read_ready)
60+ Ok ( UART_DEVICE . lock ( ) . buffer . read_ready ( ) ?)
7161 }
7262}
7363
Original file line number Diff line number Diff line change 11//! System error numbers.
22
3+ use core:: convert:: Infallible ;
4+
35use num_enum:: { IntoPrimitive , TryFromPrimitive } ;
46use thiserror:: Error ;
57
@@ -669,6 +671,12 @@ pub enum Errno {
669671 Hwpoison = 133 ,
670672}
671673
674+ impl From < Infallible > for Errno {
675+ fn from ( value : Infallible ) -> Self {
676+ match value { }
677+ }
678+ }
679+
672680/// Returns the pointer to `errno`.
673681#[ cfg( all(
674682 not( any( feature = "common-os" , feature = "nostd" ) ) ,
You can’t perform that action at this time.
0 commit comments