[PATCH 4/5] net: establish single code path for setting edev parameters
Sascha Hauer
s.hauer at pengutronix.de
Mon Jun 10 00:51:04 PDT 2024
We have net_set_ip(), net_set_gateway() and net_set_netmask() to set the
IP parameters of a network device. Most code pathes go through these
functions with the exception of setting the parameters through
globalvars on the command line. Explicitly call the accessors for this
code path as well so that all IP parameter settings go through them.
This is done in preparation to integrate a real network stack later.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
net/eth.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/net/eth.c b/net/eth.c
index 98567d8d3f..e81018c69b 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -393,6 +393,33 @@ static const char * const eth_mode_names[] = {
[ETH_MODE_DISABLED] = "disabled",
};
+static int eth_param_set_ip(struct param_d *p, void *priv)
+{
+ struct eth_device *edev = priv;
+
+ net_set_ip(edev, edev->ipaddr);
+
+ return 0;
+}
+
+static int eth_param_set_gw(struct param_d *p, void *priv)
+{
+ struct eth_device *edev = priv;
+
+ net_set_gateway(edev, net_get_gateway());
+
+ return 0;
+}
+
+static int eth_param_set_nm(struct param_d *p, void *priv)
+{
+ struct eth_device *edev = priv;
+
+ net_set_netmask(edev, edev->netmask);
+
+ return 0;
+}
+
int eth_register(struct eth_device *edev)
{
struct device *dev = &edev->dev;
@@ -428,10 +455,10 @@ int eth_register(struct eth_device *edev)
edev->devname = xstrdup(dev_name(&edev->dev));
- dev_add_param_ip(dev, "ipaddr", NULL, NULL, &edev->ipaddr, edev);
+ dev_add_param_ip(dev, "ipaddr", eth_param_set_ip, NULL, &edev->ipaddr, edev);
dev_add_param_string(dev, "serverip", NULL, NULL, &net_server, edev);
- dev_add_param_ip(dev, "gateway", NULL, NULL, &net_gateway, edev);
- dev_add_param_ip(dev, "netmask", NULL, NULL, &edev->netmask, edev);
+ dev_add_param_ip(dev, "gateway", eth_param_set_gw, NULL, &net_gateway, edev);
+ dev_add_param_ip(dev, "netmask", eth_param_set_nm, NULL, &edev->netmask, edev);
dev_add_param_mac(dev, "ethaddr", eth_param_set_ethaddr, NULL,
edev->ethaddr, edev);
edev->bootarg = xstrdup("");
--
2.39.2
More information about the barebox
mailing list