Blob Blame History Raw
From fafd0d144a8205bf76149bc50dafb7ab4ff87368 Mon Sep 17 00:00:00 2001
From: Mian Yousaf Kaukab <ykaukab@suse.de>
Date: Fri, 28 Feb 2020 09:48:39 +0100
Subject: [PATCH] net: dsa: felix: use dsa_switch_alloc()

Patch-mainline: Never, Make driver compatible with v5.3
References: jsc#SLE-9263

[1] Converted the arrays of ports in struct dsa_switch into a list
and landed in v5.5. However, in v5.3 ports are supposed to be allocated
by the driver. Use dsa_switch_alloc() to allocate struct dsa_switch
along with ports array. Since dsa_switch_alloc() use devm_kcalloc(),
remove calls to free().

[1]:https://lkml.org/lkml/2019/10/21/1186

Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
---
 drivers/net/dsa/ocelot/felix.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index d82cb2da0965..339ab04e25b2 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -697,7 +697,7 @@ static int felix_pci_probe(struct pci_dev *pdev,
 
 	ocelot->ptp = 1;
 
-	ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL);
+	ds = dsa_switch_alloc(&pdev->dev, felix->info->num_ports);
 	if (!ds) {
 		err = -ENOMEM;
 		dev_err(&pdev->dev, "Failed to allocate DSA switch\n");
@@ -719,7 +719,6 @@ static int felix_pci_probe(struct pci_dev *pdev,
 	return 0;
 
 err_register_ds:
-	kfree(ds);
 err_alloc_ds:
 err_alloc_irq:
 err_alloc_felix:
@@ -738,7 +737,6 @@ static void felix_pci_remove(struct pci_dev *pdev)
 
 	dsa_unregister_switch(felix->ds);
 
-	kfree(felix->ds);
 	kfree(felix);
 
 	pci_disable_device(pdev);
-- 
2.16.4