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: 937550 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CQiLU3xC"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41JSPZ5fpYz9s1b for ; Sun, 1 Jul 2018 21:11:30 +1000 (AEST) 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 1fZaGH-0006VJ-Hj; Sun, 01 Jul 2018 11:11:21 +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_F=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-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [195.135.220.15 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list 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_R=C3=B6der?= , Janus Piwek , =?utf-8?q?Andreas_F=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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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);