lkml.org 
[lkml]   [2018]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC net-next 09/15] net: lora: Prepare EUI helpers
Date
These will be used by the RN2483 and other LoRaWAN capable modules.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
include/linux/lora/dev.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/include/linux/lora/dev.h b/include/linux/lora/dev.h
index 531e68f0c9a6..153f9b2992ca 100644
--- a/include/linux/lora/dev.h
+++ b/include/linux/lora/dev.h
@@ -9,6 +9,27 @@

#include <linux/netdevice.h>

+typedef u8 lora_eui[8];
+
+#define PRIxLORAEUI "%02x%02x%02x%02x%02x%02x%02x%02x"
+#define PRIXLORAEUI "%02X%02X%02X%02X%02X%02X%02X%02X"
+#define LORA_EUI(x) x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]
+
+static inline int lora_strtoeui(const char *str, lora_eui *val)
+{
+ char buf[3];
+ int i, ret;
+
+ for (i = 0; i < 8; i++) {
+ strncpy(buf, str + i * 2, 2);
+ buf[2] = 0;
+ ret = kstrtou8(buf, 16, &(*val)[i]);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
struct net_device *alloc_loradev(int sizeof_priv);
void free_loradev(struct net_device *dev);
int register_loradev(struct net_device *dev);
--
2.16.4
\
 
 \ /
  Last update: 2018-07-01 13:11    [W:0.351 / U:2.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site