patch-2.4.9 linux/drivers/ieee1394/ieee1394_core.c

Next file: linux/drivers/ieee1394/ieee1394_core.h
Previous file: linux/drivers/ieee1394/hosts.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.8/linux/drivers/ieee1394/ieee1394_core.c linux/drivers/ieee1394/ieee1394_core.c
@@ -10,7 +10,6 @@
  * directory of the kernel sources for details.
  */
 
-#include <linux/module.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -31,8 +30,7 @@
 #include "csr.h"
 #include "nodemgr.h"
 
-
-atomic_t hpsb_generation = ATOMIC_INIT(0);
+static kmem_cache_t *hpsb_packet_cache;
 
 
 static void dump_packet(const char *text, quadlet_t *data, int size)
@@ -76,16 +74,17 @@
         void *data = NULL;
         int kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
 
-        packet = kmalloc(sizeof(struct hpsb_packet), kmflags);
-        if (!packet) return NULL;
+        packet = kmem_cache_alloc(hpsb_packet_cache, kmflags);
+        if (packet == NULL)
+                return NULL;
 
         memset(packet, 0, sizeof(struct hpsb_packet));
         packet->header = packet->embedded_header;
 
         if (data_size) {
                 data = kmalloc(data_size + 8, kmflags);
-                if (!data) {
-                        kfree(packet);
+                if (data == NULL) {
+			kmem_cache_free(hpsb_packet_cache, packet);
                         return NULL;
                 }
 
@@ -93,11 +92,11 @@
                 packet->data_size = data_size;
         }
 
-        INIT_LIST_HEAD(&packet->complete_tq);
+        INIT_TQ_HEAD(packet->complete_tq);
         INIT_LIST_HEAD(&packet->list);
         sema_init(&packet->state_change, 0);
         packet->state = unused;
-        packet->generation = get_hpsb_generation();
+        packet->generation = -1;
         packet->data_be = 1;
 
         return packet;
@@ -116,7 +115,7 @@
         if (!packet) return;
 
         kfree(packet->data);
-        kfree(packet);
+        kmem_cache_free(hpsb_packet_cache, packet);
 }
 
 
@@ -126,7 +125,7 @@
                 return 1;
         }
 
-        if (!hpsb_bus_reset(host)) {
+        if (!host->in_bus_reset) {
                 host->template->devctl(host, RESET_BUS, type);
                 return 0;
         } else {
@@ -333,7 +332,7 @@
         }
 
         host->reset_retries = 0;
-        inc_hpsb_generation();
+        atomic_inc(&host->generation);
         if (isroot) host->template->devctl(host, ACT_CYCLE_MASTER, 1);
         highlevel_host_reset(host);
 }
@@ -353,7 +352,7 @@
         }
 
         if (ackcode != ACK_PENDING || !packet->expect_response) {
-                packet->state = completed;
+                packet->state = complete;
                 up(&packet->state_change);
                 up(&packet->state_change);
                 run_task_queue(&packet->complete_tq);
@@ -390,7 +389,7 @@
         struct hpsb_host *host = packet->host;
 
         if (!host->initialized || host->in_bus_reset 
-            || (packet->generation != get_hpsb_generation())) {
+            || (packet->generation != get_hpsb_generation(host))) {
                 return 0;
         }
 
@@ -442,14 +441,12 @@
 
         spin_lock_irqsave(&host->pending_pkt_lock, flags);
 
-        lh = host->pending_packets.next;
-        while (lh != &host->pending_packets) {
+        list_for_each(lh, &host->pending_packets) {
                 packet = list_entry(lh, struct hpsb_packet, list);
                 if ((packet->tlabel == tlabel)
                     && (packet->node_id == (data[1] >> 16))){
                         break;
                 }
-                lh = lh->next;
         }
 
         if (lh == &host->pending_packets) {
@@ -506,7 +503,7 @@
                 break;
         }
 
-        packet->state = completed;
+        packet->state = complete;
         up(&packet->state_change);
         run_task_queue(&packet->complete_tq);
 }
@@ -721,12 +718,9 @@
         INIT_LIST_HEAD(&host->pending_packets);
         spin_unlock_irqrestore(&host->pending_pkt_lock, flags);
 
-        lh = llist.next;
-
-        while (lh != &llist) {
+        list_for_each(lh, &llist) {
                 packet = list_entry(lh, struct hpsb_packet, list);
-                lh = lh->next;
-                packet->state = completed;
+                packet->state = complete;
                 packet->ack_code = ACKX_ABORTED;
                 up(&packet->state_change);
                 run_task_queue(&packet->complete_tq);
@@ -751,11 +745,9 @@
 
 
         spin_lock_irqsave(&host->pending_pkt_lock, flags);
-        lh = host->pending_packets.next;
 
-        while (lh != &host->pending_packets) {
+        list_for_each(lh, &host->pending_packets) {
                 packet = list_entry(lh, struct hpsb_packet, list);
-                lh = lh->next;
                 if (time_before(packet->sendtime + expire, jiffies)) {
                         list_del(&packet->list);
                         list_add(&packet->list, &expiredlist);
@@ -767,11 +759,9 @@
         }
         spin_unlock_irqrestore(&host->pending_pkt_lock, flags);
 
-        lh = expiredlist.next;
-        while (lh != &expiredlist) {
+        list_for_each(lh, &expiredlist) {
                 packet = list_entry(lh, struct hpsb_packet, list);
-                lh = lh->next;
-                packet->state = completed;
+                packet->state = complete;
                 packet->ack_code = ACKX_TIMEOUT;
                 up(&packet->state_change);
                 run_task_queue(&packet->complete_tq);
@@ -781,16 +771,19 @@
 
 static int __init ieee1394_init(void)
 {
-        init_hpsb_highlevel();
-        init_csr();
-        init_ieee1394_nodemgr();
+	hpsb_packet_cache = kmem_cache_create("hpsb_packet", sizeof(struct hpsb_packet),
+					      0, 0, NULL, NULL);
+	init_hpsb_highlevel();
+	init_csr();
+	init_ieee1394_nodemgr();
 	return 0;
 }
 
 static void __exit ieee1394_cleanup(void)
 {
-        cleanup_ieee1394_nodemgr();
-        cleanup_csr();
+	cleanup_ieee1394_nodemgr();
+	cleanup_csr();
+	kmem_cache_destroy(hpsb_packet_cache);
 }
 
 module_init(ieee1394_init);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)