16
16
void efi_pci_disable_bridge_busmaster (void )
17
17
{
18
18
efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID ;
19
- unsigned long pci_handle_size = 0 ;
20
- efi_handle_t * pci_handle = NULL ;
19
+ efi_handle_t * pci_handle __free ( efi_pool ) = NULL ;
20
+ unsigned long pci_handle_num ;
21
21
efi_handle_t handle ;
22
22
efi_status_t status ;
23
23
u16 class , command ;
24
24
25
- status = efi_bs_call (locate_handle , EFI_LOCATE_BY_PROTOCOL , & pci_proto ,
26
- NULL , & pci_handle_size , NULL );
27
-
28
- if (status != EFI_BUFFER_TOO_SMALL ) {
29
- if (status != EFI_SUCCESS && status != EFI_NOT_FOUND )
30
- efi_err ("Failed to locate PCI I/O handles'\n" );
31
- return ;
32
- }
33
-
34
- status = efi_bs_call (allocate_pool , EFI_LOADER_DATA , pci_handle_size ,
35
- (void * * )& pci_handle );
25
+ status = efi_bs_call (locate_handle_buffer , EFI_LOCATE_BY_PROTOCOL ,
26
+ & pci_proto , NULL , & pci_handle_num , & pci_handle );
36
27
if (status != EFI_SUCCESS ) {
37
- efi_err ("Failed to allocate memory for 'pci_handle' \n" );
28
+ efi_err ("Failed to locate PCI I/O handles \n" );
38
29
return ;
39
30
}
40
31
41
- status = efi_bs_call (locate_handle , EFI_LOCATE_BY_PROTOCOL , & pci_proto ,
42
- NULL , & pci_handle_size , pci_handle );
43
- if (status != EFI_SUCCESS ) {
44
- efi_err ("Failed to locate PCI I/O handles'\n" );
45
- goto free_handle ;
46
- }
47
-
48
- for_each_efi_handle (handle , pci_handle , efi_get_handle_num (pci_handle_size )) {
32
+ for_each_efi_handle (handle , pci_handle , pci_handle_num ) {
49
33
efi_pci_io_protocol_t * pci ;
50
34
unsigned long segment_nr , bus_nr , device_nr , func_nr ;
51
35
@@ -81,7 +65,7 @@ void efi_pci_disable_bridge_busmaster(void)
81
65
efi_bs_call (disconnect_controller , handle , NULL , NULL );
82
66
}
83
67
84
- for_each_efi_handle (handle , pci_handle , efi_get_handle_num ( pci_handle_size ) ) {
68
+ for_each_efi_handle (handle , pci_handle , pci_handle_num ) {
85
69
efi_pci_io_protocol_t * pci ;
86
70
87
71
status = efi_bs_call (handle_protocol , handle , & pci_proto ,
@@ -107,7 +91,4 @@ void efi_pci_disable_bridge_busmaster(void)
107
91
if (status != EFI_SUCCESS )
108
92
efi_err ("Failed to disable PCI busmastering\n" );
109
93
}
110
-
111
- free_handle :
112
- efi_bs_call (free_pool , pci_handle );
113
94
}
0 commit comments