drivers/media/radio/si470x/radio-si470x-common.c
Source file repositories/reference/linux-study-clean/drivers/media/radio/si470x/radio-si470x-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/radio/si470x/radio-si470x-common.c- Extension
.c- Size
- 21898 bytes
- Lines
- 795
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
radio-si470x.h
Detected Declarations
function si470x_set_bandfunction si470x_set_chanfunction si470x_get_stepfunction si470x_get_freqfunction si470x_set_freqfunction si470x_set_seekfunction si470x_startfunction si470x_stopfunction si470x_rds_onfunction si470x_fops_readfunction si470x_fops_pollfunction si470x_fops_openfunction si470x_fops_releasefunction si470x_s_ctrlfunction si470x_vidioc_g_tunerfunction si470x_vidioc_s_tunerfunction si470x_vidioc_g_frequencyfunction si470x_vidioc_s_frequencyfunction si470x_vidioc_s_hw_freq_seekfunction si470x_vidioc_enum_freq_bandsfunction si470x_vidioc_querycapexport si470x_set_freqexport si470x_startexport si470x_stopexport si470x_ctrl_opsexport si470x_viddev_template
Annotated Snippet
if (file->f_flags & O_NONBLOCK) {
retval = -EWOULDBLOCK;
goto done;
}
if (wait_event_interruptible(radio->read_queue,
radio->wr_index != radio->rd_index) < 0) {
retval = -EINTR;
goto done;
}
}
/* calculate block count from byte count */
count /= 3;
/* copy RDS block out of internal buffer and to user buffer */
while (block_count < count) {
if (radio->rd_index == radio->wr_index)
break;
/* always transfer rds complete blocks */
if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
/* retval = -EFAULT; */
break;
/* increment and wrap read pointer */
radio->rd_index += 3;
if (radio->rd_index >= radio->buf_size)
radio->rd_index = 0;
/* increment counters */
block_count++;
buf += 3;
retval += 3;
}
done:
return retval;
}
/*
* si470x_fops_poll - poll RDS data
*/
static __poll_t si470x_fops_poll(struct file *file,
struct poll_table_struct *pts)
{
struct si470x_device *radio = video_drvdata(file);
__poll_t req_events = poll_requested_events(pts);
__poll_t retval = v4l2_ctrl_poll(file, pts);
if (req_events & (EPOLLIN | EPOLLRDNORM)) {
/* switch on rds reception */
if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
si470x_rds_on(radio);
poll_wait(file, &radio->read_queue, pts);
if (radio->rd_index != radio->wr_index)
retval |= EPOLLIN | EPOLLRDNORM;
}
return retval;
}
static int si470x_fops_open(struct file *file)
{
struct si470x_device *radio = video_drvdata(file);
return radio->fops_open(file);
}
/*
* si470x_fops_release - file release
*/
static int si470x_fops_release(struct file *file)
{
struct si470x_device *radio = video_drvdata(file);
return radio->fops_release(file);
}
/*
* si470x_fops - file operations interface
*/
static const struct v4l2_file_operations si470x_fops = {
.owner = THIS_MODULE,
.read = si470x_fops_read,
Annotation
- Immediate include surface: `radio-si470x.h`.
- Detected declarations: `function si470x_set_band`, `function si470x_set_chan`, `function si470x_get_step`, `function si470x_get_freq`, `function si470x_set_freq`, `function si470x_set_seek`, `function si470x_start`, `function si470x_stop`, `function si470x_rds_on`, `function si470x_fops_read`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.