lkml.org 
[lkml]   [2002]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] [CFT] First take on porting 8139too to new kthread API
Date
This work was done as part of the Kernel Janitors weekend party.  Believe the 
rumors; I saw Jules Asner here, it was a wild party!

Below find my first take on porting the 8139too driver to the new kthread
API. This patch is against 2.5.3-dj5 plus Christoph's kthread API. I don't
have an 8139 to test on, so if you have hardware, please let me how this
works. Jeff, Christoph: is there anything I misunderstood in my changes?

--
akk~

=============================================================================

diff -u /home/adam/code/kernel/janitor-linux.orig/drivers/net/8139too.c
/home/adam/code/kernel/janitor-linux/drivers/net/8139too.c
--- /home/adam/code/kernel/janitor-linux.orig/drivers/net/8139too.c Sun Feb
10 23:23:22 2002
+++ /home/adam/code/kernel/janitor-linux/drivers/net/8139too.c Sun Feb 10
23:23:22 2002
@@ -82,6 +82,8 @@

Robert Kuebel - Save kernel thread from dying on any signal.

+ Adam Keys - Changed to new kthread API
+
Submitting bug reports:

"rtl8139-diag -mmmaaavvveefN" output
@@ -110,6 +112,7 @@
#include <linux/mii.h>
#include <linux/completion.h>
#include <linux/crc32.h>
+#include <linux/kthread.h>
#include <asm/io.h>
#include <asm/uaccess.h>

@@ -556,7 +559,7 @@
unsigned int medialock:1; /* Don't sense media type. */
spinlock_t lock;
chip_t chipset;
- pid_t thr_pid;
+ struct kthread *thr;
wait_queue_head_t thr_wait;
struct completion thr_exited;
u32 rx_config;
@@ -585,7 +588,7 @@
static int mdio_read (struct net_device *dev, int phy_id, int location);
static void mdio_write (struct net_device *dev, int phy_id, int location,
int val);
-static int rtl8139_thread (void *data);
+static int rtl8139_thread (struct kthread *kth, void *data);
static void rtl8139_tx_timeout (struct net_device *dev);
static void rtl8139_init_ring (struct net_device *dev);
static int rtl8139_start_xmit (struct sk_buff *skb,
@@ -1291,10 +1294,18 @@
dev->irq, RTL_R8 (MediaStatus),
tp->mii.full_duplex ? "full" : "half");

- tp->thr_pid = kernel_thread (rtl8139_thread, dev, CLONE_FS | CLONE_FILES);
- if (tp->thr_pid < 0)
- printk (KERN_WARNING "%s: unable to start kernel thread\n",
- dev->name);
+ tp->thr = (struct kthread*)kmalloc( sizeof( struct kthread ), GFP_KERNEL );
+ if ( tp->thr == NULL ) {
+ printk( KERN_ERR "8139too: Could not allocate memory for kthread\n" );
+ return -ENOMEM;
+ }
+
+ tp->thr->name = "8139too";
+ tp->thr->main = rtl8139_thread;
+ if ( kthread_start( tp->thr, dev ) < 0 ) {
+ printk( KERN_WARNING "%s: unable to start kernel thread\n", dev->name );
+ }
+

return 0;
}
@@ -1547,7 +1562,7 @@
}


-static int rtl8139_thread (void *data)
+static int rtl8139_thread (struct kthread *kth, void *data)
{
struct net_device *dev = data;
struct rtl8139_private *tp = dev->priv;
@@ -2080,21 +2095,17 @@
{
struct rtl8139_private *tp = dev->priv;
void *ioaddr = tp->mmio_addr;
- int ret = 0;
unsigned long flags;

netif_stop_queue (dev);

- if (tp->thr_pid >= 0) {
+ if ( tp->thr != NULL ) {
tp->time_to_die = 1;
wmb();
- ret = kill_proc (tp->thr_pid, SIGTERM, 1);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:24    [W:0.028 / U:1.344 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site