summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2025-01-16 05:03:23 +0100
committerFabio Estevam <festevam@gmail.com>2025-01-20 08:40:39 -0300
commit4eb5ef73a9565a78dd2a18d0ff4576701bedf872 (patch)
treea80ba22621743f9feb881f247212c865b2801c6c
parente091e49afe0c47f5884928f42dd29c980478d3e7 (diff)
net: fsl_enetc: Introduce enetc_dev_id()
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@denx.de>
-rw-r--r--drivers/net/fsl_enetc.c10
1 files changed, 9 insertions, 1 deletions
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);