drivers/hsi/clients/cmt_speech.c
Source file repositories/reference/linux-study-clean/drivers/hsi/clients/cmt_speech.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hsi/clients/cmt_speech.c- Extension
.c- Size
- 34187 bytes
- Lines
- 1449
- Domain
- Driver Families
- Bucket
- drivers/hsi
- 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/errno.hlinux/module.hlinux/types.hlinux/init.hlinux/device.hlinux/miscdevice.hlinux/mm.hlinux/slab.hlinux/fs.hlinux/poll.hlinux/sched/signal.hlinux/ioctl.hlinux/uaccess.hlinux/pm_qos.hlinux/hsi/hsi.hlinux/hsi/ssi_protocol.hlinux/hsi/cs-protocol.h
Detected Declarations
struct char_queuestruct cs_charstruct cs_hsi_ifacefunction rx_ptr_shift_too_bigfunction cs_notifyfunction cs_pop_entryfunction cs_notify_controlfunction cs_notify_datafunction cs_set_cmdfunction cs_get_cmdfunction cs_release_cmdfunction cs_cmd_destructorfunction cs_free_cmdsfunction list_for_each_entry_safefunction cs_alloc_cmdsfunction cs_hsi_data_destructorfunction cs_hsi_alloc_datafunction cs_hsi_free_data_msgfunction cs_hsi_free_datafunction __cs_hsi_error_prefunction __cs_hsi_error_postfunction __cs_hsi_error_read_bitsfunction __cs_hsi_error_write_bitsfunction cs_hsi_control_read_errorfunction cs_hsi_control_write_errorfunction cs_hsi_data_read_errorfunction cs_hsi_data_write_errorfunction cs_hsi_read_on_control_completefunction cs_hsi_peek_on_control_completefunction cs_hsi_read_on_controlfunction cs_hsi_write_on_control_completefunction cs_hsi_write_on_controlfunction cs_hsi_read_on_data_completefunction cs_hsi_peek_on_data_completefunction cs_state_xfer_activefunction cs_state_idlefunction cs_hsi_read_on_datafunction cs_hsi_write_on_data_completefunction cs_hsi_write_on_datafunction cs_hsi_get_statefunction cs_hsi_commandfunction cs_hsi_set_wakelinefunction set_buffer_sizesfunction check_buf_paramsfunction cs_hsi_data_syncfunction cs_hsi_data_enablefunction cs_hsi_data_disablefunction cs_hsi_buf_config
Annotated Snippet
static const struct file_operations cs_char_fops = {
.owner = THIS_MODULE,
.read = cs_char_read,
.write = cs_char_write,
.poll = cs_char_poll,
.unlocked_ioctl = cs_char_ioctl,
.mmap = cs_char_mmap,
.open = cs_char_open,
.release = cs_char_release,
.fasync = cs_char_fasync,
};
static struct miscdevice cs_char_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "cmt_speech",
.fops = &cs_char_fops
};
static int cs_hsi_client_probe(struct device *dev)
{
int err = 0;
struct hsi_client *cl = to_hsi_client(dev);
dev_dbg(dev, "hsi_client_probe\n");
init_waitqueue_head(&cs_char_data.wait);
spin_lock_init(&cs_char_data.lock);
cs_char_data.opened = 0;
cs_char_data.cl = cl;
cs_char_data.hi = NULL;
INIT_LIST_HEAD(&cs_char_data.chardev_queue);
INIT_LIST_HEAD(&cs_char_data.dataind_queue);
cs_char_data.channel_id_cmd = hsi_get_channel_id_by_name(cl,
"speech-control");
if (cs_char_data.channel_id_cmd < 0) {
err = cs_char_data.channel_id_cmd;
dev_err(dev, "Could not get cmd channel (%d)\n", err);
return err;
}
cs_char_data.channel_id_data = hsi_get_channel_id_by_name(cl,
"speech-data");
if (cs_char_data.channel_id_data < 0) {
err = cs_char_data.channel_id_data;
dev_err(dev, "Could not get data channel (%d)\n", err);
return err;
}
err = misc_register(&cs_char_miscdev);
if (err)
dev_err(dev, "Failed to register: %d\n", err);
return err;
}
static int cs_hsi_client_remove(struct device *dev)
{
struct cs_hsi_iface *hi;
dev_dbg(dev, "hsi_client_remove\n");
misc_deregister(&cs_char_miscdev);
spin_lock_bh(&cs_char_data.lock);
hi = cs_char_data.hi;
cs_char_data.hi = NULL;
spin_unlock_bh(&cs_char_data.lock);
if (hi)
cs_hsi_stop(hi);
return 0;
}
static struct hsi_client_driver cs_hsi_driver = {
.driver = {
.name = "cmt-speech",
.owner = THIS_MODULE,
.probe = cs_hsi_client_probe,
.remove = cs_hsi_client_remove,
},
};
static int __init cs_char_init(void)
{
pr_info("CMT speech driver added\n");
return hsi_register_client_driver(&cs_hsi_driver);
}
module_init(cs_char_init);
static void __exit cs_char_exit(void)
{
hsi_unregister_client_driver(&cs_hsi_driver);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/module.h`, `linux/types.h`, `linux/init.h`, `linux/device.h`, `linux/miscdevice.h`, `linux/mm.h`, `linux/slab.h`.
- Detected declarations: `struct char_queue`, `struct cs_char`, `struct cs_hsi_iface`, `function rx_ptr_shift_too_big`, `function cs_notify`, `function cs_pop_entry`, `function cs_notify_control`, `function cs_notify_data`, `function cs_set_cmd`, `function cs_get_cmd`.
- Atlas domain: Driver Families / drivers/hsi.
- 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.