Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: endpoint: Make *_free_bar() to return error codes on failure

Modify pci_epc_get_next_free_bar() and pci_epc_get_first_free_bar() to
return error values if there are no free BARs available.

Link: https://lore.kernel.org/r/20210201195809.7342-5-kishon@ti.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Kishon Vijay Abraham I and committed by
Bjorn Helgaas
0e27aecc fa8fef0e

+13 -10
+2
drivers/pci/endpoint/functions/pci-epf-test.c
··· 834 834 linkup_notifier = epc_features->linkup_notifier; 835 835 core_init_notifier = epc_features->core_init_notifier; 836 836 test_reg_bar = pci_epc_get_first_free_bar(epc_features); 837 + if (test_reg_bar < 0) 838 + return -EINVAL; 837 839 pci_epf_configure_bar(epf, epc_features); 838 840 } 839 841
+6 -6
drivers/pci/endpoint/pci-epc-core.c
··· 90 90 * Invoke to get the first unreserved BAR that can be used by the endpoint 91 91 * function. For any incorrect value in reserved_bar return '0'. 92 92 */ 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) 95 95 { 96 96 return pci_epc_get_next_free_bar(epc_features, BAR_0); 97 97 } ··· 105 105 * Invoke to get the next unreserved BAR starting from @bar that can be used 106 106 * for endpoint function. For any incorrect value in reserved_bar return '0'. 107 107 */ 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) 110 110 { 111 111 unsigned long free_bar; 112 112 113 113 if (!epc_features) 114 - return 0; 114 + return BAR_0; 115 115 116 116 /* If 'bar - 1' is a 64-bit BAR, move to the next BAR */ 117 117 if ((epc_features->bar_fixed_64bit << 1) & 1 << bar) ··· 126 126 127 127 free_bar = find_next_zero_bit(&free_bar, 6, bar); 128 128 if (free_bar > 5) 129 - return 0; 129 + return NO_BAR; 130 130 131 131 return free_bar; 132 132 }
+4 -4
include/linux/pci-epc.h
··· 201 201 void pci_epc_stop(struct pci_epc *epc); 202 202 const struct pci_epc_features *pci_epc_get_features(struct pci_epc *epc, 203 203 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); 208 208 struct pci_epc *pci_epc_get(const char *epc_name); 209 209 void pci_epc_put(struct pci_epc *epc); 210 210
+1
include/linux/pci-epf.h
··· 21 21 }; 22 22 23 23 enum pci_barno { 24 + NO_BAR = -1, 24 25 BAR_0, 25 26 BAR_1, 26 27 BAR_2,