aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2016-12-25 20:11:34 +0100
committerJohn Crispin <john@phrozen.org>2017-08-05 08:46:36 +0200
commit74d00a8c3849c1340efd713eb94b786e304c201f (patch)
treede481743de61c34da96ab5f9dba3af3edcfb8260 /target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch
parentde350550ef648d9728351b986b0516fa29465c45 (diff)
downloadupstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.gz
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.bz2
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.zip
kernel: split patches folder up into backport, pending and hack folders
* properly format/comment all patches * merge debloat patches * merge Kconfig patches * merge swconfig patches * merge hotplug patches * drop 200-fix_localversion.patch - upstream * drop 222-arm_zimage_none.patch - unused * drop 252-mv_cesa_depends.patch - no longer required * drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused * drop 661-fq_codel_keep_dropped_stats.patch - outdated * drop 702-phy_add_aneg_done_function.patch - upstream * drop 840-rtc7301.patch - unused * drop 841-rtc_pt7c4338.patch - upstream * drop 921-use_preinit_as_init.patch - unused * drop spio-gpio-old and gpio-mmc - unused Signed-off-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch')
-rw-r--r--target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch139
1 files changed, 139 insertions, 0 deletions
diff --git a/target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch b/target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch
new file mode 100644
index 0000000000..544a074a78
--- /dev/null
+++ b/target/linux/generic/pending-4.4/073-v4.10-0001-net-bgmac-allocate-struct-bgmac-just-once-don-t-copy.patch
@@ -0,0 +1,139 @@
+From 34a5102c3235c470a6c77fba16cb971964d9c136 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 31 Jan 2017 19:37:54 +0100
+Subject: [PATCH 1/3] net: bgmac: allocate struct bgmac just once & don't copy
+ it
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So far were were allocating struct bgmac in 3 places: platform code,
+bcma code and shared bgmac_enet_probe function. The reason for this was
+bgmac_enet_probe:
+1) Requiring early-filled struct bgmac
+2) Calling alloc_etherdev on its own in order to use netdev_priv later
+
+This solution got few drawbacks:
+1) Was duplicating allocating code
+2) Required copying early-filled struct
+3) Resulted in platform/bcma code having access only to unused struct
+
+Solve this situation by simply extracting some probe code into the new
+bgmac_alloc function.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/ethernet/broadcom/bgmac-bcma.c | 4 +---
+ drivers/net/ethernet/broadcom/bgmac-platform.c | 2 +-
+ drivers/net/ethernet/broadcom/bgmac.c | 25 +++++++++++++++++--------
+ drivers/net/ethernet/broadcom/bgmac.h | 3 ++-
+ 4 files changed, 21 insertions(+), 13 deletions(-)
+
+--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
++++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
+@@ -99,12 +99,11 @@ static int bgmac_probe(struct bcma_devic
+ u8 *mac;
+ int err;
+
+- bgmac = kzalloc(sizeof(*bgmac), GFP_KERNEL);
++ bgmac = bgmac_alloc(&core->dev);
+ if (!bgmac)
+ return -ENOMEM;
+
+ bgmac->bcma.core = core;
+- bgmac->dev = &core->dev;
+ bgmac->dma_dev = core->dma_dev;
+ bgmac->irq = core->irq;
+
+@@ -285,7 +284,6 @@ static int bgmac_probe(struct bcma_devic
+ err1:
+ bcma_mdio_mii_unregister(bgmac->mii_bus);
+ err:
+- kfree(bgmac);
+ bcma_set_drvdata(core, NULL);
+
+ return err;
+--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
++++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
+@@ -93,7 +93,7 @@ static int bgmac_probe(struct platform_d
+ struct resource *regs;
+ const u8 *mac_addr;
+
+- bgmac = devm_kzalloc(&pdev->dev, sizeof(*bgmac), GFP_KERNEL);
++ bgmac = bgmac_alloc(&pdev->dev);
+ if (!bgmac)
+ return -ENOMEM;
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -1475,22 +1475,32 @@ static int bgmac_phy_connect(struct bgma
+ return 0;
+ }
+
+-int bgmac_enet_probe(struct bgmac *info)
++struct bgmac *bgmac_alloc(struct device *dev)
+ {
+ struct net_device *net_dev;
+ struct bgmac *bgmac;
+- int err;
+
+ /* Allocation and references */
+- net_dev = alloc_etherdev(sizeof(*bgmac));
++ net_dev = devm_alloc_etherdev(dev, sizeof(*bgmac));
+ if (!net_dev)
+- return -ENOMEM;
++ return NULL;
+
+ net_dev->netdev_ops = &bgmac_netdev_ops;
+ net_dev->ethtool_ops = &bgmac_ethtool_ops;
++
+ bgmac = netdev_priv(net_dev);
+- memcpy(bgmac, info, sizeof(*bgmac));
++ bgmac->dev = dev;
+ bgmac->net_dev = net_dev;
++
++ return bgmac;
++}
++EXPORT_SYMBOL_GPL(bgmac_alloc);
++
++int bgmac_enet_probe(struct bgmac *bgmac)
++{
++ struct net_device *net_dev = bgmac->net_dev;
++ int err;
++
+ net_dev->irq = bgmac->irq;
+ SET_NETDEV_DEV(net_dev, bgmac->dev);
+
+@@ -1517,7 +1527,7 @@ int bgmac_enet_probe(struct bgmac *info)
+ err = bgmac_dma_alloc(bgmac);
+ if (err) {
+ dev_err(bgmac->dev, "Unable to alloc memory for DMA\n");
+- goto err_netdev_free;
++ goto err_out;
+ }
+
+ bgmac->int_mask = BGMAC_IS_ERRMASK | BGMAC_IS_RX | BGMAC_IS_TX_MASK;
+@@ -1553,8 +1563,7 @@ err_phy_disconnect:
+ phy_disconnect(net_dev->phydev);
+ err_dma_free:
+ bgmac_dma_free(bgmac);
+-err_netdev_free:
+- free_netdev(net_dev);
++err_out:
+
+ return err;
+ }
+--- a/drivers/net/ethernet/broadcom/bgmac.h
++++ b/drivers/net/ethernet/broadcom/bgmac.h
+@@ -515,7 +515,8 @@ struct bgmac {
+ u32 set);
+ };
+
+-int bgmac_enet_probe(struct bgmac *info);
++struct bgmac *bgmac_alloc(struct device *dev);
++int bgmac_enet_probe(struct bgmac *bgmac);
+ void bgmac_enet_remove(struct bgmac *bgmac);
+
+ struct mii_bus *bcma_mdio_mii_register(struct bcma_device *core, u8 phyaddr);