drivers/hid/hid-rapoo.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-rapoo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-rapoo.c- Extension
.c- Size
- 2285 bytes
- Lines
- 102
- Domain
- Driver Families
- Bucket
- drivers/hid
- 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
asm-generic/errno-base.hasm-generic/int-ll64.hlinux/bitops.hlinux/input.hlinux/input-event-codes.hlinux/module.hlinux/hid.hlinux/usb.hhid-ids.h
Detected Declarations
function rapoo_probefunction rapoo_raw_event
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <asm-generic/errno-base.h>
#include <asm-generic/int-ll64.h>
#include <linux/bitops.h>
#include <linux/input.h>
#include <linux/input-event-codes.h>
#include <linux/module.h>
#include <linux/hid.h>
#include <linux/usb.h>
#include "hid-ids.h"
#define RAPOO_BTN_BACK 0x08
#define RAPOO_BTN_FORWARD 0x10
static const struct hid_device_id rapoo_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_RAPOO, USB_DEVICE_ID_RAPOO_2_4G_RECEIVER) },
{ }
};
MODULE_DEVICE_TABLE(hid, rapoo_devices);
static int rapoo_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
int ret;
struct input_dev *input;
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
return ret;
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (ret) {
hid_err(hdev, "start failed\n");
return ret;
}
if (hdev->bus == BUS_USB) {
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
return 0;
}
input = devm_input_allocate_device(&hdev->dev);
if (!input)
return -ENOMEM;
input->name = "Rapoo 2.4G Wireless Mouse";
input->phys = "rapoo/input1";
input->id.bustype = hdev->bus;
input->id.vendor = hdev->vendor;
input->id.product = hdev->product;
input->id.version = hdev->version;
__set_bit(EV_KEY, input->evbit);
__set_bit(KEY_BACK, input->keybit);
__set_bit(KEY_FORWARD, input->keybit);
ret = input_register_device(input);
if (ret)
return ret;
hid_set_drvdata(hdev, input);
return ret;
}
static int rapoo_raw_event(struct hid_device *hdev, struct hid_report *report, u8 *data, int size)
{
struct input_dev *input = hid_get_drvdata(hdev);
if (!input)
return 0;
if (report->id == 1 && size >= 2) {
u8 btn = data[1];
input_report_key(input, KEY_BACK, btn & RAPOO_BTN_BACK);
input_report_key(input, KEY_FORWARD, btn & RAPOO_BTN_FORWARD);
input_sync(input);
return 1;
}
return 0;
}
static struct hid_driver rapoo_driver = {
.name = "hid-rapoo",
Annotation
- Immediate include surface: `asm-generic/errno-base.h`, `asm-generic/int-ll64.h`, `linux/bitops.h`, `linux/input.h`, `linux/input-event-codes.h`, `linux/module.h`, `linux/hid.h`, `linux/usb.h`.
- Detected declarations: `function rapoo_probe`, `function rapoo_raw_event`.
- Atlas domain: Driver Families / drivers/hid.
- 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.