drivers/fsi/fsi-core.c
Source file repositories/reference/linux-study-clean/drivers/fsi/fsi-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/fsi/fsi-core.c- Extension
.c- Size
- 34963 bytes
- Lines
- 1501
- 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/crc4.hlinux/device.hlinux/fsi.hlinux/idr.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_device.hlinux/slab.hlinux/bitops.hlinux/cdev.hlinux/fs.hlinux/uaccess.hfsi-master.hfsi-slave.htrace/events/fsi.h
Detected Declarations
function fsi_bus_matchfunction fsi_probefunction fsi_removefunction fsi_device_readfunction fsi_device_writefunction fsi_device_peekfunction fsi_device_releasefunction fsi_slave_calc_addrfunction idfunction fsi_slave_report_and_clear_errorsfunction fsi_smode_echodlyfunction fsi_smode_senddlyfunction fsi_smode_lbcrrfunction fsi_smode_sidfunction fsi_slave_smodefunction fsi_slave_set_smodefunction fsi_slave_handle_errorfunction fsi_slave_readfunction fsi_slave_writefunction fsi_slave_claim_rangefunction fsi_slave_release_rangefunction fsi_device_node_matchesfunction for_each_child_of_nodefunction fsi_slave_scanfunction aligned_access_sizefunction fsi_slave_sysfs_raw_readfunction fsi_slave_sysfs_raw_writefunction fsi_slave_releasefunction fsi_slave_node_matchesfunction for_each_child_of_nodefunction cfam_readfunction cfam_writefunction cfam_llseekfunction cfam_openfunction send_term_storefunction slave_send_echo_showfunction slave_send_echo_storefunction chip_id_showfunction cfam_id_showfunction fsi_adjust_indexfunction __fsi_get_new_minorfunction fsi_get_new_minorfunction fsi_free_minorfunction fsi_slave_initfunction fsi_check_accessfunction fsi_master_readfunction fsi_master_writefunction fsi_master_link_disable
Annotated Snippet
static int fsi_bus_match(struct device *dev, const struct device_driver *drv)
{
struct fsi_device *fsi_dev = to_fsi_dev(dev);
const struct fsi_driver *fsi_drv = to_fsi_drv(drv);
const struct fsi_device_id *id;
if (!fsi_drv->id_table)
return 0;
for (id = fsi_drv->id_table; id->engine_type; id++) {
if (id->engine_type != fsi_dev->engine_type)
continue;
if (id->version == FSI_VERSION_ANY ||
id->version == fsi_dev->version) {
if (drv->of_match_table) {
if (of_driver_match_device(dev, drv))
return 1;
} else {
return 1;
}
}
}
return 0;
}
static int fsi_probe(struct device *dev)
{
struct fsi_device *fsidev = to_fsi_dev(dev);
struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
if (fsidrv->probe)
return fsidrv->probe(fsidev);
else
return 0;
}
static void fsi_remove(struct device *dev)
{
struct fsi_device *fsidev = to_fsi_dev(dev);
struct fsi_driver *fsidrv = to_fsi_drv(dev->driver);
if (fsidrv->remove)
fsidrv->remove(fsidev);
}
static const struct bus_type fsi_bus_type = {
.name = "fsi",
.match = fsi_bus_match,
.probe = fsi_probe,
.remove = fsi_remove,
};
/*
* fsi_device_read() / fsi_device_write() / fsi_device_peek()
*
* FSI endpoint-device support
*
* Read / write / peek accessors for a client
*
* Parameters:
* dev: Structure passed to FSI client device drivers on probe().
* addr: FSI address of given device. Client should pass in its base address
* plus desired offset to access its register space.
* val: For read/peek this is the value read at the specified address. For
* write this is value to write to the specified address.
* The data in val must be FSI bus endian (big endian).
* size: Size in bytes of the operation. Sizes supported are 1, 2 and 4 bytes.
* Addresses must be aligned on size boundaries or an error will result.
*/
int fsi_device_read(struct fsi_device *dev, uint32_t addr, void *val,
size_t size)
{
if (addr > dev->size || size > dev->size || addr > dev->size - size)
return -EINVAL;
return fsi_slave_read(dev->slave, dev->addr + addr, val, size);
}
EXPORT_SYMBOL_GPL(fsi_device_read);
int fsi_device_write(struct fsi_device *dev, uint32_t addr, const void *val,
size_t size)
{
if (addr > dev->size || size > dev->size || addr > dev->size - size)
return -EINVAL;
return fsi_slave_write(dev->slave, dev->addr + addr, val, size);
}
EXPORT_SYMBOL_GPL(fsi_device_write);
Annotation
- Immediate include surface: `linux/crc4.h`, `linux/device.h`, `linux/fsi.h`, `linux/idr.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_device.h`.
- Detected declarations: `function fsi_bus_match`, `function fsi_probe`, `function fsi_remove`, `function fsi_device_read`, `function fsi_device_write`, `function fsi_device_peek`, `function fsi_device_release`, `function fsi_slave_calc_addr`, `function id`, `function fsi_slave_report_and_clear_errors`.
- 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.