Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20240912133038.238786-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

+9 -36
+9 -36
drivers/firewire/ohci.c
··· 1141 1141 return d + z - 1; 1142 1142 } 1143 1143 1144 - static void context_tasklet(unsigned long data) 1144 + static void context_retire_descriptors(struct context *ctx) 1145 1145 { 1146 - struct context *ctx = (struct context *) data; 1147 1146 struct descriptor *d, *last; 1148 1147 u32 address; 1149 1148 int z; ··· 1181 1182 } 1182 1183 } 1183 1184 1185 + static void context_tasklet(unsigned long data) 1186 + { 1187 + struct context *ctx = (struct context *) data; 1188 + 1189 + context_retire_descriptors(ctx); 1190 + } 1191 + 1184 1192 static void ohci_isoc_context_work(struct work_struct *work) 1185 1193 { 1186 1194 struct fw_iso_context *base = container_of(work, struct fw_iso_context, work); 1187 1195 struct iso_context *isoc_ctx = container_of(base, struct iso_context, base); 1188 - struct context *ctx = &isoc_ctx->context; 1189 - struct descriptor *d, *last; 1190 - u32 address; 1191 - int z; 1192 - struct descriptor_buffer *desc; 1193 1196 1194 - desc = list_entry(ctx->buffer_list.next, struct descriptor_buffer, list); 1195 - last = ctx->last; 1196 - while (last->branch_address != 0) { 1197 - struct descriptor_buffer *old_desc = desc; 1198 - 1199 - address = le32_to_cpu(last->branch_address); 1200 - z = address & 0xf; 1201 - address &= ~0xf; 1202 - ctx->current_bus = address; 1203 - 1204 - // If the branch address points to a buffer outside of the current buffer, advance 1205 - // to the next buffer. 1206 - if (address < desc->buffer_bus || address >= desc->buffer_bus + desc->used) 1207 - desc = list_entry(desc->list.next, struct descriptor_buffer, list); 1208 - d = desc->buffer + (address - desc->buffer_bus) / sizeof(*d); 1209 - last = find_branch_descriptor(d, z); 1210 - 1211 - if (!ctx->callback(ctx, d, last)) 1212 - break; 1213 - 1214 - if (old_desc != desc) { 1215 - // If we've advanced to the next buffer, move the previous buffer to the 1216 - // free list. 1217 - old_desc->used = 0; 1218 - guard(spinlock_irqsave)(&ctx->ohci->lock); 1219 - list_move_tail(&old_desc->list, &ctx->buffer_list); 1220 - } 1221 - ctx->last = last; 1222 - } 1197 + context_retire_descriptors(&isoc_ctx->context); 1223 1198 } 1224 1199 1225 1200 /*