Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: plda: Remove the use of dev_err_probe()
@ 2025-08-20  8:52 Xichao Zhao
  2025-09-08 10:13 ` Manivannan Sadhasivam
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Xichao Zhao @ 2025-08-20  8:52 UTC (permalink / raw)
  To: daire.mcnamara, lpieralisi, kwilczynski, mani, bhelgaas
  Cc: robh, linux-pci, linux-kernel, Xichao Zhao

The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just
return the value instead.

Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
---
 drivers/pci/controller/plda/pcie-plda-host.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c
index 8e2db2e5b64b..3c2f68383010 100644
--- a/drivers/pci/controller/plda/pcie-plda-host.c
+++ b/drivers/pci/controller/plda/pcie-plda-host.c
@@ -599,8 +599,7 @@ int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops,
 
 	bridge = devm_pci_alloc_host_bridge(dev, 0);
 	if (!bridge)
-		return dev_err_probe(dev, -ENOMEM,
-				     "failed to alloc bridge\n");
+		return -ENOMEM;
 
 	if (port->host_ops && port->host_ops->host_init) {
 		ret = port->host_ops->host_init(port);
-- 
2.34.1


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

* Re: [PATCH] PCI: plda: Remove the use of dev_err_probe()
  2025-08-20  8:52 [PATCH] PCI: plda: Remove the use of dev_err_probe() Xichao Zhao
@ 2025-09-08 10:13 ` Manivannan Sadhasivam
  2025-09-15 13:25   ` [External] : " ALOK TIWARI
  2025-09-08 10:16 ` Manivannan Sadhasivam
  2025-09-12 22:09 ` Bjorn Helgaas
  2 siblings, 1 reply; 7+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-08 10:13 UTC (permalink / raw)
  To: Xichao Zhao
  Cc: daire.mcnamara, lpieralisi, kwilczynski, bhelgaas, robh,
	linux-pci, linux-kernel

On Wed, Aug 20, 2025 at 04:52:00PM GMT, Xichao Zhao wrote:
> The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
> Therefore, remove the useless call to dev_err_probe(), and just
> return the value instead.
> 

Change is fine as it is. But I think devm_pci_alloc_host_bridge() should return
the actual error pointer instead of NULL and let the callers guess the errno.

Callers are using both -ENOMEM and -ENODEV, both of then will mask the actual
errno that caused the failure.

Cleanup task for someone interested :)

- Mani

> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
>  drivers/pci/controller/plda/pcie-plda-host.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c
> index 8e2db2e5b64b..3c2f68383010 100644
> --- a/drivers/pci/controller/plda/pcie-plda-host.c
> +++ b/drivers/pci/controller/plda/pcie-plda-host.c
> @@ -599,8 +599,7 @@ int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops,
>  
>  	bridge = devm_pci_alloc_host_bridge(dev, 0);
>  	if (!bridge)
> -		return dev_err_probe(dev, -ENOMEM,
> -				     "failed to alloc bridge\n");
> +		return -ENOMEM;
>  
>  	if (port->host_ops && port->host_ops->host_init) {
>  		ret = port->host_ops->host_init(port);
> -- 
> 2.34.1
> 

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

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

* Re: [PATCH] PCI: plda: Remove the use of dev_err_probe()
  2025-08-20  8:52 [PATCH] PCI: plda: Remove the use of dev_err_probe() Xichao Zhao
  2025-09-08 10:13 ` Manivannan Sadhasivam
@ 2025-09-08 10:16 ` Manivannan Sadhasivam
  2025-09-12 22:09 ` Bjorn Helgaas
  2 siblings, 0 replies; 7+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-08 10:16 UTC (permalink / raw)
  To: Xichao Zhao
  Cc: daire.mcnamara, lpieralisi, kwilczynski, bhelgaas, robh,
	linux-pci, linux-kernel

