lkml.org 
[lkml]   [2012]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging/gdm72xx: use kthread APIs
Date
This patch modifies the kthread usage in the gdm_usb code, and tries to
use the kthread APIs better.

Actually the task_struct is taken as global as the limitation of priv.
we run the kthread before we allocate the priv.

did only compilation test, but not the insmod, check ps ax for kthread and
rmmod and see the thread is killed kind of tests.

There were no checks while kthread_run may fail, returing some error which can be seen by using PTR_ERR.

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
drivers/staging/gdm72xx/gdm_usb.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c
index 89268c7..126150d 100644
--- a/drivers/staging/gdm72xx/gdm_usb.c
+++ b/drivers/staging/gdm72xx/gdm_usb.c
@@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
static DECLARE_WAIT_QUEUE_HEAD(k_wait);
static LIST_HEAD(k_list);
static DEFINE_SPINLOCK(k_lock);
-static int k_mode_stop;

#define K_WAIT_TIME (2 * HZ / 100)

@@ -55,6 +54,7 @@ static int k_mode_stop;
static int init_usb(struct usbwm_dev *udev);
static void release_usb(struct usbwm_dev *udev);

+static struct task_struct *kthread;
/*#define DEBUG */
#ifdef DEBUG
static void hexdump(char *title, u8 *data, int len)
@@ -720,7 +720,7 @@ static int k_mode_thread(void *arg)

daemonize("k_mode_wimax");

- while (!k_mode_stop) {
+ while (!kthread_should_stop()) {

spin_lock_irqsave(&k_lock, flags2);
while (!list_empty(&k_list)) {
@@ -781,7 +781,11 @@ static struct usb_driver gdm_usb_driver = {
static int __init usb_gdm_wimax_init(void)
{
#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
- kthread_run(k_mode_thread, NULL, "WiMax_thread");
+ kthread = kthread_run(k_mode_thread, NULL, "WiMax_thread");
+ if (IS_ERR(kthread)) {
+ printk(KERN_ERR "%s: can't create kernel thread\n", __func__);
+ return PTR_ERR(kthread);
+ }
#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
return usb_register(&gdm_usb_driver);
}
@@ -789,7 +793,8 @@ static int __init usb_gdm_wimax_init(void)
static void __exit usb_gdm_wimax_exit(void)
{
#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
- k_mode_stop = 1;
+ if (kthread)
+ kthread_stop(kthread);
wake_up(&k_wait);
#endif
usb_deregister(&gdm_usb_driver);
--
1.7.9.5


\
 
 \ /
  Last update: 2012-07-11 09:21    [W:0.026 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site