mirror of https://gitee.com/openkylin/linux.git
[PATCH] libertas: remove thread.h and make kthread usage clearer
Remove the thread.h abstractions and opencode kthread stuff to make it clearer. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
2ca10e6d6a
commit
fe3361507a
|
@ -1134,7 +1134,7 @@ int libertas_prepare_and_send_command(wlan_private * priv,
|
||||||
lbs_deb_cmd("PREP_CMD: No free cmdnode\n");
|
lbs_deb_cmd("PREP_CMD: No free cmdnode\n");
|
||||||
|
|
||||||
/* Wake up main thread to execute next command */
|
/* Wake up main thread to execute next command */
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1402,7 @@ int libertas_prepare_and_send_command(wlan_private * priv,
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, cmdnode, 1);
|
libertas_queue_cmd(adapter, cmdnode, 1);
|
||||||
adapter->nr_cmd_pending++;
|
adapter->nr_cmd_pending++;
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
if (wait_option & CMD_OPTION_WAITFORRSP) {
|
if (wait_option & CMD_OPTION_WAITFORRSP) {
|
||||||
lbs_deb_cmd("PREP_CMD: Wait for CMD response\n");
|
lbs_deb_cmd("PREP_CMD: Wait for CMD response\n");
|
||||||
|
|
|
@ -432,7 +432,7 @@ static ssize_t libertas_lowrssi_read(struct file *file, char __user *userbuf,
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -496,7 +496,7 @@ static u16 libertas_get_events_bitmap(wlan_private *priv)
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -575,7 +575,7 @@ static ssize_t libertas_lowrssi_write(struct file *file,
|
||||||
event->events = cpu_to_le16(event_bitmap);
|
event->events = cpu_to_le16(event_bitmap);
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -628,7 +628,7 @@ static ssize_t libertas_lowsnr_read(struct file *file, char __user *userbuf,
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -727,7 +727,7 @@ static ssize_t libertas_lowsnr_write(struct file *file,
|
||||||
event->events = cpu_to_le16(event_bitmap);
|
event->events = cpu_to_le16(event_bitmap);
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -781,7 +781,7 @@ static ssize_t libertas_failcount_read(struct file *file, char __user *userbuf,
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -879,7 +879,7 @@ static ssize_t libertas_failcount_write(struct file *file,
|
||||||
event->events = cpu_to_le16(event_bitmap);
|
event->events = cpu_to_le16(event_bitmap);
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -932,7 +932,7 @@ static ssize_t libertas_bcnmiss_read(struct file *file, char __user *userbuf,
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -1029,7 +1029,7 @@ static ssize_t libertas_bcnmiss_write(struct file *file,
|
||||||
event->events = cpu_to_le16(event_bitmap);
|
event->events = cpu_to_le16(event_bitmap);
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -1082,7 +1082,7 @@ static ssize_t libertas_highrssi_read(struct file *file, char __user *userbuf,
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -1181,7 +1181,7 @@ static ssize_t libertas_highrssi_write(struct file *file,
|
||||||
event->events = cpu_to_le16(event_bitmap);
|
event->events = cpu_to_le16(event_bitmap);
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -1232,7 +1232,7 @@ static ssize_t libertas_highsnr_read(struct file *file, char __user *userbuf,
|
||||||
event->action = cpu_to_le16(CMD_ACT_GET);
|
event->action = cpu_to_le16(CMD_ACT_GET);
|
||||||
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
pcmdptr->size = cpu_to_le16(sizeof(*event) + S_DS_GEN);
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
@ -1331,7 +1331,7 @@ static ssize_t libertas_highsnr_write(struct file *file,
|
||||||
event->events = cpu_to_le16(event_bitmap);
|
event->events = cpu_to_le16(event_bitmap);
|
||||||
|
|
||||||
libertas_queue_cmd(adapter, pcmdnode, 1);
|
libertas_queue_cmd(adapter, pcmdnode, 1);
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
/* Sleep until response is generated by FW */
|
/* Sleep until response is generated by FW */
|
||||||
wait_event_interruptible(pcmdnode->cmdwait_q,
|
wait_event_interruptible(pcmdnode->cmdwait_q,
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "thread.h"
|
|
||||||
|
|
||||||
extern struct ethtool_ops libertas_ethtool_ops;
|
extern struct ethtool_ops libertas_ethtool_ops;
|
||||||
|
|
||||||
|
@ -146,7 +145,8 @@ struct _wlan_private {
|
||||||
struct device *hotplug_device;
|
struct device *hotplug_device;
|
||||||
|
|
||||||
/** thread to service interrupts */
|
/** thread to service interrupts */
|
||||||
struct wlan_thread mainthread;
|
struct task_struct *main_thread;
|
||||||
|
wait_queue_head_t waitq;
|
||||||
|
|
||||||
struct delayed_work assoc_work;
|
struct delayed_work assoc_work;
|
||||||
struct workqueue_struct *assoc_thread;
|
struct workqueue_struct *assoc_thread;
|
||||||
|
|
|
@ -341,7 +341,7 @@ static void command_timer_fn(unsigned long data)
|
||||||
lbs_deb_fw("re-sending same command because of timeout\n");
|
lbs_deb_fw("re-sending same command because of timeout\n");
|
||||||
libertas_queue_cmd(adapter, ptempnode, 0);
|
libertas_queue_cmd(adapter, ptempnode, 0);
|
||||||
|
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ static void if_usb_write_bulk_callback(struct urb *urb)
|
||||||
priv->dnld_sent = DNLD_RES_RECEIVED;
|
priv->dnld_sent = DNLD_RES_RECEIVED;
|
||||||
/* Wake main thread if commands are pending */
|
/* Wake main thread if commands are pending */
|
||||||
if (!adapter->cur_cmd)
|
if (!adapter->cur_cmd)
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
if ((adapter->connect_status == LIBERTAS_CONNECTED)) {
|
if ((adapter->connect_status == LIBERTAS_CONNECTED)) {
|
||||||
netif_wake_queue(dev);
|
netif_wake_queue(dev);
|
||||||
netif_wake_queue(priv->mesh_dev);
|
netif_wake_queue(priv->mesh_dev);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <linux/etherdevice.h>
|
#include <linux/etherdevice.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
|
|
||||||
#include <net/iw_handler.h>
|
#include <net/iw_handler.h>
|
||||||
#include <net/ieee80211.h>
|
#include <net/ieee80211.h>
|
||||||
|
@ -438,7 +439,7 @@ static void wlan_tx_timeout(struct net_device *dev)
|
||||||
priv->adapter->eventcause = 0x01000000;
|
priv->adapter->eventcause = 0x01000000;
|
||||||
libertas_send_tx_feedback(priv);
|
libertas_send_tx_feedback(priv);
|
||||||
} else
|
} else
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
} else if (priv->adapter->connect_status == LIBERTAS_CONNECTED) {
|
} else if (priv->adapter->connect_status == LIBERTAS_CONNECTED) {
|
||||||
netif_wake_queue(priv->dev);
|
netif_wake_queue(priv->dev);
|
||||||
netif_wake_queue(priv->mesh_dev);
|
netif_wake_queue(priv->mesh_dev);
|
||||||
|
@ -599,28 +600,25 @@ static void wlan_set_multicast_list(struct net_device *dev)
|
||||||
* @param data A pointer to wlan_thread structure
|
* @param data A pointer to wlan_thread structure
|
||||||
* @return 0
|
* @return 0
|
||||||
*/
|
*/
|
||||||
static int wlan_service_main_thread(void *data)
|
static int libertas_thread(void *data)
|
||||||
{
|
{
|
||||||
struct wlan_thread *thread = data;
|
struct net_device *dev = data;
|
||||||
wlan_private *priv = thread->priv;
|
wlan_private *priv = dev->priv;
|
||||||
wlan_adapter *adapter = priv->adapter;
|
wlan_adapter *adapter = priv->adapter;
|
||||||
wait_queue_t wait;
|
wait_queue_t wait;
|
||||||
u8 ireg = 0;
|
u8 ireg = 0;
|
||||||
|
|
||||||
lbs_deb_enter(LBS_DEB_THREAD);
|
lbs_deb_enter(LBS_DEB_THREAD);
|
||||||
|
|
||||||
wlan_activate_thread(thread);
|
|
||||||
|
|
||||||
init_waitqueue_entry(&wait, current);
|
init_waitqueue_entry(&wait, current);
|
||||||
|
|
||||||
set_freezable();
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
lbs_deb_thread( "main-thread 111: intcounter=%d "
|
lbs_deb_thread( "main-thread 111: intcounter=%d "
|
||||||
"currenttxskb=%p dnld_sent=%d\n",
|
"currenttxskb=%p dnld_sent=%d\n",
|
||||||
adapter->intcounter,
|
adapter->intcounter,
|
||||||
adapter->currenttxskb, priv->dnld_sent);
|
adapter->currenttxskb, priv->dnld_sent);
|
||||||
|
|
||||||
add_wait_queue(&thread->waitq, &wait);
|
add_wait_queue(&priv->waitq, &wait);
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
spin_lock_irq(&adapter->driver_lock);
|
spin_lock_irq(&adapter->driver_lock);
|
||||||
if ((adapter->psstate == PS_STATE_SLEEP) ||
|
if ((adapter->psstate == PS_STATE_SLEEP) ||
|
||||||
|
@ -643,7 +641,7 @@ static int wlan_service_main_thread(void *data)
|
||||||
adapter->currenttxskb, priv->dnld_sent);
|
adapter->currenttxskb, priv->dnld_sent);
|
||||||
|
|
||||||
set_current_state(TASK_RUNNING);
|
set_current_state(TASK_RUNNING);
|
||||||
remove_wait_queue(&thread->waitq, &wait);
|
remove_wait_queue(&priv->waitq, &wait);
|
||||||
try_to_freeze();
|
try_to_freeze();
|
||||||
|
|
||||||
lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p "
|
lbs_deb_thread("main-thread 333: intcounter=%d currenttxskb=%p "
|
||||||
|
@ -758,7 +756,6 @@ static int wlan_service_main_thread(void *data)
|
||||||
del_timer(&adapter->command_timer);
|
del_timer(&adapter->command_timer);
|
||||||
adapter->nr_cmd_pending = 0;
|
adapter->nr_cmd_pending = 0;
|
||||||
wake_up_all(&adapter->cmd_pending);
|
wake_up_all(&adapter->cmd_pending);
|
||||||
wlan_deactivate_thread(thread);
|
|
||||||
|
|
||||||
lbs_deb_leave(LBS_DEB_THREAD);
|
lbs_deb_leave(LBS_DEB_THREAD);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -841,10 +838,13 @@ int libertas_activate_card(wlan_private *priv, char *fw_name)
|
||||||
|
|
||||||
lbs_deb_enter(LBS_DEB_MAIN);
|
lbs_deb_enter(LBS_DEB_MAIN);
|
||||||
|
|
||||||
lbs_deb_thread("Starting kthread...\n");
|
lbs_deb_thread("Starting main thread...\n");
|
||||||
priv->mainthread.priv = priv;
|
init_waitqueue_head(&priv->waitq);
|
||||||
wlan_create_thread(wlan_service_main_thread,
|
priv->main_thread = kthread_run(libertas_thread, dev, "libertas_main");
|
||||||
&priv->mainthread, "wlan_main_service");
|
if (IS_ERR(priv->main_thread)) {
|
||||||
|
lbs_deb_thread("Error creating main thread.\n");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
priv->assoc_thread =
|
priv->assoc_thread =
|
||||||
create_singlethread_workqueue("libertas_assoc");
|
create_singlethread_workqueue("libertas_assoc");
|
||||||
|
@ -884,8 +884,8 @@ int libertas_activate_card(wlan_private *priv, char *fw_name)
|
||||||
err_registerdev:
|
err_registerdev:
|
||||||
destroy_workqueue(priv->assoc_thread);
|
destroy_workqueue(priv->assoc_thread);
|
||||||
/* Stop the thread servicing the interrupts */
|
/* Stop the thread servicing the interrupts */
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
wlan_terminate_thread(&priv->mainthread);
|
kthread_stop(priv->main_thread);
|
||||||
done:
|
done:
|
||||||
lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
|
lbs_deb_leave_args(LBS_DEB_NET, "ret %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1017,7 +1017,7 @@ int libertas_remove_card(wlan_private *priv)
|
||||||
adapter->surpriseremoved = 1;
|
adapter->surpriseremoved = 1;
|
||||||
|
|
||||||
/* Stop the thread servicing the interrupts */
|
/* Stop the thread servicing the interrupts */
|
||||||
wlan_terminate_thread(&priv->mainthread);
|
kthread_stop(priv->main_thread);
|
||||||
|
|
||||||
libertas_debugfs_remove_one(priv);
|
libertas_debugfs_remove_one(priv);
|
||||||
|
|
||||||
|
@ -1151,7 +1151,7 @@ void libertas_interrupt(struct net_device *dev)
|
||||||
netif_wake_queue(priv->mesh_dev);
|
netif_wake_queue(priv->mesh_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
wake_up_interruptible(&priv->mainthread.waitq);
|
wake_up_interruptible(&priv->waitq);
|
||||||
|
|
||||||
lbs_deb_leave(LBS_DEB_THREAD);
|
lbs_deb_leave(LBS_DEB_THREAD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
#ifndef __WLAN_THREAD_H_
|
|
||||||
#define __WLAN_THREAD_H_
|
|
||||||
|
|
||||||
#include <linux/kthread.h>
|
|
||||||
|
|
||||||
struct wlan_thread {
|
|
||||||
struct task_struct *task;
|
|
||||||
wait_queue_head_t waitq;
|
|
||||||
pid_t pid;
|
|
||||||
void *priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline void wlan_activate_thread(struct wlan_thread * thr)
|
|
||||||
{
|
|
||||||
/** Record the thread pid */
|
|
||||||
thr->pid = current->pid;
|
|
||||||
|
|
||||||
/** Initialize the wait queue */
|
|
||||||
init_waitqueue_head(&thr->waitq);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void wlan_deactivate_thread(struct wlan_thread * thr)
|
|
||||||
{
|
|
||||||
lbs_deb_enter(LBS_DEB_THREAD);
|
|
||||||
|
|
||||||
thr->pid = 0;
|
|
||||||
|
|
||||||
lbs_deb_leave(LBS_DEB_THREAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void wlan_create_thread(int (*wlanfunc) (void *),
|
|
||||||
struct wlan_thread * thr, char *name)
|
|
||||||
{
|
|
||||||
thr->task = kthread_run(wlanfunc, thr, "%s", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int wlan_terminate_thread(struct wlan_thread * thr)
|
|
||||||
{
|
|
||||||
lbs_deb_enter(LBS_DEB_THREAD);
|
|
||||||
|
|
||||||
/* Check if the thread is active or not */
|
|
||||||
if (!thr->pid) {
|
|
||||||
printk(KERN_ERR "Thread does not exist\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
kthread_stop(thr->task);
|
|
||||||
|
|
||||||
lbs_deb_leave(LBS_DEB_THREAD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue