Skip to content

Commit

Permalink
firewire: ohci: optimize find_branch_descriptor()
Browse files Browse the repository at this point in the history
When z==2, the condition "key == 2" is superfluous because it cannot
occur without "b == 3", as a descriptor with b!=3 and key==2 would be
an OUTPUT_MORE_IMMEDIATE descriptor which cannot be used alone.

Also remove magic numbers and needless computations on the b field.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Clemens Ladisch authored and Stefan Richter committed Apr 19, 2011
1 parent da28947 commit 0ff8fbc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/firewire/ohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,13 +1006,12 @@ static void ar_context_run(struct ar_context *ctx)

static struct descriptor *find_branch_descriptor(struct descriptor *d, int z)
{
int b, key;
__le16 branch;

b = (le16_to_cpu(d->control) & DESCRIPTOR_BRANCH_ALWAYS) >> 2;
key = (le16_to_cpu(d->control) & DESCRIPTOR_KEY_IMMEDIATE) >> 8;
branch = d->control & cpu_to_le16(DESCRIPTOR_BRANCH_ALWAYS);

/* figure out which descriptor the branch address goes in */
if (z == 2 && (b == 3 || key == 2))
if (z == 2 && branch == cpu_to_le16(DESCRIPTOR_BRANCH_ALWAYS))
return d;
else
return d + z - 1;
Expand Down

0 comments on commit 0ff8fbc

Please sign in to comment.