From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D3735F5E3 for ; Fri, 20 Mar 2026 07:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773993383; cv=none; b=gwVaLX5G+pL79Hi7G0ln8r/Fc/VooUchc1fQkyGy6lZRWVxI/E56a2WSG4IO49L3O7SgEW+ekQQUw5jfRtnW9H5JyXi3z3N/2KwAw4pg+VauV1Zg8GVdGKvq0qVhLEbNjqYRz4ON3wpWLvBZUt/6MyNrqzxifSymi0DtIq6P638= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773993383; c=relaxed/simple; bh=UAEy2Xe2unCpV2Aisrk8JVqTZDFSxpOzIYuBLw1sdN0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=POAxhNeAoDeQ96UUHGjl9IDXAQaBV5U/vDosDxaLeiXI4wayEJd7HyZx6Zo2UPiImuJhvuUZWZKyiz/ACjHeHbAD89/kSrVeXtnctRJoKLf4yXrWnTWKlsPxw0TvgZDacSl/BV2jr+pFVWy4cX5mHIviuwuHs19rTkdh4/6F5/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nbbSApdJ; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nbbSApdJ" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-b932fe2e1a7so214979666b.1 for ; Fri, 20 Mar 2026 00:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773993374; x=1774598174; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DHrhfST8MC/cgKssvPyr9ZbJixCQY5nYy4UehicETCA=; b=nbbSApdJyCwnHSybwx/1PqJDfpYiZeUb13p1b/Qir9S7qCcw7Dhvt+mQ+Nr2uqk/pq zy9ILYgR5ituptBr/iOACfuYrOe086//PAczY3fJoOe3VLbY+1OjjohAUX2Z/rqtut4k RCYVeRQAA0TAJKrqPI1buIm0hMKDj8U8kM7JQeaQxaEWpHCLGMe0bxpnKubeYNevSNQq QKQmI5FoWDlYYbJcmx47qpTFUGjtIWWVCNoYw/BAj/JzVXpw8UHTTDnbeR8fzKRdBUvs uS9rQcfUBp+h/sEz4KByTNQmn7dDSvcROjc5eiGZDadDCXl1z1ObE4KKnUBECLf6O+UZ 9PIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773993374; x=1774598174; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DHrhfST8MC/cgKssvPyr9ZbJixCQY5nYy4UehicETCA=; b=NcCfsjDJz+0YI8E6Vj+5cx2mlEtKt/I+7evy03RRsljZ8uzrDKmd94wXDSouIdr9Cf 8X7BxzO4x0paxC/ZV3HHy1vzp1cmQ67Isb/c8+h5ouICeX4uW8T3jWBLL157WLfkY+bZ 86wI/IxfIEthqbcA2u6dvyu++n2YmDevSdfoqc6f7/62sijtbW0iqPFl4aP/pQWIQfTO 5MnzXRkFa85+dTt/WPj71C4SzPNk1L/ApFhbe5HfFE69cJXr/wGQ86Gc16o4T03G+RV7 ImdkOkYIA2EPcr7190kUw3QKHiq2qPMf1hPtVaV3zE99fFqpPMboAFjk+97NzWKUTW3H o59g== X-Forwarded-Encrypted: i=1; AJvYcCU+IgTL/jjFEAFqM1nGdo7ZCrKs/1AjMkmUxpBCx58GtR5bJM/si6xV5lIdY1eijMF9TX1QIQM3sv8Y5VI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy+8h9Enna8lCcGrI1NVb9VYx+Yl0tqhtwp9vuC77DxrtLusa53 EPajBajQU/0r79gOgHEiCEAY5zv3ZQrz2QQl2vbfFN21A8F98XaqbBKK X-Gm-Gg: ATEYQzxENrVvGDUr+/67tP8ZpGgkYP2xR5ZbsBUtAPBO0aC3cXPpuFkZCIPtcTzGETF UeYfnCmrUCXUa9gZFPFAWYCRWeUPbxJmDLlmTl9rpziAravbAJfFesVpCWm9aMAIt5IMM85dGtF 8dHsqeXZ15FZ/1a6u0McZgrYCtjoD+zxpbcFri0oY716sBHayvb7FP1Qaj/H66ud7ST1Nr+OhpE TAsvaBB0gckCLfmoqcKkg59lkgo9eM7BfjA4bDUzrRZteuWsvrj6WU1dTkRvvwogU605feFcfR1 nMjWFow4G1i3n3SaSrYx+aoKpDjGNiUt+RGb/aeoFH/VBg7mbB00AGRWXRoiqgOh1s/UEzDU5uc mOJBkSkUMxxUQxtaEYAmsZH/YNM1JVmOD1p8aOE2DGob898smxP0qlS5fN1BACO7FeBAheRqG X-Received: by 2002:a17:906:a2d8:b0:b98:50b:e94a with SMTP id a640c23a62f3a-b982f244b9fmr110605666b.16.1773993373952; Fri, 20 Mar 2026 00:56:13 -0700 (PDT) Received: from gmail.com ([2a09:bac1:5540::49b:47]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b983365a14csm115965066b.43.2026.03.20.00.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 00:56:13 -0700 (PDT) From: Qingfang Deng To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alexander Lobakin , Breno Leitao , Przemek Kitszel , Kees Cook Subject: [PATCH net-next v2 1/2] net: add netdev_from_priv() helper Date: Fri, 20 Mar 2026 15:56:03 +0800 Message-ID: <20260320075605.490832-1-dqfext@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a helper to get netdev from private data pointer, so drivers won't have to store redundant netdev in priv. Signed-off-by: Qingfang Deng --- v2: update kdoc format - https://lore.kernel.org/netdev/20260319022608.323969-1-dqfext@gmail.com/ include/linux/netdevice.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7ca01eb3f7d2..6882b41bb3e8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2765,6 +2765,17 @@ static inline void *netdev_priv(const struct net_device *dev) return (void *)dev->priv; } +/** + * netdev_from_priv() - get network device from priv + * @priv: network device private data + * + * Returns: net_device to which @priv belongs + */ +static inline struct net_device *netdev_from_priv(const void *priv) +{ + return container_of(priv, struct net_device, priv); +} + /* Set the sysfs physical device reference for the network logical device * if set prior to registration will cause a symlink during initialization. */ -- 2.43.0