drivers/mtd/ubi/debug.h
Source file repositories/reference/linux-study-clean/drivers/mtd/ubi/debug.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/ubi/debug.h- Extension
.h- Size
- 11518 bytes
- Lines
- 388
- Domain
- Driver Families
- Bucket
- drivers/mtd
- 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
linux/random.h
Detected Declarations
function ubi_dbg_bitflipfunction ubi_dbg_write_failurefunction ubi_dbg_erase_failurefunction ubi_dbg_fail_bitflipfunction ubi_dbg_fail_writefunction ubi_dbg_fail_erasefunction ubi_dbg_fail_power_cutfunction ubi_dbg_fail_readfunction ubi_dbg_fail_eccerrfunction ubi_dbg_fail_fffunction ubi_dbg_fail_ff_bitflipsfunction ubi_dbg_fail_bad_hdrfunction ubi_dbg_fail_bad_hdr_ebadmsgfunction ubi_dbg_is_power_cutfunction ubi_dbg_is_bitflipfunction ubi_dbg_is_write_failurefunction ubi_dbg_is_erase_failurefunction ubi_dbg_is_eccerrfunction ubi_dbg_is_read_failurefunction ubi_dbg_is_fffunction ubi_dbg_is_ff_bitflipsfunction ubi_dbg_is_bad_hdrfunction ubi_dbg_is_bad_hdr_ebadmsgfunction ubi_dbg_is_bgt_disabledfunction ubi_dbg_chk_iofunction ubi_dbg_chk_genfunction ubi_dbg_chk_fastmapfunction ubi_enable_dbg_chk_fastmap
Annotated Snippet
#ifndef __UBI_DEBUG_H__
#define __UBI_DEBUG_H__
void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
#include <linux/random.h>
#define ubi_assert(expr) do { \
if (unlikely(!(expr))) { \
pr_crit("UBI assert failed in %s at %u (pid %d)\n", \
__func__, __LINE__, current->pid); \
dump_stack(); \
} \
} while (0)
#define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a) \
print_hex_dump(l, ps, pt, r, g, b, len, a)
#define ubi_dbg_msg(type, fmt, ...) \
pr_debug("UBI DBG " type " (pid %d): " fmt "\n", current->pid, \
##__VA_ARGS__)
/* General debugging messages */
#define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
/* Messages from the eraseblock association sub-system */
#define dbg_eba(fmt, ...) ubi_dbg_msg("eba", fmt, ##__VA_ARGS__)
/* Messages from the wear-leveling sub-system */
#define dbg_wl(fmt, ...) ubi_dbg_msg("wl", fmt, ##__VA_ARGS__)
/* Messages from the input/output sub-system */
#define dbg_io(fmt, ...) ubi_dbg_msg("io", fmt, ##__VA_ARGS__)
/* Initialization and build messages */
#define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__)
void ubi_dump_vol_info(const struct ubi_volume *vol);
void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
void ubi_dump_av(const struct ubi_ainf_volume *av);
void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type);
void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req);
int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
int len);
int ubi_debugfs_init(void);
void ubi_debugfs_exit(void);
int ubi_debugfs_init_dev(struct ubi_device *ubi);
void ubi_debugfs_exit_dev(struct ubi_device *ubi);
/**
* The following function is a legacy implementation of UBI fault-injection
* hook. When using more powerful fault injection capabilities, the legacy
* fault injection interface should be retained.
*/
int ubi_dbg_power_cut(struct ubi_device *ubi, int caller);
static inline int ubi_dbg_bitflip(const struct ubi_device *ubi)
{
if (ubi->dbg.emulate_bitflips)
return !get_random_u32_below(200);
return 0;
}
static inline int ubi_dbg_write_failure(const struct ubi_device *ubi)
{
if (ubi->dbg.emulate_io_failures)
return !get_random_u32_below(500);
return 0;
}
static inline int ubi_dbg_erase_failure(const struct ubi_device *ubi)
{
if (ubi->dbg.emulate_io_failures)
return !get_random_u32_below(400);
return 0;
}
/**
* MASK_XXX: Mask for emulate_failures in ubi_debug_info.The mask is used to
* precisely control the type and process of fault injection.
*/
/* Emulate a power cut when writing EC/VID header */
#define MASK_POWER_CUT_EC (1 << 0)
#define MASK_POWER_CUT_VID (1 << 1)
/* Emulate a power cut when writing data*/
#define MASK_POWER_CUT_DATA (1 << 2)
/* Emulate bit-flips */
#define MASK_BITFLIPS (1 << 3)
/* Emulate ecc error */
#define MASK_ECCERR (1 << 4)
/* Emulates -EIO during data read */
#define MASK_READ_FAILURE (1 << 5)
Annotation
- Immediate include surface: `linux/random.h`.
- Detected declarations: `function ubi_dbg_bitflip`, `function ubi_dbg_write_failure`, `function ubi_dbg_erase_failure`, `function ubi_dbg_fail_bitflip`, `function ubi_dbg_fail_write`, `function ubi_dbg_fail_erase`, `function ubi_dbg_fail_power_cut`, `function ubi_dbg_fail_read`, `function ubi_dbg_fail_eccerr`, `function ubi_dbg_fail_ff`.
- Atlas domain: Driver Families / drivers/mtd.
- 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.