drivers/staging/greybus/usb.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/usb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/usb.c- Extension
.c- Size
- 5717 bytes
- Lines
- 247
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/slab.hlinux/usb.hlinux/usb/hcd.hlinux/greybus.hgbphy.h
Detected Declarations
struct gb_usb_hub_control_requeststruct gb_usb_hub_control_responsestruct gb_usb_devicefunction hcd_stopfunction hcd_startfunction urb_enqueuefunction urb_dequeuefunction get_frame_numberfunction hub_status_datafunction hub_controlfunction gb_usb_probefunction gb_usb_remove
Annotated Snippet
struct gb_usb_hub_control_request {
__le16 typeReq;
__le16 wValue;
__le16 wIndex;
__le16 wLength;
};
struct gb_usb_hub_control_response {
DECLARE_FLEX_ARRAY(u8, buf);
};
struct gb_usb_device {
struct gb_connection *connection;
struct gbphy_device *gbphy_dev;
};
static inline struct gb_usb_device *to_gb_usb_device(struct usb_hcd *hcd)
{
return (struct gb_usb_device *)hcd->hcd_priv;
}
static inline struct usb_hcd *gb_usb_device_to_hcd(struct gb_usb_device *dev)
{
return container_of((void *)dev, struct usb_hcd, hcd_priv);
}
static void hcd_stop(struct usb_hcd *hcd)
{
struct gb_usb_device *dev = to_gb_usb_device(hcd);
int ret;
ret = gb_operation_sync(dev->connection, GB_USB_TYPE_HCD_STOP,
NULL, 0, NULL, 0);
if (ret)
dev_err(&dev->gbphy_dev->dev, "HCD stop failed '%d'\n", ret);
}
static int hcd_start(struct usb_hcd *hcd)
{
struct usb_bus *bus = hcd_to_bus(hcd);
struct gb_usb_device *dev = to_gb_usb_device(hcd);
int ret;
ret = gb_operation_sync(dev->connection, GB_USB_TYPE_HCD_START,
NULL, 0, NULL, 0);
if (ret) {
dev_err(&dev->gbphy_dev->dev, "HCD start failed '%d'\n", ret);
return ret;
}
hcd->state = HC_STATE_RUNNING;
if (bus->root_hub)
usb_hcd_resume_root_hub(hcd);
return 0;
}
static int urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
{
return -ENXIO;
}
static int urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
return -ENXIO;
}
static int get_frame_number(struct usb_hcd *hcd)
{
return 0;
}
static int hub_status_data(struct usb_hcd *hcd, char *buf)
{
return 0;
}
static int hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
char *buf, u16 wLength)
{
struct gb_usb_device *dev = to_gb_usb_device(hcd);
struct gb_operation *operation;
struct gb_usb_hub_control_request *request;
struct gb_usb_hub_control_response *response;
size_t response_size;
int ret;
/* FIXME: handle unspecified lengths */
response_size = sizeof(*response) + wLength;
operation = gb_operation_create(dev->connection,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/usb.h`, `linux/usb/hcd.h`, `linux/greybus.h`, `gbphy.h`.
- Detected declarations: `struct gb_usb_hub_control_request`, `struct gb_usb_hub_control_response`, `struct gb_usb_device`, `function hcd_stop`, `function hcd_start`, `function urb_enqueue`, `function urb_dequeue`, `function get_frame_number`, `function hub_status_data`, `function hub_control`.
- Atlas domain: Driver Families / drivers/staging.
- 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.