net: dsa: lan9303: Only allocate 3 ports
authorEgil Hjelmeland <privat@egil-hjelmeland.no>
Mon, 7 Aug 2017 22:22:21 +0000 (00:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Aug 2017 01:13:59 +0000 (18:13 -0700)
Save 2628 bytes on arm eabi by allocate only the required 3 ports.

Now that ds->num_ports is correct: In net/dsa/tag_lan9303.c
eliminate duplicate LAN9303_MAX_PORTS, use ds->num_ports.
(Matching the pattern of other net/dsa/tag_xxx.c files.)

Signed-off-by: Egil Hjelmeland <privat@egil-hjelmeland.no>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/lan9303-core.c
net/dsa/tag_lan9303.c

index 15befd15525184162fc26144d035c67881059eaf..46fc1d5d3c9eb2f09fe3ec14c0c9d61836fe4950 100644 (file)
@@ -811,7 +811,7 @@ static struct dsa_switch_ops lan9303_switch_ops = {
 
 static int lan9303_register_switch(struct lan9303 *chip)
 {
-       chip->ds = dsa_switch_alloc(chip->dev, DSA_MAX_PORTS);
+       chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS);
        if (!chip->ds)
                return -ENOMEM;
 
index 247774d149f9f90e1170d3cd65d6f2fdb473b28d..e23e7635fa00eb8a42cce49f803ed7ba8f4939e2 100644 (file)
@@ -39,7 +39,6 @@
  */
 
 #define LAN9303_TAG_LEN 4
-#define LAN9303_MAX_PORTS 3
 
 static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev)
 {
@@ -104,7 +103,7 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev,
 
        source_port = ntohs(lan9303_tag[1]) & 0x3;
 
-       if (source_port >= LAN9303_MAX_PORTS) {
+       if (source_port >= ds->num_ports) {
                dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid source port\n");
                return NULL;
        }