Message ID | 20221123180151.2160033-2-michael@walle.cc |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2941614wrr; Wed, 23 Nov 2022 10:04:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf6QUVE+/o4nFe+wdkpmZZO9/YgmO0WJ9lSb9X/4reiL1XTP3zZ00eXbSIPcDOXQxH4sfYLh X-Received: by 2002:a05:6402:504:b0:461:5542:6884 with SMTP id m4-20020a056402050400b0046155426884mr16837143edv.390.1669226678270; Wed, 23 Nov 2022 10:04:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226678; cv=none; d=google.com; s=arc-20160816; b=xQyOxtt/rKjKN2zTFDVDtzT3qn23ur9XPfBW9pTcD9T/y6VPLwKdw3LfyZueVSbZgH X/KeZNFv0/F3YHFxnTXt7m15CUf2qFm6lN1GNvdSbNVTmWdRqC3utXBZtjeEiE/r07V7 eheS5LqBUwtyqomIkssU2wUmlD4cK3fEStvqxPVwpdIOkVWr1TM0hobIkRtBDETabn2W dObAyUE4j/Nkov0xYXcfUi6SkWOl5GN57xwamVAwVqU/ciB6l6ipORpisbTH4DEKCGkf cfhlv2ubOqXXH7iczlgXcxTTetGhXC4ehFdo7Wjn/saLKOEY1gzJbyOdpvdb5b+ouGQQ DDww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8sjjk67lYXsbZ+8cTcOR9HPiqjFzaTQLO5gq3X9c4IA=; b=houj/tp2kQgibY+Xq8JadLReikrniSO1vu2i6UcAXqu86fFwffHdWKCtgplJyjAxzk 1jK1izDuo3cyGsF5+EZEvBuqV2UfwqJPyrekGN96i+zbufUUnIRmuWOEIdPQbnHS9lGR Z0/zDxAJS3IveaH8XKZsWOoU60P8Nm5PaYwzj1vC87stRv75pUiH9pXW8zLJYdTfk0bB nHVHLGpSLxLmZC6mBLkF+TdWyuO4TF7qnmXeuZXxyui3AfEKgD2CTpTx9vyi3m/ZinfW a56acc8Mzizx7AvhulMDirKyRa/T7iOf52Ua9eTxsrMrBOhH/W3Z8mgZ07UKqePNCyXp EHLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=zeAXKIkh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc39-20020a1709071c2700b0078d4b2754b5si17084904ejc.332.2022.11.23.10.04.03; Wed, 23 Nov 2022 10:04:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=zeAXKIkh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239496AbiKWSDL (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Wed, 23 Nov 2022 13:03:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239365AbiKWSCV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 23 Nov 2022 13:02:21 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4B1E93700; Wed, 23 Nov 2022 10:02:20 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 59D7C27B2; Wed, 23 Nov 2022 19:02:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8sjjk67lYXsbZ+8cTcOR9HPiqjFzaTQLO5gq3X9c4IA=; b=zeAXKIkh1NfD6yON6Wk9huqk9GL/RNNI0wcW3b+xZN/jZNrEJoLcYjTEq9j4Ei5Q8OHFU8 H/a+SvAyy9EIJtraA9MccxRXjPdez1bvmYjbK0qoUTnfBjtC+nTKjVg26J022Nzn7lLD3o t1ZSX8SOaqfRgO6+D+DZB8XHvNSMGp3Vc/QdG4DP8kwEHHvLh8yElLsp8DN82kS7XmzLW3 Nfe2yxX2UAR7Z+7vV8GfV6dv24MeKJr/CyEeg0lLrF4HQJ9xhreMlvdcOpTt9r0olAMoMM J7C5evjwohYhc8R7fAUtXjczWJNuOzCB5YJAQ7eyIKZ87Tl9o2QpK/Rz+V3c9w== From: Michael Walle <michael@walle.cc> To: Jonathan Corbet <corbet@lwn.net>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, Miquel Raynal <miquel.raynal@bootlin.com>, Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>, Sascha Hauer <s.hauer@pengutronix.de> Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle <michael@walle.cc>, Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v4 01/20] net: add helper eth_addr_add() Date: Wed, 23 Nov 2022 19:01:32 +0100 Message-Id: <20221123180151.2160033-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311033060736712?= X-GMAIL-MSGID: =?utf-8?q?1750311033060736712?= |
Series |
nvmem: core: introduce NVMEM layouts
|
|
Commit Message
Michael Walle
Nov. 23, 2022, 6:01 p.m. UTC
Add a helper to add an offset to a ethernet address. This comes in handy if you have a base ethernet address for multiple interfaces. Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Jakub Kicinski <kuba@kernel.org> --- changes since v3: - fix typo s/and/an/ changes since v2: - none changes since v1: - none include/linux/etherdevice.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index a541f0c4f146..224645f17c33 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -507,6 +507,20 @@ static inline void eth_addr_inc(u8 *addr) u64_to_ether_addr(u, addr); } +/** + * eth_addr_add() - Add (or subtract) an offset to/from the given MAC address. + * + * @offset: Offset to add. + * @addr: Pointer to a six-byte array containing Ethernet address to increment. + */ +static inline void eth_addr_add(u8 *addr, long offset) +{ + u64 u = ether_addr_to_u64(addr); + + u += offset; + u64_to_ether_addr(u, addr); +} + /** * is_etherdev_addr - Tell if given Ethernet address belongs to the device. * @dev: Pointer to a device structure