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: 140697 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2847438ljj; Sun, 1 Jul 2018 04:09:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpew1SoOovh5cpSxw7x8Ridc4pkMXn1F3Vwbx/lTW+lJJss9rdcGz6foxfrqgu1WxPBrLh8o X-Received: by 2002:a62:6882:: with SMTP id d124-v6mr21293100pfc.122.1530443356444; Sun, 01 Jul 2018 04:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530443356; cv=none; d=google.com; s=arc-20160816; b=oPXZntqhzqLmxx7U1drZaZ6z14I3scg8RHoRUY+SWOtK8F+EvQlY+r9UZS4X4Au+5i mJvH2JjHuuGuMlryBzEVF48HnWyRbZXDp0RYBvlx41NW6d2ZayuJUgBwIZZEG9oH9sFi WuuJl80B6S2f4W3fZVFiUCgX3oNOuxqdDpF7TLmORYQI/7em3K3c9mbuqHY3o6x3B6E7 Ne08ZvFqcaLZlzAKHWyIvkSks1yss40rNpbcgZpzm2PCw8qZ952Vn4W4hoEw5yyQhWFH xmwG0ZH2RZOIpSGSPNi0idN1WWRUv+rz642JajeVHYd+SC88gJIkzWo1uTysgMX5lNCp nRTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=fc+cCNYLxauDxS94MVbgW9rSb0y8H9XsCDbU6iiJdyM=; b=jOAbRUpqUKGNHImLzBnCV/kGGC/Xaj6nsC3QwLJOJau0DcuxpuDVxW5lMhtsW4IPq2 ci4fP7ORdKqAT6G7QnTle03/U8FC5Kt8NmYLKv847b6zbx0XEhPxHlHwV73HNLOvoRPM Sq2vVG5hv75/Pq31W0bWZiivRtnkoxNA+aqnSorgU64k0t6bhl6O530InwJvTWqibshA 3GTgcfk3H39n7w+nYtSXKrwuhJ67n6xNZJy5TCFQsHKOac7pDHEd39Dah7Fa28njT5O9 BQDAjRmTfJ7O+awf+T6muSelZmzYOCO8pCen9idIfczApAKimE2145ZSs0dAK5l4bxId c9TA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26-v6si11251445pgu.191.2018.07.01.04.09.16; Sun, 01 Jul 2018 04:09:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbeGALJF (ORCPT + 9 others); Sun, 1 Jul 2018 07:09:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:47842 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752292AbeGALJC (ORCPT ); Sun, 1 Jul 2018 07:09:02 -0400 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jian-Hong Pan , Jiri Pirko , Marcel Holtmann , "David S . Miller" , Matthias Brugger , Janus Piwek , =?utf-8?q?Michael_R=C3=B6der?= , Dollar Chen , Ken Yu , =?utf-8?q?Andreas_F=C3=A4rber?= 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 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.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(+) -- 2.16.4 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);