drivers/acpi/proc.c
Source file repositories/reference/linux-study-clean/drivers/acpi/proc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/proc.c- Extension
.c- Size
- 3455 bytes
- Lines
- 144
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/proc_fs.hlinux/seq_file.hlinux/string_choices.hlinux/suspend.hlinux/bcd.hlinux/acpi.hlinux/uaccess.hsleep.hinternal.h
Detected Declarations
function acpi_system_wakeup_device_seq_showfunction list_for_each_entryfunction physical_device_enable_wakeupfunction list_for_each_entryfunction acpi_system_write_wakeup_devicefunction acpi_system_wakeup_device_open_fsfunction acpi_sleep_proc_init
Annotated Snippet
if (!dev->physical_node_count) {
seq_printf(seq, "%c%-8s\n",
dev->wakeup.flags.valid ? '*' : ' ',
str_enabled_disabled(device_may_wakeup(&dev->dev)));
} else {
struct device *ldev;
list_for_each_entry(entry, &dev->physical_node_list,
node) {
ldev = get_device(entry->dev);
if (!ldev)
continue;
if (&entry->node !=
dev->physical_node_list.next)
seq_printf(seq, "\t\t");
seq_printf(seq, "%c%-8s %s:%s\n",
dev->wakeup.flags.valid ? '*' : ' ',
str_enabled_disabled(device_may_wakeup(ldev) ||
device_may_wakeup(&dev->dev)),
ldev->bus ? ldev->bus->name :
"no-bus", dev_name(ldev));
put_device(ldev);
}
}
mutex_unlock(&dev->physical_node_lock);
}
mutex_unlock(&acpi_device_lock);
return 0;
}
static void physical_device_enable_wakeup(struct acpi_device *adev)
{
struct acpi_device_physical_node *entry;
mutex_lock(&adev->physical_node_lock);
list_for_each_entry(entry,
&adev->physical_node_list, node)
if (entry->dev && device_can_wakeup(entry->dev)) {
bool enable = !device_may_wakeup(entry->dev);
device_set_wakeup_enable(entry->dev, enable);
}
mutex_unlock(&adev->physical_node_lock);
}
static ssize_t
acpi_system_write_wakeup_device(struct file *file,
const char __user * buffer,
size_t count, loff_t * ppos)
{
struct acpi_device *dev, *tmp;
char strbuf[5];
char str[5] = "";
if (count > 4)
count = 4;
if (copy_from_user(strbuf, buffer, count))
return -EFAULT;
strbuf[count] = '\0';
sscanf(strbuf, "%s", str);
mutex_lock(&acpi_device_lock);
list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list,
wakeup_list) {
if (!dev->wakeup.flags.valid)
continue;
if (!strncmp(dev->pnp.bus_id, str, 4)) {
if (device_can_wakeup(&dev->dev)) {
bool enable = !device_may_wakeup(&dev->dev);
device_set_wakeup_enable(&dev->dev, enable);
} else {
physical_device_enable_wakeup(dev);
}
break;
}
}
mutex_unlock(&acpi_device_lock);
return count;
}
static int
acpi_system_wakeup_device_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, acpi_system_wakeup_device_seq_show,
pde_data(inode));
Annotation
- Immediate include surface: `linux/proc_fs.h`, `linux/seq_file.h`, `linux/string_choices.h`, `linux/suspend.h`, `linux/bcd.h`, `linux/acpi.h`, `linux/uaccess.h`, `sleep.h`.
- Detected declarations: `function acpi_system_wakeup_device_seq_show`, `function list_for_each_entry`, `function physical_device_enable_wakeup`, `function list_for_each_entry`, `function acpi_system_write_wakeup_device`, `function acpi_system_wakeup_device_open_fs`, `function acpi_sleep_proc_init`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.