aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2012-03-18 14:04:43 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2012-03-18 17:15:39 -0400
commit910e76c607546ead218de8b11c32597d6b8fe7e4 (patch)
tree8a858f98ae79a998aeeef09d7b2a142d05d201b6 /drivers/firewire
parent73864012f386ca5a193f3231c9b1936e23709a94 (diff)
firewire: ohci: factor out iso completion flushing code
In preparation for the following patches that add more flushing, move the code for flushing accumulated header data into a common function. The timestamp of the last completed packed is passed through the context structure instead of a function parameter to allow accessing this value later outside of the handle_i?_packet functions. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/ohci.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 1a49743347fb..07d3c8d58b30 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -172,7 +172,7 @@ struct iso_context {
172 struct context context; 172 struct context context;
173 void *header; 173 void *header;
174 size_t header_length; 174 size_t header_length;
175 175 u16 last_timestamp;
176 u8 sync; 176 u8 sync;
177 u8 tags; 177 u8 tags;
178}; 178};
@@ -2676,6 +2676,14 @@ static void ohci_write_csr(struct fw_card *card, int csr_offset, u32 value)
2676 } 2676 }
2677} 2677}
2678 2678
2679static void flush_iso_completions(struct iso_context *ctx)
2680{
2681 ctx->base.callback.sc(&ctx->base, ctx->last_timestamp,
2682 ctx->header_length, ctx->header,
2683 ctx->base.callback_data);
2684 ctx->header_length = 0;
2685}
2686
2679static void copy_iso_headers(struct iso_context *ctx, const u32 *dma_hdr) 2687static void copy_iso_headers(struct iso_context *ctx, const u32 *dma_hdr)
2680{ 2688{
2681 u32 *ctx_hdr; 2689 u32 *ctx_hdr;
@@ -2684,6 +2692,7 @@ static void copy_iso_headers(struct iso_context *ctx, const u32 *dma_hdr)
2684 return; 2692 return;
2685 2693
2686 ctx_hdr = ctx->header + ctx->header_length; 2694 ctx_hdr = ctx->header + ctx->header_length;
2695 ctx->last_timestamp = (u16)le32_to_cpu((__force __le32)dma_hdr[0]);
2687 2696
2688 /* 2697 /*
2689 * The two iso header quadlets are byteswapped to little 2698 * The two iso header quadlets are byteswapped to little
@@ -2707,8 +2716,6 @@ static int handle_ir_packet_per_buffer(struct context *context,
2707 container_of(context, struct iso_context, context); 2716 container_of(context, struct iso_context, context);
2708 struct descriptor *pd; 2717 struct descriptor *pd;
2709 u32 buffer_dma; 2718 u32 buffer_dma;
2710 __le32 *ir_header;
2711 void *p;
2712 2719
2713 for (pd = d; pd <= last; pd++) 2720 for (pd = d; pd <= last; pd++)
2714 if (pd->transfer_status) 2721 if (pd->transfer_status)
@@ -2727,17 +2734,10 @@ static int handle_ir_packet_per_buffer(struct context *context,
2727 DMA_FROM_DEVICE); 2734 DMA_FROM_DEVICE);
2728 } 2735 }
2729 2736
2730 p = last + 1; 2737 copy_iso_headers(ctx, (u32 *) (last + 1));
2731 copy_iso_headers(ctx, p);
2732 2738
2733 if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS)) { 2739 if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS))
2734 ir_header = (__le32 *) p; 2740 flush_iso_completions(ctx);
2735 ctx->base.callback.sc(&ctx->base,
2736 le32_to_cpu(ir_header[0]) & 0xffff,
2737 ctx->header_length, ctx->header,
2738 ctx->base.callback_data);
2739 ctx->header_length = 0;
2740 }
2741 2741
2742 return 1; 2742 return 1;
2743} 2743}
@@ -2834,12 +2834,11 @@ static int handle_it_packet(struct context *context,
2834 le16_to_cpu(pd->res_count)); 2834 le16_to_cpu(pd->res_count));
2835 ctx->header_length += 4; 2835 ctx->header_length += 4;
2836 } 2836 }
2837 if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS)) { 2837
2838 ctx->base.callback.sc(&ctx->base, le16_to_cpu(last->res_count), 2838 ctx->last_timestamp = le16_to_cpu(last->res_count);
2839 ctx->header_length, ctx->header, 2839 if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS))
2840 ctx->base.callback_data); 2840 flush_iso_completions(ctx);
2841 ctx->header_length = 0; 2841
2842 }
2843 return 1; 2842 return 1;
2844} 2843}
2845 2844