patch-2.4.7 linux/drivers/ieee1394/ieee1394_transactions.c

Next file: linux/drivers/ieee1394/ieee1394_transactions.h
Previous file: linux/drivers/ieee1394/ieee1394_syms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.6/linux/drivers/ieee1394/ieee1394_transactions.c linux/drivers/ieee1394/ieee1394_transactions.c
@@ -131,9 +131,21 @@
 
         packet->header_size = 4;
         packet->data_size = length;
+        packet->type = iso;
         packet->tcode = TCODE_ISO_DATA;
 }
 
+void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data) 
+{ 
+        packet->header[0] = data;
+        packet->header[1] = ~data; 
+        packet->header_size = 8;
+        packet->data_size = 0;
+        packet->expect_response = 0;
+        packet->type = raw;             /* No CRC added */
+        packet->speed_code = SPEED_100; /* Force speed to be 100Mbps */
+}
+
 
 /**
  * get_tlabel - allocate a transaction label
@@ -384,6 +396,20 @@
         return p;
 }
 
+struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host,
+                                        quadlet_t data) 
+{
+        struct hpsb_packet *p; 
+
+        p = alloc_hpsb_packet(0); 
+        if (!p) return NULL; 
+
+        p->host = host; 
+        fill_phy_packet(p, data); 
+
+        return p; 
+}
+
 /*
  * FIXME - these functions should probably read from / write to user space to
  * avoid in kernel buffers for user space callers
@@ -440,42 +466,53 @@
         return retval;
 }
 
-
-int hpsb_write(struct hpsb_host *host, nodeid_t node, u64 addr,
-               quadlet_t *buffer, size_t length)
+struct hpsb_packet *hpsb_make_packet (struct hpsb_host *host, nodeid_t node,
+				      u64 addr, quadlet_t *buffer, size_t length)
 {
         struct hpsb_packet *packet;
-        int retval = 0;
         
-        if (length == 0) {
-                return -EINVAL;
-        }
-
-        if (host->node_id == node) {
-                switch(highlevel_write(host, node, buffer, addr, length)) {
-                case RCODE_COMPLETE:
-                        return 0;
-                case RCODE_TYPE_ERROR:
-                        return -EACCES;
-                case RCODE_ADDRESS_ERROR:
-                default:
-                        return -EINVAL;
-                }
-        }
+        if (length == 0)
+                return NULL;
 
-        if (length == 4) {
+        if (length == 4)
                 packet = hpsb_make_writeqpacket(host, node, addr, *buffer);
-        } else {
+        else
                 packet = hpsb_make_writebpacket(host, node, addr, length);
-        }
 
-        if (!packet) {
-                return -ENOMEM;
-        }
+        if (!packet)
+                return NULL;
 
-        if (length != 4) {
+        if (length != 4)
                 memcpy(packet->data, buffer, length);
-        }
+
+	return packet;
+}
+
+int hpsb_write(struct hpsb_host *host, nodeid_t node, u64 addr,
+	       quadlet_t *buffer, size_t length)
+{
+	struct hpsb_packet *packet;
+	int retval;
+
+	if (length == 0)
+		return -EINVAL;
+
+	if (host->node_id == node) {
+		switch(highlevel_write(host, node, node, buffer, addr, length)) {
+		case RCODE_COMPLETE:
+			return 0;
+		case RCODE_TYPE_ERROR:
+			return -EACCES;
+		case RCODE_ADDRESS_ERROR:
+		default:
+			return -EINVAL;
+		}
+	}
+
+	packet = hpsb_make_packet (host, node, addr, buffer, length);
+
+	if (!packet)
+		return -ENOMEM;
 
         hpsb_send_packet(packet);
         down(&packet->state_change);

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