[PATCH 3/4] parameter: always build MAC dev param functions
Lucas Stach
dev at lynxeye.de
Fri Jun 26 11:59:22 PDT 2015
The MAC dev parameter functions would only be built when CONFIG_NET is
set. This was okay as long as only network devices were using MAC dev
params. This has changed with the merge of the state framework, so
always compile them in if CONFIG_PARAMETER is set.
This moves some trivial functions to the header, to avoid the need to
also build net/eth.c in that case.
Fixes:
common/built-in.o: In function `state_mac_create':
common/state.c:387: undefined reference to `dev_add_param_mac'
Signed-off-by: Lucas Stach <dev at lynxeye.de>
---
include/net.h | 30 ++++++++++++++++++++++++++++--
lib/parameter.c | 2 --
net/net.c | 29 -----------------------------
3 files changed, 28 insertions(+), 33 deletions(-)
diff --git a/include/net.h b/include/net.h
index 364011b..245d2b5 100644
--- a/include/net.h
+++ b/include/net.h
@@ -310,8 +310,34 @@ int string_to_ip(const char *s, IPaddr_t *ip);
IPaddr_t getenv_ip(const char *name);
int setenv_ip(const char *name, IPaddr_t ip);
-int string_to_ethaddr(const char *str, u8 enetaddr[6]);
-void ethaddr_to_string(const u8 enetaddr[6], char *str);
+static inline int string_to_ethaddr(const char *str, u8 enetaddr[6])
+{
+ int reg;
+ char *e;
+
+ if (!str || strlen(str) != 17) {
+ memset(enetaddr, 0, 6);
+ return -EINVAL;
+ }
+
+ if (str[2] != ':' || str[5] != ':' || str[8] != ':' ||
+ str[11] != ':' || str[14] != ':')
+ return -EINVAL;
+
+ for (reg = 0; reg < 6; ++reg) {
+ enetaddr[reg] = simple_strtoul (str, &e, 16);
+ str = e + 1;
+ }
+
+ return 0;
+}
+
+static inline void ethaddr_to_string(const u8 enetaddr[6], char *str)
+{
+ sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x",
+ enetaddr[0], enetaddr[1], enetaddr[2], enetaddr[3],
+ enetaddr[4], enetaddr[5]);
+}
#ifdef CONFIG_NET_RESOLV
IPaddr_t resolv(char *host);
diff --git a/lib/parameter.c b/lib/parameter.c
index 865ad9f..f39b98d 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -575,7 +575,6 @@ struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name,
return &piro->param;
}
-#ifdef CONFIG_NET
struct param_ip {
struct param_d param;
IPaddr_t *ip;
@@ -739,7 +738,6 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name,
return &pm->param;
}
-#endif
/**
* dev_remove_param - remove a parameter from a device and free its
diff --git a/net/net.c b/net/net.c
index 07350ad..867ec07 100644
--- a/net/net.c
+++ b/net/net.c
@@ -136,35 +136,6 @@ void print_IPaddr (IPaddr_t x)
puts(ip_to_string(x));
}
-int string_to_ethaddr(const char *str, u8 enetaddr[6])
-{
- int reg;
- char *e;
-
- if (!str || strlen(str) != 17) {
- memset(enetaddr, 0, 6);
- return -EINVAL;
- }
-
- if (str[2] != ':' || str[5] != ':' || str[8] != ':' ||
- str[11] != ':' || str[14] != ':')
- return -EINVAL;
-
- for (reg = 0; reg < 6; ++reg) {
- enetaddr[reg] = simple_strtoul (str, &e, 16);
- str = e + 1;
- }
-
- return 0;
-}
-
-void ethaddr_to_string(const u8 enetaddr[6], char *str)
-{
- sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x",
- enetaddr[0], enetaddr[1], enetaddr[2], enetaddr[3],
- enetaddr[4], enetaddr[5]);
-}
-
static unsigned char *arp_ether;
static IPaddr_t arp_wait_ip;
--
2.1.0
More information about the barebox
mailing list