drivers/peci/device.c
Source file repositories/reference/linux-study-clean/drivers/peci/device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/peci/device.c- Extension
.c- Size
- 5276 bytes
- Lines
- 252
- Domain
- Driver Families
- Bucket
- drivers/peci
- 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/bitfield.hlinux/peci.hlinux/peci-cpu.hlinux/slab.hinternal.h
Detected Declarations
function peci_get_revisionfunction peci_get_cpu_idfunction peci_x86_cpu_familyfunction peci_x86_cpu_modelfunction peci_device_info_initfunction peci_detectfunction peci_addr_validfunction peci_dev_existsfunction peci_device_createfunction peci_device_destroyfunction __peci_driver_registerfunction peci_driver_unregisterfunction peci_device_release
Annotated Snippet
ret = device_add(&device->dev);
if (ret)
goto err_put;
return 0;
err_put:
put_device(&device->dev);
return ret;
}
void peci_device_destroy(struct peci_device *device)
{
mutex_lock(&peci_device_del_lock);
if (!device->deleted) {
device_unregister(&device->dev);
device->deleted = true;
}
mutex_unlock(&peci_device_del_lock);
}
int __peci_driver_register(struct peci_driver *driver, struct module *owner,
const char *mod_name)
{
driver->driver.bus = &peci_bus_type;
driver->driver.owner = owner;
driver->driver.mod_name = mod_name;
if (!driver->probe) {
pr_err("peci: trying to register driver without probe callback\n");
return -EINVAL;
}
if (!driver->id_table) {
pr_err("peci: trying to register driver without device id table\n");
return -EINVAL;
}
return driver_register(&driver->driver);
}
EXPORT_SYMBOL_NS_GPL(__peci_driver_register, "PECI");
void peci_driver_unregister(struct peci_driver *driver)
{
driver_unregister(&driver->driver);
}
EXPORT_SYMBOL_NS_GPL(peci_driver_unregister, "PECI");
static void peci_device_release(struct device *dev)
{
struct peci_device *device = to_peci_device(dev);
kfree(device);
}
const struct device_type peci_device_type = {
.groups = peci_device_groups,
.release = peci_device_release,
};
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/peci.h`, `linux/peci-cpu.h`, `linux/slab.h`, `internal.h`.
- Detected declarations: `function peci_get_revision`, `function peci_get_cpu_id`, `function peci_x86_cpu_family`, `function peci_x86_cpu_model`, `function peci_device_info_init`, `function peci_detect`, `function peci_addr_valid`, `function peci_dev_exists`, `function peci_device_create`, `function peci_device_destroy`.
- Atlas domain: Driver Families / drivers/peci.
- 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.