sound/usb/line6/driver.c
Source file repositories/reference/linux-study-clean/sound/usb/line6/driver.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/line6/driver.c- Extension
.c- Size
- 21916 bytes
- Lines
- 901
- Domain
- Driver Families
- Bucket
- sound/usb
- 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.
- 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/kernel.hlinux/module.hlinux/export.hlinux/slab.hlinux/usb.hsound/core.hsound/initval.hsound/hwdep.hcapture.hdriver.hmidi.hplayback.h
Detected Declarations
struct messagefunction line6_start_listenfunction line6_stop_listenfunction line6_send_raw_messagefunction line6_async_request_sentfunction line6_send_raw_message_async_partfunction line6_send_raw_message_asyncfunction line6_version_request_asyncfunction line6_send_sysex_messagefunction line6_data_receivedfunction scoped_guardfunction line6_read_datafunction line6_write_datafunction line6_read_serial_numberfunction line6_destructfunction line6_get_usb_propertiesfunction line6_hwdep_openfunction line6_hwdep_releasefunction line6_hwdep_readfunction line6_hwdep_writefunction line6_hwdep_pollfunction line6_hwdep_push_messagefunction line6_hwdep_initfunction line6_init_cap_controlfunction line6_startup_workfunction line6_probefunction line6_disconnectfunction line6_suspendfunction line6_resumeexport line6_midi_idexport line6_send_raw_messageexport line6_send_raw_message_asyncexport line6_version_request_asyncexport line6_send_sysex_messageexport line6_alloc_sysex_bufferexport line6_read_dataexport line6_write_dataexport line6_read_serial_numberexport line6_probeexport line6_disconnectexport line6_suspendexport line6_resume
Annotated Snippet
struct message {
struct usb_line6 *line6;
const char *buffer;
int size;
int done;
};
/*
Forward declarations.
*/
static void line6_data_received(struct urb *urb);
static int line6_send_raw_message_async_part(struct message *msg,
struct urb *urb);
/*
Start to listen on endpoint.
*/
static int line6_start_listen(struct usb_line6 *line6)
{
int err;
if (line6->properties->capabilities & LINE6_CAP_CONTROL_MIDI) {
usb_fill_int_urb(line6->urb_listen, line6->usbdev,
usb_rcvintpipe(line6->usbdev, line6->properties->ep_ctrl_r),
line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
line6_data_received, line6, line6->interval);
} else {
usb_fill_bulk_urb(line6->urb_listen, line6->usbdev,
usb_rcvbulkpipe(line6->usbdev, line6->properties->ep_ctrl_r),
line6->buffer_listen, LINE6_BUFSIZE_LISTEN,
line6_data_received, line6);
}
/* sanity checks of EP before actually submitting */
if (usb_urb_ep_type_check(line6->urb_listen)) {
dev_err(line6->ifcdev, "invalid control EP\n");
return -EINVAL;
}
line6->urb_listen->actual_length = 0;
err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC);
return err;
}
/*
Stop listening on endpoint.
*/
static void line6_stop_listen(struct usb_line6 *line6)
{
usb_kill_urb(line6->urb_listen);
}
/*
Send raw message in pieces of wMaxPacketSize bytes.
*/
int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
int size)
{
int i, done = 0;
const struct line6_properties *properties = line6->properties;
for (i = 0; i < size; i += line6->max_packet_size) {
int partial;
const char *frag_buf = buffer + i;
int frag_size = min(line6->max_packet_size, size - i);
int retval;
if (properties->capabilities & LINE6_CAP_CONTROL_MIDI) {
retval = usb_interrupt_msg(line6->usbdev,
usb_sndintpipe(line6->usbdev, properties->ep_ctrl_w),
(char *)frag_buf, frag_size,
&partial, LINE6_TIMEOUT);
} else {
retval = usb_bulk_msg(line6->usbdev,
usb_sndbulkpipe(line6->usbdev, properties->ep_ctrl_w),
(char *)frag_buf, frag_size,
&partial, LINE6_TIMEOUT);
}
if (retval) {
dev_err(line6->ifcdev,
"usb_bulk_msg failed (%d)\n", retval);
break;
}
done += frag_size;
}
return done;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/export.h`, `linux/slab.h`, `linux/usb.h`, `sound/core.h`, `sound/initval.h`, `sound/hwdep.h`.
- Detected declarations: `struct message`, `function line6_start_listen`, `function line6_stop_listen`, `function line6_send_raw_message`, `function line6_async_request_sent`, `function line6_send_raw_message_async_part`, `function line6_send_raw_message_async`, `function line6_version_request_async`, `function line6_send_sysex_message`, `function line6_data_received`.
- Atlas domain: Driver Families / sound/usb.
- Implementation status: integration implementation candidate.
- 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.