drivers/media/dvb-core/dvb_ca_en50221.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-core/dvb_ca_en50221.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-core/dvb_ca_en50221.c- Extension
.c- Size
- 48844 bytes
- Lines
- 1983
- Domain
- Driver Families
- Bucket
- drivers/media
- 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/slab.hlinux/list.hlinux/module.hlinux/nospec.hlinux/vmalloc.hlinux/delay.hlinux/spinlock.hlinux/sched/signal.hlinux/kthread.hmedia/dvb_ca_en50221.hmedia/dvb_ringbuffer.h
Detected Declarations
struct dvb_ca_slotstruct dvb_ca_privatefunction dvb_ca_private_freefunction dvb_ca_private_releasefunction dvb_ca_private_getfunction dvb_ca_private_putfunction dvb_ca_en50221_check_camstatusfunction dvb_ca_en50221_wait_if_statusfunction dvb_ca_en50221_link_initfunction dvb_ca_en50221_read_tuplefunction dvb_ca_en50221_parse_attributesfunction dvb_ca_en50221_set_configoptionfunction dvb_ca_en50221_read_datafunction dvb_ca_en50221_write_datafunction dvb_ca_en50221_slot_shutdownfunction dvb_ca_en50221_camchange_irqfunction dvb_ca_en50221_camready_irqfunction dvb_ca_en50221_frda_irqfunction dvb_ca_en50221_thread_wakeupfunction dvb_ca_en50221_thread_update_delayfunction dvb_ca_en50221_poll_cam_gonefunction dvb_ca_en50221_thread_state_machinefunction dvb_ca_en50221_threadfunction dvb_ca_en50221_io_do_ioctlfunction dvb_ca_en50221_io_ioctlfunction dvb_ca_en50221_io_writefunction dvb_ca_en50221_io_read_conditionfunction dvb_ca_en50221_io_readfunction dvb_ca_en50221_io_openfunction dvb_ca_en50221_io_releasefunction dvb_ca_en50221_io_pollfunction dvb_ca_en50221_initfunction dvb_ca_en50221_releaseexport dvb_ca_en50221_camchange_irqexport dvb_ca_en50221_camready_irqexport dvb_ca_en50221_frda_irqexport dvb_ca_en50221_initexport dvb_ca_en50221_release
Annotated Snippet
static const struct file_operations dvb_ca_fops = {
.owner = THIS_MODULE,
.read = dvb_ca_en50221_io_read,
.write = dvb_ca_en50221_io_write,
.unlocked_ioctl = dvb_ca_en50221_io_ioctl,
.open = dvb_ca_en50221_io_open,
.release = dvb_ca_en50221_io_release,
.poll = dvb_ca_en50221_io_poll,
.llseek = noop_llseek,
};
static const struct dvb_device dvbdev_ca = {
.priv = NULL,
.users = 1,
.readers = 1,
.writers = 1,
#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
.name = "dvb-ca-en50221",
#endif
.fops = &dvb_ca_fops,
};
/* ************************************************************************** */
/* Initialisation/shutdown functions */
/**
* dvb_ca_en50221_init - Initialise a new DVB CA EN50221 interface device.
*
* @dvb_adapter: DVB adapter to attach the new CA device to.
* @pubca: The dvb_ca instance.
* @flags: Flags describing the CA device (DVB_CA_FLAG_*).
* @slot_count: Number of slots supported.
*
* return: 0 on success, nonzero on failure
*/
int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
struct dvb_ca_en50221 *pubca, int flags, int slot_count)
{
int ret;
struct dvb_ca_private *ca = NULL;
int i;
dprintk("%s\n", __func__);
if (slot_count < 1)
return -EINVAL;
/* initialise the system data */
ca = kzalloc_obj(*ca);
if (!ca) {
ret = -ENOMEM;
goto exit;
}
kref_init(&ca->refcount);
ca->pub = pubca;
ca->flags = flags;
ca->slot_count = slot_count;
ca->slot_info = kzalloc_objs(struct dvb_ca_slot, slot_count);
if (!ca->slot_info) {
ret = -ENOMEM;
goto free_ca;
}
init_waitqueue_head(&ca->wait_queue);
ca->open = 0;
ca->wakeup = 0;
ca->next_read_slot = 0;
pubca->private = ca;
/* register the DVB device */
ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca,
DVB_DEVICE_CA, 0);
if (ret)
goto free_slot_info;
/* now initialise each slot */
for (i = 0; i < slot_count; i++) {
struct dvb_ca_slot *sl = &ca->slot_info[i];
memset(sl, 0, sizeof(struct dvb_ca_slot));
sl->slot_state = DVB_CA_SLOTSTATE_NONE;
atomic_set(&sl->camchange_count, 0);
sl->camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
mutex_init(&sl->slot_lock);
}
mutex_init(&ca->ioctl_mutex);
mutex_init(&ca->remove_mutex);
if (signal_pending(current)) {
ret = -EINTR;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/slab.h`, `linux/list.h`, `linux/module.h`, `linux/nospec.h`, `linux/vmalloc.h`, `linux/delay.h`, `linux/spinlock.h`.
- Detected declarations: `struct dvb_ca_slot`, `struct dvb_ca_private`, `function dvb_ca_private_free`, `function dvb_ca_private_release`, `function dvb_ca_private_get`, `function dvb_ca_private_put`, `function dvb_ca_en50221_check_camstatus`, `function dvb_ca_en50221_wait_if_status`, `function dvb_ca_en50221_link_init`, `function dvb_ca_en50221_read_tuple`.
- Atlas domain: Driver Families / drivers/media.
- 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.