Re: [PATCH v2] staging: wfx: use container_of() to get vif

From: Greg Kroah-Hartman
Date: Fri Apr 08 2022 - 00:46:07 EST


On Thu, Apr 07, 2022 at 11:23:49PM -0400, Jaehee Park wrote:
> Use container_of() to get vif. This improves the code in two ways:
> [1] it speeds up the compilation because container_of() saves steps to
> retrieve vif (the representation of ieee80211_vif), and
> [2] it eliminates the need to define multiple pointers. Previously,
> after setting the pointer to drv_priv, another pointer had to be
> defined by vif in struct wfx_vif to point back to ieee80211_vif.
> Remove vif from the struct wfx_vif, define a macro wvif_to_vif(ptr)
> for container_of(), and replace all wvif->vif with the newly defined
> container_of() construct.
>
> Signed-off-by: Jaehee Park <jhpark1013@xxxxxxxxx>
> ---
> Note:
> This is a revised patch to sequence the wfx.h file (with the new defines) to show up first on the diff, which makes the ordering of the diff more logical.
>
> Questions:
> - These changes had built without errors for me but it would be great if someone can test it on the actual hardware.
> - We noticed that the development of the wfx driver is happening in the netdev tree instead of Greg's tree. Do you suggest that I use the net-next tree for this change? 
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/log/drivers/staging/wfx
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/log/drivers/staging/wfx
>
> drivers/staging/wfx/wfx.h | 3 ++-
> drivers/staging/wfx/data_rx.c | 4 ++--
> drivers/staging/wfx/data_tx.c | 2 +-
> drivers/staging/wfx/key.c | 3 +--
> drivers/staging/wfx/queue.c | 2 +-
> drivers/staging/wfx/scan.c | 6 ++---
> drivers/staging/wfx/sta.c | 45 ++++++++++++++++-------------------
> 7 files changed, 31 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
> index 6594cc647c2f..78f2a416fe4f 100644
> --- a/drivers/staging/wfx/wfx.h
> +++ b/drivers/staging/wfx/wfx.h
> @@ -25,6 +25,8 @@
> #define USEC_PER_TXOP 32 /* see struct ieee80211_tx_queue_params */
> #define USEC_PER_TU 1024
>
> +#define wvif_to_vif(ptr)(container_of((void *)ptr, struct ieee80211_vif, drv_priv))

Always use whitespace properly.

> struct wfx_hwbus_ops;
>
> struct wfx_dev {
> @@ -61,7 +63,6 @@ struct wfx_dev {
>
> struct wfx_vif {
> struct wfx_dev *wdev;
> - struct ieee80211_vif *vif;

You need to test this on real hardware. For an outreachy-first-task,
this is not a good one at all.

Also this code is no longer in drivers/staging/ Please work on the
netdev mailing list as I can not take these changes anymore.

good luck!

greg k-h