drivers/mtd/chips/cfi_cmdset_0001.c
Source file repositories/reference/linux-study-clean/drivers/mtd/chips/cfi_cmdset_0001.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/chips/cfi_cmdset_0001.c- Extension
.c- Size
- 77111 bytes
- Lines
- 2706
- Domain
- Driver Families
- Bucket
- drivers/mtd
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/types.hlinux/kernel.hlinux/sched.hasm/io.hasm/byteorder.hlinux/errno.hlinux/slab.hlinux/delay.hlinux/interrupt.hlinux/reboot.hlinux/bitmap.hlinux/mtd/xip.hlinux/mtd/map.hlinux/mtd/mtd.hlinux/mtd/cfi.hfwh_lock.h
Detected Declarations
function cfi_tell_featuresfunction fixup_convert_atmel_prifunction fixup_at49bv640dx_lockfunction fixup_intel_strataflashfunction fixup_no_write_suspendfunction fixup_st_m28w320ctfunction fixup_st_m28w320cbfunction is_LH28F640BFfunction fixup_LH28F640BFfunction partitionfunction fixup_use_pointfunction fixup_use_write_buffersfunction fixup_unlock_powerup_lockfunction cfi_fixup_major_minorfunction cfi_is_micron_28F00AP30function read_pri_intelextfunction cfi_intelext_partition_fixupfunction chip_readyfunction get_chipfunction put_chipfunction elsefunction xip_enablefunction xip_wait_for_operationfunction INVALIDATE_CACHED_RANGEfunction do_point_onechipfunction cfi_intelext_pointfunction cfi_intelext_unpointfunction do_read_onechipfunction cfi_intelext_readfunction do_write_onewordfunction cfi_intelext_write_wordsfunction do_write_bufferfunction cfi_intelext_writevfunction cfi_intelext_write_buffersfunction do_erase_oneblockfunction cfi_intelext_erase_varsizefunction cfi_intelext_syncfunction do_getlockstatus_oneblockfunction do_printlockstatus_oneblockfunction do_xxlock_oneblockfunction cfi_intelext_lockfunction cfi_intelext_unlockfunction cfi_intelext_is_lockedfunction do_otp_readfunction do_otp_writefunction do_otp_lockfunction cfi_intelext_otp_walkfunction cfi_intelext_read_fact_prot_reg
Annotated Snippet
if (extp->NumProtectionFields) {
struct cfi_intelext_otpinfo *otp =
(struct cfi_intelext_otpinfo *)&extp->extra[0];
extra_size += (extp->NumProtectionFields - 1) *
sizeof(struct cfi_intelext_otpinfo);
if (extp_size >= sizeof(*extp) + extra_size) {
int i;
/* Do some byteswapping if necessary */
for (i = 0; i < extp->NumProtectionFields - 1; i++) {
otp->ProtRegAddr = le32_to_cpu(otp->ProtRegAddr);
otp->FactGroups = le16_to_cpu(otp->FactGroups);
otp->UserGroups = le16_to_cpu(otp->UserGroups);
otp++;
}
}
}
}
if (extp->MinorVersion >= '1') {
/* Burst Read info */
extra_size += 2;
if (extp_size < sizeof(*extp) + extra_size)
goto need_more;
extra_size += extp->extra[extra_size - 1];
}
if (extp->MinorVersion >= '3') {
int nb_parts, i;
/* Number of hardware-partitions */
extra_size += 1;
if (extp_size < sizeof(*extp) + extra_size)
goto need_more;
nb_parts = extp->extra[extra_size - 1];
/* skip the sizeof(partregion) field in CFI 1.4 */
if (extp->MinorVersion >= '4')
extra_size += 2;
for (i = 0; i < nb_parts; i++) {
struct cfi_intelext_regioninfo *rinfo;
rinfo = (struct cfi_intelext_regioninfo *)&extp->extra[extra_size];
extra_size += sizeof(*rinfo);
if (extp_size < sizeof(*extp) + extra_size)
goto need_more;
rinfo->NumIdentPartitions=le16_to_cpu(rinfo->NumIdentPartitions);
extra_size += (rinfo->NumBlockTypes - 1)
* sizeof(struct cfi_intelext_blockinfo);
}
if (extp->MinorVersion >= '4')
extra_size += sizeof(struct cfi_intelext_programming_regioninfo);
if (extp_size < sizeof(*extp) + extra_size) {
need_more:
extp_size = sizeof(*extp) + extra_size;
kfree(extp);
if (extp_size > 4096) {
printk(KERN_ERR
"%s: cfi_pri_intelext is too fat\n",
__func__);
return NULL;
}
goto again;
}
}
return extp;
}
struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
{
struct cfi_private *cfi = map->fldrv_priv;
struct mtd_info *mtd;
int i;
mtd = kzalloc_obj(*mtd);
if (!mtd)
return NULL;
mtd->priv = map;
mtd->type = MTD_NORFLASH;
/* Fill in the default mtd operations */
mtd->_erase = cfi_intelext_erase_varsize;
mtd->_read = cfi_intelext_read;
mtd->_write = cfi_intelext_write_words;
mtd->_sync = cfi_intelext_sync;
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/kernel.h`, `linux/sched.h`, `asm/io.h`, `asm/byteorder.h`, `linux/errno.h`, `linux/slab.h`.
- Detected declarations: `function cfi_tell_features`, `function fixup_convert_atmel_pri`, `function fixup_at49bv640dx_lock`, `function fixup_intel_strataflash`, `function fixup_no_write_suspend`, `function fixup_st_m28w320ct`, `function fixup_st_m28w320cb`, `function is_LH28F640BF`, `function fixup_LH28F640BF`, `function partition`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.