File tree 1 file changed +9
-11
lines changed
1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,13 @@ pub fn find_protocol<P: Protocol>() -> Option<ptr::NonNull<P>> {
43
43
let bt = boot_services ( ) ;
44
44
45
45
// Retrieve a handle implementing the protocol.
46
- let handle = {
47
- // Allocate space for 1 handle.
48
- let mut buffer = [ ptr:: null_mut ( ) ; 1 ] ;
49
-
50
- let search_type = boot:: SearchType :: from_proto :: < P > ( ) ;
51
-
52
- bt. locate_handle ( search_type, Some ( & mut buffer) ) . ok ( )
53
- . and_then ( |len| if len == 1 { Some ( buffer[ 0 ] ) } else { None } ) ?
54
- } ;
55
-
56
- bt. handle_protocol :: < P > ( handle)
46
+ // Note: using the `find_handles` function might not return _only_ compatible protocols.
47
+ // We have to retrieve them all and find one that works.
48
+ let handles = find_handles :: < P > ( ) . ok ( ) ?;
49
+
50
+ handles. iter ( )
51
+ . map ( |& handle| bt. handle_protocol :: < P > ( handle) )
52
+ . filter ( Option :: is_some)
53
+ . next ( )
54
+ . unwrap_or ( None )
57
55
}
You can’t perform that action at this time.
0 commit comments