lkml.org 
[lkml]   [2020]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 05/14] net: core: provide priv_to_netdev()
From
From: Bartosz Golaszewski <brgl@bgdev.pl>
Date: Mon, 11 May 2020 17:07:50 +0200

> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Appropriate amount of extra memory for private data is allocated at
> the end of struct net_device. We have a helper - netdev_priv() - that
> returns its address but we don't have the reverse: a function which
> given the address of the private data, returns the address of struct
> net_device.
>
> This has caused many drivers to store the pointer to net_device in
> the private data structure, which basically means storing the pointer
> to a structure in this very structure.
>
> This patch proposes to add priv_to_netdev() - a helper which converts
> the address of the private data to the address of the associated
> net_device.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Sorry, please don't do this. We had this almost two decades ago and
explicitly removed it intentionally.

Store the back pointer in your software state just like everyone else
does.

\
 
 \ /
  Last update: 2020-05-11 22:41    [W:0.207 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site