diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2023-01-16 14:44:56 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-01-23 09:21:37 +0100 |
commit | d98e5d91599019f2c73e38d874682eb11eb021f2 (patch) | |
tree | 00604d51bc1d39312e3f35886a34e62e6b2c22e3 | |
parent | b130788674677b63656f10bd5fb0c660f9bc07e5 (diff) | |
download | barebox-d98e5d91599019f2c73e38d874682eb11eb021f2.tar.gz barebox-d98e5d91599019f2c73e38d874682eb11eb021f2.tar.xz |
net: dsa: factor out dsa_port_alloc helper
We'll reuse this helper in a follow-up commit for allocating the CPU
port's struct dsa_port, so prepare for this by creating a helper
function.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20230116134501.2006391-5-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/net/dsa.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c index d51e9c8611..ea1a6a6996 100644 --- a/drivers/net/dsa.c +++ b/drivers/net/dsa.c @@ -235,10 +235,9 @@ static int dsa_ether_get_ethaddr(struct eth_device *edev, unsigned char *adr) return edev_master->get_ethaddr(edev_master, adr); } -static int dsa_switch_register_edev(struct dsa_switch *ds, - struct device_node *dn, int port) +static struct dsa_port *dsa_port_alloc(struct dsa_switch *ds, + struct device_node *dn, int port) { - struct eth_device *edev; struct device *dev; struct dsa_port *dp; @@ -248,14 +247,24 @@ static int dsa_switch_register_edev(struct dsa_switch *ds, dev = of_platform_device_create(dn, ds->dev); of_platform_device_dummy_drv(dev); dp->dev = dev; - - dp->rx_buf = xmalloc(DSA_PKTSIZE); dp->ds = ds; dp->index = port; + return dp; +} + +static int dsa_switch_register_edev(struct dsa_switch *ds, + struct device_node *dn, int port) +{ + struct eth_device *edev; + struct dsa_port *dp; + + dp = dsa_port_alloc(ds, dn, port); + dp->rx_buf = xmalloc(DSA_PKTSIZE); + edev = &dp->edev; edev->priv = dp; - edev->parent = dev; + edev->parent = dp->dev; edev->init = dsa_port_probe; edev->open = dsa_port_start; edev->send = dsa_port_send; |