drivers/mtd/ubi/vmt.c
Source file repositories/reference/linux-study-clean/drivers/mtd/ubi/vmt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mtd/ubi/vmt.c- Extension
.c- Size
- 23223 bytes
- Lines
- 849
- 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.
- 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/err.hlinux/math64.hlinux/slab.hlinux/export.hubi.h
Detected Declarations
function vol_attribute_showfunction vol_releasefunction fwnode_for_each_child_nodefunction ubi_create_volumefunction ubi_remove_volumefunction ubi_resize_volumefunction pendingfunction ubi_rename_volumesfunction list_for_each_entryfunction ubi_add_volumefunction ubi_free_volumefunction self_check_volumefunction self_check_volumes
Annotated Snippet
else if (attr == &attr_vol_type) {
const char *tp;
if (vol->vol_type == UBI_DYNAMIC_VOLUME)
tp = "dynamic";
else
tp = "static";
ret = sprintf(buf, "%s\n", tp);
} else if (attr == &attr_vol_name)
ret = sprintf(buf, "%s\n", vol->name);
else if (attr == &attr_vol_corrupted)
ret = sprintf(buf, "%d\n", vol->corrupted);
else if (attr == &attr_vol_alignment)
ret = sprintf(buf, "%d\n", vol->alignment);
else if (attr == &attr_vol_usable_eb_size)
ret = sprintf(buf, "%d\n", vol->usable_leb_size);
else if (attr == &attr_vol_data_bytes)
ret = sprintf(buf, "%lld\n", vol->used_bytes);
else if (attr == &attr_vol_upd_marker)
ret = sprintf(buf, "%d\n", vol->upd_marker);
else
/* This must be a bug */
ret = -EINVAL;
/* We've done the operation, drop volume and UBI device references */
spin_lock(&ubi->volumes_lock);
vol->ref_count -= 1;
ubi_assert(vol->ref_count >= 0);
spin_unlock(&ubi->volumes_lock);
return ret;
}
static struct attribute *volume_dev_attrs[] = {
&attr_vol_reserved_ebs.attr,
&attr_vol_type.attr,
&attr_vol_name.attr,
&attr_vol_corrupted.attr,
&attr_vol_alignment.attr,
&attr_vol_usable_eb_size.attr,
&attr_vol_data_bytes.attr,
&attr_vol_upd_marker.attr,
NULL
};
ATTRIBUTE_GROUPS(volume_dev);
/* Release method for volume devices */
static void vol_release(struct device *dev)
{
struct ubi_volume *vol = container_of(dev, struct ubi_volume, dev);
ubi_eba_replace_table(vol, NULL);
ubi_fastmap_destroy_checkmap(vol);
kfree(vol);
}
static struct fwnode_handle *find_volume_fwnode(struct ubi_volume *vol)
{
struct fwnode_handle *fw_vols, *fw_vol;
const char *volname;
u32 volid;
fw_vols = device_get_named_child_node(vol->dev.parent->parent, "volumes");
if (!fw_vols)
return NULL;
fwnode_for_each_child_node(fw_vols, fw_vol) {
if (!fwnode_property_read_string(fw_vol, "volname", &volname) &&
strncmp(volname, vol->name, vol->name_len))
continue;
if (!fwnode_property_read_u32(fw_vol, "volid", &volid) &&
vol->vol_id != volid)
continue;
fwnode_handle_put(fw_vols);
return fw_vol;
}
fwnode_handle_put(fw_vols);
return NULL;
}
/**
* ubi_create_volume - create volume.
* @ubi: UBI device description object
* @req: volume creation request
*
* This function creates volume described by @req. If @req->vol_id id
* %UBI_VOL_NUM_AUTO, this function automatically assign ID to the new volume
* and saves it in @req->vol_id. Returns zero in case of success and a negative
Annotation
- Immediate include surface: `linux/err.h`, `linux/math64.h`, `linux/slab.h`, `linux/export.h`, `ubi.h`.
- Detected declarations: `function vol_attribute_show`, `function vol_release`, `function fwnode_for_each_child_node`, `function ubi_create_volume`, `function ubi_remove_volume`, `function ubi_resize_volume`, `function pending`, `function ubi_rename_volumes`, `function list_for_each_entry`, `function ubi_add_volume`.
- Atlas domain: Driver Families / drivers/mtd.
- Implementation status: source implementation candidate.
- 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.