]> Pileus Git - ~andy/linux/blobdiff - drivers/firewire/fw-transaction.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[~andy/linux] / drivers / firewire / fw-transaction.c
index 1537737e442006d21668c1171fc6d98fe16149e7..283dac6d327db100853c1768be00f37dbc346b10 100644 (file)
@@ -65,8 +65,7 @@
 #define PHY_IDENTIFIER(id)             ((id) << 30)
 
 static int close_transaction(struct fw_transaction *transaction,
-                            struct fw_card *card, int rcode,
-                            u32 *payload, size_t length)
+                            struct fw_card *card, int rcode)
 {
        struct fw_transaction *t;
        unsigned long flags;
@@ -82,7 +81,7 @@ static int close_transaction(struct fw_transaction *transaction,
        spin_unlock_irqrestore(&card->lock, flags);
 
        if (&t->link != &card->transaction_list) {
-               t->callback(card, rcode, payload, length, t->callback_data);
+               t->callback(card, rcode, NULL, 0, t->callback_data);
                return 0;
        }
 
@@ -110,7 +109,7 @@ int fw_cancel_transaction(struct fw_card *card,
         * if the transaction is still pending and remove it in that case.
         */
 
-       return close_transaction(transaction, card, RCODE_CANCELLED, NULL, 0);
+       return close_transaction(transaction, card, RCODE_CANCELLED);
 }
 EXPORT_SYMBOL(fw_cancel_transaction);
 
@@ -122,7 +121,7 @@ static void transmit_complete_callback(struct fw_packet *packet,
 
        switch (status) {
        case ACK_COMPLETE:
-               close_transaction(t, card, RCODE_COMPLETE, NULL, 0);
+               close_transaction(t, card, RCODE_COMPLETE);
                break;
        case ACK_PENDING:
                t->timestamp = packet->timestamp;
@@ -130,20 +129,20 @@ static void transmit_complete_callback(struct fw_packet *packet,
        case ACK_BUSY_X:
        case ACK_BUSY_A:
        case ACK_BUSY_B:
-               close_transaction(t, card, RCODE_BUSY, NULL, 0);
+               close_transaction(t, card, RCODE_BUSY);
                break;
        case ACK_DATA_ERROR:
-               close_transaction(t, card, RCODE_DATA_ERROR, NULL, 0);
+               close_transaction(t, card, RCODE_DATA_ERROR);
                break;
        case ACK_TYPE_ERROR:
-               close_transaction(t, card, RCODE_TYPE_ERROR, NULL, 0);
+               close_transaction(t, card, RCODE_TYPE_ERROR);
                break;
        default:
                /*
                 * In this case the ack is really a juju specific
                 * rcode, so just forward that to the callback.
                 */
-               close_transaction(t, card, status, NULL, 0);
+               close_transaction(t, card, status);
                break;
        }
 }
@@ -154,6 +153,18 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
 {
        int ext_tcode;
 
+       if (tcode == TCODE_STREAM_DATA) {
+               packet->header[0] =
+                       HEADER_DATA_LENGTH(length) |
+                       destination_id |
+                       HEADER_TCODE(TCODE_STREAM_DATA);
+               packet->header_length = 4;
+               packet->payload = payload;
+               packet->payload_length = length;
+
+               goto common;
+       }
+
        if (tcode > 0x10) {
                ext_tcode = tcode & ~0x10;
                tcode = TCODE_LOCK_REQUEST;
@@ -200,7 +211,7 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
                packet->payload_length = 0;
                break;
        }
-
+ common:
        packet->speed = speed;
        packet->generation = generation;
        packet->ack = 0;
@@ -242,6 +253,9 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
  * @param callback function to be called when the transaction is completed
  * @param callback_data pointer to arbitrary data, which will be
  *   passed to the callback
+ *
+ * In case of asynchronous stream packets i.e. TCODE_STREAM_DATA, the caller
+ * needs to synthesize @destination_id with fw_stream_packet_destination_id().
  */
 void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,
                     int destination_id, int generation, int speed,
@@ -317,15 +331,15 @@ static void transaction_callback(struct fw_card *card, int rcode,
  */
 int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
                       int generation, int speed, unsigned long long offset,
-                      void *data, size_t length)
+                      void *payload, size_t length)
 {
        struct transaction_callback_data d;
        struct fw_transaction t;
 
        init_completion(&d.done);
-       d.payload = data;
+       d.payload = payload;
        fw_send_request(card, &t, tcode, destination_id, generation, speed,
-                       offset, data, length, transaction_callback, &d);
+                       offset, payload, length, transaction_callback, &d);
        wait_for_completion(&d.done);
 
        return d.rcode;