drivers/platform/arm64/lenovo-yoga-c630.c
Source file repositories/reference/linux-study-clean/drivers/platform/arm64/lenovo-yoga-c630.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/arm64/lenovo-yoga-c630.c- Extension
.c- Size
- 6054 bytes
- Lines
- 258
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cleanup.hlinux/device.hlinux/err.hlinux/i2c.hlinux/irqreturn.hlinux/lockdep.hlinux/module.hlinux/mutex.hlinux/notifier.hlinux/slab.hlinux/platform_data/lenovo-yoga-c630.h
Detected Declarations
struct yoga_c630_ecfunction yoga_c630_ec_requestfunction yoga_c630_ec_read8function yoga_c630_ec_read16function yoga_c630_ec_ucsi_get_versionfunction yoga_c630_ec_ucsi_writefunction yoga_c630_ec_ucsi_readfunction yoga_c630_ec_thread_intrfunction yoga_c630_ec_register_notifyfunction yoga_c630_ec_register_notifyfunction yoga_c630_aux_initfunction yoga_c630_ec_probeexport yoga_c630_ec_read8export yoga_c630_ec_read16export yoga_c630_ec_ucsi_get_versionexport yoga_c630_ec_ucsi_writeexport yoga_c630_ec_ucsi_readexport yoga_c630_ec_register_notifyexport yoga_c630_ec_unregister_notify
Annotated Snippet
struct yoga_c630_ec {
struct i2c_client *client;
struct mutex lock;
struct blocking_notifier_head notifier_list;
};
static int yoga_c630_ec_request(struct yoga_c630_ec *ec, u8 *req, size_t req_len,
u8 *resp, size_t resp_len)
{
int ret;
lockdep_assert_held(&ec->lock);
ret = i2c_smbus_write_i2c_block_data(ec->client, LENOVO_EC_REQUEST_REG,
req_len, req);
if (ret < 0)
return ret;
return i2c_smbus_read_i2c_block_data(ec->client, LENOVO_EC_RESPONSE_REG,
resp_len, resp);
}
int yoga_c630_ec_read8(struct yoga_c630_ec *ec, u8 addr)
{
u8 req[2] = { LENOVO_EC_READ_REG, };
int ret;
u8 val;
guard(mutex)(&ec->lock);
req[1] = addr;
ret = yoga_c630_ec_request(ec, req, sizeof(req), &val, 1);
if (ret < 0)
return ret;
return val;
}
EXPORT_SYMBOL_GPL(yoga_c630_ec_read8);
int yoga_c630_ec_read16(struct yoga_c630_ec *ec, u8 addr)
{
u8 req[2] = { LENOVO_EC_READ_REG, };
int ret;
u8 msb;
u8 lsb;
/* don't overflow the address */
if (addr == 0xff)
return -EINVAL;
guard(mutex)(&ec->lock);
req[1] = addr;
ret = yoga_c630_ec_request(ec, req, sizeof(req), &lsb, 1);
if (ret < 0)
return ret;
req[1] = addr + 1;
ret = yoga_c630_ec_request(ec, req, sizeof(req), &msb, 1);
if (ret < 0)
return ret;
return msb << 8 | lsb;
}
EXPORT_SYMBOL_GPL(yoga_c630_ec_read16);
u16 yoga_c630_ec_ucsi_get_version(struct yoga_c630_ec *ec)
{
u8 req[3] = { 0xb3, 0xf2, };
int ret;
u8 msb;
u8 lsb;
guard(mutex)(&ec->lock);
req[2] = LENOVO_EC_UCSI_VERSION;
ret = yoga_c630_ec_request(ec, req, sizeof(req), &lsb, 1);
if (ret < 0)
return ret;
req[2] = LENOVO_EC_UCSI_VERSION + 1;
ret = yoga_c630_ec_request(ec, req, sizeof(req), &msb, 1);
if (ret < 0)
return ret;
return msb << 8 | lsb;
}
EXPORT_SYMBOL_GPL(yoga_c630_ec_ucsi_get_version);
int yoga_c630_ec_ucsi_write(struct yoga_c630_ec *ec,
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/cleanup.h`, `linux/device.h`, `linux/err.h`, `linux/i2c.h`, `linux/irqreturn.h`, `linux/lockdep.h`, `linux/module.h`.
- Detected declarations: `struct yoga_c630_ec`, `function yoga_c630_ec_request`, `function yoga_c630_ec_read8`, `function yoga_c630_ec_read16`, `function yoga_c630_ec_ucsi_get_version`, `function yoga_c630_ec_ucsi_write`, `function yoga_c630_ec_ucsi_read`, `function yoga_c630_ec_thread_intr`, `function yoga_c630_ec_register_notify`, `function yoga_c630_ec_register_notify`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.