Skip to content

Commit f6ec339

Browse files
damien-lemoalbjorn-helgaas
authored andcommitted
PCI: endpoint: Move pci_epf_type_add_cfs() code
pci_epf_type_add_cfs() is called only from pci_ep_cfs_add_type_group() in drivers/pci/endpoint/pci-ep-cfs.c, so there is no need to export this function. Move its code from pci-epf-core.c to pci-ep-cfs.c as a static function. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 70b3740 commit f6ec339

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

drivers/pci/endpoint/pci-ep-cfs.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,42 @@ static const struct config_item_type pci_epf_type = {
509509
.ct_owner = THIS_MODULE,
510510
};
511511

512+
/**
513+
* pci_epf_type_add_cfs() - Help function drivers to expose function specific
514+
* attributes in configfs
515+
* @epf: the EPF device that has to be configured using configfs
516+
* @group: the parent configfs group (corresponding to entries in
517+
* pci_epf_device_id)
518+
*
519+
* Invoke to expose function specific attributes in configfs.
520+
*
521+
* Return: A pointer to a config_group structure or NULL if the function driver
522+
* does not have anything to expose (attributes configured by user) or if
523+
* the function driver does not implement the add_cfs() method.
524+
*
525+
* Returns an error pointer if this function is called for an unbound EPF device
526+
* or if the EPF driver add_cfs() method fails.
527+
*/
528+
static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
529+
struct config_group *group)
530+
{
531+
struct config_group *epf_type_group;
532+
533+
if (!epf->driver) {
534+
dev_err(&epf->dev, "epf device not bound to driver\n");
535+
return NULL;
536+
}
537+
538+
if (!epf->driver->ops->add_cfs)
539+
return NULL;
540+
541+
mutex_lock(&epf->lock);
542+
epf_type_group = epf->driver->ops->add_cfs(epf, group);
543+
mutex_unlock(&epf->lock);
544+
545+
return epf_type_group;
546+
}
547+
512548
static void pci_ep_cfs_add_type_group(struct pci_epf_group *epf_group)
513549
{
514550
struct config_group *group;

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,6 @@ static DEFINE_MUTEX(pci_epf_mutex);
2020
static struct bus_type pci_epf_bus_type;
2121
static const struct device_type pci_epf_type;
2222

23-
/**
24-
* pci_epf_type_add_cfs() - Help function drivers to expose function specific
25-
* attributes in configfs
26-
* @epf: the EPF device that has to be configured using configfs
27-
* @group: the parent configfs group (corresponding to entries in
28-
* pci_epf_device_id)
29-
*
30-
* Invoke to expose function specific attributes in configfs. If the function
31-
* driver does not have anything to expose (attributes configured by user),
32-
* return NULL.
33-
*/
34-
struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
35-
struct config_group *group)
36-
{
37-
struct config_group *epf_type_group;
38-
39-
if (!epf->driver) {
40-
dev_err(&epf->dev, "epf device not bound to driver\n");
41-
return NULL;
42-
}
43-
44-
if (!epf->driver->ops->add_cfs)
45-
return NULL;
46-
47-
mutex_lock(&epf->lock);
48-
epf_type_group = epf->driver->ops->add_cfs(epf, group);
49-
mutex_unlock(&epf->lock);
50-
51-
return epf_type_group;
52-
}
53-
EXPORT_SYMBOL_GPL(pci_epf_type_add_cfs);
54-
5523
/**
5624
* pci_epf_unbind() - Notify the function driver that the binding between the
5725
* EPF device and EPC device has been lost

include/linux/pci-epf.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,6 @@ void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
214214
enum pci_epc_interface_type type);
215215
int pci_epf_bind(struct pci_epf *epf);
216216
void pci_epf_unbind(struct pci_epf *epf);
217-
struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
218-
struct config_group *group);
219217
int pci_epf_add_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf);
220218
void pci_epf_remove_vepf(struct pci_epf *epf_pf, struct pci_epf *epf_vf);
221219
#endif /* __LINUX_PCI_EPF_H */

0 commit comments

Comments
 (0)