drivers/s390/char/tape_char.c
Source file repositories/reference/linux-study-clean/drivers/s390/char/tape_char.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/char/tape_char.c- Extension
.c- Size
- 10466 bytes
- Lines
- 457
- Domain
- Driver Families
- Bucket
- drivers/s390
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/types.hlinux/proc_fs.hlinux/mtio.hlinux/uaccess.htape.htape_std.htape_class.h
Detected Declarations
function tapechar_setup_devicefunction tapechar_cleanup_devicefunction tapechar_readfunction tapechar_writefunction tapechar_openfunction tapechar_releasefunction __tapechar_ioctlfunction tapechar_ioctlfunction tapechar_initfunction tapechar_exit
Annotated Snippet
static const struct file_operations tape_fops =
{
.owner = THIS_MODULE,
.read = tapechar_read,
.write = tapechar_write,
.unlocked_ioctl = tapechar_ioctl,
.open = tapechar_open,
.release = tapechar_release,
};
static int tapechar_major = TAPECHAR_MAJOR;
/*
* This function is called for every new tapedevice
*/
int
tapechar_setup_device(struct tape_device * device)
{
char device_name[20];
scnprintf(device_name, sizeof(device_name), "ntibm%i", device->first_minor / 2);
device->nt = register_tape_dev(
&device->cdev->dev,
MKDEV(tapechar_major, device->first_minor),
&tape_fops,
device_name,
"non-rewinding"
);
device_name[0] = 'r';
device->rt = register_tape_dev(
&device->cdev->dev,
MKDEV(tapechar_major, device->first_minor + 1),
&tape_fops,
device_name,
"rewinding"
);
return 0;
}
void
tapechar_cleanup_device(struct tape_device *device)
{
unregister_tape_dev(&device->cdev->dev, device->rt);
device->rt = NULL;
unregister_tape_dev(&device->cdev->dev, device->nt);
device->nt = NULL;
}
/*
* Tape device read function
*/
static ssize_t
tapechar_read(struct file *filp, char __user *data, size_t count, loff_t *ppos)
{
struct tape_request *request;
struct ccw1 *ccw, *last_ccw;
struct tape_device *device;
struct idal_buffer **ibs;
size_t block_size;
size_t read = 0;
int rc;
DBF_EVENT(6, "TCHAR:read\n");
device = (struct tape_device *) filp->private_data;
/*
* If the tape isn't terminated yet, do it now. And since we then
* are at the end of the tape there wouldn't be anything to read
* anyways. So we return immediately.
*/
if(device->required_tapemarks) {
return tape_std_terminate_write(device);
}
/* Find out block size to use */
if (device->char_data.block_size != 0) {
if (count < device->char_data.block_size) {
DBF_EVENT(3, "TCHAR:read smaller than block "
"size was requested\n");
return -EINVAL;
}
block_size = device->char_data.block_size;
} else {
block_size = count;
}
rc = tape_check_idalbuffer(device, block_size);
if (rc)
Annotation
- Immediate include surface: `linux/module.h`, `linux/types.h`, `linux/proc_fs.h`, `linux/mtio.h`, `linux/uaccess.h`, `tape.h`, `tape_std.h`, `tape_class.h`.
- Detected declarations: `function tapechar_setup_device`, `function tapechar_cleanup_device`, `function tapechar_read`, `function tapechar_write`, `function tapechar_open`, `function tapechar_release`, `function __tapechar_ioctl`, `function tapechar_ioctl`, `function tapechar_init`, `function tapechar_exit`.
- Atlas domain: Driver Families / drivers/s390.
- 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.