drivers/mfd/ucb1x00-core.c
Source file repositories/reference/linux-study-clean/drivers/mfd/ucb1x00-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mfd/ucb1x00-core.c- Extension
.c- Size
- 19889 bytes
- Lines
- 782
- Domain
- Driver Families
- Bucket
- drivers/mfd
- 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.
- 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/kernel.hlinux/sched.hlinux/slab.hlinux/init.hlinux/errno.hlinux/interrupt.hlinux/irq.hlinux/device.hlinux/mutex.hlinux/mfd/ucb1x00.hlinux/pm.hlinux/gpio/driver.h
Detected Declarations
function ucb1x00_io_set_dirfunction ucb1x00_io_writefunction ucb1x00_io_readfunction ucb1x00_gpio_setfunction ucb1x00_gpio_getfunction ucb1x00_gpio_direction_inputfunction ucb1x00_gpio_direction_outputfunction ucb1x00_to_irqfunction ucb1x00_adc_enablefunction conversionsfunction ucb1x00_adc_disablefunction ucb1x00_irqfunction ucb1x00_irq_updatefunction ucb1x00_irq_noopfunction ucb1x00_irq_unmaskfunction ucb1x00_irq_set_typefunction ucb1x00_irq_set_wakefunction ucb1x00_add_devfunction ucb1x00_remove_devfunction ADS_EXT_IRQfunction ucb1x00_releasefunction ucb1x00_probefunction ucb1x00_removefunction ucb1x00_register_driverfunction ucb1x00_unregister_driverfunction ucb1x00_suspendfunction ucb1x00_resumefunction ucb1x00_initfunction ucb1x00_exitmodule init ucb1x00_initexport ucb1x00_io_set_direxport ucb1x00_io_writeexport ucb1x00_io_readexport ucb1x00_adc_enableexport ucb1x00_adc_readexport ucb1x00_adc_disableexport ucb1x00_register_driverexport ucb1x00_unregister_driver
Annotated Snippet
ret = device_add(&ucb->dev);
if (ret)
goto err_dev_add;
ucb1x00_enable(ucb);
ucb->irq = ucb1x00_detect_irq(ucb);
ucb1x00_disable(ucb);
if (!ucb->irq) {
dev_err(&ucb->dev, "IRQ probe failed\n");
ret = -ENODEV;
goto err_no_irq;
}
ucb->gpio.base = -1;
irq_base = pdata ? pdata->irq_base : 0;
ucb->irq_base = irq_alloc_descs(-1, irq_base, 16, -1);
if (ucb->irq_base < 0) {
dev_err(&ucb->dev, "unable to allocate 16 irqs: %d\n",
ucb->irq_base);
ret = ucb->irq_base;
goto err_irq_alloc;
}
for (i = 0; i < 16; i++) {
unsigned irq = ucb->irq_base + i;
irq_set_chip_and_handler(irq, &ucb1x00_irqchip, handle_edge_irq);
irq_set_chip_data(irq, ucb);
irq_clear_status_flags(irq, IRQ_NOREQUEST);
}
irq_set_irq_type(ucb->irq, IRQ_TYPE_EDGE_RISING);
irq_set_chained_handler_and_data(ucb->irq, ucb1x00_irq, ucb);
if (pdata && pdata->gpio_base) {
ucb->gpio.label = dev_name(&ucb->dev);
ucb->gpio.parent = &ucb->dev;
ucb->gpio.owner = THIS_MODULE;
ucb->gpio.base = pdata->gpio_base;
ucb->gpio.ngpio = 10;
ucb->gpio.set = ucb1x00_gpio_set;
ucb->gpio.get = ucb1x00_gpio_get;
ucb->gpio.direction_input = ucb1x00_gpio_direction_input;
ucb->gpio.direction_output = ucb1x00_gpio_direction_output;
ucb->gpio.to_irq = ucb1x00_to_irq;
ret = gpiochip_add_data(&ucb->gpio, ucb);
if (ret)
goto err_gpio_add;
} else
dev_info(&ucb->dev, "gpio_base not set so no gpiolib support");
mcp_set_drvdata(mcp, ucb);
if (pdata)
device_set_wakeup_capable(&ucb->dev, pdata->can_wakeup);
INIT_LIST_HEAD(&ucb->devs);
mutex_lock(&ucb1x00_mutex);
list_add_tail(&ucb->node, &ucb1x00_devices);
list_for_each_entry(drv, &ucb1x00_drivers, node) {
ucb1x00_add_dev(ucb, drv);
}
mutex_unlock(&ucb1x00_mutex);
return ret;
err_gpio_add:
irq_set_chained_handler(ucb->irq, NULL);
err_irq_alloc:
if (ucb->irq_base > 0)
irq_free_descs(ucb->irq_base, 16);
err_no_irq:
device_del(&ucb->dev);
err_dev_add:
put_device(&ucb->dev);
out:
if (pdata && pdata->reset)
pdata->reset(UCB_RST_PROBE_FAIL);
return ret;
}
static void ucb1x00_remove(struct mcp *mcp)
{
struct ucb1x00_plat_data *pdata = mcp->attached_device.platform_data;
struct ucb1x00 *ucb = mcp_get_drvdata(mcp);
struct list_head *l, *n;
mutex_lock(&ucb1x00_mutex);
list_del(&ucb->node);
list_for_each_safe(l, n, &ucb->devs) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/slab.h`, `linux/init.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/irq.h`.
- Detected declarations: `function ucb1x00_io_set_dir`, `function ucb1x00_io_write`, `function ucb1x00_io_read`, `function ucb1x00_gpio_set`, `function ucb1x00_gpio_get`, `function ucb1x00_gpio_direction_input`, `function ucb1x00_gpio_direction_output`, `function ucb1x00_to_irq`, `function ucb1x00_adc_enable`, `function conversions`.
- Atlas domain: Driver Families / drivers/mfd.
- Implementation status: integration 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.