drivers/mux/core.c
Source file repositories/reference/linux-study-clean/drivers/mux/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mux/core.c- Extension
.c- Size
- 25895 bytes
- Lines
- 911
- Domain
- Driver Families
- Bucket
- drivers/mux
- 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.
- 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/delay.hlinux/device.hlinux/err.hlinux/export.hlinux/idr.hlinux/init.hlinux/module.hlinux/mux/consumer.hlinux/mux/driver.hlinux/of.hlinux/slab.h
Detected Declarations
struct mux_statestruct devm_mux_state_statefunction mux_initfunction mux_exitfunction mux_chip_releasefunction mux_chip_allocfunction mux_control_setfunction mux_chip_registerfunction mux_chip_unregisterfunction mux_chip_freefunction devm_mux_chip_releasefunction devm_mux_chip_allocfunction devm_mux_chip_reg_releasefunction devm_mux_chip_registerfunction mux_control_statesfunction __mux_control_selectfunction mux_control_delayfunction mux_control_select_delayfunction mux_state_select_delayfunction mux_control_try_select_delayfunction mux_state_try_select_delayfunction mux_control_deselectfunction mux_state_deselectfunction mux_getfunction mux_control_getfunction mux_control_get_optionalfunction mux_control_putfunction devm_mux_control_releasefunction devm_mux_control_getfunction mux_state_getfunction mux_state_putfunction devm_mux_state_releasefunction __devm_mux_state_getfunction devm_mux_state_get_from_npfunction devm_mux_state_get_optionalfunction devm_mux_state_get_selectedfunction devm_mux_state_get_optional_selectedmodule init mux_initexport mux_chip_allocexport mux_chip_registerexport mux_chip_unregisterexport mux_chip_freeexport devm_mux_chip_allocexport devm_mux_chip_registerexport mux_control_statesexport mux_control_select_delayexport mux_state_select_delayexport mux_control_try_select_delay
Annotated Snippet
ret = device_add(&mux_chip->dev);
if (ret < 0)
dev_err(&mux_chip->dev,
"device_add failed in %s: %d\n", __func__, ret);
return ret;
}
EXPORT_SYMBOL_GPL(mux_chip_register);
/**
* mux_chip_unregister() - Take the mux-chip off-line.
* @mux_chip: The mux-chip to unregister.
*
* mux_chip_unregister() reverses the effects of mux_chip_register().
* But not completely, you should not try to call mux_chip_register()
* on a mux-chip that has been registered before.
*/
void mux_chip_unregister(struct mux_chip *mux_chip)
{
device_del(&mux_chip->dev);
}
EXPORT_SYMBOL_GPL(mux_chip_unregister);
/**
* mux_chip_free() - Free the mux-chip for good.
* @mux_chip: The mux-chip to free.
*
* mux_chip_free() reverses the effects of mux_chip_alloc().
*/
void mux_chip_free(struct mux_chip *mux_chip)
{
if (!mux_chip)
return;
put_device(&mux_chip->dev);
}
EXPORT_SYMBOL_GPL(mux_chip_free);
static void devm_mux_chip_release(struct device *dev, void *res)
{
struct mux_chip *mux_chip = *(struct mux_chip **)res;
mux_chip_free(mux_chip);
}
/**
* devm_mux_chip_alloc() - Resource-managed version of mux_chip_alloc().
* @dev: The parent device implementing the mux interface.
* @controllers: The number of mux controllers to allocate for this chip.
* @sizeof_priv: Size of extra memory area for private use by the caller.
*
* See mux_chip_alloc() for more details.
*
* Return: A pointer to the new mux-chip, or an ERR_PTR with a negative errno.
*/
struct mux_chip *devm_mux_chip_alloc(struct device *dev,
unsigned int controllers,
size_t sizeof_priv)
{
struct mux_chip **ptr, *mux_chip;
ptr = devres_alloc(devm_mux_chip_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv);
if (IS_ERR(mux_chip)) {
devres_free(ptr);
return mux_chip;
}
*ptr = mux_chip;
devres_add(dev, ptr);
return mux_chip;
}
EXPORT_SYMBOL_GPL(devm_mux_chip_alloc);
static void devm_mux_chip_reg_release(struct device *dev, void *res)
{
struct mux_chip *mux_chip = *(struct mux_chip **)res;
mux_chip_unregister(mux_chip);
}
/**
* devm_mux_chip_register() - Resource-managed version mux_chip_register().
* @dev: The parent device implementing the mux interface.
* @mux_chip: The mux-chip to register.
*
* See mux_chip_register() for more details.
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/export.h`, `linux/idr.h`, `linux/init.h`, `linux/module.h`, `linux/mux/consumer.h`.
- Detected declarations: `struct mux_state`, `struct devm_mux_state_state`, `function mux_init`, `function mux_exit`, `function mux_chip_release`, `function mux_chip_alloc`, `function mux_control_set`, `function mux_chip_register`, `function mux_chip_unregister`, `function mux_chip_free`.
- Atlas domain: Driver Families / drivers/mux.
- Implementation status: integration implementation candidate.
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.