drivers/usb/misc/usbio.c

Source file repositories/reference/linux-study-clean/drivers/usb/misc/usbio.c

File Facts

System
Linux kernel
Corpus path
drivers/usb/misc/usbio.c
Extension
.c
Size
19415 bytes
Lines
753
Domain
Driver Families
Bucket
drivers/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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct usbio_protver {
	u8 ver;
} __packed;

struct usbio_fwver {
	u8 major;
	u8 minor;
	__le16 patch;
	__le16 build;
} __packed;

/***********************************
 * USBIO Bridge Device Definitions *
 ***********************************/

/**
 * struct usbio_device - the usb device exposing IOs
 *
 * @dev: the device in the usb interface
 * @udev: the detected usb device
 * @intf: the usb interface
 * @quirks: quirks
 * @ctrl_mutex: protects ctrl_buf
 * @ctrl_pipe: the control transfer pipe
 * @ctrlbuf_len: the size of the control transfer pipe
 * @ctrlbuf: the buffer used for control transfers
 * @bulk_mutex: protects tx_buf, rx_buf and split bulk-transfers getting interrupted
 * @tx_pipe: the bulk out pipe
 * @txbuf_len: the size of the bulk out pipe
 * @txbuf: the buffer used for bulk out transfers
 * @rx_pipe: the bulk in pipe
 * @rxbuf_len: the size of the bulk in pipe
 * @rxdat_len: the data length at rx buffer
 * @rxbuf: the buffer used for bulk in transfers
 * @urb: the urb to read bulk pipe
 * @done: completion object as request is done
 * @cli_list: device's client list
 * @nr_gpio_banks: Number of GPIO banks
 * @gpios: GPIO bank descriptors
 * @nr_gpio_banks: Number of I2C busses
 * @gpios: I2C bank descriptors
 */
struct usbio_device {
	struct device *dev;
	struct usb_device *udev;
	struct usb_interface *intf;
	unsigned long quirks;

	struct mutex ctrl_mutex;
	unsigned int ctrl_pipe;
	u16 ctrlbuf_len;
	void *ctrlbuf;

	struct mutex bulk_mutex;
	unsigned int tx_pipe;
	u16 txbuf_len;
	void *txbuf;

	unsigned int rx_pipe;
	u16 rxbuf_len;
	u16 rxdat_len;
	void *rxbuf;
	struct urb *urb;

	struct completion done;

	struct list_head cli_list;

	unsigned int nr_gpio_banks;
	struct usbio_gpio_bank_desc gpios[USBIO_MAX_GPIOBANKS];

	unsigned int nr_i2c_buses;
	struct usbio_i2c_bus_desc i2cs[USBIO_MAX_I2CBUSES];
};

/**
 * struct usbio_client - represents a usbio client
 *
 * @auxdev: auxiliary device object
 * @mutex: protects @bridge
 * @bridge: usbio bridge who service the client
 * @link: usbio bridge clients list member
 */
struct usbio_client {
	struct auxiliary_device auxdev;
	struct mutex mutex;
	struct usbio_device *bridge;
	struct list_head link;
};

Annotation

Implementation Notes