drivers/platform/x86/lg-laptop.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/lg-laptop.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/lg-laptop.c- Extension
.c- Size
- 21178 bytes
- Lines
- 913
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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/acpi.hlinux/bitfield.hlinux/bits.hlinux/device.hlinux/dev_printk.hlinux/dmi.hlinux/input.hlinux/input/sparse-keymap.hlinux/kernel.hlinux/leds.hlinux/module.hlinux/platform_device.hlinux/string_choices.hlinux/types.hacpi/battery.h
Detected Declarations
function ggovfunction wmi_notifyfunction wmi_input_setupfunction fan_mode_storefunction fan_mode_showfunction usb_charge_storefunction usb_charge_showfunction reader_mode_storefunction reader_mode_showfunction fn_lock_storefunction fn_lock_showfunction charge_control_end_threshold_storefunction charge_control_end_threshold_showfunction battery_care_limit_showfunction battery_care_limit_storefunction lg_battery_addfunction lg_battery_removefunction tpad_led_setfunction tpad_led_getfunction kbd_backlight_setfunction get_kbd_backlight_levelfunction kbd_backlight_getfunction wmi_input_destroyfunction lg_laptop_address_space_writefunction lg_laptop_address_space_readfunction lg_laptop_address_space_handlerfunction lg_laptop_remove_address_space_handlerfunction acpi_probefunction acpi_remove
Annotated Snippet
if (eventcode == 0x10000000) {
led_classdev_notify_brightness_hw_changed(
&kbd_backlight, get_kbd_backlight_level(kbd_backlight.dev->parent));
} else {
key = sparse_keymap_entry_from_scancode(
wmi_input_dev, eventcode);
if (key && key->type == KE_KEY)
sparse_keymap_report_entry(wmi_input_dev,
key, 1, true);
}
}
pr_debug("Type: %i Eventcode: 0x%llx\n", obj->type,
obj->integer.value);
}
static void wmi_input_setup(void)
{
acpi_status status;
wmi_input_dev = input_allocate_device();
if (wmi_input_dev) {
wmi_input_dev->name = "LG WMI hotkeys";
wmi_input_dev->phys = "wmi/input0";
wmi_input_dev->id.bustype = BUS_HOST;
if (sparse_keymap_setup(wmi_input_dev, wmi_keymap, NULL) ||
input_register_device(wmi_input_dev)) {
pr_info("Cannot initialize input device");
input_free_device(wmi_input_dev);
return;
}
inited |= INIT_SPARSE_KEYMAP;
status = wmi_install_notify_handler(WMI_EVENT_GUID0, wmi_notify,
(void *)0);
if (ACPI_SUCCESS(status))
inited |= INIT_INPUT_WMI_0;
status = wmi_install_notify_handler(WMI_EVENT_GUID2, wmi_notify,
(void *)2);
if (ACPI_SUCCESS(status))
inited |= INIT_INPUT_WMI_2;
} else {
pr_info("Cannot allocate input device");
}
}
static ssize_t fan_mode_store(struct device *dev,
struct device_attribute *attr,
const char *buffer, size_t count)
{
unsigned long value;
union acpi_object *r;
int ret;
ret = kstrtoul(buffer, 10, &value);
if (ret)
return ret;
if (value >= 3)
return -EINVAL;
r = lg_wmab(dev, WM_FAN_MODE, WM_SET,
FIELD_PREP(FAN_MODE_LOWER, value) |
FIELD_PREP(FAN_MODE_UPPER, value));
kfree(r);
return count;
}
static ssize_t fan_mode_show(struct device *dev,
struct device_attribute *attr, char *buffer)
{
unsigned int mode;
union acpi_object *r;
r = lg_wmab(dev, WM_FAN_MODE, WM_GET, 0);
if (!r)
return -EIO;
if (r->type != ACPI_TYPE_INTEGER) {
kfree(r);
return -EIO;
}
mode = FIELD_GET(FAN_MODE_LOWER, r->integer.value);
kfree(r);
return sysfs_emit(buffer, "%d\n", mode);
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/device.h`, `linux/dev_printk.h`, `linux/dmi.h`, `linux/input.h`, `linux/input/sparse-keymap.h`.
- Detected declarations: `function ggov`, `function wmi_notify`, `function wmi_input_setup`, `function fan_mode_store`, `function fan_mode_show`, `function usb_charge_store`, `function usb_charge_show`, `function reader_mode_store`, `function reader_mode_show`, `function fn_lock_store`.
- Atlas domain: Driver Families / drivers/platform.
- 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.