drivers/gpib/common/gpib_os.c
Source file repositories/reference/linux-study-clean/drivers/gpib/common/gpib_os.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpib/common/gpib_os.c- Extension
.c- Size
- 59958 bytes
- Lines
- 2325
- Domain
- Driver Families
- Bucket
- drivers/gpib
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
ibsys.hlinux/module.hlinux/wait.hlinux/list.hlinux/fs.hlinux/pci.hlinux/device.hlinux/init.hlinux/string.hlinux/vmalloc.hlinux/fcntl.hlinux/kmod.hlinux/uaccess.h
Detected Declarations
function watchdog_timeoutfunction os_start_timerfunction io_timed_outfunction get_hzfunction pseudo_irq_handlerfunction gpib_request_pseudo_irqfunction gpib_free_pseudo_irqfunction num_status_bytesfunction push_status_bytefunction pop_status_bytefunction get_serial_poll_bytefunction autopoll_all_devicesfunction setup_serial_pollfunction read_serial_poll_bytefunction cleanup_serial_pollfunction serial_poll_singlefunction serial_poll_allfunction dvrspfunction init_gpib_file_privatefunction ibopenfunction ibclosefunction ibioctlfunction board_type_ioctlfunction read_ioctlfunction command_ioctlfunction write_ioctlfunction status_bytes_ioctlfunction increment_open_device_countfunction subtract_open_device_countfunction decrement_open_device_countfunction cleanup_open_devicesfunction open_dev_ioctlfunction close_dev_ioctlfunction serial_poll_ioctlfunction wait_ioctlfunction parallel_poll_ioctlfunction online_ioctlfunction remote_enable_ioctlfunction take_control_ioctlfunction line_status_ioctlfunction pad_ioctlfunction sad_ioctlfunction eos_ioctlfunction request_service_ioctlfunction request_service2_ioctlfunction iobase_ioctlfunction irq_ioctlfunction dma_ioctl
Annotated Snippet
static const struct file_operations ib_fops = {
.owner = THIS_MODULE,
.llseek = NULL,
.unlocked_ioctl = &ibioctl,
.compat_ioctl = &ibioctl,
.open = &ibopen,
.release = &ibclose,
};
struct gpib_board board_array[GPIB_MAX_NUM_BOARDS];
LIST_HEAD(registered_drivers);
void init_gpib_descriptor(struct gpib_descriptor *desc)
{
desc->pad = 0;
desc->sad = -1;
desc->is_board = 0;
desc->autopoll_enabled = 0;
atomic_set(&desc->io_in_progress, 0);
atomic_set(&desc->descriptor_busy, 0);
}
int gpib_register_driver(struct gpib_interface *interface, struct module *provider_module)
{
struct gpib_interface_list *entry;
entry = kmalloc_obj(*entry);
if (!entry)
return -ENOMEM;
entry->interface = interface;
entry->module = provider_module;
list_add(&entry->list, ®istered_drivers);
return 0;
}
EXPORT_SYMBOL(gpib_register_driver);
void gpib_unregister_driver(struct gpib_interface *interface)
{
int i;
struct list_head *list_ptr;
for (i = 0; i < GPIB_MAX_NUM_BOARDS; i++) {
struct gpib_board *board = &board_array[i];
if (board->interface == interface) {
if (board->use_count > 0)
pr_warn("gpib: Warning: deregistered interface %s in use\n",
interface->name);
iboffline(board);
board->interface = NULL;
}
}
for (list_ptr = registered_drivers.next; list_ptr != ®istered_drivers;) {
struct gpib_interface_list *entry;
entry = list_entry(list_ptr, struct gpib_interface_list, list);
list_ptr = list_ptr->next;
if (entry->interface == interface) {
list_del(&entry->list);
kfree(entry);
}
}
}
EXPORT_SYMBOL(gpib_unregister_driver);
static void init_gpib_board_config(struct gpib_board_config *config)
{
memset(config, 0, sizeof(struct gpib_board_config));
config->pci_bus = -1;
config->pci_slot = -1;
}
void init_gpib_board(struct gpib_board *board)
{
board->interface = NULL;
board->provider_module = NULL;
board->buffer = NULL;
board->buffer_length = 0;
board->status = 0;
init_waitqueue_head(&board->wait);
mutex_init(&board->user_mutex);
mutex_init(&board->big_gpib_mutex);
board->locking_pid = 0;
spin_lock_init(&board->locking_pid_spinlock);
spin_lock_init(&board->spinlock);
timer_setup(&board->timer, NULL, 0);
board->dev = NULL;
Annotation
- Immediate include surface: `ibsys.h`, `linux/module.h`, `linux/wait.h`, `linux/list.h`, `linux/fs.h`, `linux/pci.h`, `linux/device.h`, `linux/init.h`.
- Detected declarations: `function watchdog_timeout`, `function os_start_timer`, `function io_timed_out`, `function get_hz`, `function pseudo_irq_handler`, `function gpib_request_pseudo_irq`, `function gpib_free_pseudo_irq`, `function num_status_bytes`, `function push_status_byte`, `function pop_status_byte`.
- Atlas domain: Driver Families / drivers/gpib.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.