LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: <gregkh@suse.de>
To: xemul@openvz.org, akpm@linux-foundation.org,
baldrick.bulk@free.fr, baldrick@free.fr, gregkh@suse.de,
linux-kernel@vger.kernel.org
Subject: patch usb-usbatm-convert-heavy-init-dances-to-kthread-api.patch added to gregkh-2.6 tree
Date: Tue, 19 Feb 2008 11:43:45 -0800 [thread overview]
Message-ID: <12034502253856@kroah.org> (raw)
In-Reply-To: <47B03EE1.8060806@openvz.org>
This is a note to let you know that I've just added the patch titled
Subject: USB: usbatm: convert heavy init dances to kthread API
to my gregkh-2.6 tree. Its filename is
usb-usbatm-convert-heavy-init-dances-to-kthread-api.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
>From linux-usb-owner@vger.kernel.org Mon Feb 11 04:29:00 2008
From: Pavel Emelyanov <xemul@openvz.org>
Date: Mon, 11 Feb 2008 15:26:09 +0300
Subject: USB: usbatm: convert heavy init dances to kthread API
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Duncan Sands <baldrick.bulk@free.fr>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, linux-usb@vger.kernel.org
Message-ID: <47B03EE1.8060806@openvz.org>
This is an attempt to kill two birds with one stone.
First, we kill one more user of kernel_thread, which is scheduled
for removal. Second - we kill one of the last users of kill_proc -
the function which is also to be removed, because it uses a pid_t
which is not safe now.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Duncan Sands <baldrick@free.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/usb/atm/usbatm.c | 25 ++++++++++++++-----------
drivers/usb/atm/usbatm.h | 2 +-
2 files changed, 15 insertions(+), 12 deletions(-)
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -80,6 +80,7 @@
#include <linux/stat.h>
#include <linux/timer.h>
#include <linux/wait.h>
+#include <linux/kthread.h>
#ifdef VERBOSE_DEBUG
static int usbatm_print_packet(const unsigned char *data, int len);
@@ -1014,10 +1015,7 @@ static int usbatm_do_heavy_init(void *ar
struct usbatm_data *instance = arg;
int ret;
- daemonize(instance->driver->driver_name);
allow_signal(SIGTERM);
- instance->thread_pid = current->pid;
-
complete(&instance->thread_started);
ret = instance->driver->heavy_init(instance, instance->usb_intf);
@@ -1026,7 +1024,7 @@ static int usbatm_do_heavy_init(void *ar
ret = usbatm_atm_init(instance);
mutex_lock(&instance->serialize);
- instance->thread_pid = -1;
+ instance->thread = NULL;
mutex_unlock(&instance->serialize);
complete_and_exit(&instance->thread_exited, ret);
@@ -1034,13 +1032,18 @@ static int usbatm_do_heavy_init(void *ar
static int usbatm_heavy_init(struct usbatm_data *instance)
{
- int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_FS | CLONE_FILES);
+ struct task_struct *t;
- if (ret < 0) {
- usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret);
- return ret;
+ t = kthread_create(usbatm_do_heavy_init, instance,
+ instance->driver->driver_name);
+ if (IS_ERR(t)) {
+ usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n",
+ __func__, PTR_ERR(t));
+ return PTR_ERR(t);
}
+ instance->thread = t;
+ wake_up_process(t);
wait_for_completion(&instance->thread_started);
return 0;
@@ -1124,7 +1127,7 @@ int usbatm_usb_probe(struct usb_interfac
kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */
mutex_init(&instance->serialize);
- instance->thread_pid = -1;
+ instance->thread = NULL;
init_completion(&instance->thread_started);
init_completion(&instance->thread_exited);
@@ -1287,8 +1290,8 @@ void usbatm_usb_disconnect(struct usb_in
mutex_lock(&instance->serialize);
instance->disconnected = 1;
- if (instance->thread_pid >= 0)
- kill_proc(instance->thread_pid, SIGTERM, 1);
+ if (instance->thread != NULL)
+ send_sig(SIGTERM, instance->thread, 1);
mutex_unlock(&instance->serialize);
wait_for_completion(&instance->thread_exited);
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -176,7 +176,7 @@ struct usbatm_data {
int disconnected;
/* heavy init */
- int thread_pid;
+ struct task_struct *thread;
struct completion thread_started;
struct completion thread_exited;
Patches currently in gregkh-2.6 which might be from xemul@openvz.org are
usb/usb-usbatm-convert-heavy-init-dances-to-kthread-api.patch
prev parent reply other threads:[~2008-02-19 19:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-11 12:26 [PATCH] Usbatm: convert heavy init dances to kthread API Pavel Emelyanov
2008-02-11 12:39 ` Duncan Sands
2008-02-19 19:43 ` gregkh [this message]
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=12034502253856@kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=baldrick.bulk@free.fr \
--cc=baldrick@free.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=xemul@openvz.org \
--subject='Re: patch usb-usbatm-convert-heavy-init-dances-to-kthread-api.patch added to gregkh-2.6 tree' \
/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
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).