* [PATCH net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one()
@ 2023-05-31 20:41 Heiner Kallweit
2023-06-01 15:44 ` Simon Horman
2023-06-02 5:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2023-05-31 20:41 UTC (permalink / raw)
To: Jakub Kicinski, David Miller, Realtek linux nic maintainers,
Eric Dumazet, Paolo Abeni
Cc: netdev@vger.kernel.org
In addition to properly handling probe deferrals dev_err_probe()
conveniently combines printing an error message with returning
the errno. So let's use it for every error path in rtl_init_one()
to simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/ethernet/realtek/r8169_main.c | 40 +++++++++--------------
1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 5e6308d57..9445f04f8 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5196,44 +5196,35 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
/* enable device (incl. PCI PM wakeup and hotplug setup) */
rc = pcim_enable_device(pdev);
- if (rc < 0) {
- dev_err(&pdev->dev, "enable failure\n");
- return rc;
- }
+ if (rc < 0)
+ return dev_err_probe(&pdev->dev, rc, "enable failure\n");
if (pcim_set_mwi(pdev) < 0)
dev_info(&pdev->dev, "Mem-Wr-Inval unavailable\n");
/* use first MMIO region */
region = ffs(pci_select_bars(pdev, IORESOURCE_MEM)) - 1;
- if (region < 0) {
- dev_err(&pdev->dev, "no MMIO resource found\n");
- return -ENODEV;
- }
+ if (region < 0)
+ return dev_err_probe(&pdev->dev, -ENODEV, "no MMIO resource found\n");
rc = pcim_iomap_regions(pdev, BIT(region), KBUILD_MODNAME);
- if (rc < 0) {
- dev_err(&pdev->dev, "cannot remap MMIO, aborting\n");
- return rc;
- }
+ if (rc < 0)
+ return dev_err_probe(&pdev->dev, rc, "cannot remap MMIO, aborting\n");
tp->mmio_addr = pcim_iomap_table(pdev)[region];
txconfig = RTL_R32(tp, TxConfig);
- if (txconfig == ~0U) {
- dev_err(&pdev->dev, "PCI read failed\n");
- return -EIO;
- }
+ if (txconfig == ~0U)
+ return dev_err_probe(&pdev->dev, -EIO, "PCI read failed\n");
xid = (txconfig >> 20) & 0xfcf;
/* Identify chip attached to board */
chipset = rtl8169_get_mac_version(xid, tp->supports_gmii);
- if (chipset == RTL_GIGA_MAC_NONE) {
- dev_err(&pdev->dev, "unknown chip XID %03x, contact r8169 maintainers (see MAINTAINERS file)\n", xid);
- return -ENODEV;
- }
-
+ if (chipset == RTL_GIGA_MAC_NONE)
+ return dev_err_probe(&pdev->dev, -ENODEV,
+ "unknown chip XID %03x, contact r8169 maintainers (see MAINTAINERS file)\n",
+ xid);
tp->mac_version = chipset;
tp->dash_type = rtl_check_dash(tp);
@@ -5253,10 +5244,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
rtl_hw_reset(tp);
rc = rtl_alloc_irq(tp);
- if (rc < 0) {
- dev_err(&pdev->dev, "Can't allocate interrupt\n");
- return rc;
- }
+ if (rc < 0)
+ return dev_err_probe(&pdev->dev, rc, "Can't allocate interrupt\n");
+
tp->irq = pci_irq_vector(pdev, 0);
INIT_WORK(&tp->wk.work, rtl_task);
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one()
2023-05-31 20:41 [PATCH net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one() Heiner Kallweit
@ 2023-06-01 15:44 ` Simon Horman
2023-06-02 5:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-06-01 15:44 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Jakub Kicinski, David Miller, Realtek linux nic maintainers,
Eric Dumazet, Paolo Abeni, netdev@vger.kernel.org
On Wed, May 31, 2023 at 10:41:32PM +0200, Heiner Kallweit wrote:
> In addition to properly handling probe deferrals dev_err_probe()
> conveniently combines printing an error message with returning
> the errno. So let's use it for every error path in rtl_init_one()
> to simplify the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one()
2023-05-31 20:41 [PATCH net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one() Heiner Kallweit
2023-06-01 15:44 ` Simon Horman
@ 2023-06-02 5:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-02 5:00 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: kuba, davem, nic_swsd, edumazet, pabeni, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 31 May 2023 22:41:32 +0200 you wrote:
> In addition to properly handling probe deferrals dev_err_probe()
> conveniently combines printing an error message with returning
> the errno. So let's use it for every error path in rtl_init_one()
> to simplify the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>
> [...]
Here is the summary with links:
- [net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one()
https://git.kernel.org/netdev/net-next/c/733b3e27650b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-02 5:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 20:41 [PATCH net-next] r8169: use dev_err_probe in all appropriate places in rtl_init_one() Heiner Kallweit
2023-06-01 15:44 ` Simon Horman
2023-06-02 5:00 ` patchwork-bot+netdevbpf
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).