drivers/usb/renesas_usbhs/mod_gadget.c
Source file repositories/reference/linux-study-clean/drivers/usb/renesas_usbhs/mod_gadget.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/renesas_usbhs/mod_gadget.c- Extension
.c- Size
- 28819 bytes
- Lines
- 1185
- 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.
- 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
linux/delay.hlinux/dma-mapping.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/usb/ch9.hlinux/usb/gadget.hlinux/usb/otg.hcommon.h
Detected Declarations
struct usbhsg_requeststruct usbhsg_gprivstruct usbhsg_uepstruct usbhsg_gprivstruct usbhsg_recip_handlefunction __usbhsg_queue_popfunction usbhsg_queue_popfunction usbhsg_queue_donefunction usbhsg_queue_pushfunction usbhsg_dma_map_ctrlfunction usbhsg_recip_handler_std_control_donefunction usbhsg_recip_handler_std_clear_endpointfunction usbhsg_recip_handler_std_set_devicefunction usbhsg_recip_handler_std_set_endpointfunction __usbhsg_recip_send_completefunction __usbhsg_recip_send_statusfunction usbhsg_recip_handler_std_get_devicefunction usbhsg_recip_handler_std_get_interfacefunction usbhsg_recip_handler_std_get_endpointfunction usbhsg_recip_run_handlefunction usbhsg_irq_dev_statefunction usbhsg_irq_ctrl_stagefunction usbhsg_pipe_disablefunction usbhsg_ep_enablefunction usbhsg_ep_disablefunction usbhsg_ep_free_requestfunction usbhsg_ep_queuefunction usbhsg_ep_dequeuefunction __usbhsg_ep_set_halt_wedgefunction usb_ep_set_haltfunction usbhsg_ep_set_haltfunction usbhsg_ep_set_wedgefunction usbhsg_can_pullupfunction usbhsg_update_pullupfunction usbhsg_try_startfunction usbhsg_try_stopfunction usbhsm_phy_get_vbusfunction usbhs_mod_phy_modefunction usbhsg_gadget_startfunction usbhsg_gadget_stopfunction usbhsg_get_framefunction usbhsg_pullupfunction usbhsg_set_selfpoweredfunction usbhsg_vbus_sessionfunction usbhsg_startfunction usbhsg_stopfunction usbhs_mod_gadget_probefunction usbhs_mod_gadget_remove
Annotated Snippet
struct usbhsg_request {
struct usb_request req;
struct usbhs_pkt pkt;
};
#define EP_NAME_SIZE 8
struct usbhsg_gpriv;
struct usbhsg_uep {
struct usb_ep ep;
struct usbhs_pipe *pipe;
spinlock_t lock; /* protect the pipe */
char ep_name[EP_NAME_SIZE];
struct usbhsg_gpriv *gpriv;
};
struct usbhsg_gpriv {
struct usb_gadget gadget;
struct usbhs_mod mod;
int uep_size;
struct usb_gadget_driver *driver;
struct usb_phy *transceiver;
bool vbus_active;
u32 status;
#define USBHSG_STATUS_STARTED (1 << 0)
#define USBHSG_STATUS_REGISTERD (1 << 1)
#define USBHSG_STATUS_WEDGE (1 << 2)
#define USBHSG_STATUS_SELF_POWERED (1 << 3)
#define USBHSG_STATUS_SOFT_CONNECT (1 << 4)
struct usbhsg_uep uep[] __counted_by(uep_size);
};
struct usbhsg_recip_handle {
char *name;
int (*device)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
struct usb_ctrlrequest *ctrl);
int (*interface)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
struct usb_ctrlrequest *ctrl);
int (*endpoint)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
struct usb_ctrlrequest *ctrl);
};
/*
* macro
*/
#define usbhsg_priv_to_gpriv(priv) \
container_of( \
usbhs_mod_get(priv, USBHS_GADGET), \
struct usbhsg_gpriv, mod)
#define __usbhsg_for_each_uep(start, pos, g, i) \
for ((i) = start; \
((i) < (g)->uep_size) && ((pos) = (g)->uep + (i)); \
(i)++)
#define usbhsg_for_each_uep(pos, gpriv, i) \
__usbhsg_for_each_uep(1, pos, gpriv, i)
#define usbhsg_for_each_uep_with_dcp(pos, gpriv, i) \
__usbhsg_for_each_uep(0, pos, gpriv, i)
#define usbhsg_gadget_to_gpriv(g)\
container_of(g, struct usbhsg_gpriv, gadget)
#define usbhsg_req_to_ureq(r)\
container_of(r, struct usbhsg_request, req)
#define usbhsg_ep_to_uep(e) container_of(e, struct usbhsg_uep, ep)
#define usbhsg_gpriv_to_dev(gp) usbhs_priv_to_dev((gp)->mod.priv)
#define usbhsg_gpriv_to_priv(gp) ((gp)->mod.priv)
#define usbhsg_gpriv_to_dcp(gp) ((gp)->uep)
#define usbhsg_gpriv_to_nth_uep(gp, i) ((gp)->uep + i)
#define usbhsg_uep_to_gpriv(u) ((u)->gpriv)
#define usbhsg_uep_to_pipe(u) ((u)->pipe)
#define usbhsg_pipe_to_uep(p) ((p)->mod_private)
#define usbhsg_is_dcp(u) ((u) == usbhsg_gpriv_to_dcp((u)->gpriv))
#define usbhsg_ureq_to_pkt(u) (&(u)->pkt)
#define usbhsg_pkt_to_ureq(i) \
container_of(i, struct usbhsg_request, pkt)
#define usbhsg_is_not_connected(gp) ((gp)->gadget.speed == USB_SPEED_UNKNOWN)
/* status */
#define usbhsg_status_init(gp) do {(gp)->status = 0; } while (0)
#define usbhsg_status_set(gp, b) (gp->status |= b)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/dma-mapping.h`, `linux/io.h`, `linux/module.h`, `linux/platform_device.h`, `linux/usb/ch9.h`, `linux/usb/gadget.h`, `linux/usb/otg.h`.
- Detected declarations: `struct usbhsg_request`, `struct usbhsg_gpriv`, `struct usbhsg_uep`, `struct usbhsg_gpriv`, `struct usbhsg_recip_handle`, `function __usbhsg_queue_pop`, `function usbhsg_queue_pop`, `function usbhsg_queue_done`, `function usbhsg_queue_push`, `function usbhsg_dma_map_ctrl`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
- 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.