drivers/media/dvb-core/dvbdev.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-core/dvbdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-core/dvbdev.c- Extension
.c- Size
- 26554 bytes
- Lines
- 1138
- 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/types.hlinux/errno.hlinux/string.hlinux/module.hlinux/kernel.hlinux/i2c.hlinux/init.hlinux/slab.hlinux/device.hlinux/fs.hlinux/cdev.hlinux/mutex.hmedia/dvbdev.hmedia/tuner.h
Detected Declarations
function dvb_device_openfunction dvb_generic_openfunction dvb_generic_releasefunction dvb_generic_ioctlfunction dvbdev_get_free_idfunction dvb_media_device_freefunction dvb_create_tsout_entityfunction dvb_create_media_entityfunction dvb_register_media_devicefunction dvb_register_devicefunction probefunction dvb_remove_devicefunction dvb_free_devicefunction dvb_device_putfunction dvb_unregister_devicefunction dvb_create_io_intf_linksfunction media_device_for_each_entityfunction dvb_create_media_graphfunction media_device_for_each_entityfunction media_device_for_each_entityfunction dvbdev_check_free_adapter_numfunction list_for_eachfunction dvbdev_get_free_adapter_numfunction dvb_register_adapterfunction dvb_unregister_adapterfunction video_usercopyfunction dvb_module_releasefunction dvb_ueventfunction init_dvbdevfunction exit_dvbdevfunction list_for_each_entry_safemodule init init_dvbdevexport dvb_generic_openexport dvb_generic_releaseexport dvb_generic_ioctlexport dvb_register_deviceexport dvb_remove_deviceexport dvb_device_getexport dvb_unregister_deviceexport dvb_create_media_graphexport dvb_register_adapterexport dvb_unregister_adapterexport dvb_module_probeexport dvb_module_release
Annotated Snippet
const struct file_operations *new_fops;
new_fops = fops_get(dvbdev->fops);
if (!new_fops)
goto fail;
file->private_data = dvb_device_get(dvbdev);
replace_fops(file, new_fops);
if (file->f_op->open)
err = file->f_op->open(inode, file);
up_read(&minor_rwsem);
mutex_unlock(&dvbdev_mutex);
if (err)
dvb_device_put(dvbdev);
return err;
}
fail:
up_read(&minor_rwsem);
mutex_unlock(&dvbdev_mutex);
return -ENODEV;
}
static const struct file_operations dvb_device_fops = {
.owner = THIS_MODULE,
.open = dvb_device_open,
.llseek = noop_llseek,
};
static struct cdev dvb_device_cdev;
int dvb_generic_open(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
if (!dvbdev)
return -ENODEV;
if (!dvbdev->users)
return -EBUSY;
if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
if (!dvbdev->readers)
return -EBUSY;
dvbdev->readers--;
} else {
if (!dvbdev->writers)
return -EBUSY;
dvbdev->writers--;
}
dvbdev->users--;
return 0;
}
EXPORT_SYMBOL(dvb_generic_open);
int dvb_generic_release(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
if (!dvbdev)
return -ENODEV;
if ((file->f_flags & O_ACCMODE) == O_RDONLY)
dvbdev->readers++;
else
dvbdev->writers++;
dvbdev->users++;
dvb_device_put(dvbdev);
return 0;
}
EXPORT_SYMBOL(dvb_generic_release);
long dvb_generic_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
struct dvb_device *dvbdev = file->private_data;
if (!dvbdev)
return -ENODEV;
if (!dvbdev->kernel_ioctl)
return -EINVAL;
return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
}
EXPORT_SYMBOL(dvb_generic_ioctl);
static int dvbdev_get_free_id(struct dvb_adapter *adap, int type)
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/string.h`, `linux/module.h`, `linux/kernel.h`, `linux/i2c.h`, `linux/init.h`, `linux/slab.h`.
- Detected declarations: `function dvb_device_open`, `function dvb_generic_open`, `function dvb_generic_release`, `function dvb_generic_ioctl`, `function dvbdev_get_free_id`, `function dvb_media_device_free`, `function dvb_create_tsout_entity`, `function dvb_create_media_entity`, `function dvb_register_media_device`, `function dvb_register_device`.
- 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.