]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: rearrange tc_init()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 15 Oct 2025 16:10:56 +0000 (17:10 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 16 Oct 2025 22:58:22 +0000 (15:58 -0700)
To make future changes easier, rearrange the use of dma_cap->l3l4fnum
vs priv->flow_entries_max.

Always initialise priv->flow_entries_max from dma_cap->l3l4fnum, then
use priv->flow_entries_max to determine whether we allocate
priv->flow_entries and set it up.

This change is safe because tc_init() is only called once from
stmmac_dvr_probe().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/E1v945Y-0000000Ameb-2gDI@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c

index 97e89a604abd7a01bb8e904c38f10716e0a911c1..ef65cf511f3e25eb512187d52775bb363bb83902 100644 (file)
@@ -262,10 +262,10 @@ static int tc_init(struct stmmac_priv *priv)
        unsigned int count;
        int ret, i;
 
-       if (dma_cap->l3l4fnum) {
-               priv->flow_entries_max = dma_cap->l3l4fnum;
+       priv->flow_entries_max = dma_cap->l3l4fnum;
+       if (priv->flow_entries_max) {
                priv->flow_entries = devm_kcalloc(priv->device,
-                                                 dma_cap->l3l4fnum,
+                                                 priv->flow_entries_max,
                                                  sizeof(*priv->flow_entries),
                                                  GFP_KERNEL);
                if (!priv->flow_entries)