drivers/usb/misc/sisusbvga/sisusbvga.c
Source file repositories/reference/linux-study-clean/drivers/usb/misc/sisusbvga/sisusbvga.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/misc/sisusbvga/sisusbvga.c- Extension
.c- Size
- 71020 bytes
- Lines
- 2970
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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/mutex.hlinux/module.hlinux/kernel.hlinux/signal.hlinux/errno.hlinux/poll.hlinux/init.hlinux/slab.hlinux/spinlock.hlinux/kref.hlinux/usb.hlinux/vmalloc.hsisusb.h
Detected Declarations
function sisusb_free_buffersfunction sisusb_free_urbsfunction sisusb_all_freefunction sisusb_kill_all_busyfunction sisusb_wait_all_out_completefunction sisusb_outurb_availablefunction sisusb_get_free_outbuffunction sisusb_alloc_outbuffunction sisusb_free_outbuffunction sisusb_bulk_completeoutfunction sisusb_bulkout_msgfunction sisusb_bulk_completeinfunction sisusb_bulkin_msgfunction fromfunction sisusb_recv_bulk_msgfunction sisusb_send_packetfunction sisusb_send_bridge_packetfunction sisusb_write_memio_bytefunction sisusb_write_memio_wordfunction sisusb_write_memio_24bitfunction sisusb_write_memio_longfunction sisusb_write_mem_bulkfunction sisusb_read_memio_bytefunction sisusb_read_memio_wordfunction sisusb_read_memio_24bitfunction sisusb_read_memio_longfunction sisusb_read_mem_bulkfunction sisusb_setidxregfunction sisusb_getidxregfunction sisusb_setidxregandorfunction sisusb_setidxregmaskfunction sisusb_setidxregorfunction sisusb_setidxregandfunction sisusb_testreadwritefunction sisusb_write_pci_configfunction sisusb_read_pci_configfunction sisusb_clear_vramfunction modefunction sisusb_getbuswidthfunction sisusb_verify_mclkfunction sisusb_set_rankfunction sisusb_check_rbcfunction sisusb_check_ranksfunction sisusb_get_sdram_sizefunction sisusb_setup_screenfunction sisusb_set_default_modefunction sisusb_init_gfxcorefunction sisusb_get_ramconfig
Annotated Snippet
static const struct file_operations usb_sisusb_fops = {
.owner = THIS_MODULE,
.open = sisusb_open,
.release = sisusb_release,
.read = sisusb_read,
.write = sisusb_write,
.llseek = sisusb_lseek,
#ifdef CONFIG_COMPAT
.compat_ioctl = sisusb_compat_ioctl,
#endif
.unlocked_ioctl = sisusb_ioctl
};
static struct usb_class_driver usb_sisusb_class = {
.name = "sisusbvga%d",
.fops = &usb_sisusb_fops,
.minor_base = SISUSB_MINOR
};
static int sisusb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
struct sisusb_usb_data *sisusb;
int retval = 0, i;
static const u8 ep_addresses[] = {
SISUSB_EP_GFX_IN | USB_DIR_IN,
SISUSB_EP_GFX_OUT | USB_DIR_OUT,
SISUSB_EP_GFX_BULK_OUT | USB_DIR_OUT,
SISUSB_EP_GFX_LBULK_OUT | USB_DIR_OUT,
SISUSB_EP_BRIDGE_IN | USB_DIR_IN,
SISUSB_EP_BRIDGE_OUT | USB_DIR_OUT,
0};
/* Are the expected endpoints present? */
if (!usb_check_bulk_endpoints(intf, ep_addresses)) {
dev_err(&intf->dev, "Invalid USB2VGA device\n");
return -EINVAL;
}
dev_info(&dev->dev, "USB2VGA dongle found at address %d\n",
dev->devnum);
/* Allocate memory for our private */
sisusb = kzalloc_obj(*sisusb);
if (!sisusb)
return -ENOMEM;
kref_init(&sisusb->kref);
mutex_init(&(sisusb->lock));
sisusb->sisusb_dev = dev;
sisusb->vrambase = SISUSB_PCI_MEMBASE;
sisusb->mmiobase = SISUSB_PCI_MMIOBASE;
sisusb->mmiosize = SISUSB_PCI_MMIOSIZE;
sisusb->ioportbase = SISUSB_PCI_IOPORTBASE;
/* Everything else is zero */
/* Register device */
retval = usb_register_dev(intf, &usb_sisusb_class);
if (retval) {
dev_err(&sisusb->sisusb_dev->dev,
"Failed to get a minor for device %d\n",
dev->devnum);
retval = -ENODEV;
goto error_1;
}
sisusb->minor = intf->minor;
/* Allocate buffers */
sisusb->ibufsize = SISUSB_IBUF_SIZE;
sisusb->ibuf = kmalloc(SISUSB_IBUF_SIZE, GFP_KERNEL);
if (!sisusb->ibuf) {
retval = -ENOMEM;
goto error_2;
}
sisusb->numobufs = 0;
sisusb->obufsize = SISUSB_OBUF_SIZE;
for (i = 0; i < NUMOBUFS; i++) {
sisusb->obuf[i] = kmalloc(SISUSB_OBUF_SIZE, GFP_KERNEL);
if (!sisusb->obuf[i]) {
if (i == 0) {
retval = -ENOMEM;
goto error_3;
}
break;
}
Annotation
- Immediate include surface: `linux/mutex.h`, `linux/module.h`, `linux/kernel.h`, `linux/signal.h`, `linux/errno.h`, `linux/poll.h`, `linux/init.h`, `linux/slab.h`.
- Detected declarations: `function sisusb_free_buffers`, `function sisusb_free_urbs`, `function sisusb_all_free`, `function sisusb_kill_all_busy`, `function sisusb_wait_all_out_complete`, `function sisusb_outurb_available`, `function sisusb_get_free_outbuf`, `function sisusb_alloc_outbuf`, `function sisusb_free_outbuf`, `function sisusb_bulk_completeout`.
- Atlas domain: Driver Families / drivers/usb.
- 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.