Commit aedbeb4e authored by Sean Anderson's avatar Sean Anderson Committed by David S. Miller

net: fman: Clean up error handling

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: default avatarSean Anderson <sean.anderson@seco.com>
Acked-by: default avatarCamelia Groza <camelia.groza@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5b6acb55
...@@ -291,15 +291,11 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -291,15 +291,11 @@ static int mac_probe(struct platform_device *_of_dev)
init = of_device_get_match_data(dev); init = of_device_get_match_data(dev);
mac_dev = devm_kzalloc(dev, sizeof(*mac_dev), GFP_KERNEL); mac_dev = devm_kzalloc(dev, sizeof(*mac_dev), GFP_KERNEL);
if (!mac_dev) { if (!mac_dev)
err = -ENOMEM; return -ENOMEM;
goto _return;
}
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv)
err = -ENOMEM; return -ENOMEM;
goto _return;
}
/* Save private information */ /* Save private information */
mac_dev->priv = priv; mac_dev->priv = priv;
...@@ -312,8 +308,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -312,8 +308,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!dev_node) { if (!dev_node) {
dev_err(dev, "of_get_parent(%pOF) failed\n", dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node); mac_node);
err = -EINVAL; return -EINVAL;
goto _return_of_node_put;
} }
of_dev = of_find_device_by_node(dev_node); of_dev = of_find_device_by_node(dev_node);
...@@ -352,28 +347,24 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -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); err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res);
if (err) { if (err) {
dev_err_probe(dev, err, "could not request resource\n"); 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)); mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res));
if (!mac_dev->vaddr) { if (!mac_dev->vaddr) {
dev_err(dev, "devm_ioremap() failed\n"); dev_err(dev, "devm_ioremap() failed\n");
err = -EIO; return -EIO;
goto _return_of_node_put;
} }
mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res); mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res);
if (!of_device_is_available(mac_node)) { if (!of_device_is_available(mac_node))
err = -ENODEV; return -ENODEV;
goto _return_of_node_put;
}
/* Get the cell-index */ /* Get the cell-index */
err = of_property_read_u32(mac_node, "cell-index", &val); err = of_property_read_u32(mac_node, "cell-index", &val);
if (err) { if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node); dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
err = -EINVAL; return -EINVAL;
goto _return_of_node_put;
} }
priv->cell_index = (u8)val; priv->cell_index = (u8)val;
...@@ -387,15 +378,13 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -387,15 +378,13 @@ static int mac_probe(struct platform_device *_of_dev)
if (unlikely(nph < 0)) { if (unlikely(nph < 0)) {
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n", dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node); mac_node);
err = nph; return nph;
goto _return_of_node_put;
} }
if (nph != ARRAY_SIZE(mac_dev->port)) { 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", dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
mac_node); mac_node);
err = -EINVAL; return -EINVAL;
goto _return_of_node_put;
} }
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) { for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
...@@ -404,8 +393,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -404,8 +393,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!dev_node) { if (!dev_node) {
dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n", dev_err(dev, "of_parse_phandle(%pOF, fsl,fman-ports) failed\n",
mac_node); mac_node);
err = -EINVAL; return -EINVAL;
goto _return_of_node_put;
} }
of_dev = of_find_device_by_node(dev_node); of_dev = of_find_device_by_node(dev_node);
...@@ -465,7 +453,7 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -465,7 +453,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) { if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err); dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node); of_node_put(mac_dev->phy_node);
goto _return_of_node_put; return err;
} }
/* pause frame autonegotiation enabled */ /* pause frame autonegotiation enabled */
...@@ -492,11 +480,10 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -492,11 +480,10 @@ static int mac_probe(struct platform_device *_of_dev)
priv->eth_dev = NULL; priv->eth_dev = NULL;
} }
goto _return; return err;
_return_of_node_put: _return_of_node_put:
of_node_put(dev_node); of_node_put(dev_node);
_return:
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment