hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/pci/endpoint/pci-ep-cfs.c
....@@ -1,5 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/**
2
+/*
33 * configfs to configure the PCI endpoint
44 *
55 * Copyright (C) 2017 Texas Instruments
....@@ -29,7 +29,6 @@
2929 struct config_group group;
3030 struct pci_epc *epc;
3131 bool start;
32
- unsigned long function_num_map;
3332 };
3433
3534 static inline struct pci_epf_group *to_pci_epf_group(struct config_item *item)
....@@ -58,6 +57,7 @@
5857
5958 if (!start) {
6059 pci_epc_stop(epc);
60
+ epc_group->start = 0;
6161 return len;
6262 }
6363
....@@ -89,37 +89,22 @@
8989 struct config_item *epf_item)
9090 {
9191 int ret;
92
- u32 func_no = 0;
9392 struct pci_epf_group *epf_group = to_pci_epf_group(epf_item);
9493 struct pci_epc_group *epc_group = to_pci_epc_group(epc_item);
9594 struct pci_epc *epc = epc_group->epc;
9695 struct pci_epf *epf = epf_group->epf;
9796
98
- func_no = find_first_zero_bit(&epc_group->function_num_map,
99
- BITS_PER_LONG);
100
- if (func_no >= BITS_PER_LONG)
101
- return -EINVAL;
102
-
103
- set_bit(func_no, &epc_group->function_num_map);
104
- epf->func_no = func_no;
105
-
10697 ret = pci_epc_add_epf(epc, epf);
10798 if (ret)
108
- goto err_add_epf;
99
+ return ret;
109100
110101 ret = pci_epf_bind(epf);
111
- if (ret)
112
- goto err_epf_bind;
102
+ if (ret) {
103
+ pci_epc_remove_epf(epc, epf);
104
+ return ret;
105
+ }
113106
114107 return 0;
115
-
116
-err_epf_bind:
117
- pci_epc_remove_epf(epc, epf);
118
-
119
-err_add_epf:
120
- clear_bit(func_no, &epc_group->function_num_map);
121
-
122
- return ret;
123108 }
124109
125110 static void pci_epc_epf_unlink(struct config_item *epc_item,
....@@ -134,7 +119,6 @@
134119
135120 epc = epc_group->epc;
136121 epf = epf_group->epf;
137
- clear_bit(epf->func_no, &epc_group->function_num_map);
138122 pci_epf_unbind(epf);
139123 pci_epc_remove_epf(epc, epf);
140124 }