drivers/s390/char/vmur.c
Source file repositories/reference/linux-study-clean/drivers/s390/char/vmur.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/s390/char/vmur.c- Extension
.c- Size
- 24483 bytes
- Lines
- 1065
- 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.
- 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/cdev.hlinux/slab.hlinux/module.hlinux/kobject.hlinux/uaccess.hasm/machine.hasm/cio.hasm/ccwdev.hasm/debug.hasm/diag.hasm/scsw.hvmur.h
Detected Declarations
function devicefunction urdev_freefunction urdev_getfunction urdev_putfunction timefunction do_ur_iofunction ur_ueventfunction ur_int_handlerfunction ur_attr_reclen_showfunction ur_create_attributesfunction ur_remove_attributesfunction get_urd_classfunction urfile_freefunction do_writefunction ur_writefunction diag_position_to_recordfunction diag_read_filefunction diag14_readfunction ur_readfunction diag_read_next_file_infofunction verify_uri_devicefunction verify_devicefunction get_uri_file_reclenfunction get_file_reclenfunction ur_openfunction ur_releasefunction ur_llseekfunction urdevfunction ur_set_onlinefunction ur_set_offline_forcefunction ur_set_offlinefunction ur_removefunction ur_initfunction ur_exitmodule init ur_init
Annotated Snippet
static const struct file_operations ur_fops = {
.owner = THIS_MODULE,
.open = ur_open,
.release = ur_release,
.read = ur_read,
.write = ur_write,
.llseek = ur_llseek,
};
/*
* ccw_device infrastructure:
* ur_probe creates the struct urdev (with refcount = 1), the device
* attributes, sets up the interrupt handler and validates the virtual
* unit record device.
* ur_remove removes the device attributes and drops the reference to
* struct urdev.
*
* ur_probe, ur_remove, ur_set_online and ur_set_offline are serialized
* by the vmur_mutex lock.
*
* urd->char_device is used as indication that the online function has
* been completed successfully.
*/
static int ur_probe(struct ccw_device *cdev)
{
struct urdev *urd;
int rc;
TRACE("ur_probe: cdev=%p\n", cdev);
mutex_lock(&vmur_mutex);
urd = urdev_alloc(cdev);
if (!urd) {
rc = -ENOMEM;
goto fail_unlock;
}
rc = ur_create_attributes(&cdev->dev);
if (rc) {
rc = -ENOMEM;
goto fail_urdev_put;
}
/* validate virtual unit record device */
urd->class = get_urd_class(urd);
if (urd->class < 0) {
rc = urd->class;
goto fail_remove_attr;
}
if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) {
rc = -EOPNOTSUPP;
goto fail_remove_attr;
}
spin_lock_irq(get_ccwdev_lock(cdev));
dev_set_drvdata(&cdev->dev, urd);
cdev->handler = ur_int_handler;
spin_unlock_irq(get_ccwdev_lock(cdev));
mutex_unlock(&vmur_mutex);
return 0;
fail_remove_attr:
ur_remove_attributes(&cdev->dev);
fail_urdev_put:
urdev_put(urd);
fail_unlock:
mutex_unlock(&vmur_mutex);
return rc;
}
static int ur_set_online(struct ccw_device *cdev)
{
struct urdev *urd;
int minor, major, rc;
char node_id[16];
TRACE("ur_set_online: cdev=%p\n", cdev);
mutex_lock(&vmur_mutex);
urd = urdev_get_from_cdev(cdev);
if (!urd) {
/* ur_remove already deleted our urd */
rc = -ENODEV;
goto fail_unlock;
}
if (urd->char_device) {
/* Another ur_set_online was faster */
rc = -EBUSY;
goto fail_urdev_put;
Annotation
- Immediate include surface: `linux/cdev.h`, `linux/slab.h`, `linux/module.h`, `linux/kobject.h`, `linux/uaccess.h`, `asm/machine.h`, `asm/cio.h`, `asm/ccwdev.h`.
- Detected declarations: `function device`, `function urdev_free`, `function urdev_get`, `function urdev_put`, `function time`, `function do_ur_io`, `function ur_uevent`, `function ur_int_handler`, `function ur_attr_reclen_show`, `function ur_create_attributes`.
- 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.