diff mbox series

[1/2] wifi: wilc1000: simplify remain on channel support

Message ID 20231026141016.71407-1-dmantipov@yandex.ru
State New
Headers show
Series [1/2] wifi: wilc1000: simplify remain on channel support | expand

Commit Message

Dmitry Antipov Oct. 26, 2023, 2:10 p.m. UTC
For 'struct wilc_remain_ch', drop set but otherwise unused 'duration'
field and adjust 'expired' callback assuming that the only data passed
to it is 'struct wilc_vif *', thus making 'wilc_remain_on_channel()'
a bit simpler as well. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/microchip/wilc1000/cfg80211.c |  8 +++-----
 drivers/net/wireless/microchip/wilc1000/hif.c      | 13 +++++--------
 drivers/net/wireless/microchip/wilc1000/hif.h      | 13 +++++--------
 3 files changed, 13 insertions(+), 21 deletions(-)

Comments

Ajay Singh Oct. 26, 2023, 11:45 p.m. UTC | #1
Thanks Dmitry

On 10/26/23 07:10, Dmitry Antipov wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Ensure 'sdio_release_host()' is always issued on return
> from 'wilc_sdio_cmd53()'. Compile tested only.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Acked-by: Ajay Singh <ajay.kathat@microchip.com>

> ---
>  drivers/net/wireless/microchip/wilc1000/sdio.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
> index 87948ba69a22..0d13e3e46e98 100644
> --- a/drivers/net/wireless/microchip/wilc1000/sdio.c
> +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
> @@ -106,9 +106,10 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
>                 size = cmd->count;
> 
>         if (cmd->use_global_buf) {
> -               if (size > sizeof(u32))
> -                       return -EINVAL;
> -
> +               if (size > sizeof(u32)) {
> +                       ret = -EINVAL;
> +                       goto out;
> +               }
>                 buf = sdio_priv->cmd53_buf;
>         }
> 
> @@ -123,7 +124,7 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd)
>                 if (cmd->use_global_buf)
>                         memcpy(cmd->buffer, buf, size);
>         }
> -
> +out:
>         sdio_release_host(func);
> 
>         if (ret)
> --
> 2.41.0
>
Ajay Singh Oct. 26, 2023, 11:46 p.m. UTC | #2
On 10/26/23 07:10, Dmitry Antipov wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> For 'struct wilc_remain_ch', drop set but otherwise unused 'duration'
> field and adjust 'expired' callback assuming that the only data passed
> to it is 'struct wilc_vif *', thus making 'wilc_remain_on_channel()'
> a bit simpler as well. Compile tested only.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Acked-by: Ajay Singh <ajay.kathat@microchip.com>

