@@ -48,7 +48,7 @@ struct Mapping {
48
48
}
49
49
50
50
impl 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 > {
52
52
let alloc = RangeAllocator :: new ( size) ?;
53
53
Ok ( Self {
54
54
address,
@@ -162,7 +162,7 @@ impl ProcessInner {
162
162
/// Returns an existing node with the given pointer and cookie, if one exists.
163
163
///
164
164
/// 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 > > > {
166
166
match self . nodes . get ( & ptr) {
167
167
None => Ok ( None ) ,
168
168
Some ( node) => {
@@ -185,7 +185,7 @@ impl ProcessInner {
185
185
cookie : usize ,
186
186
strong : bool ,
187
187
thread : Option < & Thread > ,
188
- ) -> KernelResult < Option < NodeRef > > {
188
+ ) -> Result < Option < NodeRef > > {
189
189
Ok ( match self . get_existing_node ( ptr, cookie) ? {
190
190
None => None ,
191
191
Some ( node) => Some ( self . new_node_ref ( node, strong, thread) ) ,
@@ -225,7 +225,7 @@ struct ArcReservation<T> {
225
225
}
226
226
227
227
impl < T > ArcReservation < T > {
228
- fn new ( ) -> KernelResult < Self > {
228
+ fn new ( ) -> Result < Self > {
229
229
Ok ( Self {
230
230
mem : Arc :: try_new ( MaybeUninit :: < T > :: uninit ( ) ) ?,
231
231
} )
@@ -293,7 +293,7 @@ unsafe impl Send for Process {}
293
293
unsafe impl Sync for Process { }
294
294
295
295
impl Process {
296
- fn new ( ctx : Arc < Context > ) -> KernelResult < Ref < Self > > {
296
+ fn new ( ctx : Arc < Context > ) -> Result < Ref < Self > > {
297
297
let mut proc_ref = Ref :: try_new ( Self {
298
298
ref_count : RefCount :: new ( ) ,
299
299
ctx,
@@ -338,7 +338,7 @@ impl Process {
338
338
Either :: Right ( Registration :: new ( self , thread, & mut inner) )
339
339
}
340
340
341
- fn get_thread ( & self , id : i32 ) -> KernelResult < Arc < Thread > > {
341
+ fn get_thread ( & self , id : i32 ) -> Result < Arc < Thread > > {
342
342
// TODO: Consider using read/write locks here instead.
343
343
{
344
344
let inner = self . inner . lock ( ) ;
@@ -367,7 +367,7 @@ impl Process {
367
367
self . inner . lock ( ) . push_work ( work)
368
368
}
369
369
370
- fn set_as_manager ( & self , info : Option < FlatBinderObject > , thread : & Thread ) -> KernelResult {
370
+ fn set_as_manager ( & self , info : Option < FlatBinderObject > , thread : & Thread ) -> Result {
371
371
let ( ptr, cookie) = if let Some ( obj) = info {
372
372
( unsafe { obj. __bindgen_anon_1 . binder } , obj. cookie )
373
373
} else {
@@ -390,7 +390,7 @@ impl Process {
390
390
cookie : usize ,
391
391
strong : bool ,
392
392
thread : Option < & Thread > ,
393
- ) -> KernelResult < NodeRef > {
393
+ ) -> Result < NodeRef > {
394
394
// Try to find an existing node.
395
395
{
396
396
let mut inner = self . inner . lock ( ) ;
@@ -416,7 +416,7 @@ impl Process {
416
416
& self ,
417
417
node_ref : NodeRef ,
418
418
is_mananger : bool ,
419
- ) -> KernelResult < u32 > {
419
+ ) -> Result < u32 > {
420
420
let mut refs = self . node_refs . lock ( ) ;
421
421
422
422
// Do a lookup before inserting.
@@ -475,7 +475,7 @@ impl Process {
475
475
drop ( removed) ;
476
476
}
477
477
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 {
479
479
if inc && handle == 0 {
480
480
if let Ok ( node_ref) = self . ctx . get_manager_node ( strong) {
481
481
if core:: ptr:: eq ( self , & * node_ref. node . owner ) {
@@ -514,11 +514,7 @@ impl Process {
514
514
}
515
515
}
516
516
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 {
522
518
let ptr = reader. read :: < usize > ( ) ?;
523
519
let cookie = reader. read :: < usize > ( ) ?;
524
520
self . update_node ( ptr, cookie, strong, true ) ;
@@ -539,7 +535,7 @@ impl Process {
539
535
) )
540
536
}
541
537
542
- // TODO: Review if we want an Option or a KernelResult .
538
+ // TODO: Review if we want an Option or a Result .
543
539
pub ( crate ) fn buffer_get ( & self , ptr : usize ) -> Option < Allocation > {
544
540
let mut inner = self . inner . lock ( ) ;
545
541
let mapping = inner. mapping . as_mut ( ) ?;
@@ -574,7 +570,7 @@ impl Process {
574
570
}
575
571
}
576
572
577
- fn create_mapping ( & self , vma : & mut bindings:: vm_area_struct ) -> KernelResult {
573
+ fn create_mapping ( & self , vma : & mut bindings:: vm_area_struct ) -> Result {
578
574
let size = core:: cmp:: min (
579
575
( vma. vm_end - vma. vm_start ) as usize ,
580
576
bindings:: SZ_4M as usize ,
@@ -606,7 +602,7 @@ impl Process {
606
602
Ok ( ( ) )
607
603
}
608
604
609
- fn version ( & self , data : UserSlicePtr ) -> KernelResult {
605
+ fn version ( & self , data : UserSlicePtr ) -> Result {
610
606
data. writer ( ) . write ( & BinderVersion :: current ( ) )
611
607
}
612
608
@@ -623,7 +619,7 @@ impl Process {
623
619
self . inner . lock ( ) . max_threads = max;
624
620
}
625
621
626
- fn get_node_debug_info ( & self , data : UserSlicePtr ) -> KernelResult {
622
+ fn get_node_debug_info ( & self , data : UserSlicePtr ) -> Result {
627
623
let ( mut reader, mut writer) = data. reader_writer ( ) ;
628
624
629
625
// Read the starting point.
@@ -643,7 +639,7 @@ impl Process {
643
639
writer. write ( & out)
644
640
}
645
641
646
- fn get_node_info_from_ref ( & self , data : UserSlicePtr ) -> KernelResult {
642
+ fn get_node_info_from_ref ( & self , data : UserSlicePtr ) -> Result {
647
643
let ( mut reader, mut writer) = data. reader_writer ( ) ;
648
644
let mut out = reader. read :: < BinderNodeInfoForRef > ( ) ?;
649
645
@@ -686,11 +682,7 @@ impl Process {
686
682
ret
687
683
}
688
684
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 {
694
686
let handle: u32 = reader. read ( ) ?;
695
687
let cookie: usize = reader. read ( ) ?;
696
688
@@ -733,11 +725,7 @@ impl Process {
733
725
Ok ( ( ) )
734
726
}
735
727
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 {
741
729
let handle: u32 = reader. read ( ) ?;
742
730
let cookie: usize = reader. read ( ) ?;
743
731
@@ -767,7 +755,7 @@ impl Process {
767
755
}
768
756
769
757
impl 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 > {
771
759
let thread = self . get_thread ( unsafe { rust_helper_current_pid ( ) } ) ?;
772
760
match cmd {
773
761
bindings:: BINDER_SET_MAX_THREADS => self . set_max_threads ( reader. read ( ) ?) ,
@@ -781,7 +769,7 @@ impl IoctlHandler for Process {
781
769
Ok ( 0 )
782
770
}
783
771
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 > {
785
773
let thread = self . get_thread ( unsafe { rust_helper_current_pid ( ) } ) ?;
786
774
match cmd {
787
775
bindings:: BINDER_WRITE_READ => thread. write_read ( data, file. is_blocking ( ) ) ?,
@@ -801,7 +789,7 @@ unsafe impl RefCounted for Process {
801
789
}
802
790
803
791
impl FileOpener < Arc < Context > > for Process {
804
- fn open ( ctx : & Arc < Context > ) -> KernelResult < Self :: Wrapper > {
792
+ fn open ( ctx : & Arc < Context > ) -> Result < Self :: Wrapper > {
805
793
let process = Self :: new ( ctx. clone ( ) ) ?;
806
794
// SAFETY: Pointer is pinned behind `Ref`.
807
795
Ok ( unsafe { Pin :: new_unchecked ( process) } )
@@ -892,15 +880,15 @@ impl FileOperations for Process {
892
880
}
893
881
}
894
882
895
- fn ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> KernelResult < i32 > {
883
+ fn ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> Result < i32 > {
896
884
cmd. dispatch ( self , file)
897
885
}
898
886
899
- fn compat_ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> KernelResult < i32 > {
887
+ fn compat_ioctl ( & self , file : & File , cmd : & mut IoctlCommand ) -> Result < i32 > {
900
888
cmd. dispatch ( self , file)
901
889
}
902
890
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 {
904
892
// TODO: Only group leader is allowed to create mappings.
905
893
906
894
if vma. vm_start == 0 {
@@ -918,7 +906,7 @@ impl FileOperations for Process {
918
906
self . create_mapping ( vma)
919
907
}
920
908
921
- fn poll ( & self , file : & File , table : & PollTable ) -> KernelResult < u32 > {
909
+ fn poll ( & self , file : & File , table : & PollTable ) -> Result < u32 > {
922
910
let thread = self . get_thread ( unsafe { rust_helper_current_pid ( ) } ) ?;
923
911
let ( from_proc, mut mask) = thread. poll ( file, table) ;
924
912
if mask == 0 && from_proc && !self . inner . lock ( ) . work . is_empty ( ) {
0 commit comments