drivers/usb/storage/onetouch.c
Source file repositories/reference/linux-study-clean/drivers/usb/storage/onetouch.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/storage/onetouch.c- Extension
.c- Size
- 7800 bytes
- Lines
- 308
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/input.hlinux/slab.hlinux/module.hlinux/usb/input.husb.hdebug.hscsiglue.hunusual_onetouch.h
Detected Declarations
struct usb_onetouchfunction usb_onetouch_irqfunction usb_onetouch_openfunction usb_onetouch_closefunction usb_onetouch_pm_hookfunction onetouch_connect_inputfunction onetouch_release_inputfunction onetouch_probe
Annotated Snippet
struct usb_onetouch {
char name[128];
char phys[64];
struct input_dev *dev; /* input device interface */
struct usb_device *udev; /* usb device */
struct urb *irq; /* urb for interrupt in report */
unsigned char *data; /* input data */
dma_addr_t data_dma;
unsigned int is_open:1;
};
/*
* The table of devices
*/
#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
vendorName, productName, useProtocol, useTransport, \
initFunction, flags) \
{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
.driver_info = (flags) }
static const struct usb_device_id onetouch_usb_ids[] = {
# include "unusual_onetouch.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, onetouch_usb_ids);
#undef UNUSUAL_DEV
/*
* The flags table
*/
#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
vendor_name, product_name, use_protocol, use_transport, \
init_function, Flags) \
{ \
.vendorName = vendor_name, \
.productName = product_name, \
.useProtocol = use_protocol, \
.useTransport = use_transport, \
.initFunction = init_function, \
}
static const struct us_unusual_dev onetouch_unusual_dev_list[] = {
# include "unusual_onetouch.h"
{ } /* Terminating entry */
};
#undef UNUSUAL_DEV
static void usb_onetouch_irq(struct urb *urb)
{
struct usb_onetouch *onetouch = urb->context;
signed char *data = onetouch->data;
struct input_dev *dev = onetouch->dev;
int status = urb->status;
int retval;
switch (status) {
case 0: /* success */
break;
case -ECONNRESET: /* unlink */
case -ENOENT:
case -ESHUTDOWN:
return;
/* -EPIPE: should clear the halt */
default: /* error */
goto resubmit;
}
input_report_key(dev, ONETOUCH_BUTTON, data[0] & 0x02);
input_sync(dev);
resubmit:
retval = usb_submit_urb (urb, GFP_ATOMIC);
if (retval)
dev_err(&dev->dev, "can't resubmit intr, %s-%s/input0, "
"retval %d\n", onetouch->udev->bus->bus_name,
onetouch->udev->devpath, retval);
}
static int usb_onetouch_open(struct input_dev *dev)
{
struct usb_onetouch *onetouch = input_get_drvdata(dev);
onetouch->is_open = 1;
onetouch->irq->dev = onetouch->udev;
if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/input.h`, `linux/slab.h`, `linux/module.h`, `linux/usb/input.h`, `usb.h`, `debug.h`, `scsiglue.h`.
- Detected declarations: `struct usb_onetouch`, `function usb_onetouch_irq`, `function usb_onetouch_open`, `function usb_onetouch_close`, `function usb_onetouch_pm_hook`, `function onetouch_connect_input`, `function onetouch_release_input`, `function onetouch_probe`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
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.