drivers/firewire/ohci-serdes-test.c
Source file repositories/reference/linux-study-clean/drivers/firewire/ohci-serdes-test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firewire/ohci-serdes-test.c- Extension
.c- Size
- 4105 bytes
- Lines
- 123
- Domain
- Driver Families
- Bucket
- drivers/firewire
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hohci.h
Detected Declarations
function test_self_id_count_register_deserializationfunction test_self_id_receive_buffer_deserializationfunction test_at_data_serdesfunction test_it_data_serdes
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
//
// ohci-serdes-test.c - An application of Kunit to check serialization/deserialization of data in
// buffers and registers defined in 1394 OHCI specification.
//
// Copyright (c) 2024 Takashi Sakamoto
#include <kunit/test.h>
#include "ohci.h"
static void test_self_id_count_register_deserialization(struct kunit *test)
{
const u32 expected = 0x803d0594;
bool is_error = ohci1394_self_id_count_is_error(expected);
u8 generation = ohci1394_self_id_count_get_generation(expected);
u32 size = ohci1394_self_id_count_get_size(expected);
KUNIT_EXPECT_TRUE(test, is_error);
KUNIT_EXPECT_EQ(test, 0x3d, generation);
KUNIT_EXPECT_EQ(test, 0x165, size);
}
static void test_self_id_receive_buffer_deserialization(struct kunit *test)
{
const u32 buffer[] = {
0x0006f38b,
0x807fcc56,
0x7f8033a9,
0x8145cc5e,
0x7eba33a1,
};
u8 generation = ohci1394_self_id_receive_q0_get_generation(buffer[0]);
u16 timestamp = ohci1394_self_id_receive_q0_get_timestamp(buffer[0]);
KUNIT_EXPECT_EQ(test, 0x6, generation);
KUNIT_EXPECT_EQ(test, 0xf38b, timestamp);
}
static void test_at_data_serdes(struct kunit *test)
{
static const __le32 expected[] = {
cpu_to_le32(0x00020e80),
cpu_to_le32(0xffc2ffff),
cpu_to_le32(0xe0000000),
};
__le32 quadlets[] = {0, 0, 0};
bool has_src_bus_id = ohci1394_at_data_get_src_bus_id(expected);
unsigned int speed = ohci1394_at_data_get_speed(expected);
unsigned int tlabel = ohci1394_at_data_get_tlabel(expected);
unsigned int retry = ohci1394_at_data_get_retry(expected);
unsigned int tcode = ohci1394_at_data_get_tcode(expected);
unsigned int destination_id = ohci1394_at_data_get_destination_id(expected);
u64 destination_offset = ohci1394_at_data_get_destination_offset(expected);
KUNIT_EXPECT_FALSE(test, has_src_bus_id);
KUNIT_EXPECT_EQ(test, 0x02, speed);
KUNIT_EXPECT_EQ(test, 0x03, tlabel);
KUNIT_EXPECT_EQ(test, 0x02, retry);
KUNIT_EXPECT_EQ(test, 0x08, tcode);
ohci1394_at_data_set_src_bus_id(quadlets, has_src_bus_id);
ohci1394_at_data_set_speed(quadlets, speed);
ohci1394_at_data_set_tlabel(quadlets, tlabel);
ohci1394_at_data_set_retry(quadlets, retry);
ohci1394_at_data_set_tcode(quadlets, tcode);
ohci1394_at_data_set_destination_id(quadlets, destination_id);
ohci1394_at_data_set_destination_offset(quadlets, destination_offset);
KUNIT_EXPECT_MEMEQ(test, quadlets, expected, sizeof(expected));
}
static void test_it_data_serdes(struct kunit *test)
{
static const __le32 expected[] = {
cpu_to_le32(0x000349a7),
cpu_to_le32(0x02300000),
};
__le32 quadlets[] = {0, 0};
unsigned int scode = ohci1394_it_data_get_speed(expected);
unsigned int tag = ohci1394_it_data_get_tag(expected);
unsigned int channel = ohci1394_it_data_get_channel(expected);
unsigned int tcode = ohci1394_it_data_get_tcode(expected);
unsigned int sync = ohci1394_it_data_get_sync(expected);
unsigned int data_length = ohci1394_it_data_get_data_length(expected);
KUNIT_EXPECT_EQ(test, 0x03, scode);
Annotation
- Immediate include surface: `kunit/test.h`, `ohci.h`.
- Detected declarations: `function test_self_id_count_register_deserialization`, `function test_self_id_receive_buffer_deserialization`, `function test_at_data_serdes`, `function test_it_data_serdes`.
- Atlas domain: Driver Families / drivers/firewire.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.