drivers/platform/x86/sony-laptop.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/sony-laptop.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/sony-laptop.c- Extension
.c- Size
- 117871 bytes
- Lines
- 4751
- Domain
- Driver Families
- Bucket
- drivers/platform
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/types.hlinux/backlight.hlinux/platform_device.hlinux/err.hlinux/dmi.hlinux/pci.hlinux/interrupt.hlinux/delay.hlinux/input.hlinux/kfifo.hlinux/workqueue.hlinux/acpi.hlinux/slab.hlinux/sonypi.hlinux/rfkill.hlinux/poll.hlinux/miscdevice.hlinux/uaccess.hacpi/video.h
Detected Declarations
struct sony_laptop_input_sstruct sony_laptop_keypressstruct sony_nc_valuestruct sony_nc_handlesstruct sony_backlight_propsstruct sony_nc_eventstruct kbd_backlightstruct battery_care_controlstruct snc_thermal_ctrlstruct snc_lid_resume_controlstruct snc_gfx_switch_controlstruct touchpad_controlstruct sony_pic_ioportstruct sony_pic_irqstruct sonypi_eventtypesstruct sony_pic_devstruct sonypi_eventstruct sonypi_compat_senum sony_nc_rfkillenum event_typesenum gfx_switchfunction do_sony_laptop_release_keyfunction sony_laptop_report_input_eventfunction sony_laptop_setup_inputfunction sony_laptop_remove_inputfunction sony_pf_addfunction sony_pf_removefunction sony_nc_buffer_callfunction sony_nc_int_callfunction sony_nc_handles_showfunction sony_nc_handles_setupfunction sony_nc_handles_cleanupfunction sony_find_snc_handlefunction sony_call_snc_handlefunction brightness_default_validatefunction boolean_validatefunction sony_nc_sysfs_showfunction sony_nc_sysfs_storefunction sony_backlight_update_statusfunction sony_backlight_get_brightnessfunction sony_nc_get_brightness_ngfunction sony_nc_update_status_ngfunction sony_nc_hotkeys_decodefunction sony_nc_notifyfunction sony_walk_callbackfunction sony_nc_function_setupfunction sony_nc_function_cleanupfunction sony_nc_function_resume
Annotated Snippet
static const struct file_operations sonypi_misc_fops = {
.owner = THIS_MODULE,
.read = sonypi_misc_read,
.poll = sonypi_misc_poll,
.open = sonypi_misc_open,
.release = sonypi_misc_release,
.fasync = sonypi_misc_fasync,
.unlocked_ioctl = sonypi_misc_ioctl,
.llseek = noop_llseek,
};
static struct miscdevice sonypi_misc_device = {
.minor = MISC_DYNAMIC_MINOR,
.name = "sonypi",
.fops = &sonypi_misc_fops,
};
static void sonypi_compat_report_event(u8 event)
{
kfifo_in_locked(&sonypi_compat.fifo, (unsigned char *)&event,
sizeof(event), &sonypi_compat.fifo_lock);
kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN);
wake_up_interruptible(&sonypi_compat.fifo_proc_list);
}
static int sonypi_compat_init(void)
{
int error;
spin_lock_init(&sonypi_compat.fifo_lock);
error =
kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
if (error) {
pr_err("kfifo_alloc failed\n");
return error;
}
init_waitqueue_head(&sonypi_compat.fifo_proc_list);
if (minor != -1)
sonypi_misc_device.minor = minor;
error = misc_register(&sonypi_misc_device);
if (error) {
pr_err("misc_register failed\n");
goto err_free_kfifo;
}
if (minor == -1)
pr_info("device allocated minor is %d\n",
sonypi_misc_device.minor);
return 0;
err_free_kfifo:
kfifo_free(&sonypi_compat.fifo);
return error;
}
static void sonypi_compat_exit(void)
{
misc_deregister(&sonypi_misc_device);
kfifo_free(&sonypi_compat.fifo);
}
#else
static int sonypi_compat_init(void) { return 0; }
static void sonypi_compat_exit(void) { }
static void sonypi_compat_report_event(u8 event) { }
#endif /* CONFIG_SONYPI_COMPAT */
/*
* ACPI callbacks
*/
static acpi_status
sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
{
u32 i;
struct sony_pic_dev *dev = (struct sony_pic_dev *)context;
switch (resource->type) {
case ACPI_RESOURCE_TYPE_START_DEPENDENT:
{
/* start IO enumeration */
struct sony_pic_ioport *ioport = kzalloc_obj(*ioport);
if (!ioport)
return AE_ERROR;
list_add(&ioport->list, &dev->ioports);
return AE_OK;
}
case ACPI_RESOURCE_TYPE_END_DEPENDENT:
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/types.h`, `linux/backlight.h`, `linux/platform_device.h`, `linux/err.h`.
- Detected declarations: `struct sony_laptop_input_s`, `struct sony_laptop_keypress`, `struct sony_nc_value`, `struct sony_nc_handles`, `struct sony_backlight_props`, `struct sony_nc_event`, `struct kbd_backlight`, `struct battery_care_control`, `struct snc_thermal_ctrl`, `struct snc_lid_resume_control`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.