linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ajay Singh <ajay.kathat@microchip.com>
To: Claudiu Beznea <Claudiu.Beznea@microchip.com>
Cc: <linux-wireless@vger.kernel.org>, <devel@driverdev.osuosl.org>,
	<gregkh@linuxfoundation.org>, <ganesh.krishna@microchip.com>,
	<venkateswara.kaja@microchip.com>, <aditya.shankar@microchip.com>,
	<adham.abozaeid@microchip.com>
Subject: Re: [PATCH 11/24] staging: wilc1000: move hif specific static variables to 'wilc' structure
Date: Thu, 23 Aug 2018 15:39:41 +0530	[thread overview]
Message-ID: <20180823153941.0ff5f43e@ajaysk-VirtualBox> (raw)
In-Reply-To: <8020e04f-23b0-1b1c-9d75-9dc5fdfde9f3@microchip.com>

On Thu, 23 Aug 2018 11:11:09 +0300
Claudiu Beznea <Claudiu.Beznea@microchip.com> wrote:

> On 14.08.2018 09:50, Ajay Singh wrote:
> > Avoid use of static variable and move it in 'wilc' structure
> > related to hif and added NULL before accessing hif_workqueue in
> > wilc_enqueue_work().
> > 
> > Below variables are moved to 'wilc' struct:
> >  struct workqueue_struct *hif_workqueue;
> >  struct mutex hif_deinit_lock;
> >  struct completion hif_driver_comp;
> > 
> > Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> > ---
> >  drivers/staging/wilc1000/host_interface.c     | 43
> > ++++++++++++++-------------
> > drivers/staging/wilc1000/wilc_wfi_netdevice.h |  4 +++ 2 files
> > changed, 26 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/staging/wilc1000/host_interface.c
> > b/drivers/staging/wilc1000/host_interface.c index 642c314..d5d81843
> > 100644 --- a/drivers/staging/wilc1000/host_interface.c
> > +++ b/drivers/staging/wilc1000/host_interface.c
> > @@ -187,9 +187,6 @@ struct join_bss_param {
> >  
> >  static struct host_if_drv *terminated_handle;
> >  static u8 p2p_listen_state;
> > -static struct workqueue_struct *hif_workqueue;
> > -static struct completion hif_driver_comp;
> > -static struct mutex hif_deinit_lock;
> >  static struct timer_list periodic_rssi;
> >  static struct wilc_vif *periodic_rssi_vif;
> >  
> > @@ -225,7 +222,11 @@ wilc_alloc_work(struct wilc_vif *vif, void
> > (*work_fun)(struct work_struct *), static int
> > wilc_enqueue_work(struct host_if_msg *msg) {
> >  	INIT_WORK(&msg->work, msg->fn);
> > -	if (!hif_workqueue || !queue_work(hif_workqueue,
> > &msg->work)) +
> > +	if (!msg->vif || !msg->vif->wilc
> > || !msg->vif->wilc->hif_workqueue)
> > +		return -EINVAL;
> > +
> > +	if (!queue_work(msg->vif->wilc->hif_workqueue, &msg->work))
> >  		return -EINVAL;
> >  
> >  	return 0;
> > @@ -316,7 +317,7 @@ static void handle_set_wfi_drv_handler(struct
> > work_struct *work) if (ret)
> >  		netdev_err(vif->ndev, "Failed to set driver
> > handler\n"); 
> > -	complete(&hif_driver_comp);
> > +	complete(&vif->wilc->hif_driver_comp);
> >  	kfree(buffer);
> >  
> >  free_msg:
> > @@ -340,7 +341,7 @@ static void handle_set_operation_mode(struct
> > work_struct *work) wilc_get_vif_idx(vif));
> >  
> >  	if (hif_op_mode->mode == IDLE_MODE)
> > -		complete(&hif_driver_comp);
> > +		complete(&vif->wilc->hif_driver_comp);
> >  
> >  	if (ret)
> >  		netdev_err(vif->ndev, "Failed to set operation
> > mode\n"); @@ -3454,11 +3455,11 @@ int wilc_init(struct net_device
> > *dev, struct host_if_drv **hif_drv_handler) vif->obtaining_ip =
> > false; 
> >  	if (wilc->clients_count == 0) {
> > -		init_completion(&hif_driver_comp);
> > -		mutex_init(&hif_deinit_lock);
> > +		init_completion(&wilc->hif_driver_comp);
> > +		mutex_init(&wilc->hif_deinit_lock);
> >  
> > -		hif_workqueue =
> > create_singlethread_workqueue("WILC_wq");
> > -		if (!hif_workqueue) {
> > +		wilc->hif_workqueue =
> > create_singlethread_workqueue("WILC_wq");
> > +		if (!wilc->hif_workqueue) {
> >  			netdev_err(vif->ndev, "Failed to create
> > workqueue\n"); kfree(hif_drv);
> >  			return -ENOMEM;
> > @@ -3502,7 +3503,7 @@ int wilc_deinit(struct wilc_vif *vif)
> >  		return -EFAULT;
> >  	}
> >  
> > -	mutex_lock(&hif_deinit_lock);
> > +	mutex_lock(&vif->wilc->hif_deinit_lock);
> >  
> >  	terminated_handle = hif_drv;
> >  
> > @@ -3512,7 +3513,7 @@ int wilc_deinit(struct wilc_vif *vif)
> >  	del_timer_sync(&hif_drv->remain_on_ch_timer);
> >  
> >  	wilc_set_wfi_drv_handler(vif, 0, 0, 0);
> > -	wait_for_completion(&hif_driver_comp);
> > +	wait_for_completion(&vif->wilc->hif_driver_comp);
> >  
> >  	if (hif_drv->usr_scan_req.scan_result) {
> >  		hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
> > NULL, @@ -3536,14 +3537,14 @@ int wilc_deinit(struct wilc_vif *vif)
> >  				wait_for_completion(&msg->work_comp);
> >  			kfree(msg);
> >  		}
> > -		destroy_workqueue(hif_workqueue);
> > +		destroy_workqueue(vif->wilc->hif_workqueue);
> >  	}
> >  
> >  	kfree(hif_drv);
> >  
> >  	vif->wilc->clients_count--;
> >  	terminated_handle = NULL;
> > -	mutex_unlock(&hif_deinit_lock);
> > +	mutex_unlock(&vif->wilc->hif_deinit_lock);
> >  	return result;
> >  }
> >  
> > @@ -3596,7 +3597,7 @@ void wilc_gnrl_async_info_received(struct
> > wilc *wilc, u8 *buffer, u32 length) struct host_if_drv *hif_drv;
> >  	struct wilc_vif *vif;
> >  
> > -	mutex_lock(&hif_deinit_lock);
> > +	mutex_lock(&wilc->hif_deinit_lock);
> >  
> >  	id = buffer[length - 4];
> >  	id |= (buffer[length - 3] << 8);
> > @@ -3604,26 +3605,26 @@ void wilc_gnrl_async_info_received(struct
> > wilc *wilc, u8 *buffer, u32 length) id |= (buffer[length - 1] <<
> > 24); vif = wilc_get_vif_from_idx(wilc, id);
> >  	if (!vif) {
> > -		mutex_unlock(&hif_deinit_lock);
> > +		mutex_unlock(&wilc->hif_deinit_lock);
> >  		return;
> >  	}
> >  
> >  	hif_drv = vif->hif_drv;
> >  
> >  	if (!hif_drv || hif_drv == terminated_handle) {
> > -		mutex_unlock(&hif_deinit_lock);
> > +		mutex_unlock(&wilc->hif_deinit_lock);
> >  		return;
> >  	}
> >  
> >  	if (!hif_drv->usr_conn_req.conn_result) {
> >  		netdev_err(vif->ndev, "%s: conn_result is NULL\n",
> > __func__);
> > -		mutex_unlock(&hif_deinit_lock);
> > +		mutex_unlock(&wilc->hif_deinit_lock);
> >  		return;
> >  	}
> >  
> >  	msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info,
> > false); if (IS_ERR(msg)) {
> > -		mutex_unlock(&hif_deinit_lock);
> > +		mutex_unlock(&wilc->hif_deinit_lock);
> >  		return;
> >  	}
> >  
> > @@ -3631,7 +3632,7 @@ void wilc_gnrl_async_info_received(struct
> > wilc *wilc, u8 *buffer, u32 length) msg->body.async_info.buffer =
> > kmemdup(buffer, length, GFP_KERNEL); if
> > (!msg->body.async_info.buffer) { kfree(msg);
> > -		mutex_unlock(&hif_deinit_lock);
> > +		mutex_unlock(&wilc->hif_deinit_lock);
> >  		return;
> >  	}
> >  
> > @@ -3642,7 +3643,7 @@ void wilc_gnrl_async_info_received(struct
> > wilc *wilc, u8 *buffer, u32 length) kfree(msg);
> >  	}
> >  
> > -	mutex_unlock(&hif_deinit_lock);
> > +	mutex_unlock(&wilc->hif_deinit_lock);
> >  }
> >  
> >  void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer,
> > u32 length) diff --git
> > a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
> > b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index
> > ee8eda7..eb00e42 100644 ---
> > a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++
> > b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -173,6 +173,10
> > @@ struct wilc { struct rf_info dummy_statistics; bool enable_ps;
> >  	int clients_count;
> > +	struct workqueue_struct *hif_workqueue;
> > +	/* deinitialization lock */
> > +	struct mutex hif_deinit_lock;
> > +	struct completion hif_driver_comp;  
> 
> I'm thinking now... wouldn't fit these better to struct host_if_drv?

No, In my opinion it should be part of 'wilc' struct as only the single
instance of there variables is required. 'host_if_drv' is maintained
separately for each interface.

> 
> >  };
> >  
> >  struct wilc_wfi_mon_priv {
> >   

  reply	other threads:[~2018-08-23 13:38 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-14  6:49 [PATCH 00/24] staging: wilc1000: avoid use of static and global variable Ajay Singh
2018-08-14  6:49 ` [PATCH 01/24] staging: wilc1000: move 'wilc_enable_ps' global variable into 'wilc' struct Ajay Singh
2018-08-14  6:49 ` [PATCH 02/24] staging: wilc1000: move 'aging_timer' static variable to wilc_priv struct Ajay Singh
2018-08-14  6:49 ` [PATCH 03/24] staging: wilc1000: fix to use correct index to free scanned info in clear_shadow_scan() Ajay Singh
2018-08-14  6:49 ` [PATCH 04/24] staging: wilc1000: remove unnecessary NULL check " Ajay Singh
2018-08-14  6:49 ` [PATCH 05/24] staging: wilc1000: moved last_scanned_shadow & last_scanned_cnt to wilc_priv struct Ajay Singh
2018-08-14  6:49 ` [PATCH 06/24] staging: wilc1000: move during_ip_timer & wilc_optaining_ip to 'wilc_vif' struct Ajay Singh
2018-08-23  8:09   ` Claudiu Beznea
2018-08-23  9:43     ` Ajay Singh
2018-08-24  8:47       ` Claudiu Beznea
2018-08-14  6:49 ` [PATCH 07/24] staging: wilc1000: remove unused variable 'op_ifcs' Ajay Singh
2018-08-14  6:50 ` [PATCH 08/24] staging: wilc1000: avoid use of extra 'if' condition in wilc_init() Ajay Singh
2018-08-14  6:50 ` [PATCH 09/24] staging: wilc1000: move static variable clients_count to 'wilc' structure Ajay Singh
2018-08-23  8:09   ` Claudiu Beznea
2018-08-25  0:13     ` Adham Abozaeid
2018-08-14  6:50 ` [PATCH 10/24] staging: wilc1000: move wilc_multicast_mac_addr_list to 'wilc_vif' struct Ajay Singh
2018-08-23  8:10   ` Claudiu Beznea
2018-08-23 10:00     ` Ajay Singh
2018-08-24  8:47       ` Claudiu Beznea
2018-08-25  0:32         ` Adham Abozaeid
2018-08-27  5:40           ` Ajay Singh
2018-08-14  6:50 ` [PATCH 11/24] staging: wilc1000: move hif specific static variables to 'wilc' structure Ajay Singh
2018-08-23  8:11   ` Claudiu Beznea
2018-08-23 10:09     ` Ajay Singh [this message]
2018-08-24  8:47       ` Claudiu Beznea
2018-08-14  6:50 ` [PATCH 12/24] staging: wilc1000: move static variable 'terminated_handle' to wilc_vif struct Ajay Singh
2018-08-23  8:11   ` Claudiu Beznea
2018-08-23 14:36     ` Ajay Singh
2018-08-24  8:46       ` Claudiu Beznea
2018-08-27  5:27         ` Ajay Singh
2018-08-14  6:50 ` [PATCH 13/24] staging: wilc1000: move 'periodic_rssi' as part of 'wilc_vif' struct Ajay Singh
2018-08-14  6:50 ` [PATCH 14/24] staging: wilc1000: rename 'dummy_statistics' variable to 'periodic_stat' Ajay Singh
2018-08-14  6:50 ` [PATCH 15/24] staging: wilc1000: move 'rcv_assoc_resp' as part of hif_drv Ajay Singh
2018-08-14  6:50 ` [PATCH 16/24] staging: wilc1000: refactor tcp_process() to avoid extra leading tabs Ajay Singh
2018-08-14  6:50 ` [PATCH 17/24] staging: wilc1000: use lowercase for get_BSSID() and HIL variable Ajay Singh
2018-08-14  6:50 ` [PATCH 18/24] staging: wilc1000: move tcp_ack_filter algo related variables to 'wilc_vif' struct Ajay Singh
2018-08-14  6:50 ` [PATCH 19/24] staging: wilc1000: avoid line over 80 chars in wilc_wlan_txq_filter_dup_tcp_ack() Ajay Singh
2018-08-23  8:11   ` Claudiu Beznea
2018-08-23 12:18     ` Ajay Singh
2018-08-14  6:50 ` [PATCH 20/24] staging: wilc1000: avoid line over 80 chars in tcp_process() Ajay Singh
2018-08-23  8:12   ` Claudiu Beznea
2018-08-23 10:33     ` Ajay Singh
2018-08-24  9:31       ` Claudiu Beznea
2018-08-27  5:24         ` Ajay Singh
2018-08-27 12:00           ` Dan Carpenter
2018-08-28  4:29             ` Ajay Singh
2018-08-14  6:50 ` [PATCH 21/24] staging: wilc1000: remove unused code to set and get IP address Ajay Singh
2018-08-14  6:50 ` [PATCH 22/24] staging: wilc1000: move 'chip_ps_state' static variable as part of 'wilc' struct Ajay Singh
2018-08-14  6:50 ` [PATCH 23/24] staging: wilc1000: move 'wilc_connecting' static variable to 'wilc_vif' struct Ajay Singh
2018-08-23  8:12   ` Claudiu Beznea
2018-08-23 10:55   ` Greg KH
2018-08-23 11:27     ` Ajay Singh
2018-08-23 12:37       ` Dan Carpenter
2018-08-23 13:06         ` Ajay Singh
2018-08-14  6:50 ` [PATCH 24/24] staging: wilc1000: remove unnecessary static variable 'p2p_listen_state' Ajay Singh
2018-08-23  8:13   ` Claudiu Beznea
2018-08-23 12:07     ` Ajay Singh
2018-08-23  8:09 ` [PATCH 00/24] staging: wilc1000: avoid use of static and global variable Claudiu Beznea
2018-08-23  9:35   ` Ajay Singh
2018-08-27 17:10 ` Greg KH
2018-08-28  4:35   ` Ajay Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180823153941.0ff5f43e@ajaysk-VirtualBox \
    --to=ajay.kathat@microchip.com \
    --cc=Claudiu.Beznea@microchip.com \
    --cc=adham.abozaeid@microchip.com \
    --cc=aditya.shankar@microchip.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=ganesh.krishna@microchip.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=venkateswara.kaja@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).