[openib-general] [PATCH] ib_mad: Use kthread_create rather than daemonize

Hal Rosenstock halr at voltaire.com
Sun Sep 12 13:45:25 PDT 2004


ib_mad: Use kthread_create rather than daemonize

Index: ib_mad.c
===================================================================
--- ib_mad.c	(revision 792)
+++ ib_mad.c	(working copy)
@@ -703,10 +703,6 @@
 	struct ib_mad_port_private *priv = param;
 	struct ib_mad_thread_data *thread_data = &priv->thread_data;
 
-	lock_kernel();
-	daemonize("ib_mad-%-6s-%-2d", priv->device->name, priv->port);
-	unlock_kernel();
-
 	while (1) {
 		if (down_interruptible(&thread_data->sem)) {
 			printk(KERN_DEBUG "Exiting ib_mad thread\n");
@@ -725,13 +721,22 @@
 /*
  * Initialize the IB MAD thread
  */
-static void ib_mad_thread_init(struct ib_mad_port_private *priv)
+static int ib_mad_thread_init(struct ib_mad_port_private *priv)
 {
 	struct ib_mad_thread_data *thread_data = &priv->thread_data;
 
 	sema_init(&thread_data->sem, 0);
 	thread_data->run = 1;
-	kernel_thread(ib_mad_thread, priv, 0);
+	priv->mad_thread = kthread_create(ib_mad_thread,
+					  priv,
+					  "ib_mad-%-6s-%-2d",
+					  priv->device->name,
+					  priv->port);
+	if (IS_ERR(priv->mad_thread)) {
+		printk(KERN_ERR "couldn't start mad thread\n");
+		return 1;
+	}	
+	return 0;
 }
 
 /*
@@ -1185,10 +1190,13 @@
 		priv->recv_posted_mad_count[i] = 0;
 	}
 
-	ib_mad_thread_init(priv);
+	ret = ib_mad_thread_init(priv);
+	if (ret) 
+		goto error8;
+
 	ret = ib_mad_port_start(priv);
 	if (ret) {
-		printk(KERN_ERR "Could not start port\n");
+		printk(KERN_ERR "Couldn't start port\n");
 		goto error8;
 	}
 
Index: ib_mad_priv.h
===================================================================
--- ib_mad_priv.h	(revision 792)
+++ ib_mad_priv.h	(working copy)
@@ -57,6 +57,7 @@
 #define __IB_MAD_PRIV_H_
 
 #include <linux/pci.h>
+#include <linux/kthread.h>
 
 
 #define IB_MAD_QPS_CORE		2 /* Always QP0 and QP1 */
@@ -123,6 +124,7 @@
 
 struct ib_mad_port_private {
 	struct list_head port_list;
+	struct task_struct *mad_thread;
 	struct ib_device *device;
 	int port;
 	struct ib_qp *qp[IB_MAD_QPS_SUPPORTED];





More information about the general mailing list