Skip to content

Commit 5d56765

Browse files
committed
firewire: core: add helper function to retire descriptors
Both IR/IT contexts use the same code to retire completed descriptors as AT context uses. This commit adds a helper function to reduce the duplicated codes. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 6ffa9bd commit 5d56765

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

drivers/firewire/ohci.c

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,9 +1141,8 @@ static struct descriptor *find_branch_descriptor(struct descriptor *d, int z)
11411141
return d + z - 1;
11421142
}
11431143

1144-
static void context_tasklet(unsigned long data)
1144+
static void context_retire_descriptors(struct context *ctx)
11451145
{
1146-
struct context *ctx = (struct context *) data;
11471146
struct descriptor *d, *last;
11481147
u32 address;
11491148
int z;
@@ -1182,45 +1181,19 @@ static void context_tasklet(unsigned long data)
11821181
}
11831182
}
11841183

1184+
static void context_tasklet(unsigned long data)
1185+
{
1186+
struct context *ctx = (struct context *) data;
1187+
1188+
context_retire_descriptors(ctx);
1189+
}
1190+
11851191
static void ohci_isoc_context_work(struct work_struct *work)
11861192
{
11871193
struct fw_iso_context *base = container_of(work, struct fw_iso_context, work);
11881194
struct iso_context *isoc_ctx = container_of(base, struct iso_context, base);
1189-
struct context *ctx = &isoc_ctx->context;
1190-
struct descriptor *d, *last;
1191-
u32 address;
1192-
int z;
1193-
struct descriptor_buffer *desc;
1194-
1195-
desc = list_entry(ctx->buffer_list.next, struct descriptor_buffer, list);
1196-
last = ctx->last;
1197-
while (last->branch_address != 0) {
1198-
struct descriptor_buffer *old_desc = desc;
1199-
1200-
address = le32_to_cpu(last->branch_address);
1201-
z = address & 0xf;
1202-
address &= ~0xf;
1203-
ctx->current_bus = address;
1204-
1205-
// If the branch address points to a buffer outside of the current buffer, advance
1206-
// to the next buffer.
1207-
if (address < desc->buffer_bus || address >= desc->buffer_bus + desc->used)
1208-
desc = list_entry(desc->list.next, struct descriptor_buffer, list);
1209-
d = desc->buffer + (address - desc->buffer_bus) / sizeof(*d);
1210-
last = find_branch_descriptor(d, z);
1211-
1212-
if (!ctx->callback(ctx, d, last))
1213-
break;
12141195

1215-
if (old_desc != desc) {
1216-
// If we've advanced to the next buffer, move the previous buffer to the
1217-
// free list.
1218-
old_desc->used = 0;
1219-
guard(spinlock_irqsave)(&ctx->ohci->lock);
1220-
list_move_tail(&old_desc->list, &ctx->buffer_list);
1221-
}
1222-
ctx->last = last;
1223-
}
1196+
context_retire_descriptors(&isoc_ctx->context);
12241197
}
12251198

12261199
/*

0 commit comments

Comments
 (0)