@@ -48,7 +48,7 @@ struct Mapping {
4848}
4949
5050impl Mapping {
51- fn new ( address : usize , size : usize , pages : Arc < [ Pages < 0 > ] > ) -> KernelResult < Self > {
51+ fn new ( address : usize , size : usize , pages : Arc < [ Pages < 0 > ] > ) -> Result < Self > {
5252 let alloc = RangeAllocator :: new ( size) ?;
5353 Ok ( Self {
5454 address,
@@ -162,7 +162,7 @@ impl ProcessInner {
162162 /// Returns an existing node with the given pointer and cookie, if one exists.
163163 ///
164164 /// Returns an error if a node with the given pointer but a different cookie exists.
165- fn get_existing_node ( & self , ptr : usize , cookie : usize ) -> KernelResult < Option < Arc < Node > > > {
165+ fn get_existing_node ( & self , ptr : usize , cookie : usize ) -> Result < Option < Arc < Node > > > {
166166 match self . nodes . get ( & ptr) {
167167 None => Ok ( None ) ,
168168 Some ( node) => {
@@ -185,7 +185,7 @@ impl ProcessInner {
185185 cookie : usize ,
186186 strong : bool ,
187187 thread : Option < & Thread > ,
188- ) -> KernelResult < Option < NodeRef > > {
188+ ) -> Result < Option < NodeRef > > {
189189 Ok ( match self . get_existing_node ( ptr, cookie) ? {
190190 None => None ,
191191 Some ( node) => Some ( self . new_node_ref ( node, strong, thread) ) ,
@@ -225,7 +225,7 @@ struct ArcReservation<T> {
225225}
226226
227227impl < T > ArcReservation < T > {
228- fn new ( ) -> KernelResult < Self > {
228+ fn new ( ) -> Result < Self > {
229229 Ok ( Self {
230230 mem : Arc :: try_new ( MaybeUninit :: < T > :: uninit ( ) ) ?,
231231 } )
@@ -293,7 +293,7 @@ unsafe impl Send for Process {}
293293unsafe impl Sync for Process { }
294294
295295impl Process {
296- fn new ( ctx : Arc < Context > ) -> KernelResult < Ref < Self > > {
296+ fn new ( ctx : Arc < Context > ) -> Result < Ref < Self > > {
297297 let mut proc_ref = Ref :: try_new ( Self {
298298 ref_count : RefCount :: new ( ) ,
299299 ctx,
@@ -338,7 +338,7 @@ impl Process {
338338 Either :: Right ( Registration :: new ( self , thread, & mut inner) )
339339 }
340340
341- fn get_thread ( & self , id : i32 ) -> KernelResult < Arc < Thread > > {
341+ fn get_thread ( & self , id : i32 ) -> Result < Arc < Thread > > {
342342 // TODO: Consider using read/write locks here instead.
343343 {
344344 let inner = self . inner . lock ( ) ;
@@ -367,7 +367,7 @@ impl Process {
367367 self . inner . lock ( ) . push_work ( work)
368368 }
369369
370- fn set_as_manager ( & self , info : Option < FlatBinderObject > , thread : & Thread ) -> KernelResult {
370+ fn set_as_manager ( & self , info : Option < FlatBinderObject > , thread : & Thread ) -> Result {
371371 let ( ptr, cookie) = if let Some ( obj) = info {
372372 ( unsafe { obj. __bindgen_anon_1 . binder } , obj. cookie )
373373 } else {
@@ -390,7 +390,7 @@ impl Process {
390390 cookie : usize ,
391391 strong : bool ,
392392 thread : Option < & Thread > ,
393- ) -> KernelResult < NodeRef > {
393+ ) -> Result < NodeRef > {
394394 // Try to find an existing node.
395395 {
396396 let mut inner = self . inner . lock ( ) ;
@@ -416,7 +416,7 @@ impl Process {
416416 & self ,
417417 node_ref : NodeRef ,
418418 is_mananger : bool ,
419- ) -> KernelResult < u32 > {
419+ ) -> Result < u32 > {
420420 let mut refs = self . node_refs . lock ( ) ;
421421
422422 // Do a lookup before inserting.
@@ -475,7 +475,7 @@ impl Process {
475475 drop ( removed) ;
476476 }
477477
478- pub ( crate ) fn update_ref ( & self , handle : u32 , inc : bool , strong : bool ) -> KernelResult {
478+ pub ( crate ) fn update_ref ( & self , handle : u32 , inc : bool , strong : bool ) -> Result {
479479 if inc && handle == 0 {
480480 if let Ok ( node_ref) = self . ctx . get_manager_node ( strong) {
481481 if core:: ptr:: eq ( self , & * node_ref. node . owner ) {
@@ -514,11 +514,7 @@ impl Process {
514514 }
515515 }
516516
517- pub ( crate ) fn inc_ref_done (
518- & self ,
519- reader : & mut UserSlicePtrReader ,
520- strong : bool ,
521- ) -> KernelResult {
517+ pub ( crate ) fn inc_ref_done ( & self , reader : & mut UserSlicePtrReader , strong : bool ) -> Result {
522518 let ptr = reader. read :: < usize > ( ) ?;
523519 let cookie = reader. read :: < usize > ( ) ?;
524520 self . update_node ( ptr, cookie, strong, true ) ;
@@ -539,7 +535,7 @@ impl Process {
539535 ) )
540536 }
541537
542- // TODO: Review if we want an Option or a KernelResult .
538+ // TODO: Review if we want an Option or a Result .
543539 pub ( crate ) fn buffer_get ( & self , ptr : usize ) -> Option < Allocation > {
544540 let mut inner = self . inner . lock ( ) ;
545541 let mapping = inner. mapping . as_mut ( ) ?;
@@ -574,7 +570,7 @@ impl Process {
574570 }
575571 }
576572
577- fn create_mapping ( & self , vma : & mut bindings:: vm_area_struct ) -> KernelResult {
573+ fn create_mapping ( & self , vma : & mut bindings:: vm_area_struct ) -> Result {
578574 let size = core:: cmp:: min (
579575 ( vma. vm_end - vma. vm_start ) as usize ,
580576 bindings:: SZ_4M as usize ,
@@ -606,7 +602,7 @@ impl Process {
606602 Ok ( ( ) )
607603 }
608604
609- fn version ( & self , data : UserSlicePtr ) -> KernelResult {
605+ fn version ( & self , data : UserSlicePtr ) -> Result {
610606 data. writer ( ) . write ( & BinderVersion :: current ( ) )
611607 }
612608
@@ -623,7 +619,7 @@ impl Process {
623619 self . inner . lock ( ) . max_threads = max;
624620 }
625621
626- fn get_node_debug_info ( & self , data : UserSlicePtr ) -> KernelResult {
622+ fn get_node_debug_info ( & self , data : UserSlicePtr ) -> Result {
627623 let ( mut reader, mut writer) = data. reader_writer ( ) ;
628624
629625 // Read the starting point.
@@ -643,7 +639,7 @@ impl Process {
643639 writer. write ( & out)
644640 }
645641
646- fn get_node_info_from_ref ( & self , data : UserSlicePtr ) -> KernelResult {
642+ fn get_node_info_from_ref ( & self , data : UserSlicePtr ) -> Result {
647643 let ( mut reader, mut writer) = data. reader_writer ( ) ;
648644 let mut out = reader. read :: < BinderNodeInfoForRef > ( ) ?;
649645
@@ -686,11 +682,7 @@ impl Process {
686682 ret
687683 }
688684
689- pub ( crate ) fn request_death (
690- & self ,
691- reader : & mut UserSlicePtrReader ,
692- thread : & Thread ,
693- ) -> KernelResult {
685+ pub ( crate ) fn request_death ( & self , reader : & mut UserSlicePtrReader , thread : & Thread ) -> Result {
694686 let handle: u32 = reader. read ( ) ?;
695687 let cookie: usize = reader. read ( ) ?;
696688
@@ -733,11 +725,7 @@ impl Process {
733725 Ok ( ( ) )
734726 }
735727
736- pub ( crate ) fn clear_death (
737- & self ,
738- reader : & mut UserSlicePtrReader ,
739- thread : & Thread ,
740- ) -> KernelResult {
728+ pub ( crate ) fn clear_death ( & self , reader : & mut UserSlicePtrReader , thread : & Thread ) -> Result {
741729 let handle: u32 = reader. read ( ) ?;
742730 let cookie: usize = reader. read ( ) ?;
743731
@@ -767,7 +755,7 @@ impl Process {
767755}
768756
769757impl IoctlHandler for Process {
770- fn write ( & self , _file : & File , cmd : u32 , reader : & mut UserSlicePtrReader ) -> KernelResult < i32 > {
758+ fn write ( & self , _file : & File , cmd : u32 , reader : & mut UserSlicePtrReader ) -> Result < i32 > {
771759 let thread = self . get_thread ( unsafe { rust_helper_current_pid ( ) } ) ?;
772760 match cmd {
773761 bindings:: BINDER_SET_MAX_THREADS => self . set_max_threads ( reader. read ( ) ?) ,
@@ -781,7 +769,7 @@ impl IoctlHandler for Process {
781769 Ok ( 0 )
782770 }
783771
784- fn read_write ( & self , file : & File , cmd : u32 , data : UserSlicePtr ) -> KernelResult < i32 > {
772+ fn read_write ( & self , file : & File , cmd : u32 , data : UserSlicePtr ) -> Result < i32 > {
785773 let thread = self . get_thread ( unsafe { rust_helper_current_pid ( ) } ) ?;
786774 match cmd {
787775 bindings:: BINDER_WRITE_READ => thread. write_read ( data, file. is_blocking ( ) ) ?,
@@ -801,7 +789,7 @@ unsafe impl RefCounted for Process {
801789}
802790
803791impl FileOpener < Arc < Context > > for Process {
804- fn open ( ctx : & Arc < Context > ) -> KernelResult < Self :: Wrapper > {
792+ fn open ( ctx : & Arc < Context > ) -> Result < Self :: Wrapper > {
805793 let process = Self :: new ( ctx. clone ( ) ) ?;
806794 // SAFETY: Pointer is pinned behind `Ref`.
807795 Ok ( unsafe { Pin :: new_unchecked ( process) } )
@@ -892,15 +880,15 @@ impl FileOperations for Process {
892880 }
893881 }
894882
895- fn ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> KernelResult < i32 > {
883+ fn ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> Result < i32 > {
896884 cmd. dispatch ( self , file)
897885 }
898886
899- fn compat_ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> KernelResult < i32 > {
887+ fn compat_ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> Result < i32 > {
900888 cmd. dispatch ( self , file)
901889 }
902890
903- fn mmap ( & self , _file : & File , vma : & mut bindings:: vm_area_struct ) -> KernelResult {
891+ fn mmap ( & self , _file : & File , vma : & mut bindings:: vm_area_struct ) -> Result {
904892 // TODO: Only group leader is allowed to create mappings.
905893
906894 if vma. vm_start == 0 {
@@ -918,7 +906,7 @@ impl FileOperations for Process {
918906 self . create_mapping ( vma)
919907 }
920908
921- fn poll ( & self , file : & File , table : & PollTable ) -> KernelResult < u32 > {
909+ fn poll ( & self , file : & File , table : & PollTable ) -> Result < u32 > {
922910 let thread = self . get_thread ( unsafe { rust_helper_current_pid ( ) } ) ?;
923911 let ( from_proc, mut mask) = thread. poll ( file, table) ;
924912 if mask == 0 && from_proc && !self . inner . lock ( ) . work . is_empty ( ) {
0 commit comments