diff options
-rw-r--r-- | drivers/ieee1394/ohci1394.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 4622c99c12f2..8d92246bdc3b 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c | |||
@@ -181,36 +181,35 @@ static int alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d, | |||
181 | static void ohci1394_pci_remove(struct pci_dev *pdev); | 181 | static void ohci1394_pci_remove(struct pci_dev *pdev); |
182 | 182 | ||
183 | #ifndef __LITTLE_ENDIAN | 183 | #ifndef __LITTLE_ENDIAN |
184 | static unsigned hdr_sizes[] = | 184 | const static size_t hdr_sizes[] = { |
185 | { | ||
186 | 3, /* TCODE_WRITEQ */ | 185 | 3, /* TCODE_WRITEQ */ |
187 | 4, /* TCODE_WRITEB */ | 186 | 4, /* TCODE_WRITEB */ |
188 | 3, /* TCODE_WRITE_RESPONSE */ | 187 | 3, /* TCODE_WRITE_RESPONSE */ |
189 | 0, /* ??? */ | 188 | 0, /* reserved */ |
190 | 3, /* TCODE_READQ */ | 189 | 3, /* TCODE_READQ */ |
191 | 4, /* TCODE_READB */ | 190 | 4, /* TCODE_READB */ |
192 | 3, /* TCODE_READQ_RESPONSE */ | 191 | 3, /* TCODE_READQ_RESPONSE */ |
193 | 4, /* TCODE_READB_RESPONSE */ | 192 | 4, /* TCODE_READB_RESPONSE */ |
194 | 1, /* TCODE_CYCLE_START (???) */ | 193 | 1, /* TCODE_CYCLE_START */ |
195 | 4, /* TCODE_LOCK_REQUEST */ | 194 | 4, /* TCODE_LOCK_REQUEST */ |
196 | 2, /* TCODE_ISO_DATA */ | 195 | 2, /* TCODE_ISO_DATA */ |
197 | 4, /* TCODE_LOCK_RESPONSE */ | 196 | 4, /* TCODE_LOCK_RESPONSE */ |
197 | /* rest is reserved or link-internal */ | ||
198 | }; | 198 | }; |
199 | 199 | ||
200 | /* Swap headers */ | 200 | static inline void header_le32_to_cpu(quadlet_t *data, unsigned char tcode) |
201 | static inline void packet_swab(quadlet_t *data, int tcode) | ||
202 | { | 201 | { |
203 | size_t size = hdr_sizes[tcode]; | 202 | size_t size; |
204 | 203 | ||
205 | if (tcode > TCODE_LOCK_RESPONSE || hdr_sizes[tcode] == 0) | 204 | if (unlikely(tcode >= ARRAY_SIZE(hdr_sizes))) |
206 | return; | 205 | return; |
207 | 206 | ||
207 | size = hdr_sizes[tcode]; | ||
208 | while (size--) | 208 | while (size--) |
209 | data[size] = swab32(data[size]); | 209 | data[size] = le32_to_cpu(data[size]); |
210 | } | 210 | } |
211 | #else | 211 | #else |
212 | /* Don't waste cycles on same sex byte swaps */ | 212 | #define header_le32_to_cpu(w,x) do {} while (0) |
213 | #define packet_swab(w,x) do {} while (0) | ||
214 | #endif /* !LITTLE_ENDIAN */ | 213 | #endif /* !LITTLE_ENDIAN */ |
215 | 214 | ||
216 | /*********************************** | 215 | /*********************************** |
@@ -701,7 +700,7 @@ static void insert_packet(struct ti_ohci *ohci, | |||
701 | d->prg_cpu[idx]->data[2] = packet->header[2]; | 700 | d->prg_cpu[idx]->data[2] = packet->header[2]; |
702 | d->prg_cpu[idx]->data[3] = packet->header[3]; | 701 | d->prg_cpu[idx]->data[3] = packet->header[3]; |
703 | } | 702 | } |
704 | packet_swab(d->prg_cpu[idx]->data, packet->tcode); | 703 | header_le32_to_cpu(d->prg_cpu[idx]->data, packet->tcode); |
705 | } | 704 | } |
706 | 705 | ||
707 | if (packet->data_size) { /* block transmit */ | 706 | if (packet->data_size) { /* block transmit */ |
@@ -777,7 +776,7 @@ static void insert_packet(struct ti_ohci *ohci, | |||
777 | d->prg_cpu[idx]->data[0] = packet->speed_code<<16 | | 776 | d->prg_cpu[idx]->data[0] = packet->speed_code<<16 | |
778 | (packet->header[0] & 0xFFFF); | 777 | (packet->header[0] & 0xFFFF); |
779 | d->prg_cpu[idx]->data[1] = packet->header[0] & 0xFFFF0000; | 778 | d->prg_cpu[idx]->data[1] = packet->header[0] & 0xFFFF0000; |
780 | packet_swab(d->prg_cpu[idx]->data, packet->tcode); | 779 | header_le32_to_cpu(d->prg_cpu[idx]->data, packet->tcode); |
781 | 780 | ||
782 | d->prg_cpu[idx]->begin.control = | 781 | d->prg_cpu[idx]->begin.control = |
783 | cpu_to_le32(DMA_CTL_OUTPUT_MORE | | 782 | cpu_to_le32(DMA_CTL_OUTPUT_MORE | |
@@ -2731,7 +2730,7 @@ static void dma_rcv_tasklet (unsigned long data) | |||
2731 | * bus reset. We always ignore it. */ | 2730 | * bus reset. We always ignore it. */ |
2732 | if (tcode != OHCI1394_TCODE_PHY) { | 2731 | if (tcode != OHCI1394_TCODE_PHY) { |
2733 | if (!ohci->no_swap_incoming) | 2732 | if (!ohci->no_swap_incoming) |
2734 | packet_swab(d->spb, tcode); | 2733 | header_le32_to_cpu(d->spb, tcode); |
2735 | DBGMSG("Packet received from node" | 2734 | DBGMSG("Packet received from node" |
2736 | " %d ack=0x%02X spd=%d tcode=0x%X" | 2735 | " %d ack=0x%02X spd=%d tcode=0x%X" |
2737 | " length=%d ctx=%d tlabel=%d", | 2736 | " length=%d ctx=%d tlabel=%d", |