drivers/staging/greybus/hid.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/hid.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/hid.c- Extension
.c- Size
- 11835 bytes
- Lines
- 521
- 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.
- 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/bitops.hlinux/hid.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/slab.hlinux/greybus.h
Detected Declarations
struct gb_hidfunction gb_hid_get_descfunction gb_hid_get_report_descfunction gb_hid_set_powerfunction gb_hid_get_reportfunction gb_hid_set_reportfunction gb_hid_request_handlerfunction gb_hid_report_lenfunction gb_hid_find_max_reportfunction list_for_each_entryfunction gb_hid_free_buffersfunction gb_hid_alloc_buffersfunction gb_hid_init_reportfunction gb_hid_init_reportsfunction __gb_hid_get_raw_reportfunction __gb_hid_output_raw_reportfunction gb_hid_raw_requestfunction gb_hid_parsefunction gb_hid_startfunction gb_hid_stopfunction gb_hid_openfunction gb_hid_closefunction gb_hid_powerfunction gb_hid_initfunction gb_hid_probefunction gb_hid_disconnect
Annotated Snippet
struct gb_hid {
struct gb_bundle *bundle;
struct gb_connection *connection;
struct hid_device *hid;
struct gb_hid_desc_response hdesc;
unsigned long flags;
#define GB_HID_STARTED 0x01
#define GB_HID_READ_PENDING 0x04
unsigned int bufsize;
char *inbuf;
};
/* Routines to get controller's information over greybus */
/* Operations performed on greybus */
static int gb_hid_get_desc(struct gb_hid *ghid)
{
return gb_operation_sync(ghid->connection, GB_HID_TYPE_GET_DESC, NULL,
0, &ghid->hdesc, sizeof(ghid->hdesc));
}
static int gb_hid_get_report_desc(struct gb_hid *ghid, char *rdesc)
{
int ret;
ret = gb_pm_runtime_get_sync(ghid->bundle);
if (ret)
return ret;
ret = gb_operation_sync(ghid->connection, GB_HID_TYPE_GET_REPORT_DESC,
NULL, 0, rdesc,
le16_to_cpu(ghid->hdesc.wReportDescLength));
gb_pm_runtime_put_autosuspend(ghid->bundle);
return ret;
}
static int gb_hid_set_power(struct gb_hid *ghid, int type)
{
int ret;
ret = gb_pm_runtime_get_sync(ghid->bundle);
if (ret)
return ret;
ret = gb_operation_sync(ghid->connection, type, NULL, 0, NULL, 0);
gb_pm_runtime_put_autosuspend(ghid->bundle);
return ret;
}
static int gb_hid_get_report(struct gb_hid *ghid, u8 report_type, u8 report_id,
unsigned char *buf, int len)
{
struct gb_hid_get_report_request request;
int ret;
ret = gb_pm_runtime_get_sync(ghid->bundle);
if (ret)
return ret;
request.report_type = report_type;
request.report_id = report_id;
ret = gb_operation_sync(ghid->connection, GB_HID_TYPE_GET_REPORT,
&request, sizeof(request), buf, len);
gb_pm_runtime_put_autosuspend(ghid->bundle);
return ret;
}
static int gb_hid_set_report(struct gb_hid *ghid, u8 report_type, u8 report_id,
unsigned char *buf, int len)
{
struct gb_hid_set_report_request *request;
struct gb_operation *operation;
int ret, size = sizeof(*request) + len - 1;
ret = gb_pm_runtime_get_sync(ghid->bundle);
if (ret)
return ret;
operation = gb_operation_create(ghid->connection,
GB_HID_TYPE_SET_REPORT, size, 0,
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/hid.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/slab.h`, `linux/greybus.h`.
- Detected declarations: `struct gb_hid`, `function gb_hid_get_desc`, `function gb_hid_get_report_desc`, `function gb_hid_set_power`, `function gb_hid_get_report`, `function gb_hid_set_report`, `function gb_hid_request_handler`, `function gb_hid_report_len`, `function gb_hid_find_max_report`, `function list_for_each_entry`.
- 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.