File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -834,6 +834,8 @@ static int pci_epf_test_bind(struct pci_epf *epf)
834834 linkup_notifier = epc_features -> linkup_notifier ;
835835 core_init_notifier = epc_features -> core_init_notifier ;
836836 test_reg_bar = pci_epc_get_first_free_bar (epc_features );
837+ if (test_reg_bar < 0 )
838+ return - EINVAL ;
837839 pci_epf_configure_bar (epf , epc_features );
838840 }
839841
Original file line number Diff line number Diff line change @@ -90,8 +90,8 @@ EXPORT_SYMBOL_GPL(pci_epc_get);
9090 * Invoke to get the first unreserved BAR that can be used by the endpoint
9191 * function. For any incorrect value in reserved_bar return '0'.
9292 */
93- unsigned int pci_epc_get_first_free_bar ( const struct pci_epc_features
94- * epc_features )
93+ enum pci_barno
94+ pci_epc_get_first_free_bar ( const struct pci_epc_features * epc_features )
9595{
9696 return pci_epc_get_next_free_bar (epc_features , BAR_0 );
9797}
@@ -105,13 +105,13 @@ EXPORT_SYMBOL_GPL(pci_epc_get_first_free_bar);
105105 * Invoke to get the next unreserved BAR starting from @bar that can be used
106106 * for endpoint function. For any incorrect value in reserved_bar return '0'.
107107 */
108- unsigned int pci_epc_get_next_free_bar (const struct pci_epc_features
109- * epc_features , enum pci_barno bar )
108+ enum pci_barno pci_epc_get_next_free_bar (const struct pci_epc_features
109+ * epc_features , enum pci_barno bar )
110110{
111111 unsigned long free_bar ;
112112
113113 if (!epc_features )
114- return 0 ;
114+ return BAR_0 ;
115115
116116 /* If 'bar - 1' is a 64-bit BAR, move to the next BAR */
117117 if ((epc_features -> bar_fixed_64bit << 1 ) & 1 << bar )
@@ -126,7 +126,7 @@ unsigned int pci_epc_get_next_free_bar(const struct pci_epc_features
126126
127127 free_bar = find_next_zero_bit (& free_bar , 6 , bar );
128128 if (free_bar > 5 )
129- return 0 ;
129+ return NO_BAR ;
130130
131131 return free_bar ;
132132}
Original file line number Diff line number Diff line change @@ -201,10 +201,10 @@ int pci_epc_start(struct pci_epc *epc);
201201void pci_epc_stop (struct pci_epc * epc );
202202const struct pci_epc_features * pci_epc_get_features (struct pci_epc * epc ,
203203 u8 func_no );
204- unsigned int pci_epc_get_first_free_bar ( const struct pci_epc_features
205- * epc_features );
206- unsigned int pci_epc_get_next_free_bar (const struct pci_epc_features
207- * epc_features , enum pci_barno bar );
204+ enum pci_barno
205+ pci_epc_get_first_free_bar ( const struct pci_epc_features * epc_features );
206+ enum pci_barno pci_epc_get_next_free_bar (const struct pci_epc_features
207+ * epc_features , enum pci_barno bar );
208208struct pci_epc * pci_epc_get (const char * epc_name );
209209void pci_epc_put (struct pci_epc * epc );
210210
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ enum pci_notify_event {
2121};
2222
2323enum pci_barno {
24+ NO_BAR = -1 ,
2425 BAR_0 ,
2526 BAR_1 ,
2627 BAR_2 ,
You can’t perform that action at this time.
0 commit comments