drivers/mfd/mcp-core.c
Source file repositories/reference/linux-study-clean/drivers/mfd/mcp-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/mcp-core.c- Extension
.c- Size
- 5581 bytes
- Lines
- 236
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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/module.hlinux/init.hlinux/errno.hlinux/smp.hlinux/device.hlinux/slab.hlinux/string.hlinux/mfd/mcp.h
Detected Declarations
function Copyrightfunction mcp_bus_probefunction mcp_bus_removefunction mcp_set_telecom_divisorfunction mcp_set_audio_divisorfunction mcp_reg_writefunction mcp_reg_readfunction mcp_enablefunction mcp_disablefunction mcp_releasefunction mcp_host_addfunction mcp_host_delfunction mcp_host_freefunction mcp_driver_registerfunction mcp_driver_unregisterfunction mcp_initfunction mcp_exitmodule init mcp_initexport mcp_set_telecom_divisorexport mcp_set_audio_divisorexport mcp_reg_writeexport mcp_reg_readexport mcp_enableexport mcp_disableexport mcp_host_allocexport mcp_host_addexport mcp_host_delexport mcp_host_freeexport mcp_driver_registerexport mcp_driver_unregister
Annotated Snippet
static int mcp_bus_match(struct device *dev, const struct device_driver *drv)
{
return 1;
}
static int mcp_bus_probe(struct device *dev)
{
struct mcp *mcp = to_mcp(dev);
struct mcp_driver *drv = to_mcp_driver(dev->driver);
return drv->probe(mcp);
}
static void mcp_bus_remove(struct device *dev)
{
struct mcp *mcp = to_mcp(dev);
struct mcp_driver *drv = to_mcp_driver(dev->driver);
drv->remove(mcp);
}
static const struct bus_type mcp_bus_type = {
.name = "mcp",
.match = mcp_bus_match,
.probe = mcp_bus_probe,
.remove = mcp_bus_remove,
};
/**
* mcp_set_telecom_divisor - set the telecom divisor
* @mcp: MCP interface structure
* @div: SIB clock divisor
*
* Set the telecom divisor on the MCP interface. The resulting
* sample rate is SIBCLOCK/div.
*/
void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div)
{
unsigned long flags;
spin_lock_irqsave(&mcp->lock, flags);
mcp->ops->set_telecom_divisor(mcp, div);
spin_unlock_irqrestore(&mcp->lock, flags);
}
EXPORT_SYMBOL(mcp_set_telecom_divisor);
/**
* mcp_set_audio_divisor - set the audio divisor
* @mcp: MCP interface structure
* @div: SIB clock divisor
*
* Set the audio divisor on the MCP interface.
*/
void mcp_set_audio_divisor(struct mcp *mcp, unsigned int div)
{
unsigned long flags;
spin_lock_irqsave(&mcp->lock, flags);
mcp->ops->set_audio_divisor(mcp, div);
spin_unlock_irqrestore(&mcp->lock, flags);
}
EXPORT_SYMBOL(mcp_set_audio_divisor);
/**
* mcp_reg_write - write a device register
* @mcp: MCP interface structure
* @reg: 4-bit register index
* @val: 16-bit data value
*
* Write a device register. The MCP interface must be enabled
* to prevent this function hanging.
*/
void mcp_reg_write(struct mcp *mcp, unsigned int reg, unsigned int val)
{
unsigned long flags;
spin_lock_irqsave(&mcp->lock, flags);
mcp->ops->reg_write(mcp, reg, val);
spin_unlock_irqrestore(&mcp->lock, flags);
}
EXPORT_SYMBOL(mcp_reg_write);
/**
* mcp_reg_read - read a device register
* @mcp: MCP interface structure
* @reg: 4-bit register index
*
* Read a device register and return its value. The MCP interface
* must be enabled to prevent this function hanging.
*/
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/errno.h`, `linux/smp.h`, `linux/device.h`, `linux/slab.h`, `linux/string.h`, `linux/mfd/mcp.h`.
- Detected declarations: `function Copyright`, `function mcp_bus_probe`, `function mcp_bus_remove`, `function mcp_set_telecom_divisor`, `function mcp_set_audio_divisor`, `function mcp_reg_write`, `function mcp_reg_read`, `function mcp_enable`, `function mcp_disable`, `function mcp_release`.
- Atlas domain: Driver Families / drivers/mfd.
- 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.