[PATCH 06/13] net: fsl_enetc: Introduce enetc_dev_id()

Marek Vasut marex at denx.de
Thu Jan 16 05:03:23 CET 2025


Introduce mapping function enetc_dev_id(), which converts PCIe BDF of
the ENETC into linear incrementing index usable e.g. as interface index.
This replaces the current ad-hoc calculation used in the code with a
dedicated function. No functional change.

Signed-off-by: Marek Vasut <marex at denx.de>
---
Cc: Alice Guo <alice.guo at nxp.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome.forissier at linaro.org>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Markus Gothe <markus.gothe at genexis.eu>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Robert Marko <robert.marko at sartura.hr>
Cc: Romain Naour <romain.naour at smile.fr>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tim Harvey <tharvey at gateworks.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: Ye Li <ye.li at nxp.com>
Cc: u-boot at lists.denx.de
---
 drivers/net/fsl_enetc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index 639853539a1..e6f5ca633aa 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -32,6 +32,14 @@ static int enetc_is_ls1028a(struct udevice *dev)
 	       pplat->vendor == PCI_VENDOR_ID_FREESCALE;
 }
 
+static int enetc_dev_id(struct udevice *dev)
+{
+	if (enetc_is_ls1028a(dev))
+		return PCI_FUNC(pci_get_devfn(dev));
+
+	return 0;
+}
+
 /*
  * sets the MAC address in IERB registers, this setting is persistent and
  * carried over to Linux.
@@ -109,7 +117,7 @@ static int enetc_bind(struct udevice *dev)
 	 * PCI function # and enetc#N based on interface count
 	 */
 	if (ofnode_valid(dev_ofnode(dev)))
-		sprintf(name, "enetc-%u", PCI_FUNC(pci_get_devfn(dev)));
+		sprintf(name, "enetc-%u", enetc_dev_id(dev));
 	else
 		sprintf(name, "enetc#%u", eth_num_devices++);
 	device_set_name(dev, name);
-- 
2.45.2



More information about the U-Boot mailing list