Skip to content

Commit 4af4361

Browse files
committed
firewire: ohci: replace hard-coded values with inline functions for asynchronous packet header
This commit replaces the hard-coded values with the common inline functions to serialize and deserialize the header of asynchronous packet. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 1162825 commit 4af4361

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/firewire/ohci.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -517,14 +517,14 @@ static const char *tcodes[] = {
517517
static void log_ar_at_event(struct fw_ohci *ohci,
518518
char dir, int speed, u32 *header, int evt)
519519
{
520-
int tcode = header[0] >> 4 & 0xf;
520+
int tcode = async_header_get_tcode(header);
521521
char specific[12];
522522

523523
if (likely(!(param_debug & OHCI_PARAM_DEBUG_AT_AR)))
524524
return;
525525

526526
if (unlikely(evt >= ARRAY_SIZE(evts)))
527-
evt = 0x1f;
527+
evt = 0x1f;
528528

529529
if (evt == OHCI1394_evt_bus_reset) {
530530
ohci_notice(ohci, "A%c evt_bus_reset, generation %d\n",
@@ -539,7 +539,8 @@ static void log_ar_at_event(struct fw_ohci *ohci,
539539
break;
540540
case 0x1: case 0x5: case 0x7: case 0x9: case 0xb:
541541
snprintf(specific, sizeof(specific), " %x,%x",
542-
header[3] >> 16, header[3] & 0xffff);
542+
async_header_get_data_length(header),
543+
async_header_get_extended_tcode(header));
543544
break;
544545
default:
545546
specific[0] = '\0';
@@ -556,17 +557,17 @@ static void log_ar_at_event(struct fw_ohci *ohci,
556557
break;
557558
case 0x0: case 0x1: case 0x4: case 0x5: case 0x9:
558559
ohci_notice(ohci,
559-
"A%c spd %x tl %02x, %04x -> %04x, %s, %s, %04x%08x%s\n",
560-
dir, speed, header[0] >> 10 & 0x3f,
561-
header[1] >> 16, header[0] >> 16, evts[evt],
562-
tcodes[tcode], header[1] & 0xffff, header[2], specific);
560+
"A%c spd %x tl %02x, %04x -> %04x, %s, %s, %012llx%s\n",
561+
dir, speed, async_header_get_tlabel(header),
562+
async_header_get_source(header), async_header_get_destination(header),
563+
evts[evt], tcodes[tcode], async_header_get_offset(header), specific);
563564
break;
564565
default:
565566
ohci_notice(ohci,
566567
"A%c spd %x tl %02x, %04x -> %04x, %s, %s%s\n",
567-
dir, speed, header[0] >> 10 & 0x3f,
568-
header[1] >> 16, header[0] >> 16, evts[evt],
569-
tcodes[tcode], specific);
568+
dir, speed, async_header_get_tlabel(header),
569+
async_header_get_source(header), async_header_get_destination(header),
570+
evts[evt], tcodes[tcode], specific);
570571
}
571572
}
572573

@@ -854,7 +855,7 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
854855
p.header[1] = cond_le32_to_cpu(buffer[1]);
855856
p.header[2] = cond_le32_to_cpu(buffer[2]);
856857

857-
tcode = (p.header[0] >> 4) & 0x0f;
858+
tcode = async_header_get_tcode(p.header);
858859
switch (tcode) {
859860
case TCODE_WRITE_QUADLET_REQUEST:
860861
case TCODE_READ_QUADLET_RESPONSE:
@@ -875,7 +876,7 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
875876
case TCODE_LOCK_RESPONSE:
876877
p.header[3] = cond_le32_to_cpu(buffer[3]);
877878
p.header_length = 16;
878-
p.payload_length = p.header[3] >> 16;
879+
p.payload_length = async_header_get_data_length(p.header);
879880
if (p.payload_length > MAX_ASYNC_PAYLOAD) {
880881
ar_context_abort(ctx, "invalid packet length");
881882
return NULL;
@@ -912,8 +913,7 @@ static __le32 *handle_ar_packet(struct ar_context *ctx, __le32 *buffer)
912913
* Several controllers, notably from NEC and VIA, forget to
913914
* write ack_complete status at PHY packet reception.
914915
*/
915-
if (evt == OHCI1394_evt_no_status &&
916-
(p.header[0] & 0xff) == (OHCI1394_phy_tcode << 4))
916+
if (evt == OHCI1394_evt_no_status && tcode == OHCI1394_phy_tcode)
917917
p.ack = ACK_COMPLETE;
918918

919919
/*
@@ -1354,7 +1354,7 @@ static int at_context_queue_packet(struct context *ctx,
13541354
* accordingly.
13551355
*/
13561356

1357-
tcode = (packet->header[0] >> 4) & 0x0f;
1357+
tcode = async_header_get_tcode(packet->header);
13581358
header = (__le32 *) &d[1];
13591359
switch (tcode) {
13601360
case TCODE_WRITE_QUADLET_REQUEST:

0 commit comments

Comments
 (0)