linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixup changes to pci_epf_type_add_cfs()
@ 2023-05-15  5:14 Damien Le Moal
  2023-05-15  5:14 ` [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs() Damien Le Moal
  2023-05-15  5:15 ` [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs() Damien Le Moal
  0 siblings, 2 replies; 7+ messages in thread
From: Damien Le Moal @ 2023-05-15  5:14 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I, Manivannan Sadhasivami

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(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs()
  2023-05-15  5:14 [PATCH 0/2] Fixup changes to pci_epf_type_add_cfs() Damien Le Moal
@ 2023-05-15  5:14 ` Damien Le Moal
  2023-05-15  7:19   ` Manivannan Sadhasivami
  2023-05-15  5:15 ` [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs() Damien Le Moal
  1 sibling, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2023-05-15  5:14 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I, Manivannan Sadhasivami

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.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/pci/endpoint/pci-ep-cfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
index 0fb6c376166f..d8a6abe2c31c 100644
--- a/drivers/pci/endpoint/pci-ep-cfs.c
+++ b/drivers/pci/endpoint/pci-ep-cfs.c
@@ -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)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs()
  2023-05-15  5:14 [PATCH 0/2] Fixup changes to pci_epf_type_add_cfs() Damien Le Moal
  2023-05-15  5:14 ` [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs() Damien Le Moal
@ 2023-05-15  5:15 ` Damien Le Moal
  2023-05-15  7:21   ` Manivannan Sadhasivami
  1 sibling, 1 reply; 7+ messages in thread
From: Damien Le Moal @ 2023-05-15  5:15 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I, Manivannan Sadhasivami

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")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/pci/endpoint/pci-ep-cfs.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
index d8a6abe2c31c..15e17a661875 100644
--- a/drivers/pci/endpoint/pci-ep-cfs.c
+++ b/drivers/pci/endpoint/pci-ep-cfs.c
@@ -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)
 {
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs()
  2023-05-15  5:14 ` [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs() Damien Le Moal
@ 2023-05-15  7:19   ` Manivannan Sadhasivami
  2023-05-15  7:31     ` Damien Le Moal
  0 siblings, 1 reply; 7+ messages in thread
From: Manivannan Sadhasivami @ 2023-05-15  7:19 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I

On Mon, May 15, 2023 at 02:14:59PM +0900, Damien Le Moal wrote:
> 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

> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>  drivers/pci/endpoint/pci-ep-cfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
> index 0fb6c376166f..d8a6abe2c31c 100644
> --- a/drivers/pci/endpoint/pci-ep-cfs.c
> +++ b/drivers/pci/endpoint/pci-ep-cfs.c
> @@ -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)
> -- 
> 2.40.1
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs()
  2023-05-15  5:15 ` [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs() Damien Le Moal
@ 2023-05-15  7:21   ` Manivannan Sadhasivami
  2023-05-15  7:32     ` Damien Le Moal
  0 siblings, 1 reply; 7+ messages in thread
From: Manivannan Sadhasivami @ 2023-05-15  7:21 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I

On Mon, May 15, 2023 at 02:15:00PM +0900, Damien Le Moal wrote:
> 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")
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>  drivers/pci/endpoint/pci-ep-cfs.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
> index d8a6abe2c31c..15e17a661875 100644
> --- a/drivers/pci/endpoint/pci-ep-cfs.c
> +++ b/drivers/pci/endpoint/pci-ep-cfs.c
> @@ -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

Spurious?

- Mani

> + *
> + * 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)
>  {
> -- 
> 2.40.1
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs()
  2023-05-15  7:19   ` Manivannan Sadhasivami
@ 2023-05-15  7:31     ` Damien Le Moal
  0 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2023-05-15  7:31 UTC (permalink / raw)
  To: Manivannan Sadhasivami
  Cc: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I

On 5/15/23 16:19, Manivannan Sadhasivami wrote:
> On Mon, May 15, 2023 at 02:14:59PM +0900, Damien Le Moal wrote:
>> 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.

> 
> - Mani
> 
>> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
>> ---
>>  drivers/pci/endpoint/pci-ep-cfs.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
>> index 0fb6c376166f..d8a6abe2c31c 100644
>> --- a/drivers/pci/endpoint/pci-ep-cfs.c
>> +++ b/drivers/pci/endpoint/pci-ep-cfs.c
>> @@ -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)
>> -- 
>> 2.40.1
>>
> 

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs()
  2023-05-15  7:21   ` Manivannan Sadhasivami
@ 2023-05-15  7:32     ` Damien Le Moal
  0 siblings, 0 replies; 7+ messages in thread
From: Damien Le Moal @ 2023-05-15  7:32 UTC (permalink / raw)
  To: Manivannan Sadhasivami
  Cc: linux-pci, Bjorn Helgaas, Lorenzo Pieralisi,
	Kishon Vijay Abraham I

On 5/15/23 16:21, Manivannan Sadhasivami wrote:
> On Mon, May 15, 2023 at 02:15:00PM +0900, Damien Le Moal wrote:
>> 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")
>> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
>> ---
>>  drivers/pci/endpoint/pci-ep-cfs.c | 18 ++++++++++++++++++
>>  1 file changed, 18 insertions(+)
>>
>> diff --git a/drivers/pci/endpoint/pci-ep-cfs.c b/drivers/pci/endpoint/pci-ep-cfs.c
>> index d8a6abe2c31c..15e17a661875 100644
>> --- a/drivers/pci/endpoint/pci-ep-cfs.c
>> +++ b/drivers/pci/endpoint/pci-ep-cfs.c
>> @@ -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
> 
> Spurious?

Oops. Indeed. Fixing this.

> 
> - Mani
> 
>> + *
>> + * 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)
>>  {
>> -- 
>> 2.40.1
>>
> 

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-15  7:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15  5:14 [PATCH 0/2] Fixup changes to pci_epf_type_add_cfs() Damien Le Moal
2023-05-15  5:14 ` [PATCH 1/2] PCI: endpoint: Improve pci_epf_type_add_cfs() Damien Le Moal
2023-05-15  7:19   ` Manivannan Sadhasivami
2023-05-15  7:31     ` Damien Le Moal
2023-05-15  5:15 ` [PATCH 2/2] PCI: endpoint: Add kdoc description of pci_epf_type_add_cfs() Damien Le Moal
2023-05-15  7:21   ` Manivannan Sadhasivami
2023-05-15  7:32     ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).