On Wed, Aug 20, 2025 at 04:52:00PM GMT, Xichao Zhao wrote:
> The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
> Therefore, remove the useless call to dev_err_probe(), and just
> return the value instead.
> 
> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>

Applied to pci/controller/plda!

- Mani

> ---
>  drivers/pci/controller/plda/pcie-plda-host.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c
> index 8e2db2e5b64b..3c2f68383010 100644
> --- a/drivers/pci/controller/plda/pcie-plda-host.c
> +++ b/drivers/pci/controller/plda/pcie-plda-host.c
> @@ -599,8 +599,7 @@ int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops,
>  
>  	bridge = devm_pci_alloc_host_bridge(dev, 0);
>  	if (!bridge)
> -		return dev_err_probe(dev, -ENOMEM,
> -				     "failed to alloc bridge\n");
> +		return -ENOMEM;
>  
>  	if (port->host_ops && port->host_ops->host_init) {
>  		ret = port->host_ops->host_init(port);
> -- 
> 2.34.1
> 

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

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

* Re: [PATCH] PCI: plda: Remove the use of dev_err_probe()
  2025-08-20  8:52 [PATCH] PCI: plda: Remove the use of dev_err_probe() Xichao Zhao
  2025-09-08 10:13 ` Manivannan Sadhasivam
  2025-09-08 10:16 ` Manivannan Sadhasivam
@ 2025-09-12 22:09 ` Bjorn Helgaas
  2 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2025-09-12 22:09 UTC (permalink / raw)
  To: Xichao Zhao
  Cc: daire.mcnamara, lpieralisi, kwilczynski, mani, bhelgaas, robh,
	linux-pci, linux-kernel

On Wed, Aug 20, 2025 at 04:52:00PM +0800, Xichao Zhao wrote:
> The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
> Therefore, remove the useless call to dev_err_probe(), and just
> return the value instead.

Seems sort of weird to avoid dev_err_probe(-ENOMEM) because we have
internal knowledge that dev_err_probe() does nothing in that case.

It leads to patterns where the first few things in a .probe() function
return -ENOMEM directly and later things use dev_err_probe(), and
there's no obvious reason for the difference.

But it's very common, so I guess it's OK with me to follow the common
pattern even though it's a bit strange.

> Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com>
> ---
>  drivers/pci/controller/plda/pcie-plda-host.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c
> index 8e2db2e5b64b..3c2f68383010 100644
> --- a/drivers/pci/controller/plda/pcie-plda-host.c
> +++ b/drivers/pci/controller/plda/pcie-plda-host.c
> @@ -599,8 +599,7 @@ int plda_pcie_host_init(struct plda_pcie_rp *port, struct pci_ops *ops,
>  
>  	bridge = devm_pci_alloc_host_bridge(dev, 0);
>  	if (!bridge)
> -		return dev_err_probe(dev, -ENOMEM,
> -				     "failed to alloc bridge\n");
> +		return -ENOMEM;
>  
>  	if (port->host_ops && port->host_ops->host_init) {
>  		ret = port->host_ops->host_init(port);
> -- 
> 2.34.1
> 

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

* Re: [External] : Re: [PATCH] PCI: plda: Remove the use of dev_err_probe()
  2025-09-08 10:13 ` Manivannan Sadhasivam
@ 2025-09-15 13:25   ` ALOK TIWARI
  2025-09-15 14:07     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 7+ messages in thread
From: ALOK TIWARI @ 2025-09-15 13:25 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: daire.mcnamara, lpieralisi, kwilczynski, bhelgaas, robh,
	linux-pci, linux-kernel, Xichao Zhao

Hi Mani,

On 9/8/2025 3:43 PM, Manivannan Sadhasivam wrote:
> On Wed, Aug 20, 2025 at 04:52:00PM GMT, Xichao Zhao wrote:
>> The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
>> Therefore, remove the useless call to dev_err_probe(), and just
>> return the value instead.
>>
> 
> Change is fine as it is. But I think devm_pci_alloc_host_bridge() should return
> the actual error pointer instead of NULL and let the callers guess the errno.
> 
> Callers are using both -ENOMEM and -ENODEV, both of then will mask the actual
> errno that caused the failure.
> 
> Cleanup task for someone interested :)
> 
> - Mani

Did you really intend to do that,
Should that be an RFC (for cleanup task) patch ?

Thanks,
Alok

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

* Re: [External] : Re: [PATCH] PCI: plda: Remove the use of dev_err_probe()
  2025-09-15 13:25   ` [External] : " ALOK TIWARI
@ 2025-09-15 14:07     ` Manivannan Sadhasivam
  2025-09-15 19:10       ` ALOK TIWARI
  0 siblings, 1 reply; 7+ messages in thread
From: Manivannan Sadhasivam @ 2025-09-15 14:07 UTC (permalink / raw)
  To: ALOK TIWARI
  Cc: daire.mcnamara, lpieralisi, kwilczynski, bhelgaas, robh,
	linux-pci, linux-kernel, Xichao Zhao

On Mon, Sep 15, 2025 at 06:55:29PM GMT, ALOK TIWARI wrote:
> Hi Mani,
> 
> On 9/8/2025 3:43 PM, Manivannan Sadhasivam wrote:
> > On Wed, Aug 20, 2025 at 04:52:00PM GMT, Xichao Zhao wrote:
> > > The dev_err_probe() doesn't do anything when error is '-ENOMEM'.
> > > Therefore, remove the useless call to dev_err_probe(), and just
> > > return the value instead.
> > > 
> > 
> > Change is fine as it is. But I think devm_pci_alloc_host_bridge() should return
> > the actual error pointer instead of NULL and let the callers guess the errno.
> > 
> > Callers are using both -ENOMEM and -ENODEV, both of then will mask the actual
> > errno that caused the failure.
> > 
> > Cleanup task for someone interested :)
> > 
> > - Mani
> 
> Did you really intend to do that,

