From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: netdev@vger.kernel.org, andrew@lunn.ch, horms@kernel.org,
kuba@kernel.org, jiri@resnulli.us, pabeni@redhat.com,
hfdevel@gmx.net, naveenm@marvell.com, jdamato@fastly.com
Subject: Re: [PATCH net-next v9 6/6] net: tn40xx: add phylink support
Date: Sun, 9 Jun 2024 11:34:28 +0100 [thread overview]
Message-ID: <ZmWFNATfPWEPSLyf@shell.armlinux.org.uk> (raw)
In-Reply-To: <20240605232608.65471-7-fujita.tomonori@gmail.com>
On Thu, Jun 06, 2024 at 08:26:08AM +0900, FUJITA Tomonori wrote:
> @@ -1670,6 +1681,12 @@ static int tn40_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> goto err_unset_drvdata;
> }
>
> + ret = tn40_mdiobus_init(priv);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to initialize mdio bus.\n");
> + goto err_free_irq;
> + }
> +
...
> +err_unregister_phydev:
> + tn40_phy_unregister(priv);
> err_free_irq:
> pci_free_irq_vectors(pdev);
> err_unset_drvdata:
and from previous patches:
+ pci_set_drvdata(pdev, NULL);
+err_iounmap:
+ iounmap(regs);
+err_free_regions:
+ pci_release_regions(pdev);
+err_disable_device:
+ pci_disable_device(pdev);
+ return ret;
+}
So, if tn40_mdiobus_init() returns non-zero, this value will be returned
to higher kernel levels via tn40_probe().
...
> +int tn40_phy_register(struct tn40_priv *priv)
> +{
> + struct phylink_config *config;
> + struct phy_device *phydev;
> + struct phylink *phylink;
> +
> + phydev = phy_find_first(priv->mdio);
> + if (!phydev) {
> + dev_err(&priv->pdev->dev, "PHY isn't found\n");
> + return -1;
And my email client, setup with rules to catch common programming
mistakes, highlights the above line. I have no idea why people do
this... why people think "lets return -1 on error". It seems to be
a very common pattern... but it's utterly wrong. -1 is -EPERM, aka
"Operation not permitted". This is not what you mean here. Please
return a more suitable negative errno symbol... and please refrain
from using "return -1" in kernel code.
(The only case where "return -1" may be permissible is where the
value doesn't get propagated outside of the compilation unit, but
even there, there is the possibility that later changes may end
up propagating it outside... personally, I would like to see
"return -1" totally banned from the kernel.)
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2024-06-09 10:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 23:26 [PATCH net-next v9 0/6] add ethernet driver for Tehuti Networks TN40xx chips FUJITA Tomonori
2024-06-05 23:26 ` [PATCH net-next v9 1/6] net: tn40xx: add pci " FUJITA Tomonori
2024-06-09 11:17 ` Hans-Frieder Vogt
2024-06-09 12:13 ` FUJITA Tomonori
2024-06-05 23:26 ` [PATCH net-next v9 2/6] net: tn40xx: add register defines FUJITA Tomonori
2024-06-05 23:26 ` [PATCH net-next v9 3/6] net: tn40xx: add basic Tx handling FUJITA Tomonori
2024-06-09 11:41 ` Hans-Frieder Vogt
2024-06-10 6:48 ` FUJITA Tomonori
2024-06-10 21:02 ` FUJITA Tomonori
2024-06-05 23:26 ` [PATCH net-next v9 4/6] net: tn40xx: add basic Rx handling FUJITA Tomonori
2024-06-10 9:59 ` Russell King (Oracle)
2024-06-10 12:28 ` FUJITA Tomonori
2024-06-05 23:26 ` [PATCH net-next v9 5/6] net: tn40xx: add mdio bus support FUJITA Tomonori
2024-06-09 11:22 ` Hans-Frieder Vogt
2024-06-10 7:35 ` FUJITA Tomonori
2024-06-10 10:04 ` Russell King (Oracle)
2024-06-10 12:05 ` FUJITA Tomonori
2024-06-05 23:26 ` [PATCH net-next v9 6/6] net: tn40xx: add phylink support FUJITA Tomonori
2024-06-09 10:34 ` Russell King (Oracle) [this message]
2024-06-10 6:10 ` FUJITA Tomonori
2024-06-10 15:42 ` Andrew Lunn
2024-06-10 20:57 ` FUJITA Tomonori
2024-06-09 9:10 ` [PATCH net-next v9 0/6] add ethernet driver for Tehuti Networks TN40xx chips Hans-Frieder Vogt
2024-06-09 10:42 ` Russell King (Oracle)
2024-06-09 12:40 ` Hans-Frieder Vogt
2024-06-09 13:48 ` Russell King (Oracle)
2024-06-09 18:42 ` Hans-Frieder Vogt
[not found] ` <c3f29b80-0085-4dd2-8d78-f2ac2a004474@gmx.net>
2024-06-09 19:12 ` Russell King (Oracle)
2024-06-10 15:37 ` Andrew Lunn
2024-06-09 11:53 ` FUJITA Tomonori
2024-06-11 4:54 ` FUJITA Tomonori
2024-06-11 5:30 ` FUJITA Tomonori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZmWFNATfPWEPSLyf@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=fujita.tomonori@gmail.com \
--cc=hfdevel@gmx.net \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=naveenm@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).