drivers/hid/hid-retrode.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-retrode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-retrode.c- Extension
.c- Size
- 2037 bytes
- Lines
- 99
- 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
linux/input.hlinux/slab.hlinux/hid.hlinux/module.hhid-ids.h
Detected Declarations
function Copyrightfunction retrode_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* HID driver for Retrode 2 controller adapter and plug-in extensions
*
* Copyright (c) 2017 Bastien Nocera <hadess@hadess.net>
*/
/*
*/
#include <linux/input.h>
#include <linux/slab.h>
#include <linux/hid.h>
#include <linux/module.h>
#include "hid-ids.h"
#define CONTROLLER_NAME_BASE "Retrode"
static int retrode_input_configured(struct hid_device *hdev,
struct hid_input *hi)
{
struct hid_field *field = hi->report->field[0];
const char *suffix;
int number = 0;
char *name;
switch (field->report->id) {
case 0:
suffix = "SNES Mouse";
break;
case 1:
case 2:
suffix = "SNES / N64";
number = field->report->id;
break;
case 3:
case 4:
suffix = "Mega Drive";
number = field->report->id - 2;
break;
default:
hid_err(hdev, "Got unhandled report id %d\n", field->report->id);
suffix = "Unknown";
}
if (number)
name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
"%s %s #%d", CONTROLLER_NAME_BASE,
suffix, number);
else
name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
"%s %s", CONTROLLER_NAME_BASE, suffix);
if (!name)
return -ENOMEM;
hi->input->name = name;
return 0;
}
static int retrode_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
int ret;
/* Has no effect on the mouse device */
hdev->quirks |= HID_QUIRK_MULTI_INPUT;
ret = hid_parse(hdev);
if (ret)
return ret;
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (ret)
return ret;
return 0;
}
static const struct hid_device_id retrode_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_FUTURE_TECHNOLOGY, USB_DEVICE_ID_RETRODE2) },
{ }
};
MODULE_DEVICE_TABLE(hid, retrode_devices);
static struct hid_driver retrode_driver = {
.name = "hid-retrode",
.id_table = retrode_devices,
Annotation
- Immediate include surface: `linux/input.h`, `linux/slab.h`, `linux/hid.h`, `linux/module.h`, `hid-ids.h`.
- Detected declarations: `function Copyright`, `function retrode_probe`.
- 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.