drivers/gpu/drm/imagination/pvr_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imagination/pvr_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/imagination/pvr_test.c- Extension
.c- Size
- 2093 bytes
- Lines
- 74
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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
pvr_device.hlinux/errno.hlinux/stddef.hlinux/string.hlinux/types.hkunit/test.hkunit/visibility.h
Detected Declarations
function decode_gpuid_string
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/* Copyright (c) 2025 Imagination Technologies Ltd. */
#include "pvr_device.h"
#include <linux/errno.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/types.h>
#include <kunit/test.h>
#include <kunit/visibility.h>
static void decode_gpuid_string(struct kunit *test)
{
const struct pvr_gpu_id bad_gpuid = { 0xdead, 0xbeef, 0xcafe, 0xface };
const u64 packed_bad_gpuid = pvr_gpu_id_to_packed_bvnc(&bad_gpuid);
#define GPUID_TEST_CASE(str_, err_, value_) \
do { \
struct pvr_gpu_id _gpuid_out = bad_gpuid; \
int _err; \
_err = pvr_gpuid_decode_string(NULL, str_, &_gpuid_out); \
KUNIT_EXPECT_EQ(test, _err, err_); \
KUNIT_EXPECT_EQ(test, \
pvr_gpu_id_to_packed_bvnc(&_gpuid_out), \
value_); \
} while (0)
#define GPUID_TEST_CASE_OK(str_, b_, v_, n_, c_) \
GPUID_TEST_CASE(str_, 0, PVR_PACKED_BVNC(b_, v_, n_, c_))
#define GPUID_TEST_CASE_INVAL(str_) \
GPUID_TEST_CASE(str_, -EINVAL, packed_bad_gpuid)
GPUID_TEST_CASE_OK("12.34.56.78", 12, 34, 56, 78);
GPUID_TEST_CASE_OK("0.0.0.0", 0, 0, 0, 0);
GPUID_TEST_CASE_INVAL("");
GPUID_TEST_CASE_INVAL("42.foobar-invalid.gpuid.bvnc");
/* String longer than PVR_GPUID_STRING_MAX_LENGTH. */
GPUID_TEST_CASE_INVAL("12.34.56.789012345678901234567890123456");
/* Single value overflowing u16. */
GPUID_TEST_CASE_INVAL("12.34.56.999999");
/* Wrong number of parts and/or dots. */
GPUID_TEST_CASE_INVAL("12.34.56.78.90");
GPUID_TEST_CASE_INVAL("12.34.56..78");
GPUID_TEST_CASE_INVAL("12.34..56");
GPUID_TEST_CASE_INVAL("12.34.56");
#undef GPUID_TEST_CASE_INVAL
#undef GPUID_TEST_CASE_OK
#undef GPUID_TEST_CASE
}
static struct kunit_case pvr_tests_cases[] = {
KUNIT_CASE(decode_gpuid_string),
{},
};
static struct kunit_suite pvr_tests_suite = {
.name = "pvr_tests",
.test_cases = pvr_tests_cases,
};
kunit_test_suite(pvr_tests_suite);
MODULE_AUTHOR("Imagination Technologies Ltd.");
MODULE_LICENSE("Dual MIT/GPL");
MODULE_DESCRIPTION("pvr kunit tests");
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
Annotation
- Immediate include surface: `pvr_device.h`, `linux/errno.h`, `linux/stddef.h`, `linux/string.h`, `linux/types.h`, `kunit/test.h`, `kunit/visibility.h`.
- Detected declarations: `function decode_gpuid_string`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.