From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: netdev@vger.kernel.org
Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net,
kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com,
woojung.huh@microchip.com, UNGLinuxDriver@microchip.com
Subject: [PATCH 10/11] net: dsa: microchip: ksz8795: dynamic allocate memory for flush_dyn_mac_table
Date: Wed, 18 Nov 2020 23:03:56 +0100 [thread overview]
Message-ID: <20201118220357.22292-11-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20201118220357.22292-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: - based on "[PATCH v4 05/11] net: dsa: microchip: ksz8795: dynamica allocate memory for flush_dyn_mac_table"
- lore: https://lore.kernel.org/netdev/20200803054442.20089-6-m.grzeschik@pengutronix.de/
---
drivers/net/dsa/microchip/ksz8795.c | 8 ++++++--
drivers/net/dsa/microchip/ksz8795_reg.h | 2 --
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 9ea5ec61513023f..418f71e5b90761c 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -750,11 +750,14 @@ 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];
int first, index, cnt;
struct ksz_port *p;
+ u8 *learn = kzalloc(dev->port_cnt, GFP_KERNEL);
- if ((uint)port < TOTAL_PORT_NUM) {
+ if (!learn)
+ return;
+
+ if ((uint)port < dev->port_cnt) {
first = port;
cnt = port + 1;
} else {
@@ -779,6 +782,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,
diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h
index 6377165a236fdf3..681d19ab27b89da 100644
--- a/drivers/net/dsa/microchip/ksz8795_reg.h
+++ b/drivers/net/dsa/microchip/ksz8795_reg.h
@@ -846,8 +846,6 @@
#define KS_PRIO_IN_REG 4
-#define TOTAL_PORT_NUM 5
-
#define KSZ8795_COUNTER_NUM 0x20
/* Common names used by other drivers */
--
2.29.2
next prev parent reply other threads:[~2020-11-18 22:04 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-18 22:03 [PATCH 00/11] net: dsa: microchip: make ksz8795 driver more dynamic Michael Grzeschik
2020-11-18 22:03 ` [PATCH 01/11] net: dsa: microchip: ksz8795: remove unused last_port variable Michael Grzeschik
2020-11-19 0:05 ` Andrew Lunn
2020-11-19 3:06 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 02/11] net: dsa: microchip: ksz8795: remove superfluous port_cnt assignment Michael Grzeschik
2020-11-19 0:10 ` Andrew Lunn
2020-11-19 3:07 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 03/11] net: dsa: microchip: ksz8795: move variable assignments from detect to init Michael Grzeschik
2020-11-19 0:14 ` Andrew Lunn
2020-11-19 3:07 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 04/11] net: dsa: microchip: ksz8795: use reg_mib_cnt where possible Michael Grzeschik
2020-11-19 0:16 ` Andrew Lunn
2020-11-19 3:08 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 05/11] net: dsa: microchip: ksz8795: use mib_cnt " Michael Grzeschik
2020-11-19 0:20 ` Andrew Lunn
2020-11-19 7:36 ` Michael Grzeschik
2020-11-19 3:09 ` Florian Fainelli
2020-11-19 7:01 ` kernel test robot
2020-11-18 22:03 ` [PATCH 06/11] net: dsa: microchip: ksz8795: use phy_port_cnt " Michael Grzeschik
2020-11-19 0:29 ` Andrew Lunn
2020-11-19 8:40 ` Michael Grzeschik
2020-11-19 13:59 ` Andrew Lunn
2020-11-19 3:13 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 07/11] net: dsa: microchip: remove superfluous num_ports asignment Michael Grzeschik
2020-11-19 0:32 ` Andrew Lunn
2020-11-19 3:10 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 08/11] net: dsa: microchip: ksz8795: align port_cnt usage with other microchip drivers Michael Grzeschik
2020-11-19 0:35 ` Andrew Lunn
2020-11-19 18:06 ` Tristram.Ha
2020-11-19 3:13 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 09/11] net: dsa: microchip: remove usage of mib_port_count Michael Grzeschik
2020-11-19 1:13 ` Andrew Lunn
2020-11-19 3:12 ` Florian Fainelli
2020-11-18 22:03 ` Michael Grzeschik [this message]
2020-11-19 1:21 ` [PATCH 10/11] net: dsa: microchip: ksz8795: dynamic allocate memory for flush_dyn_mac_table Andrew Lunn
2020-11-19 3:12 ` Florian Fainelli
2020-11-18 22:03 ` [PATCH 11/11] net: dsa: microchip: ksz8795: use num_vlans where possible Michael Grzeschik
2020-11-19 1:22 ` Andrew Lunn
2020-11-19 3:11 ` Florian Fainelli
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=20201118220357.22292-11-m.grzeschik@pengutronix.de \
--to=m.grzeschik@pengutronix.de \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel@pengutronix.de \
--cc=matthias.schiffer@ew.tq-group.com \
--cc=netdev@vger.kernel.org \
--cc=woojung.huh@microchip.com \
/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).