> ---
>  drivers/net/wireless/microchip/wilc1000/cfg80211.c |  8 +++-----
>  drivers/net/wireless/microchip/wilc1000/hif.c      | 13 +++++--------
>  drivers/net/wireless/microchip/wilc1000/hif.h      | 13 +++++--------
>  3 files changed, 13 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
> index da52f91693b5..bf2a60533506 100644
> --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c
> +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
> @@ -1094,9 +1094,8 @@ static void wilc_wfi_mgmt_tx_complete(void *priv, int status)
>         kfree(pv_data);
>  }
> 
> -static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie)
> +static void wilc_wfi_remain_on_channel_expired(struct wilc_vif *vif, u64 cookie)
>  {
> -       struct wilc_vif *vif = data;
>         struct wilc_priv *priv = &vif->priv;
>         struct wilc_wfi_p2p_listen_params *params = &priv->remain_on_ch_params;
> 
> @@ -1128,9 +1127,8 @@ static int remain_on_channel(struct wiphy *wiphy,
>         if (id == 0)
>                 id = ++priv->inc_roc_cookie;
> 
> -       ret = wilc_remain_on_channel(vif, id, duration, chan->hw_value,
> -                                    wilc_wfi_remain_on_channel_expired,
> -                                    (void *)vif);
> +       ret = wilc_remain_on_channel(vif, id, chan->hw_value,
> +                                    wilc_wfi_remain_on_channel_expired);
>         if (ret)
>                 return ret;
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c
> index a28da5938481..2c42683dd5fb 100644
> --- a/drivers/net/wireless/microchip/wilc1000/hif.c
> +++ b/drivers/net/wireless/microchip/wilc1000/hif.c
> @@ -878,7 +878,7 @@ static int handle_remain_on_chan(struct wilc_vif *vif,
>         if (result)
>                 return -EBUSY;
> 
> -       hif_drv->remain_on_ch.arg = hif_remain_ch->arg;
> +       hif_drv->remain_on_ch.vif = hif_remain_ch->vif;
>         hif_drv->remain_on_ch.expired = hif_remain_ch->expired;
>         hif_drv->remain_on_ch.ch = hif_remain_ch->ch;
>         hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie;
> @@ -915,7 +915,7 @@ static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie)
>                 }
> 
>                 if (hif_drv->remain_on_ch.expired) {
> -                       hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
> +                       hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.vif,
>                                                       cookie);
>                 }
>         } else {
> @@ -1669,18 +1669,15 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
>         }
>  }
> 
> -int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
> -                          u32 duration, u16 chan,
> -                          void (*expired)(void *, u64),
> -                          void *user_arg)
> +int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
> +                          void (*expired)(struct wilc_vif *, u64))
>  {
>         struct wilc_remain_ch roc;
>         int result;
> 
>         roc.ch = chan;
>         roc.expired = expired;
> -       roc.arg = user_arg;
> -       roc.duration = duration;
> +       roc.vif = vif;
>         roc.cookie = cookie;
>         result = handle_remain_on_chan(vif, &roc);
>         if (result)
> diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h b/drivers/net/wireless/microchip/wilc1000/hif.h
> index 8e386db72e45..b0cb35590027 100644
> --- a/drivers/net/wireless/microchip/wilc1000/hif.h
> +++ b/drivers/net/wireless/microchip/wilc1000/hif.h
> @@ -118,11 +118,11 @@ struct wilc_conn_info {
>         void *param;
>  };
> 
> +struct wilc_vif;
>  struct wilc_remain_ch {
>         u16 ch;
> -       u32 duration;
> -       void (*expired)(void *priv, u64 cookie);
> -       void *arg;
> +       void (*expired)(struct wilc_vif *vif, u64 cookie);
> +       struct wilc_vif *vif;
>         u64 cookie;
>  };
> 
> @@ -150,7 +150,6 @@ struct host_if_drv {
>         u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
>  };
> 
> -struct wilc_vif;
>  int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
>                  const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
>                  u8 mode, u8 cipher_mode, u8 index);
> @@ -192,10 +191,8 @@ int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
>  int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
>  int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
>                                 u8 *mc_list);
> -int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
> -                          u32 duration, u16 chan,
> -                          void (*expired)(void *, u64),
> -                          void *user_arg);
> +int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
> +                          void (*expired)(struct wilc_vif *, u64));
>  int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
>  void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
>  int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
> --
> 2.41.0
>
Kalle Valo Oct. 30, 2023, 5:24 p.m. UTC | #3
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> For 'struct wilc_remain_ch', drop set but otherwise unused 'duration'
> field and adjust 'expired' callback assuming that the only data passed
> to it is 'struct wilc_vif *', thus making 'wilc_remain_on_channel()'
> a bit simpler as well. Compile tested only.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> Acked-by: Ajay Singh <ajay.kathat@microchip.com>

2 patches applied to wireless-next.git, thanks.