No, I don't have bandwidth right now.

> Should that be an RFC (for cleanup task) patch ?
> 

No need of RFC.

- Mani

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

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

* Re: [External] : Re: [PATCH] PCI: plda: Remove the use of dev_err_probe()
  2025-09-15 14:07     ` Manivannan Sadhasivam
@ 2025-09-15 19:10       ` ALOK TIWARI
  0 siblings, 0 replies; 7+ messages in thread
From: ALOK TIWARI @ 2025-09-15 19:10 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: daire.mcnamara, lpieralisi, kwilczynski, bhelgaas, robh,
	linux-pci, linux-kernel, Xichao Zhao



On 9/15/2025 7:37 PM, Manivannan Sadhasivam wrote:
>>> Change is fine as it is. But I think devm_pci_alloc_host_bridge() should return
>>> the actual error pointer instead of NULL and let the callers guess the errno.
>>>
>>> Callers are using both -ENOMEM and -ENODEV, both of then will mask the actual
>>> errno that caused the failure.
>>>
>>> Cleanup task for someone interested 🙂
>>>
>>> - Mani
>> Did you really intend to do that,
> No, I don't have bandwidth right now.
> 
>> Should that be an RFC (for cleanup task) patch ?

I am planning to send a patch for this cleanup.
It will touch all files under drivers/pci/controller/,
and I hope it will be useful.

Thanks,
Alok

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

end of thread, other threads:[~2025-09-15 19:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20  8:52 [PATCH] PCI: plda: Remove the use of dev_err_probe() Xichao Zhao
2025-09-08 10:13 ` Manivannan Sadhasivam
2025-09-15 13:25   ` [External] : " ALOK TIWARI
2025-09-15 14:07     ` Manivannan Sadhasivam
2025-09-15 19:10       ` ALOK TIWARI
2025-09-08 10:16 ` Manivannan Sadhasivam
2025-09-12 22:09 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox