Skip to content

Commit ef1433f

Browse files
kishonLorenzo Pieralisi
authored andcommitted
PCI: endpoint: Create configfs entry for each pci_epf_device_id table entry
In order to be able to provide correct driver_data for pci_epf device, a separate configfs entry for each pci_epf_device_id table entry in pci_epf_driver is required. Add support to create configfs entry for each pci_epf_device_id table entry here. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Tested-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
1 parent ecc57ef commit ef1433f

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

drivers/pci/endpoint/pci-epf-core.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <linux/pci-epf.h>
1616
#include <linux/pci-ep-cfs.h>
1717

18+
static DEFINE_MUTEX(pci_epf_mutex);
19+
1820
static struct bus_type pci_epf_bus_type;
1921
static const struct device_type pci_epf_type;
2022

@@ -143,7 +145,13 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space);
143145
*/
144146
void pci_epf_unregister_driver(struct pci_epf_driver *driver)
145147
{
146-
pci_ep_cfs_remove_epf_group(driver->group);
148+
struct config_group *group;
149+
150+
mutex_lock(&pci_epf_mutex);
151+
list_for_each_entry(group, &driver->epf_group, group_entry)
152+
pci_ep_cfs_remove_epf_group(group);
153+
list_del(&driver->epf_group);
154+
mutex_unlock(&pci_epf_mutex);
147155
driver_unregister(&driver->driver);
148156
}
149157
EXPORT_SYMBOL_GPL(pci_epf_unregister_driver);
@@ -159,6 +167,8 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver,
159167
struct module *owner)
160168
{
161169
int ret;
170+
struct config_group *group;
171+
const struct pci_epf_device_id *id;
162172

163173
if (!driver->ops)
164174
return -EINVAL;
@@ -173,7 +183,16 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver,
173183
if (ret)
174184
return ret;
175185

176-
driver->group = pci_ep_cfs_add_epf_group(driver->driver.name);
186+
INIT_LIST_HEAD(&driver->epf_group);
187+
188+
id = driver->id_table;
189+
while (id->name[0]) {
190+
group = pci_ep_cfs_add_epf_group(id->name);
191+
mutex_lock(&pci_epf_mutex);
192+
list_add_tail(&group->group_entry, &driver->epf_group);
193+
mutex_unlock(&pci_epf_mutex);
194+
id++;
195+
}
177196

178197
return 0;
179198
}

include/linux/pci-epf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct pci_epf_ops {
7272
* @driver: PCI EPF driver
7373
* @ops: set of function pointers for performing EPF operations
7474
* @owner: the owner of the module that registers the PCI EPF driver
75-
* @group: configfs group corresponding to the PCI EPF driver
75+
* @epf_group: list of configfs group corresponding to the PCI EPF driver
7676
* @id_table: identifies EPF devices for probing
7777
*/
7878
struct pci_epf_driver {
@@ -82,7 +82,7 @@ struct pci_epf_driver {
8282
struct device_driver driver;
8383
struct pci_epf_ops *ops;
8484
struct module *owner;
85-
struct config_group *group;
85+
struct list_head epf_group;
8686
const struct pci_epf_device_id *id_table;
8787
};
8888

0 commit comments

Comments
 (0)