From: Alexandros Couloumbis Date: Fri, 29 May 2020 10:10:39 +0000 (+0300) Subject: linux/adm5120: rework linux-4.19 network driver (still non-operational) X-Git-Url: http://git.ozo.com/?a=commitdiff_plain;h=ba74b78c756e66a1c32a52cba075615b8b2ff7d4;p=openwrt%2F.git linux/adm5120: rework linux-4.19 network driver (still non-operational) --- diff --git a/target/linux/adm5120/patches-4.19/730-struct_device_DMA_API.patch b/target/linux/adm5120/patches-4.19/730-struct_device_DMA_API.patch index 291482aee2..4c04c46cf8 100644 --- a/target/linux/adm5120/patches-4.19/730-struct_device_DMA_API.patch +++ b/target/linux/adm5120/patches-4.19/730-struct_device_DMA_API.patch @@ -1,54 +1,88 @@ +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; } @@ -57,7 +91,7 @@ { int i; -@@ -839,15 +839,22 @@ static void adm5120_switch_cleanup(void) +@@ -839,12 +845,13 @@ static void adm5120_switch_cleanup(void) } } @@ -73,20 +107,17 @@ 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; @@ -96,16 +127,17 @@ 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) { @@ -114,17 +146,17 @@ + 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; + } }