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: Add pci_epf_ops to expose function-specific attrs

In addition to the attributes that are generic across function drivers
documented in Documentation/PCI/endpoint/pci-endpoint-cfs.rst, there could
be function-specific attributes that has to be exposed by the function
driver to be configured by the user. Add ->add_cfs() in pci_epf_ops to be
populated by the function driver if it has to expose any function-specific
attributes and pci_epf_type_add_cfs() to be invoked by pci-ep-cfs.c when
sub-directory to main function directory is created.

Link: https://lore.kernel.org/r/20210201195809.7342-10-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
256ae475 87d5972e

+37
+32
drivers/pci/endpoint/pci-epf-core.c
··· 21 21 static const struct device_type pci_epf_type; 22 22 23 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 + 55 + /** 24 56 * pci_epf_unbind() - Notify the function driver that the binding between the 25 57 * EPF device and EPC device has been lost 26 58 * @epf: the EPF device which has lost the binding with the EPC device
+5
include/linux/pci-epf.h
··· 62 62 * @bind: ops to perform when a EPC device has been bound to EPF device 63 63 * @unbind: ops to perform when a binding has been lost between a EPC device 64 64 * and EPF device 65 + * @add_cfs: ops to initialize function specific configfs attributes 65 66 */ 66 67 struct pci_epf_ops { 67 68 int (*bind)(struct pci_epf *epf); 68 69 void (*unbind)(struct pci_epf *epf); 70 + struct config_group *(*add_cfs)(struct pci_epf *epf, 71 + struct config_group *group); 69 72 }; 70 73 71 74 /** ··· 191 188 enum pci_epc_interface_type type); 192 189 int pci_epf_bind(struct pci_epf *epf); 193 190 void pci_epf_unbind(struct pci_epf *epf); 191 + struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf, 192 + struct config_group *group); 194 193 #endif /* __LINUX_PCI_EPF_H */