From patchwork Sun Sep 17 16:58:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 9954949 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 0404D60208 for ; Sun, 17 Sep 2017 16:58:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E51F728A00 for ; Sun, 17 Sep 2017 16:58:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA03628A02; Sun, 17 Sep 2017 16:58:43 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B83AA28A01 for ; Sun, 17 Sep 2017 16:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751651AbdIQQ6j (ORCPT ); Sun, 17 Sep 2017 12:58:39 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:43334 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751619AbdIQQ6j (ORCPT ); Sun, 17 Sep 2017 12:58:39 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 83BE3487DB; Sun, 17 Sep 2017 18:58:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id lZLnNwp_sYKC; Sun, 17 Sep 2017 18:58:32 +0200 (CEST) From: Hauke Mehrtens To: johannes@sipsolutions.net Cc: backports@vger.kernel.org, Hauke Mehrtens Subject: [PATCH 4/4] header: add ether_addr_to_u64() and u64_to_ether_addr() Date: Sun, 17 Sep 2017 18:58:13 +0200 Message-Id: <20170917165813.17580-5-hauke@hauke-m.de> In-Reply-To: <20170917165813.17580-1-hauke@hauke-m.de> References: <20170917165813.17580-1-hauke@hauke-m.de> Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP These function were added in commit 5952758101 ("dsa: mv88e6xxx: Optimise atu_get") and are now used by mwifiex. Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/etherdevice.h | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/backport/backport-include/linux/etherdevice.h b/backport/backport-include/linux/etherdevice.h index 92256e00..a00e6660 100644 --- a/backport/backport-include/linux/etherdevice.h +++ b/backport/backport-include/linux/etherdevice.h @@ -193,4 +193,38 @@ static inline int eth_skb_pad(struct sk_buff *skb) } #endif /* LINUX_VERSION_IS_LESS(3,19,0) */ +#if LINUX_VERSION_IS_LESS(4,11,0) +/** + * ether_addr_to_u64 - Convert an Ethernet address into a u64 value. + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Return a u64 value of the address + */ +static inline u64 ether_addr_to_u64(const u8 *addr) +{ + u64 u = 0; + int i; + + for (i = 0; i < ETH_ALEN; i++) + u = u << 8 | addr[i]; + + return u; +} + +/** + * u64_to_ether_addr - Convert a u64 to an Ethernet address. + * @u: u64 to convert to an Ethernet MAC address + * @addr: Pointer to a six-byte array to contain the Ethernet address + */ +static inline void u64_to_ether_addr(u64 u, u8 *addr) +{ + int i; + + for (i = ETH_ALEN - 1; i >= 0; i--) { + addr[i] = u & 0xff; + u = u >> 8; + } +} +#endif /* LINUX_VERSION_IS_LESS(4,11,0) */ + #endif /* _BACKPORT_LINUX_ETHERDEVICE_H */