drivers/peci/cpu.c
Source file repositories/reference/linux-study-clean/drivers/peci/cpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/peci/cpu.c- Extension
.c- Size
- 7565 bytes
- Lines
- 345
- 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.
- 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/auxiliary_bus.hlinux/module.hlinux/peci.hlinux/peci-cpu.hlinux/slab.hinternal.h
Detected Declarations
struct peci_cpufunction peci_temp_readfunction peci_pcs_readfunction peci_pci_local_readfunction peci_ep_pci_local_readfunction peci_mmio_readfunction adev_releasefunction unregister_adevfunction devm_adev_addfunction peci_cpu_add_adevicesfunction peci_cpu_probe
Annotated Snippet
struct peci_cpu {
struct peci_device *device;
const struct peci_device_id *id;
};
static void adev_release(struct device *dev)
{
struct auxiliary_device *adev = to_auxiliary_dev(dev);
kfree(adev->name);
kfree(adev);
}
static struct auxiliary_device *adev_alloc(struct peci_cpu *priv, int idx)
{
struct peci_controller *controller = to_peci_controller(priv->device->dev.parent);
struct auxiliary_device *adev;
const char *name;
int ret;
adev = kzalloc_obj(*adev);
if (!adev)
return ERR_PTR(-ENOMEM);
name = kasprintf(GFP_KERNEL, "%s.%s", peci_adev_types[idx], (const char *)priv->id->data);
if (!name) {
ret = -ENOMEM;
goto free_adev;
}
adev->name = name;
adev->dev.parent = &priv->device->dev;
adev->dev.release = adev_release;
adev->id = (controller->id << 16) | (priv->device->addr);
ret = auxiliary_device_init(adev);
if (ret)
goto free_name;
return adev;
free_name:
kfree(name);
free_adev:
kfree(adev);
return ERR_PTR(ret);
}
static void unregister_adev(void *_adev)
{
struct auxiliary_device *adev = _adev;
auxiliary_device_delete(adev);
auxiliary_device_uninit(adev);
}
static int devm_adev_add(struct device *dev, int idx)
{
struct peci_cpu *priv = dev_get_drvdata(dev);
struct auxiliary_device *adev;
int ret;
adev = adev_alloc(priv, idx);
if (IS_ERR(adev))
return PTR_ERR(adev);
ret = auxiliary_device_add(adev);
if (ret) {
auxiliary_device_uninit(adev);
return ret;
}
ret = devm_add_action_or_reset(&priv->device->dev, unregister_adev, adev);
if (ret)
return ret;
return 0;
}
static void peci_cpu_add_adevices(struct peci_cpu *priv)
{
struct device *dev = &priv->device->dev;
int ret, i;
for (i = 0; i < ARRAY_SIZE(peci_adev_types); i++) {
ret = devm_adev_add(dev, i);
if (ret) {
dev_warn(dev, "Failed to register PECI auxiliary: %s, ret = %d\n",
peci_adev_types[i], ret);
continue;
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/module.h`, `linux/peci.h`, `linux/peci-cpu.h`, `linux/slab.h`, `internal.h`.
- Detected declarations: `struct peci_cpu`, `function peci_temp_read`, `function peci_pcs_read`, `function peci_pci_local_read`, `function peci_ep_pci_local_read`, `function peci_mmio_read`, `function adev_release`, `function unregister_adev`, `function devm_adev_add`, `function peci_cpu_add_adevices`.
- Atlas domain: Driver Families / drivers/peci.
- Implementation status: integration 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.