netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: andrew@lunn.ch
Cc: netdev@vger.kernel.org, f.fainelli@gmail.com,
	davem@davemloft.net, kernel@pengutronix.de
Subject: [PATCH v4 05/11] net: dsa: microchip: ksz8795: dynamic allocate memory for flush_dyn_mac_table
Date: Mon,  3 Aug 2020 07:44:36 +0200	[thread overview]
Message-ID: <20200803054442.20089-6-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20200803054442.20089-1-m.grzeschik@pengutronix.de>

To get the driver working with other chips using different port counts
the dyn_mac_table should be flushed depending on the amount of physical
ports.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

---
v1 -> v4: - extracted this change from bigger previous patch

 drivers/net/dsa/microchip/ksz8795.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 947ea1e45f5b2c6..ba722f730bf0f7b 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -750,11 +750,11 @@ static void ksz8795_port_stp_state_set(struct dsa_switch *ds, int port,
 
 static void ksz8795_flush_dyn_mac_table(struct ksz_device *dev, int port)
 {
-	u8 learn[TOTAL_PORT_NUM];
+	u8 *learn = kzalloc(dev->mib_port_cnt, GFP_KERNEL);
 	int first, index, cnt;
 	struct ksz_port *p;
 
-	if ((uint)port < TOTAL_PORT_NUM) {
+	if ((uint)port < dev->mib_port_cnt) {
 		first = port;
 		cnt = port + 1;
 	} else {
@@ -779,6 +779,7 @@ static void ksz8795_flush_dyn_mac_table(struct ksz_device *dev, int port)
 		if (!(learn[index] & PORT_LEARN_DISABLE))
 			ksz_pwrite8(dev, index, P_STP_CTRL, learn[index]);
 	}
+	kfree(learn);
 }
 
 static int ksz8795_port_vlan_filtering(struct dsa_switch *ds, int port,
-- 
2.28.0


  parent reply	other threads:[~2020-08-03  5:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03  5:44 [PATCH v4 00/11] microchip: add support for ksz88x3 driver family Michael Grzeschik
2020-08-03  5:44 ` [PATCH v4 01/11] net: phy: Add support for microchip SMI0 MDIO bus Michael Grzeschik
2020-08-03 17:38   ` Florian Fainelli
2020-08-03  5:44 ` [PATCH v4 02/11] dt-bindings: net: mdio-gpio: add compatible for microchip,mdio-smi0 Michael Grzeschik
2020-08-03  5:44 ` [PATCH v4 03/11] net: tag: ksz: Add KSZ8863 tag code Michael Grzeschik
2020-08-03  5:44 ` [PATCH v4 04/11] net: dsa: microchip: ksz8795: use port_cnt where possible Michael Grzeschik
2020-08-03 17:40   ` Florian Fainelli
2020-08-03  5:44 ` Michael Grzeschik [this message]
2020-08-03 17:40   ` [PATCH v4 05/11] net: dsa: microchip: ksz8795: dynamic allocate memory for flush_dyn_mac_table Florian Fainelli
2020-08-03  5:44 ` [PATCH v4 06/11] net: dsa: microchip: ksz8795: change drivers prefix to be generic Michael Grzeschik
2020-08-03 15:42   ` Jakub Kicinski
2020-08-03  5:44 ` [PATCH v4 07/11] net: dsa: microchip: ksz8795: move register offsets and shifts to separate struct Michael Grzeschik
2020-08-03 18:21   ` Florian Fainelli
2020-08-03  5:44 ` [PATCH v4 08/11] net: dsa: microchip: ksz8795: add support for ksz88xx chips Michael Grzeschik
2020-08-03  5:44 ` [PATCH v4 09/11] net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support Michael Grzeschik
2020-08-03 13:31   ` Randy Dunlap
2020-08-03 18:12   ` Florian Fainelli
2020-09-10 11:44   ` Matthias Schiffer
2020-08-03  5:44 ` [PATCH v4 10/11] net: dsa: microchip: Add Microchip KSZ8863 SPI " Michael Grzeschik
2020-08-03 18:14   ` Florian Fainelli
2020-08-03  5:44 ` [PATCH v4 11/11] dt-bindings: net: dsa: document additional Microchip KSZ8863/8873 switch Michael Grzeschik
2020-08-03 17:41   ` Florian Fainelli
2020-09-10 11:41 ` [PATCH v4 00/11] microchip: add support for ksz88x3 driver family Matthias Schiffer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200803054442.20089-6-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).