summaryrefslogtreecommitdiffstats
path: root/drivers/net/cpsw.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-11-20 10:21:24 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-11-27 10:42:53 +0100
commit7cc4a2ad95d5037d5362696cd71209c43ccb803b (patch)
tree8ae37b50ea6ed9766b34180462716af574e801a6 /drivers/net/cpsw.c
parent046157602e551f4bbe5071916b3360361a99f2a5 (diff)
downloadbarebox-7cc4a2ad95d5037d5362696cd71209c43ccb803b.tar.gz
barebox-7cc4a2ad95d5037d5362696cd71209c43ccb803b.tar.xz
net: cpsw: straighten error path
This mainly has the effect of checking the return value of eth_register. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/cpsw.c')
-rw-r--r--drivers/net/cpsw.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 6141328af8..5e68e1be6a 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -906,7 +906,7 @@ static void cpsw_slave_init_data(struct cpsw_slave *slave, int slave_num,
slave->phy_if = data->phy_if;
}
-static void cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
+static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
struct cpsw_priv *priv)
{
void *regs = priv->regs;
@@ -929,7 +929,7 @@ static void cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
edev->set_ethaddr = cpsw_set_hwaddr;
edev->parent = priv->dev;
- eth_register(edev);
+ return eth_register(edev);
}
struct cpsw_data {
@@ -1111,7 +1111,7 @@ int cpsw_probe(struct device_d *dev)
if (dev->device_node) {
ret = cpsw_probe_dt(priv);
if (ret)
- return ret;
+ goto out;
} else {
priv->data = *data;
priv->num_slaves = data->num_slaves;
@@ -1135,7 +1135,8 @@ int cpsw_probe(struct device_d *dev)
cpsw_data = &cpsw2_data;
break;
default:
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
priv->descs = regs + cpsw_data->cppi_ram_ofs;
@@ -1190,9 +1191,16 @@ int cpsw_probe(struct device_d *dev)
mdiobus_register(&priv->miibus);
- cpsw_slave_setup(&priv->slaves[0], 0, priv);
+ ret = cpsw_slave_setup(&priv->slaves[0], 0, priv);
+ if (ret)
+ goto out;
return 0;
+out:
+ free(priv->slaves);
+ free(priv);
+
+ return ret;
}
static __maybe_unused struct of_device_id cpsw_dt_ids[] = {