a0ddf39ac642 wifi: wilc1000: simplify remain on channel support
ebab2723d0bd wifi: wilc1000: always release SDIO host in wilc_sdio_cmd53()
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
index da52f91693b5..bf2a60533506 100644
--- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -1094,9 +1094,8 @@  static void wilc_wfi_mgmt_tx_complete(void *priv, int status)
 	kfree(pv_data);
 }
 
-static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie)
+static void wilc_wfi_remain_on_channel_expired(struct wilc_vif *vif, u64 cookie)
 {
-	struct wilc_vif *vif = data;
 	struct wilc_priv *priv = &vif->priv;
 	struct wilc_wfi_p2p_listen_params *params = &priv->remain_on_ch_params;
 
@@ -1128,9 +1127,8 @@  static int remain_on_channel(struct wiphy *wiphy,
 	if (id == 0)
 		id = ++priv->inc_roc_cookie;
 
-	ret = wilc_remain_on_channel(vif, id, duration, chan->hw_value,
-				     wilc_wfi_remain_on_channel_expired,
-				     (void *)vif);
+	ret = wilc_remain_on_channel(vif, id, chan->hw_value,
+				     wilc_wfi_remain_on_channel_expired);
 	if (ret)
 		return ret;
 
diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c
index a28da5938481..2c42683dd5fb 100644
--- a/drivers/net/wireless/microchip/wilc1000/hif.c
+++ b/drivers/net/wireless/microchip/wilc1000/hif.c
@@ -878,7 +878,7 @@  static int handle_remain_on_chan(struct wilc_vif *vif,
 	if (result)
 		return -EBUSY;
 
-	hif_drv->remain_on_ch.arg = hif_remain_ch->arg;
+	hif_drv->remain_on_ch.vif = hif_remain_ch->vif;
 	hif_drv->remain_on_ch.expired = hif_remain_ch->expired;
 	hif_drv->remain_on_ch.ch = hif_remain_ch->ch;
 	hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie;
@@ -915,7 +915,7 @@  static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie)
 		}
 
 		if (hif_drv->remain_on_ch.expired) {
-			hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
+			hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.vif,
 						      cookie);
 		}
 	} else {
@@ -1669,18 +1669,15 @@  void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
 	}
 }
 
-int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
-			   u32 duration, u16 chan,
-			   void (*expired)(void *, u64),
-			   void *user_arg)
+int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
+			   void (*expired)(struct wilc_vif *, u64))
 {
 	struct wilc_remain_ch roc;
 	int result;
 
 	roc.ch = chan;
 	roc.expired = expired;
-	roc.arg = user_arg;
-	roc.duration = duration;
+	roc.vif = vif;
 	roc.cookie = cookie;
 	result = handle_remain_on_chan(vif, &roc);
 	if (result)
diff --git a/drivers/net/wireless/microchip/wilc1000/hif.h b/drivers/net/wireless/microchip/wilc1000/hif.h
index 8e386db72e45..b0cb35590027 100644
--- a/drivers/net/wireless/microchip/wilc1000/hif.h
+++ b/drivers/net/wireless/microchip/wilc1000/hif.h
@@ -118,11 +118,11 @@  struct wilc_conn_info {
 	void *param;
 };
 
+struct wilc_vif;
 struct wilc_remain_ch {
 	u16 ch;
-	u32 duration;
-	void (*expired)(void *priv, u64 cookie);
-	void *arg;
+	void (*expired)(struct wilc_vif *vif, u64 cookie);
+	struct wilc_vif *vif;
 	u64 cookie;
 };
 
@@ -150,7 +150,6 @@  struct host_if_drv {
 	u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
 };
 
-struct wilc_vif;
 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
 		 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
 		 u8 mode, u8 cipher_mode, u8 index);
@@ -192,10 +191,8 @@  int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
 int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
 				u8 *mc_list);
-int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
-			   u32 duration, u16 chan,
-			   void (*expired)(void *, u64),
-			   void *user_arg);
+int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
+			   void (*expired)(struct wilc_vif *, u64));
 int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
 void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
 int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,