From: Sean Anderson <sean.anderson@seco.com>
To: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org
Cc: Madalin Bucur <madalin.bucur@nxp.com>,
Sean Anderson <sean.anderson@seco.com>,
open list <linux-kernel@vger.kernel.org>,
Camelia Groza <camelia.groza@nxp.com>,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH net-next v5 09/14] net: fman: Clean up error handling
Date: Fri, 2 Sep 2022 17:57:31 -0400 [thread overview]
Message-ID: <20220902215737.981341-10-sean.anderson@seco.com> (raw)
In-Reply-To: <20220902215737.981341-1-sean.anderson@seco.com>
This removes the _return label, since something like
err = -EFOO;
goto _return;
can be replaced by the briefer
return -EFOO;
Additionally, this skips going to _return_of_node_put when dev_node has
already been put (preventing a double put).
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
---
(no changes since v1)
drivers/net/ethernet/freescale/fman/mac.c | 43 ++++++++---------------
1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 66a3742a862b..7b7526fd7da3 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -291,15 +291,11 @@ static int mac_probe(struct platform_device *_of_dev)
init = of_device_get_match_data(dev);
mac_dev = devm_kzalloc(dev, sizeof(*mac_dev), GFP_KERNEL);
- if (!mac_dev) {
- err = -ENOMEM;
- goto _return;
- }
+ if (!mac_dev)
+ return -ENOMEM;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
- if (!priv) {
- err = -ENOMEM;
- goto _return;
- }
+ if (!priv)
+ return -ENOMEM;
/* Save private information */
mac_dev->priv = priv;
@@ -312,8 +308,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!dev_node) {
dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node);
- err = -EINVAL;
- goto _return_of_node_put;
+ return -EINVAL;
}
of_dev = of_find_device_by_node(dev_node);
@@ -352,28 +347,24 @@ static int mac_probe(struct platform_device *_of_dev)
err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res);
if (err) {
dev_err_probe(dev, err, "could not request resource\n");
- goto _return_of_node_put;
+ return err;
}
mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res));
if (!mac_dev->vaddr) {
dev_err(dev, "devm_ioremap() failed\n");
- err = -EIO;
- goto _return_of_node_put;
+ return -EIO;
}
mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res);
- if (!of_device_is_available(mac_node)) {
- err = -ENODEV;
- goto _return_of_node_put;
- }
+ if (!of_device_is_available(mac_node))
+ return -ENODEV;
/* Get the cell-index */
err = of_property_read_u32(mac_node, "cell-index", &val);
if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
- err = -EINVAL;
- goto _return_of_node_put;
+ return -EINVAL;
}
priv->cell_index = (u8)val;
@@ -387,15 +378,13 @@ static int mac_probe(struct platform_device *_of_dev)
if (unlikely(nph < 0)) {
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node);
- err = nph;
- goto _return_of_node_put;
+ return nph;
}
if (nph != ARRAY_SIZE(mac_dev->port)) {
dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
mac_node);
- err = -EINVAL;
- goto _return_of_node_put;
+ return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -404,8 +393,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!dev_node) {
dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n",
mac_node);
- err = -EINVAL;
- goto _return_of_node_put;
+ return -EINVAL;
}
of_dev = of_find_device_by_node(dev_node);
@@ -465,7 +453,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node);
- goto _return_of_node_put;
+ return err;
}
/* pause frame autonegotiation enabled */
@@ -492,11 +480,10 @@ static int mac_probe(struct platform_device *_of_dev)
priv->eth_dev = NULL;
}
- goto _return;
+ return err;
_return_of_node_put:
of_node_put(dev_node);
-_return:
return err;
}
--
2.35.1.1320.gc452695387.dirty
next prev parent reply other threads:[~2022-09-02 22:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 21:57 [PATCH net-next v5 00/14] net: dpaa: Cleanups in preparation for phylink conversion (part 2) Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 01/14] net: fman: Move initialization to mac-specific files Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 02/14] net: fman: Mark mac methods static Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 03/14] net: fman: Inline several functions into initialization Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 04/14] net: fman: Remove internal_phy_node from params Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 05/14] net: fman: Map the base address once Sean Anderson
2022-10-17 15:15 ` Geert Uytterhoeven
2022-10-17 15:34 ` Sean Anderson
2022-10-17 15:49 ` Geert Uytterhoeven
2022-09-02 21:57 ` [PATCH net-next v5 06/14] net: fman: Pass params directly to mac init Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 07/14] net: fman: Use mac_dev for some params Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 08/14] net: fman: Specify type of mac_dev for exception_cb Sean Anderson
2022-09-02 21:57 ` Sean Anderson [this message]
2022-09-02 21:57 ` [PATCH net-next v5 10/14] net: fman: Change return type of disable to void Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 11/14] net: dpaa: Use mac_dev variable in dpaa_netdev_init Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 12/14] soc: fsl: qbman: Add helper for sanity checking cgr ops Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 13/14] soc: fsl: qbman: Add CGR update function Sean Anderson
2022-09-02 21:57 ` [PATCH net-next v5 14/14] net: dpaa: Adjust queue depth on rate change Sean Anderson
2022-09-05 13:40 ` [PATCH net-next v5 00/14] net: dpaa: Cleanups in preparation for phylink conversion (part 2) patchwork-bot+netdevbpf
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=20220902215737.981341-10-sean.anderson@seco.com \
--to=sean.anderson@seco.com \
--cc=camelia.groza@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=madalin.bucur@nxp.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).