Skip to contentSkip to conversation

Fixup changes to pci_epf_type_add_cfs()

PATCH In review Damien Le Moal 3 participants 6 messages May 15, 2023 – May 29, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Fixup changes to pci_epf_type_add_cfs()

A couple of patches to improve and document the changes to pci_epf_type_add_cfs() done with patch
893f14fed7d3 ("PCI: endpoint: Move pci_epf_type_add_cfs() code").

Changes from v1:
- Changed error from EINVAL to ENODEV in patch 1
- Removed spurious line in kdoc comment in patch 2

Damien Le Moal (2):
PCI: endpoint: Improve pci_epf_type_add_cfs()
PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs()

 drivers/pci/endpoint/pci-ep-cfs.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/2 PCI: endpoint: Improve pci_epf_type_add_cfs()

pci_epf_type_add_cfs() should not be called with an unbound EPF device, that is, an epf device with epf->driver not set. For such case, replace the NULL return in pci_epf_type_add_cfs() with a clear ERR_PTR(-ENODEV) pointer error return.

---
 drivers/pci/endpoint/pci-ep-cfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/pci-ep-cfs.c +1 -1
index 0fb6c376166f..0bf5be986e9b 100644
@@ -516,7 +516,7 @@ static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
 
 	if (!epf->driver) {
 		dev_err(&epf->dev, "epf device not bound to driver\n");
-		return NULL;
+		return ERR_PTR(-ENODEV);
 	}
 
 	if (!epf->driver->ops->add_cfs)
Signature · 1 line
2.40.1
#3 lore raw

PATCH v2 2/2 PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs()

In reply to Damien Le Moal

Restore an improve the kdoc function description for pci_epf_type_add_cfs() that was removed with commit 893f14fed7d3 ("PCI: endpoint: Move pci_epf_type_add_cfs() code").

Fixes 893f14fed7d3 ("PCI: endpoint: Move pci_epf_type_add_cfs() code")
---
 drivers/pci/endpoint/pci-ep-cfs.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +16 -0
index 0bf5be986e9b..be042c3f50b5 100644
@@ -509,6 +509,22 @@ static const struct config_item_type pci_epf_type = {
 	.ct_owner	= THIS_MODULE,
 };
 
+/**
+ * pci_epf_type_add_cfs() - Help function drivers to expose function specific   
+ *                          attributes in configfs
+ * @epf: the EPF device that has to be configured using configfs
+ * @group: the parent configfs group (corresponding to entries in
+ *         pci_epf_device_id)
+ *
+ * Invoke to expose function specific attributes in configfs.
+ *
+ * Return: A pointer to a config_group structure or NULL if the function driver
+ * does not have anything to expose (attributes configured by user) or if the
+ * the function driver does not implement the add_cfs() method.
+ *
+ * Returns an error pointer if this function is called for an unbound EPF device
+ * or if the EPF driver add_cfs() method fails.
+ */
 static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
 						 struct config_group *group)
 {
Signature · 1 line
2.40.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs()

In reply to Damien Le Moal
Quoted 6 lines · Damien Le Moal

pci_epf_type_add_cfs() should not be called with an unbound EPF device, that is, an epf device with epf->driver not set. For such case, replace the NULL return in pci_epf_type_add_cfs() with a clear ERR_PTR(-ENODEV) pointer error return.

- Mani

Quoted 20 lines
---
 drivers/pci/endpoint/pci-ep-cfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/pci-ep-cfs.c +1 -1
index 0fb6c376166f..0bf5be986e9b 100644
@@ -516,7 +516,7 @@ static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
 
 	if (!epf->driver) {
 		dev_err(&epf->dev, "epf device not bound to driver\n");
-		return NULL;
+		return ERR_PTR(-ENODEV);
 	}
 
 	if (!epf->driver->ops->add_cfs)
Signature · 1 line
2.40.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs()

In reply to Damien Le Moal
Quoted 6 lines · Damien Le Moal

Restore an improve the kdoc function description for pci_epf_type_add_cfs() that was removed with commit 893f14fed7d3 ("PCI: endpoint: Move pci_epf_type_add_cfs() code").

Fixes 893f14fed7d3 ("PCI: endpoint: Move pci_epf_type_add_cfs() code")

- Mani

Quoted 34 lines
---
 drivers/pci/endpoint/pci-ep-cfs.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +16 -0
index 0bf5be986e9b..be042c3f50b5 100644
@@ -509,6 +509,22 @@ static const struct config_item_type pci_epf_type = {
 	.ct_owner	= THIS_MODULE,
 };
 
+/**
+ * pci_epf_type_add_cfs() - Help function drivers to expose function specific   
+ *                          attributes in configfs
+ * @epf: the EPF device that has to be configured using configfs
+ * @group: the parent configfs group (corresponding to entries in
+ *         pci_epf_device_id)
+ *
+ * Invoke to expose function specific attributes in configfs.
+ *
+ * Return: A pointer to a config_group structure or NULL if the function driver
+ * does not have anything to expose (attributes configured by user) or if the
+ * the function driver does not implement the add_cfs() method.
+ *
+ * Returns an error pointer if this function is called for an unbound EPF device
+ * or if the EPF driver add_cfs() method fails.
+ */
 static struct config_group *pci_epf_type_add_cfs(struct pci_epf *epf,
 						 struct config_group *group)
 {
Signature · 1 line
2.40.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#5 lore raw
In reply to Damien Le Moal
Quoted 9 lines · Damien Le Moal

A couple of patches to improve and document the changes to pci_epf_type_add_cfs() done with patch
893f14fed7d3 ("PCI: endpoint: Move pci_epf_type_add_cfs() code").

Changes from v1:
- Changed error from EINVAL to ENODEV in patch 1
- Removed spurious line in kdoc comment in patch 2

[...]

Squashed second patch with the patch it was fixing and applied [1/2] to controller/endpoint, thanks!

[1/2] PCI: endpoint: Improve pci_epf_type_add_cfs()

      https://git.kernel.org/pci/pci/c/de22e068e9bb
	    //

Thanks,
Lorenzo