From patchwork Sun Jul 1 11:07:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 10498627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6079260284 for ; Sun, 1 Jul 2018 11:11:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D3E28AF3 for ; Sun, 1 Jul 2018 11:11:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4372628AFB; Sun, 1 Jul 2018 11:11:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C28F128AF3 for ; Sun, 1 Jul 2018 11:11:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YIKl/wF74nPAPhpOSQTC2T16fjSB9CbPqHSqiRORToo=; b=CQiLU3xCyenrmq 2Bc9FIiZ1/gS1acwlEVrsEcvkzT3wDlsMMYbAKSJwcx23PVjwVG8Ai2saRqW5RS0JJau/EzIf4fen fXKbv++W1FC0wht6/P5GRlpSNKZ061FvThahGG8pePMjNt0sC1JOMU2WR2+8DSUP/9wLN27XWxyug T2LfrGNazvfX6B+HoDODiviXWTDWDMUygn91MYHW0XL0i6DXJ7DAq3SZ5q7I8FNb/PSSOGq9PnjSW bDxOY2HG9ChcjG1atiuxk7muML3OYclLclrQ7mPJYwjqPzxgVBgp5v9UokTo92QSxTfIcZ2O8QTog HtA4SmAHTNUJ/HNRKT6g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fZaGE-0006VJ-IA; Sun, 01 Jul 2018 11:11:18 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fZaEP-0004XW-9R for linux-arm-kernel@lists.infradead.org; Sun, 01 Jul 2018 11:09:30 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EA72CAF54; Sun, 1 Jul 2018 11:08:59 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: netdev@vger.kernel.org Subject: [RFC net-next 09/15] net: lora: Prepare EUI helpers Date: Sun, 1 Jul 2018 13:07:58 +0200 Message-Id: <20180701110804.32415-10-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180701110804.32415-1-afaerber@suse.de> References: <20180701110804.32415-1-afaerber@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180701_040925_908289_B0CBD302 X-CRM114-Status: GOOD ( 10.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthias Brugger , Jiri Pirko , Marcel Holtmann , Dollar Chen , linux-kernel@vger.kernel.org, =?UTF-8?q?Michael=20R=C3=B6der?= , Janus Piwek , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Jian-Hong Pan , Ken Yu , "David S . Miller" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP These will be used by the RN2483 and other LoRaWAN capable modules. Signed-off-by: Andreas Färber --- 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 +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);