drivers/md/dm-vdo/numeric.h
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/numeric.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/numeric.h- Extension
.h- Size
- 1960 bytes
- Lines
- 79
- Domain
- Driver Families
- Bucket
- drivers/md
- 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.
Dependency Surface
linux/unaligned.hlinux/kernel.hlinux/types.h
Detected Declarations
function decode_s64_lefunction encode_s64_lefunction decode_u64_lefunction encode_u64_lefunction decode_s32_lefunction encode_s32_lefunction decode_u32_lefunction encode_u32_lefunction decode_u16_lefunction encode_u16_le
Annotated Snippet
#ifndef UDS_NUMERIC_H
#define UDS_NUMERIC_H
#include <linux/unaligned.h>
#include <linux/kernel.h>
#include <linux/types.h>
/*
* These utilities encode or decode a number from an offset in a larger data buffer and then
* advance the offset pointer to the next field in the buffer.
*/
static inline void decode_s64_le(const u8 *buffer, size_t *offset, s64 *decoded)
{
*decoded = get_unaligned_le64(buffer + *offset);
*offset += sizeof(s64);
}
static inline void encode_s64_le(u8 *data, size_t *offset, s64 to_encode)
{
put_unaligned_le64(to_encode, data + *offset);
*offset += sizeof(s64);
}
static inline void decode_u64_le(const u8 *buffer, size_t *offset, u64 *decoded)
{
*decoded = get_unaligned_le64(buffer + *offset);
*offset += sizeof(u64);
}
static inline void encode_u64_le(u8 *data, size_t *offset, u64 to_encode)
{
put_unaligned_le64(to_encode, data + *offset);
*offset += sizeof(u64);
}
static inline void decode_s32_le(const u8 *buffer, size_t *offset, s32 *decoded)
{
*decoded = get_unaligned_le32(buffer + *offset);
*offset += sizeof(s32);
}
static inline void encode_s32_le(u8 *data, size_t *offset, s32 to_encode)
{
put_unaligned_le32(to_encode, data + *offset);
*offset += sizeof(s32);
}
static inline void decode_u32_le(const u8 *buffer, size_t *offset, u32 *decoded)
{
*decoded = get_unaligned_le32(buffer + *offset);
*offset += sizeof(u32);
}
static inline void encode_u32_le(u8 *data, size_t *offset, u32 to_encode)
{
put_unaligned_le32(to_encode, data + *offset);
*offset += sizeof(u32);
}
static inline void decode_u16_le(const u8 *buffer, size_t *offset, u16 *decoded)
{
*decoded = get_unaligned_le16(buffer + *offset);
*offset += sizeof(u16);
}
static inline void encode_u16_le(u8 *data, size_t *offset, u16 to_encode)
{
put_unaligned_le16(to_encode, data + *offset);
*offset += sizeof(u16);
}
#endif /* UDS_NUMERIC_H */
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/kernel.h`, `linux/types.h`.
- Detected declarations: `function decode_s64_le`, `function encode_s64_le`, `function decode_u64_le`, `function encode_u64_le`, `function decode_s32_le`, `function encode_s32_le`, `function decode_u32_le`, `function encode_u32_le`, `function decode_u16_le`, `function encode_u16_le`.
- Atlas domain: Driver Families / drivers/md.
- 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.