2021-09-15 15:14:30

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH] net/alacritech: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
And using dev_err_probe() can reduce code size, and simplify the code.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/net/ethernet/alacritech/slicoss.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/alacritech/slicoss.c b/drivers/net/ethernet/alacritech/slicoss.c
index 696517eae77f..170ff8c77983 100644
--- a/drivers/net/ethernet/alacritech/slicoss.c
+++ b/drivers/net/ethernet/alacritech/slicoss.c
@@ -1743,10 +1743,8 @@ static int slic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
int err;

err = pci_enable_device(pdev);
- if (err) {
- dev_err(&pdev->dev, "failed to enable PCI device\n");
- return err;
- }
+ if (err)
+ return dev_err_probe(&pdev->dev, err, "failed to enable PCI device\n");

pci_set_master(pdev);
pci_try_set_mwi(pdev);
--
2.25.1


2021-09-15 21:23:07

by Lino Sanfilippo

[permalink] [raw]
Subject: Re: [PATCH] net/alacritech: Make use of the helper function dev_err_probe()


Hi,

On 15.09.21 at 16:57, Cai Huoqing wrote:
> When possible use dev_err_probe help to properly deal with the
> PROBE_DEFER error, the benefit is that DEFER issue will be logged
> in the devices_deferred debugfs file.
> And using dev_err_probe() can reduce code size, and simplify the code.
>
> Signed-off-by: Cai Huoqing <[email protected]>
> ---
> drivers/net/ethernet/alacritech/slicoss.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/alacritech/slicoss.c b/drivers/net/ethernet/alacritech/slicoss.c
> index 696517eae77f..170ff8c77983 100644
> --- a/drivers/net/ethernet/alacritech/slicoss.c
> +++ b/drivers/net/ethernet/alacritech/slicoss.c
> @@ -1743,10 +1743,8 @@ static int slic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> int err;
>
> err = pci_enable_device(pdev);
> - if (err) {
> - dev_err(&pdev->dev, "failed to enable PCI device\n");
> - return err;
> - }
> + if (err)
> + return dev_err_probe(&pdev->dev, err, "failed to enable PCI device\n");
>
> pci_set_master(pdev);
> pci_try_set_mwi(pdev);
>

in which case does pci_enable_device() ever return -EPROBE_DEFER?

Regards,
Lino