drivers/bus/mhi/ep/main.c
Source file repositories/reference/linux-study-clean/drivers/bus/mhi/ep/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bus/mhi/ep/main.c- Extension
.c- Size
- 48867 bytes
- Lines
- 1726
- Domain
- Driver Families
- Bucket
- drivers/bus
- 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.
- 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/bitfield.hlinux/delay.hlinux/dma-direction.hlinux/interrupt.hlinux/io.hlinux/irq.hlinux/mhi_ep.hlinux/mod_devicetable.hlinux/module.hinternal.h
Detected Declarations
function mhi_ep_send_eventfunction mhi_ep_send_completion_eventfunction mhi_ep_send_state_change_eventfunction mhi_ep_send_ee_eventfunction mhi_ep_send_cmd_comp_eventfunction mhi_ep_process_cmd_ringfunction mhi_ep_queue_is_emptyfunction mhi_ep_read_completionfunction IEOTfunction mhi_ep_read_channelfunction mhi_ep_process_ch_ringfunction mhi_ep_skb_completionfunction mhi_ep_queue_skbfunction mhi_ep_cache_host_cfgfunction mhi_ep_free_host_cfgfunction mhi_ep_enable_intfunction mhi_ep_enablefunction mhi_ep_cmd_ring_workerfunction mhi_ep_ch_ring_workerfunction mhi_ep_state_workerfunction list_for_each_entry_safefunction mhi_ep_queue_channel_dbfunction mhi_ep_check_channel_interruptfunction mhi_ep_process_ctrl_interruptfunction doorbellfunction mhi_ep_abort_transferfunction mhi_ep_reset_workerfunction mhi_ep_handle_syserrfunction mhi_ep_power_upfunction mhi_ep_power_downfunction mhi_ep_suspend_channelsfunction mhi_ep_resume_channelsfunction mhi_ep_release_devicefunction channelfunction mhi_ep_destroy_devicefunction mhi_ep_chan_initfunction mhi_ep_power_upfunction mhi_ep_unregister_controllerfunction mhi_ep_probefunction mhi_ep_removefunction __mhi_ep_driver_registerfunction mhi_ep_driver_unregisterfunction mhi_ep_ueventfunction mhi_ep_matchfunction mhi_ep_initfunction mhi_ep_exitexport mhi_ep_queue_is_emptyexport mhi_ep_queue_skb
Annotated Snippet
struct device_driver *driver = &mhi_drv->driver;
if (!mhi_drv->probe || !mhi_drv->remove)
return -EINVAL;
/* Client drivers should have callbacks defined for both channels */
if (!mhi_drv->ul_xfer_cb || !mhi_drv->dl_xfer_cb)
return -EINVAL;
driver->bus = &mhi_ep_bus_type;
driver->owner = owner;
return driver_register(driver);
}
EXPORT_SYMBOL_GPL(__mhi_ep_driver_register);
void mhi_ep_driver_unregister(struct mhi_ep_driver *mhi_drv)
{
driver_unregister(&mhi_drv->driver);
}
EXPORT_SYMBOL_GPL(mhi_ep_driver_unregister);
static int mhi_ep_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev);
return add_uevent_var(env, "MODALIAS=" MHI_EP_DEVICE_MODALIAS_FMT,
mhi_dev->name);
}
static int mhi_ep_match(struct device *dev, const struct device_driver *drv)
{
struct mhi_ep_device *mhi_dev = to_mhi_ep_device(dev);
const struct mhi_ep_driver *mhi_drv = to_mhi_ep_driver(drv);
const struct mhi_device_id *id;
/*
* If the device is a controller type then there is no client driver
* associated with it
*/
if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER)
return 0;
for (id = mhi_drv->id_table; id->chan[0]; id++)
if (!strcmp(mhi_dev->name, id->chan)) {
mhi_dev->id = id;
return 1;
}
return 0;
};
const struct bus_type mhi_ep_bus_type = {
.name = "mhi_ep",
.dev_name = "mhi_ep",
.match = mhi_ep_match,
.uevent = mhi_ep_uevent,
.probe = mhi_ep_probe,
.remove = mhi_ep_remove,
};
static int __init mhi_ep_init(void)
{
return bus_register(&mhi_ep_bus_type);
}
static void __exit mhi_ep_exit(void)
{
bus_unregister(&mhi_ep_bus_type);
}
postcore_initcall(mhi_ep_init);
module_exit(mhi_ep_exit);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("MHI Bus Endpoint stack");
MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>");
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/dma-direction.h`, `linux/interrupt.h`, `linux/io.h`, `linux/irq.h`, `linux/mhi_ep.h`, `linux/mod_devicetable.h`.
- Detected declarations: `function mhi_ep_send_event`, `function mhi_ep_send_completion_event`, `function mhi_ep_send_state_change_event`, `function mhi_ep_send_ee_event`, `function mhi_ep_send_cmd_comp_event`, `function mhi_ep_process_cmd_ring`, `function mhi_ep_queue_is_empty`, `function mhi_ep_read_completion`, `function IEOT`, `function mhi_ep_read_channel`.
- Atlas domain: Driver Families / drivers/bus.
- Implementation status: pattern 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.