drivers/hid/hid-kysona.c
Source file repositories/reference/linux-study-clean/drivers/hid/hid-kysona.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/hid-kysona.c- Extension
.c- Size
- 7791 bytes
- Lines
- 293
- 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.
- 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/device.hlinux/hid.hlinux/usb.hhid-ids.h
Detected Declarations
struct kysona_drvdatafunction kysona_battery_get_propertyfunction kysona_m600_fetch_onlinefunction kysona_fetch_onlinefunction kysona_m600_fetch_batteryfunction kysona_fetch_batteryfunction kysona_battery_timer_tickfunction kysona_battery_probefunction kysona_probefunction kysona_raw_eventfunction kysona_remove
Annotated Snippet
struct kysona_drvdata {
struct hid_device *hdev;
bool online;
struct power_supply_desc battery_desc;
struct power_supply *battery;
u8 battery_capacity;
bool battery_charging;
u16 battery_voltage;
struct delayed_work battery_work;
};
static enum power_supply_property kysona_battery_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
POWER_SUPPLY_PROP_ONLINE
};
static int kysona_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct kysona_drvdata *drv_data = power_supply_get_drvdata(psy);
int ret = 0;
switch (psp) {
case POWER_SUPPLY_PROP_PRESENT:
val->intval = 1;
break;
case POWER_SUPPLY_PROP_ONLINE:
val->intval = drv_data->online;
break;
case POWER_SUPPLY_PROP_STATUS:
if (drv_data->online)
val->intval = drv_data->battery_charging ?
POWER_SUPPLY_STATUS_CHARGING :
POWER_SUPPLY_STATUS_DISCHARGING;
else
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
break;
case POWER_SUPPLY_PROP_SCOPE:
val->intval = POWER_SUPPLY_SCOPE_DEVICE;
break;
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = drv_data->battery_capacity;
break;
case POWER_SUPPLY_PROP_VOLTAGE_NOW:
/* hardware reports voltage in mV. sysfs expects uV */
val->intval = drv_data->battery_voltage * 1000;
break;
case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = drv_data->hdev->name;
break;
default:
ret = -EINVAL;
break;
}
return ret;
}
static const char kysona_online_request[] = {
0x08, ONLINE_REPORT_ID, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a
};
static const char kysona_battery_request[] = {
0x08, BATTERY_REPORT_ID, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49
};
static int kysona_m600_fetch_online(struct hid_device *hdev)
{
u8 *write_buf;
int ret;
/* Request online information */
write_buf = kmemdup(kysona_online_request, sizeof(kysona_online_request), GFP_KERNEL);
if (!write_buf)
return -ENOMEM;
ret = hid_hw_raw_request(hdev, kysona_online_request[0],
write_buf, sizeof(kysona_online_request),
HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
if (ret < (int)sizeof(kysona_online_request)) {
hid_err(hdev, "hid_hw_raw_request() failed with %d\n", ret);
ret = -ENODATA;
Annotation
- Immediate include surface: `linux/device.h`, `linux/hid.h`, `linux/usb.h`, `hid-ids.h`.
- Detected declarations: `struct kysona_drvdata`, `function kysona_battery_get_property`, `function kysona_m600_fetch_online`, `function kysona_fetch_online`, `function kysona_m600_fetch_battery`, `function kysona_fetch_battery`, `function kysona_battery_timer_tick`, `function kysona_battery_probe`, `function kysona_probe`, `function kysona_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.