+diff --git a/drivers/net/adm5120sw.c b/drivers/net/adm5120sw.c
+index eb17a0d..024551f 100644
--- a/drivers/net/adm5120sw.c
+++ b/drivers/net/adm5120sw.c
-@@ -428,11 +428,11 @@ static void adm5120_switch_rx_ring_reset
+@@ -428,11 +428,12 @@ static void adm5120_switch_rx_ring_reset(struct dma_desc *desc,
dirty_rxl = 0;
}
-static int adm5120_switch_tx_ring_alloc(void)
+static int adm5120_switch_tx_ring_alloc(struct net_device *dev)
{
++ struct adm5120_if_priv *priv = netdev_priv(dev);
int err;
- txl_descs = dma_alloc_coherent(NULL, TX_DESCS_SIZE, &txl_descs_dma,
-+ txl_descs = dma_alloc_coherent(&dev->dev, TX_DESCS_SIZE, &txl_descs_dma,
++ txl_descs = dma_alloc_coherent(&priv->dev->dev, TX_DESCS_SIZE, &txl_descs_dma,
GFP_DMA | GFP_KERNEL);
if (!txl_descs) {
err = -ENOMEM;
-@@ -451,7 +451,7 @@ err:
+@@ -451,8 +452,9 @@ static int adm5120_switch_tx_ring_alloc(void)
return err;
}
-static void adm5120_switch_tx_ring_free(void)
+static void adm5120_switch_tx_ring_free(struct net_device *dev)
{
++ struct adm5120_if_priv *priv = netdev_priv(dev);
int i;
-@@ -467,13 +467,13 @@ static void adm5120_switch_tx_ring_free(
+ if (txl_skbuff) {
+@@ -463,17 +465,18 @@ static void adm5120_switch_tx_ring_free(void)
+ }
+
+ if (txl_descs)
+- dma_free_coherent(NULL, TX_DESCS_SIZE, txl_descs,
++ dma_free_coherent(&priv->dev->dev, TX_DESCS_SIZE, txl_descs,
txl_descs_dma);
}
-static int adm5120_switch_rx_ring_alloc(void)
+static int adm5120_switch_rx_ring_alloc(struct net_device *dev)
{
++ struct adm5120_if_priv *priv = netdev_priv(dev);
int err;
int i;
/* init RX ring */
- rxl_descs = dma_alloc_coherent(NULL, RX_DESCS_SIZE, &rxl_descs_dma,
-+ rxl_descs = dma_alloc_coherent(&dev->dev, RX_DESCS_SIZE, &rxl_descs_dma,
++ rxl_descs = dma_alloc_coherent(&priv->dev->dev, RX_DESCS_SIZE, &rxl_descs_dma,
GFP_DMA | GFP_KERNEL);
if (!rxl_descs) {
err = -ENOMEM;
-@@ -503,7 +503,7 @@ err:
+@@ -503,8 +506,9 @@ static int adm5120_switch_rx_ring_alloc(void)
return err;
}
-static void adm5120_switch_rx_ring_free(void)
+static void adm5120_switch_rx_ring_free(struct net_device *dev)
{
++ struct adm5120_if_priv *priv = netdev_priv(dev);
int i;
-@@ -824,7 +824,7 @@ static struct net_device *adm5120_if_all
+ if (rxl_skbuff) {
+@@ -515,7 +519,7 @@ static void adm5120_switch_rx_ring_free(void)
+ }
+
+ if (rxl_descs)
+- dma_free_coherent(NULL, RX_DESCS_SIZE, rxl_descs,
++ dma_free_coherent(&priv->dev->dev, RX_DESCS_SIZE, rxl_descs,
+ rxl_descs_dma);
+ }
+
+@@ -809,8 +813,10 @@ static struct net_device *adm5120_if_alloc(void)
+ struct adm5120_if_priv *priv;
+
+ dev = alloc_etherdev(sizeof(*priv));
+- if (!dev)
++ if (!dev) {
++ SW_ERR("alloc_etherdev failed\n");
+ return NULL;
++ }
+
+ priv = netdev_priv(dev);
+ priv->dev = dev;
+@@ -824,7 +830,7 @@ static struct net_device *adm5120_if_alloc(void)
return dev;
}
{
int i;
-@@ -839,15 +839,22 @@ static void adm5120_switch_cleanup(void)
+@@ -839,12 +845,13 @@ static void adm5120_switch_cleanup(void)
}
}
u32 t;
int i, err;
-+ dev = adm5120_if_alloc();
-+ if (!dev) {
-+ err = -ENOMEM;
-+ goto err;
-+ }
-+
- adm5120_nrdevs = adm5120_eth_num_ports;
-
- t = CPUP_CONF_DCPUP | CPUP_CONF_CRCP |
-@@ -879,11 +886,11 @@ static int adm5120_switch_probe(struct p
+@@ -879,11 +886,17 @@ static int adm5120_switch_probe(struct platform_device *pdev)
sw_int_mask(SWITCH_INTS_ALL);
sw_int_ack(SWITCH_INTS_ALL);
- err = adm5120_switch_rx_ring_alloc();
++ dev = platform_get_drvdata(pdev);
++ if (!dev) {
++ err = -ENOMEM;
++ return err;
++ }
++
+ err = adm5120_switch_rx_ring_alloc(dev);
if (err)
goto err;
if (err)
goto err;
-@@ -933,7 +940,7 @@ static int adm5120_switch_probe(struct p
+@@ -933,16 +946,29 @@ static int adm5120_switch_probe(struct platform_device *pdev)
return 0;
err:
- adm5120_switch_cleanup();
+ adm5120_switch_cleanup(dev);
- SW_ERR("init failed\n");
+- SW_ERR("init failed\n");
++ SW_ERR("probe_init failed\n");
return err;
-@@ -941,8 +948,21 @@ err:
+ }
static int adm5120_switch_remove(struct platform_device *pdev)
{
+ struct net_device *dev;
+ int err;
+
-+ dev = adm5120_if_alloc();
++ dev = platform_get_drvdata(pdev);
+ if (!dev) {
+ err = -ENOMEM;
+
+ adm5120_switch_cleanup(dev);
-+ SW_ERR("init failed\n");
++ SW_ERR("remove_init failed\n");
+
+ return err;
+ } else {
-+ adm5120_switch_cleanup(dev);
-+ return 0;
++ adm5120_switch_cleanup(dev);
++ return 0;
+ }
}