drivers/bus/mhi/host/init.c
Source file repositories/reference/linux-study-clean/drivers/bus/mhi/host/init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bus/mhi/host/init.c- Extension
.c- Size
- 37939 bytes
- Lines
- 1477
- 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/debugfs.hlinux/device.hlinux/dma-direction.hlinux/dma-mapping.hlinux/idr.hlinux/interrupt.hlinux/list.hlinux/mhi.hlinux/mod_devicetable.hlinux/module.hlinux/slab.hlinux/vmalloc.hlinux/wait.hinternal.htrace.h
Detected Declarations
function serial_number_showfunction oem_pk_hash_showfunction soc_reset_storefunction trigger_edl_storefunction mhi_alloc_aligned_ringfunction mhi_deinit_free_irqfunction mhi_init_irq_setupfunction mhi_deinit_dev_ctxtfunction mhi_init_dev_ctxtfunction mhi_init_mmiofunction mhi_deinit_chan_ctxtfunction mhi_init_chan_ctxtfunction parse_ev_cfgfunction parse_ch_cfgfunction parse_configfunction mhi_register_controllerfunction mhi_unregister_controllerfunction mhi_free_controllerfunction mhi_prepare_for_power_upfunction mhi_unprepare_after_power_downfunction mhi_release_devicefunction mhi_probefunction mhi_removefunction __mhi_driver_registerfunction mhi_driver_unregisterfunction mhi_ueventfunction mhi_matchfunction mhi_initfunction mhi_exitexport mhi_register_controllerexport mhi_unregister_controllerexport mhi_alloc_controllerexport mhi_free_controllerexport mhi_prepare_for_power_upexport mhi_unprepare_after_power_downexport __mhi_driver_registerexport mhi_driver_unregister
Annotated Snippet
struct device_driver *drv = dev->driver;
struct mhi_driver *mhi_drv = to_mhi_driver(drv);
struct mhi_event *mhi_event;
struct mhi_chan *ul_chan = mhi_dev->ul_chan;
struct mhi_chan *dl_chan = mhi_dev->dl_chan;
int ret;
/* Bring device out of LPM */
ret = mhi_device_get_sync(mhi_dev);
if (ret)
return ret;
ret = -EINVAL;
if (ul_chan) {
/*
* If channel supports LPM notifications then status_cb should
* be provided
*/
if (ul_chan->lpm_notify && !mhi_drv->status_cb)
goto exit_probe;
/* For non-offload channels then xfer_cb should be provided */
if (!ul_chan->offload_ch && !mhi_drv->ul_xfer_cb)
goto exit_probe;
ul_chan->xfer_cb = mhi_drv->ul_xfer_cb;
}
ret = -EINVAL;
if (dl_chan) {
/*
* If channel supports LPM notifications then status_cb should
* be provided
*/
if (dl_chan->lpm_notify && !mhi_drv->status_cb)
goto exit_probe;
/* For non-offload channels then xfer_cb should be provided */
if (!dl_chan->offload_ch && !mhi_drv->dl_xfer_cb)
goto exit_probe;
mhi_event = &mhi_cntrl->mhi_event[dl_chan->er_index];
/*
* If the channel event ring is managed by client, then
* status_cb must be provided so that the framework can
* notify pending data
*/
if (mhi_event->cl_manage && !mhi_drv->status_cb)
goto exit_probe;
dl_chan->xfer_cb = mhi_drv->dl_xfer_cb;
}
/* Call the user provided probe function */
ret = mhi_drv->probe(mhi_dev, mhi_dev->id);
if (ret)
goto exit_probe;
mhi_device_put(mhi_dev);
return ret;
exit_probe:
mhi_unprepare_from_transfer(mhi_dev);
mhi_device_put(mhi_dev);
return ret;
}
static void mhi_remove(struct device *dev)
{
struct mhi_device *mhi_dev = to_mhi_device(dev);
struct mhi_driver *mhi_drv = to_mhi_driver(dev->driver);
struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
struct mhi_chan *mhi_chan;
enum mhi_ch_state ch_state[] = {
MHI_CH_STATE_DISABLED,
MHI_CH_STATE_DISABLED
};
int dir;
/* Skip if it is a controller device */
if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER)
return;
/* Reset both channels */
for (dir = 0; dir < 2; dir++) {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/debugfs.h`, `linux/device.h`, `linux/dma-direction.h`, `linux/dma-mapping.h`, `linux/idr.h`, `linux/interrupt.h`, `linux/list.h`.
- Detected declarations: `function serial_number_show`, `function oem_pk_hash_show`, `function soc_reset_store`, `function trigger_edl_store`, `function mhi_alloc_aligned_ring`, `function mhi_deinit_free_irq`, `function mhi_init_irq_setup`, `function mhi_deinit_dev_ctxt`, `function mhi_init_dev_ctxt`, `function mhi_init_mmio`.
- 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.