drivers/base/firmware_loader/sysfs_upload.c
Source file repositories/reference/linux-study-clean/drivers/base/firmware_loader/sysfs_upload.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/firmware_loader/sysfs_upload.c- Extension
.c- Size
- 10333 bytes
- Lines
- 409
- Domain
- Driver Families
- Bucket
- drivers/base
- 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.
- 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/firmware.hlinux/module.hlinux/slab.hsysfs_upload.h
Detected Declarations
function status_showfunction error_showfunction cancel_storefunction remaining_size_showfunction fw_upload_is_visiblefunction fw_upload_update_progressfunction fw_upload_set_errorfunction fw_upload_prog_completefunction fw_upload_mainfunction fw_upload_startfunction fw_upload_freefunction firmware_upload_registerfunction firmware_upload_unregisterexport firmware_upload_registerexport firmware_upload_unregister
Annotated Snippet
ret = device_add(fw_dev);
if (ret) {
dev_err(fw_dev, "%s: device_register failed\n", __func__);
put_device(fw_dev);
goto exit_module_put;
}
return fw_upload;
free_fw_upload_priv:
kfree(fw_upload_priv);
free_fw_upload:
kfree(fw_upload);
exit_module_put:
module_put(module);
return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(firmware_upload_register);
/**
* firmware_upload_unregister() - Unregister firmware upload interface
* @fw_upload: pointer to struct fw_upload
**/
void firmware_upload_unregister(struct fw_upload *fw_upload)
{
struct fw_sysfs *fw_sysfs = fw_upload->priv;
struct fw_upload_priv *fw_upload_priv = fw_sysfs->fw_upload_priv;
struct module *module = fw_upload_priv->module;
mutex_lock(&fw_upload_priv->lock);
if (fw_upload_priv->progress == FW_UPLOAD_PROG_IDLE) {
mutex_unlock(&fw_upload_priv->lock);
goto unregister;
}
fw_upload_priv->ops->cancel(fw_upload);
mutex_unlock(&fw_upload_priv->lock);
/* Ensure lower-level device-driver is finished */
flush_work(&fw_upload_priv->work);
unregister:
device_unregister(&fw_sysfs->dev);
module_put(module);
}
EXPORT_SYMBOL_GPL(firmware_upload_unregister);
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/slab.h`, `sysfs_upload.h`.
- Detected declarations: `function status_show`, `function error_show`, `function cancel_store`, `function remaining_size_show`, `function fw_upload_is_visible`, `function fw_upload_update_progress`, `function fw_upload_set_error`, `function fw_upload_prog_complete`, `function fw_upload_main`, `function fw_upload_start`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration 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.