Skip to contentSkip to conversation

Fixup changes to pci_epf_type_add_cfs()

PATCH Superseded Damien Le Moal 2 participants 7 messages May 15, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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").

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 | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH 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(-EINVAL) 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..d8a6abe2c31c 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(-EINVAL);
 	}
 
 	if (!epf->driver->ops->add_cfs)
Signature · 1 line
2.40.1
#4 lore raw

PATCH 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 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +18 -0
index d8a6abe2c31c..15e17a661875 100644
@@ -509,6 +509,24 @@ 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: NULL if the function driver
+ *
+ * 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
#2 lore raw

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

In reply to Damien Le Moal
Quoted 5 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(-EINVAL) error return.

Shouldn't the error code be -ENODEV?

- Mani

Quoted 21 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..d8a6abe2c31c 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(-EINVAL);
 	}
 
 	if (!epf->driver->ops->add_cfs)
Signature · 1 line
2.40.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#5 lore raw

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

In reply to Damien Le Moal
Quoted 18 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")
---
 drivers/pci/endpoint/pci-ep-cfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +0 -0
index d8a6abe2c31c..15e17a661875 100644
@@ -509,6 +509,24 @@ static const struct config_item_type pci_epf_type = {
 	.ct_owner	= THIS_MODULE,
 };
 

drivers/pci/endpoint/pci-ep-cfs.c static const struct config_item_type pci_epf_type = { · line 521

Quoted 10 lines
drivers/pci/endpoint/pci-ep-cfs.c +10 -0
+/**
+ * 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: NULL if the function driver

Spurious?

- Mani

Quoted 14 lines
drivers/pci/endpoint/pci-ep-cfs.c +8 -0
+ *
+ * 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
மணிவண்ணன் சதாசிவம்
#3 lore raw

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

In reply to Manivannan Sadhasivami
Quoted 8 lines · Manivannan Sadhasivami
Quoted 5 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(-EINVAL) error return.

Shouldn't the error code be -ENODEV?

Yeah, I wondered about it and settled for EINVAL... Will change to ENODEV.

Quoted 25 lines

- Mani

Quoted 21 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..d8a6abe2c31c 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(-EINVAL);
 	}
 
 	if (!epf->driver->ops->add_cfs)
Signature · 1 line
2.40.1
Signature · 2 lines
Damien Le Moal
Western Digital Research
#6 lore raw

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

In reply to Manivannan Sadhasivami
Quoted 19 lines · Manivannan Sadhasivami
Quoted 18 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")
---
 drivers/pci/endpoint/pci-ep-cfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +0 -0
index d8a6abe2c31c..15e17a661875 100644
@@ -509,6 +509,24 @@ static const struct config_item_type pci_epf_type = {
 	.ct_owner	= THIS_MODULE,
 };
 
Quoted 12 lines

drivers/pci/endpoint/pci-ep-cfs.c static const struct config_item_type pci_epf_type = { · line 521

Quoted 10 lines
drivers/pci/endpoint/pci-ep-cfs.c +10 -0
+/**
+ * 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: NULL if the function driver

Spurious?

Oops. Indeed. Fixing this.

Quoted 18 lines

- Mani

Quoted 14 lines
drivers/pci/endpoint/pci-ep-cfs.c +8 -0
+ *
+ * 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 · 2 lines
Damien Le Moal
Western Digital Research