drivers/pnp/pnpacpi/core.c
Source file repositories/reference/linux-study-clean/drivers/pnp/pnpacpi/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pnp/pnpacpi/core.c- Extension
.c- Size
- 7559 bytes
- Lines
- 326
- Domain
- Driver Families
- Bucket
- drivers/pnp
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/acpi.hlinux/pnp.hlinux/slab.hlinux/mod_devicetable.h../base.hpnpacpi.h
Detected Declarations
function ispnpidacpifunction pnpacpi_get_resourcesfunction pnpacpi_set_resourcesfunction pnpacpi_disable_resourcesfunction pnpacpi_can_wakeupfunction pnpacpi_suspendfunction pnpacpi_resumefunction pnpacpi_get_idfunction list_for_each_entryfunction pnpacpi_add_devicefunction list_for_each_entryfunction pnpacpi_add_device_handlerfunction pnpacpi_initfunction pnpacpi_setupmodule init pnpacpi_initexport pnpacpi_protocol
Annotated Snippet
if (!ret) {
acpi_status status;
status = acpi_set_current_resources(handle, &buffer);
if (ACPI_FAILURE(status))
ret = -EIO;
}
kfree(buffer.pointer);
}
if (!ret && acpi_device_power_manageable(acpi_dev))
ret = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
return ret;
}
static int pnpacpi_disable_resources(struct pnp_dev *dev)
{
struct acpi_device *acpi_dev;
acpi_status status;
dev_dbg(&dev->dev, "disable resources\n");
acpi_dev = ACPI_COMPANION(&dev->dev);
if (!acpi_dev) {
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
return 0;
}
/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
if (acpi_device_power_manageable(acpi_dev))
acpi_device_set_power(acpi_dev, ACPI_STATE_D3_COLD);
/* continue even if acpi_device_set_power() fails */
status = acpi_evaluate_object(acpi_dev->handle, "_DIS", NULL, NULL);
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
return -ENODEV;
return 0;
}
#ifdef CONFIG_ACPI_SLEEP
static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
{
struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
if (!acpi_dev) {
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
return false;
}
return acpi_bus_can_wakeup(acpi_dev->handle);
}
static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
{
struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
int error = 0;
if (!acpi_dev) {
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
return 0;
}
if (device_can_wakeup(&dev->dev)) {
error = acpi_pm_set_device_wakeup(&dev->dev,
device_may_wakeup(&dev->dev));
if (error)
return error;
}
if (acpi_device_power_manageable(acpi_dev)) {
int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL,
ACPI_STATE_D3_COLD);
if (power_state < 0)
power_state = (state.event == PM_EVENT_ON) ?
ACPI_STATE_D0 : ACPI_STATE_D3_COLD;
/*
* acpi_device_set_power() can fail (keyboard port can't be
* powered-down?), and in any case, our return value is ignored
* by pnp_bus_suspend(). Hence we don't revert the wakeup
* setting if the set_power fails.
*/
error = acpi_device_set_power(acpi_dev, power_state);
}
return error;
}
static int pnpacpi_resume(struct pnp_dev *dev)
Annotation
- Immediate include surface: `linux/export.h`, `linux/acpi.h`, `linux/pnp.h`, `linux/slab.h`, `linux/mod_devicetable.h`, `../base.h`, `pnpacpi.h`.
- Detected declarations: `function ispnpidacpi`, `function pnpacpi_get_resources`, `function pnpacpi_set_resources`, `function pnpacpi_disable_resources`, `function pnpacpi_can_wakeup`, `function pnpacpi_suspend`, `function pnpacpi_resume`, `function pnpacpi_get_id`, `function list_for_each_entry`, `function pnpacpi_add_device`.
- Atlas domain: Driver Families / drivers/pnp.
- 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.