drivers/fsi/fsi-sbefifo.c
Source file repositories/reference/linux-study-clean/drivers/fsi/fsi-sbefifo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fsi/fsi-sbefifo.c- Extension
.c- Size
- 29639 bytes
- Lines
- 1147
- Domain
- Driver Families
- Bucket
- drivers/fsi
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/device.hlinux/errno.hlinux/fs.hlinux/fsi.hlinux/fsi-sbefifo.hlinux/kernel.hlinux/cdev.hlinux/module.hlinux/mutex.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/sched.hlinux/slab.hlinux/uaccess.hlinux/delay.hlinux/uio.hlinux/vmalloc.hlinux/mm.huapi/linux/fsi.h
Detected Declarations
struct sbefifostruct sbefifo_userenum sbe_statefunction timeout_showfunction __sbefifo_dump_ffdcfunction sbefifo_dump_ffdcfunction sbefifo_parse_statusfunction sbefifo_regrfunction sbefifo_regwfunction sbefifo_check_sbe_statefunction sbefifo_down_readfunction sbefifo_up_writefunction sbefifo_request_resetfunction sbefifo_cleanup_hwfunction sbefifo_waitfunction sbefifo_send_commandfunction sbefifo_read_responsefunction resetfunction sbefifo_do_commandfunction sbefifo_collect_async_ffdcfunction __sbefifo_submitfunction sbefifo_submitfunction sbefifo_release_commandfunction sbefifo_user_openfunction sbefifo_user_readfunction sbefifo_user_writefunction sbefifo_user_releasefunction sbefifo_cmd_timeoutfunction sbefifo_read_timeoutfunction sbefifo_user_ioctlfunction sbefifo_freefunction sbefifo_probefunction sbefifo_unregister_childfunction sbefifo_removeexport sbefifo_parse_statusexport sbefifo_submit
Annotated Snippet
static const struct file_operations sbefifo_fops = {
.owner = THIS_MODULE,
.open = sbefifo_user_open,
.read = sbefifo_user_read,
.write = sbefifo_user_write,
.release = sbefifo_user_release,
.unlocked_ioctl = sbefifo_user_ioctl,
};
static void sbefifo_free(struct device *dev)
{
struct sbefifo *sbefifo = container_of(dev, struct sbefifo, dev);
put_device(&sbefifo->fsi_dev->dev);
kfree(sbefifo);
}
/*
* Probe/remove
*/
static int sbefifo_probe(struct fsi_device *fsi_dev)
{
struct device *dev = &fsi_dev->dev;
struct sbefifo *sbefifo;
struct device_node *np;
struct platform_device *child;
char child_name[32];
int rc, didx, child_idx = 0;
dev_dbg(dev, "Found sbefifo device\n");
sbefifo = kzalloc_obj(*sbefifo);
if (!sbefifo)
return -ENOMEM;
/* Grab a reference to the device (parent of our cdev), we'll drop it later */
if (!get_device(dev)) {
kfree(sbefifo);
return -ENODEV;
}
sbefifo->magic = SBEFIFO_MAGIC;
sbefifo->fsi_dev = fsi_dev;
fsi_set_drvdata(fsi_dev, sbefifo);
mutex_init(&sbefifo->lock);
sbefifo->timeout_in_cmd_ms = SBEFIFO_TIMEOUT_IN_CMD;
sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP;
/* Create chardev for userspace access */
sbefifo->dev.type = &fsi_cdev_type;
sbefifo->dev.parent = dev;
sbefifo->dev.release = sbefifo_free;
device_initialize(&sbefifo->dev);
/* Allocate a minor in the FSI space */
rc = fsi_get_new_minor(fsi_dev, fsi_dev_sbefifo, &sbefifo->dev.devt, &didx);
if (rc)
goto err;
dev_set_name(&sbefifo->dev, "sbefifo%d", didx);
cdev_init(&sbefifo->cdev, &sbefifo_fops);
rc = cdev_device_add(&sbefifo->cdev, &sbefifo->dev);
if (rc) {
dev_err(dev, "Error %d creating char device %s\n",
rc, dev_name(&sbefifo->dev));
goto err_free_minor;
}
/* Create platform devs for dts child nodes (occ, etc) */
for_each_available_child_of_node(dev->of_node, np) {
snprintf(child_name, sizeof(child_name), "%s-dev%d",
dev_name(&sbefifo->dev), child_idx++);
child = of_platform_device_create(np, child_name, dev);
if (!child)
dev_warn(dev, "failed to create child %s dev\n",
child_name);
}
device_create_file(&sbefifo->dev, &dev_attr_timeout);
return 0;
err_free_minor:
fsi_free_minor(sbefifo->dev.devt);
err:
put_device(&sbefifo->dev);
return rc;
}
static int sbefifo_unregister_child(struct device *dev, void *data)
Annotation
- Immediate include surface: `linux/device.h`, `linux/errno.h`, `linux/fs.h`, `linux/fsi.h`, `linux/fsi-sbefifo.h`, `linux/kernel.h`, `linux/cdev.h`, `linux/module.h`.
- Detected declarations: `struct sbefifo`, `struct sbefifo_user`, `enum sbe_state`, `function timeout_show`, `function __sbefifo_dump_ffdc`, `function sbefifo_dump_ffdc`, `function sbefifo_parse_status`, `function sbefifo_regr`, `function sbefifo_regw`, `function sbefifo_check_sbe_state`.
- Atlas domain: Driver Families / drivers/fsi.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.