drivers/platform/olpc/olpc-ec.c
Source file repositories/reference/linux-study-clean/drivers/platform/olpc/olpc-ec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/olpc/olpc-ec.c- Extension
.c- Size
- 11264 bytes
- Lines
- 493
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/completion.hlinux/debugfs.hlinux/spinlock.hlinux/mutex.hlinux/platform_device.hlinux/slab.hlinux/workqueue.hlinux/init.hlinux/list.hlinux/regulator/driver.hlinux/olpc-ec.h
Detected Declarations
struct ec_cmd_descstruct olpc_ec_privfunction olpc_ec_driver_registerfunction olpc_ec_workerfunction queue_ec_descriptorfunction olpc_ec_cmdfunction olpc_ec_wakeup_setfunction olpc_ec_wakeup_clearfunction olpc_ec_mask_writefunction olpc_ec_wakeup_availablefunction olpc_ec_sci_queryfunction ec_dbgfs_cmd_writefunction ec_dbgfs_cmd_readfunction olpc_ec_set_dcon_powerfunction dcon_regulator_enablefunction dcon_regulator_disablefunction dcon_regulator_is_enabledfunction olpc_ec_probefunction olpc_ec_suspendfunction olpc_ec_resumefunction olpc_ec_init_moduleexport olpc_ec_driver_registerexport olpc_ec_cmdexport olpc_ec_wakeup_setexport olpc_ec_wakeup_clearexport olpc_ec_mask_writeexport olpc_ec_wakeup_availableexport olpc_ec_sci_query
Annotated Snippet
static const struct file_operations ec_dbgfs_ops = {
.write = ec_dbgfs_cmd_write,
.read = ec_dbgfs_cmd_read,
};
static struct dentry *olpc_ec_setup_debugfs(void)
{
struct dentry *dbgfs_dir;
dbgfs_dir = debugfs_create_dir("olpc-ec", NULL);
debugfs_create_file("cmd", 0600, dbgfs_dir, NULL, &ec_dbgfs_ops);
return dbgfs_dir;
}
#else
static struct dentry *olpc_ec_setup_debugfs(void)
{
return NULL;
}
#endif /* CONFIG_DEBUG_FS */
static int olpc_ec_set_dcon_power(struct olpc_ec_priv *ec, bool state)
{
unsigned char ec_byte = state;
int ret;
if (ec->dcon_enabled == state)
return 0;
ret = olpc_ec_cmd(EC_DCON_POWER_MODE, &ec_byte, 1, NULL, 0);
if (ret)
return ret;
ec->dcon_enabled = state;
return 0;
}
static int dcon_regulator_enable(struct regulator_dev *rdev)
{
struct olpc_ec_priv *ec = rdev_get_drvdata(rdev);
return olpc_ec_set_dcon_power(ec, true);
}
static int dcon_regulator_disable(struct regulator_dev *rdev)
{
struct olpc_ec_priv *ec = rdev_get_drvdata(rdev);
return olpc_ec_set_dcon_power(ec, false);
}
static int dcon_regulator_is_enabled(struct regulator_dev *rdev)
{
struct olpc_ec_priv *ec = rdev_get_drvdata(rdev);
return ec->dcon_enabled ? 1 : 0;
}
static const struct regulator_ops dcon_regulator_ops = {
.enable = dcon_regulator_enable,
.disable = dcon_regulator_disable,
.is_enabled = dcon_regulator_is_enabled,
};
static const struct regulator_desc dcon_desc = {
.name = "dcon",
.id = 0,
.ops = &dcon_regulator_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.enable_time = 25000,
};
static int olpc_ec_probe(struct platform_device *pdev)
{
struct olpc_ec_priv *ec;
struct regulator_config config = { };
struct regulator_dev *regulator;
int err;
if (!ec_driver)
return -ENODEV;
ec = kzalloc_obj(*ec);
if (!ec)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/completion.h`, `linux/debugfs.h`, `linux/spinlock.h`, `linux/mutex.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/workqueue.h`, `linux/init.h`.
- Detected declarations: `struct ec_cmd_desc`, `struct olpc_ec_priv`, `function olpc_ec_driver_register`, `function olpc_ec_worker`, `function queue_ec_descriptor`, `function olpc_ec_cmd`, `function olpc_ec_wakeup_set`, `function olpc_ec_wakeup_clear`, `function olpc_ec_mask_write`, `function olpc_ec_wakeup_available`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: pattern 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.