Re: [PATCH] replace kernel_thread() with kthread_run() in RT2870

From: Peter Teoh
Date: Sat Mar 14 2009 - 00:07:41 EST


Sorry, mixed up the patches with another patch. Here is the correct
one. Thanks.


On Sat, Mar 14, 2009 at 12:01 PM, Peter Teoh <htmldeveloper@xxxxxxxxx> wrote:
> As advised by Greg KH:
>
> http://lkml.org/lkml/2009/3/13/131
>
> Replaced the usage of kernel_thread() with kthread_run().   Compiled
> successfully, but not tested as I don't have the hardware.
>
> (parsed by scripts/checkpatch.pl as well).
>
> Thanks.
>
> --
> Regards,
> Peter Teoh
>



--
Regards,
Peter Teoh
Replace use of kernel_thread() with kthread_run(), as the former is deprecated.

Signed-off-by: Peter Teoh <htmldeveloper@xxxxxxxxx>

diff --git a/drivers/staging/rt2870/common/2870_rtmp_init.c b/drivers/staging/rt2870/common/2870_rtmp_init.c
index 9f5143b..9a81d0e 100644
--- a/drivers/staging/rt2870/common/2870_rtmp_init.c
+++ b/drivers/staging/rt2870/common/2870_rtmp_init.c
@@ -765,7 +765,7 @@ NDIS_STATUS CreateThreads(
{
PRTMP_ADAPTER pAd = net_dev->ml_priv;
POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
- pid_t pid_number = -1;
+ struct task_struct *tsk;

//init_MUTEX(&(pAd->usbdev_semaphore));

@@ -780,35 +780,38 @@ NDIS_STATUS CreateThreads(

// Creat MLME Thread
pObj->MLMEThr_pid= THREAD_PID_INIT_VALUE;
- pid_number = kernel_thread(MlmeThread, pAd, CLONE_VM);
- if (pid_number < 0)
- {
+ tsk = kthread_run(MlmeThread, pAd, pAd->net_dev->name);
+
+ if (IS_ERR(tsk)) {
printk (KERN_WARNING "%s: unable to start Mlme thread\n",pAd->net_dev->name);
return NDIS_STATUS_FAILURE;
}
- pObj->MLMEThr_pid = GET_PID(pid_number);
+
+ pObj->MLMEThr_pid = get_pid(task_pid(tsk));
// Wait for the thread to start
wait_for_completion(&(pAd->mlmeComplete));

// Creat Command Thread
pObj->RTUSBCmdThr_pid= THREAD_PID_INIT_VALUE;
- pid_number = kernel_thread(RTUSBCmdThread, pAd, CLONE_VM);
- if (pid_number < 0)
+ tsk = kthread_run(RTUSBCmdThread, pAd, pAd->net_dev->name);
+
+ if (IS_ERR(tsk) < 0)
{
printk (KERN_WARNING "%s: unable to start RTUSBCmd thread\n",pAd->net_dev->name);
return NDIS_STATUS_FAILURE;
}
- pObj->RTUSBCmdThr_pid = GET_PID(pid_number);
+
+ pObj->RTUSBCmdThr_pid = get_pid(task_pid(tsk));
wait_for_completion(&(pAd->CmdQComplete));

pObj->TimerQThr_pid= THREAD_PID_INIT_VALUE;
- pid_number = kernel_thread(TimerQThread, pAd, CLONE_VM);
- if (pid_number < 0)
+ tsk = kthread_run(TimerQThread, pAd, pAd->net_dev->name);
+ if (IS_ERR(tsk) < 0)
{
printk (KERN_WARNING "%s: unable to start TimerQThread\n",pAd->net_dev->name);
return NDIS_STATUS_FAILURE;
}
- pObj->TimerQThr_pid = GET_PID(pid_number);
+ pObj->TimerQThr_pid = get_pid(task_pid(tsk));
// Wait for the thread to start
wait_for_completion(&(pAd->TimerQComplete));

diff --git a/drivers/staging/rt2870/rt_linux.h b/drivers/staging/rt2870/rt_linux.h
index 859f9ce..9a8ed1b 100644
--- a/drivers/staging/rt2870/rt_linux.h
+++ b/drivers/staging/rt2870/rt_linux.h
@@ -44,6 +44,7 @@
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
+#include <linux/kthread.h>

#include <linux/spinlock.h>
#include <linux/init.h>