drivers/dibs/dibs_main.c
Source file repositories/reference/linux-study-clean/drivers/dibs/dibs_main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dibs/dibs_main.c- Extension
.c- Size
- 6110 bytes
- Lines
- 277
- Domain
- Driver Families
- Bucket
- drivers/dibs
- 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/types.hlinux/slab.hlinux/err.hlinux/dibs.hdibs_loopback.h
Detected Declarations
struct dibs_dev_listfunction dibs_setup_forwardingfunction dibs_register_clientfunction dibs_unregister_clientfunction dibs_dev_releasefunction gid_showfunction fabric_id_showfunction dibs_dev_addfunction dibs_dev_delfunction dibs_initfunction dibs_exitmodule init dibs_initexport dibs_register_clientexport dibs_unregister_clientexport dibs_dev_allocexport dibs_dev_addexport dibs_dev_del
Annotated Snippet
ret = device_add(&dibs->dev);
if (ret)
goto free_client_arr;
ret = sysfs_create_group(&dibs->dev.kobj, &dibs_dev_attr_group);
if (ret) {
dev_err(&dibs->dev, "sysfs_create_group failed for dibs_dev\n");
goto err_device_del;
}
mutex_lock(&dibs_dev_list.mutex);
mutex_lock(&clients_lock);
for (i = 0; i < max_client; ++i) {
if (clients[i]) {
clients[i]->ops->add_dev(dibs);
dibs_setup_forwarding(clients[i], dibs);
}
}
mutex_unlock(&clients_lock);
list_add(&dibs->list, &dibs_dev_list.list);
mutex_unlock(&dibs_dev_list.mutex);
return 0;
err_device_del:
device_del(&dibs->dev);
free_client_arr:
kfree(dibs->dmb_clientid_arr);
return ret;
}
EXPORT_SYMBOL_GPL(dibs_dev_add);
void dibs_dev_del(struct dibs_dev *dibs)
{
unsigned long flags;
int i;
sysfs_remove_group(&dibs->dev.kobj, &dibs_dev_attr_group);
spin_lock_irqsave(&dibs->lock, flags);
for (i = 0; i < MAX_DIBS_CLIENTS; ++i)
dibs->subs[i] = NULL;
spin_unlock_irqrestore(&dibs->lock, flags);
mutex_lock(&dibs_dev_list.mutex);
mutex_lock(&clients_lock);
for (i = 0; i < max_client; ++i) {
if (clients[i])
clients[i]->ops->del_dev(dibs);
}
mutex_unlock(&clients_lock);
list_del_init(&dibs->list);
mutex_unlock(&dibs_dev_list.mutex);
device_del(&dibs->dev);
kfree(dibs->dmb_clientid_arr);
}
EXPORT_SYMBOL_GPL(dibs_dev_del);
static int __init dibs_init(void)
{
int rc;
rc = class_register(&dibs_class);
if (rc)
return rc;
rc = dibs_loopback_init();
if (rc)
pr_err("%s fails with %d\n", __func__, rc);
return rc;
}
static void __exit dibs_exit(void)
{
dibs_loopback_exit();
class_unregister(&dibs_class);
}
subsys_initcall(dibs_init);
module_exit(dibs_exit);
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/slab.h`, `linux/err.h`, `linux/dibs.h`, `dibs_loopback.h`.
- Detected declarations: `struct dibs_dev_list`, `function dibs_setup_forwarding`, `function dibs_register_client`, `function dibs_unregister_client`, `function dibs_dev_release`, `function gid_show`, `function fabric_id_show`, `function dibs_dev_add`, `function dibs_dev_del`, `function dibs_init`.
- Atlas domain: Driver Families / drivers/dibs.
- 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.