Message ID | 20221206200740.3567551-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 q4csp3026550wrr; Tue, 6 Dec 2022 12:08:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6MmFWgbrrIqfbAZI+TCxQGNTJDCo+Hp1ZLszVyzevO53AyHQTbWLCwyIcD7n8JnNXo//b/ X-Received: by 2002:a17:902:bd42:b0:186:9c2b:3a39 with SMTP id b2-20020a170902bd4200b001869c2b3a39mr72669787plx.115.1670357306536; Tue, 06 Dec 2022 12:08:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670357306; cv=none; d=google.com; s=arc-20160816; b=ycqIvZBKWHCMR4N03LzqG6kRGslzci+qjuXtBkpGKFIrBB7woWAeiR/agINC+0lHg2 vy2snzDzVsDnUr6y7ojt3gDJwR/mBogYX6rIXoNdM12ZCdiBdH+WDTzDGAbnhZR7ztO8 6CKUutVtad8m+PpxhxSoLW6TXP2aoU9kONfu7CWqNJ//nB0VNUu0sbZT8+EE3/J8Uf9O f5n93xvK0y8ibngYfGHj48yrtkbHGT1EE5K4JXVG+5w6FK6Cr7M/OZbflj6Zfrr4VrOI dkPJ92K+e4zy/Eiw/3tD5WvwlFbTV/0JOCnPnSd6yyyuEJmt+G64R0s23oQ/dnejy+BZ tQLw== 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=ILxP0jW0nBzAhvh7z1J9P1H1PJrtvXTRHQ4DduPRocE=; b=Kvk8iMXPZqO/iiRA8xNlFmOBnhujWr9WBvJ65jGcYwZHAvUgGWf4vwhdcvVrGsa7bG QShT4YYmajMQEGyjygD+8L0NciG6w9x1F64XjPFZu+slJt2vYJUXeWF3/YxyBXaoFs9J y+cHIe7CwGCSF7tG+I7t0+e0B7NOZzmm9RoN6IqCsIGDeE78S9jS+F55JX+n4EnmyUBX bxUUwE6vWgZs8N5zrVyXtqfqz00N9gEvxewnVLas5hCjd1bPWkx4O/3QWbs2cXYUqpj2 9HpPE59EPG/FgBoCy291IWYGFvHPxlCeu2OM9tnuOmbwxewAW95xKb1tLA6fGYIqeapd mpHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b="Q5qPxmm/"; 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 b12-20020a630c0c000000b00422c003b4c9si18719013pgl.46.2022.12.06.12.08.13; Tue, 06 Dec 2022 12:08:26 -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="Q5qPxmm/"; 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 S229699AbiLFUHx (ORCPT <rfc822;jaysivo@gmail.com> + 99 others); Tue, 6 Dec 2022 15:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbiLFUHu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 6 Dec 2022 15:07:50 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F62CE05; Tue, 6 Dec 2022 12:07:48 -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 05674256D; Tue, 6 Dec 2022 21:07:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1670357266; 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=ILxP0jW0nBzAhvh7z1J9P1H1PJrtvXTRHQ4DduPRocE=; b=Q5qPxmm//GWuGUlu28YuGCCZP07ElXzUaoHnPSgrXHcDyHCa2WZcE7jxPiIik1qKI0Iqgh KMJveO7U2Ty0lStusmHGY8dOCKR0XyQpbK29xr/XoAqQafBs7PzHIBduj9TVG2U+Eg5jg2 Z+oF/N7bfk13aGNnL++TvrhJpN/DGKskUQPoUTQM+ycjfETt4ClSZKOeY4NEO64EOOlpVM GhOIx/KDDJieM3CaJ8oVIu6KUambo+SdO58wK1djNdh4qnXZybtKSEYu9LQUQpOfbM+ifc zVjzZ+6aUFnOqOQHlDcJoL7LWM6poTCgv1yIKBVLu/5M9GCmUKijOwkgA3T8SA== 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>, Dan Carpenter <error27@gmail.com>, Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org> Subject: [PATCH v5 01/21] net: add helper eth_addr_add() Date: Tue, 6 Dec 2022 21:07:20 +0100 Message-Id: <20221206200740.3567551-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221206200740.3567551-1-michael@walle.cc> References: <20221206200740.3567551-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?1751496583110030751?= X-GMAIL-MSGID: =?utf-8?q?1751496583110030751?= |
Series |
nvmem: core: introduce NVMEM layouts
|
|
Commit Message
Michael Walle
Dec. 6, 2022, 8:07 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 v4: - none 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