Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 198920
b: refs/heads/master
c: 7906054
h: refs/heads/master
v: v3
  • Loading branch information
Clemens Ladisch authored and Stefan Richter committed Apr 19, 2010
1 parent fbe43d6 commit 8f7f0fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: edd5bdaf128e04066caac84fcb21377197ea0d64
refs/heads/master: 7906054f0d597246178b3154adca76de29913aa5
24 changes: 19 additions & 5 deletions trunk/drivers/firewire/core-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,23 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
packet->payload_mapped = false;
}

static int allocate_tlabel(struct fw_card *card)
{
int tlabel;

tlabel = card->current_tlabel;
while (card->tlabel_mask & (1ULL << tlabel)) {
tlabel = (tlabel + 1) & 0x3f;
if (tlabel == card->current_tlabel)
return -EBUSY;
}

card->current_tlabel = (tlabel + 1) & 0x3f;
card->tlabel_mask |= 1ULL << tlabel;

return tlabel;
}

/**
* This function provides low-level access to the IEEE1394 transaction
* logic. Most C programs would use either fw_read(), fw_write() or
Expand Down Expand Up @@ -290,16 +307,13 @@ void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,

spin_lock_irqsave(&card->lock, flags);

tlabel = card->current_tlabel;
if (card->tlabel_mask & (1ULL << tlabel)) {
tlabel = allocate_tlabel(card);
if (tlabel < 0) {
spin_unlock_irqrestore(&card->lock, flags);
callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data);
return;
}

card->current_tlabel = (card->current_tlabel + 1) & 0x3f;
card->tlabel_mask |= (1ULL << tlabel);

t->node_id = destination_id;
t->tlabel = tlabel;
t->callback = callback;
Expand Down

0 comments on commit 8f7f0fc

Please sign in to comment.