platform/x86: samsung-galaxybook: Refactor camera lens cover input device

Rename the camera_lens_cover_switch input device to a generic input
device which can be used for multiple input events. Move input device
allocation and registration into a dedicated galaxybook_input_init()
helper which is called early in probe so that the device is available
to all features.

No functional change.

Signed-off-by: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
Link: https://patch.msgid.link/20260418004613.93981-2-ayaanmirzabaig85@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
Ayaan Mirza Baig
2026-04-18 00:46:13 +00:00
committed by Ilpo Järvinen
parent 863810d498
commit 72d52bac02

View File

@@ -53,7 +53,7 @@ struct samsung_galaxybook {
void *i8042_filter_ptr;
struct work_struct block_recording_hotkey_work;
struct input_dev *camera_lens_cover_switch;
struct input_dev *input;
struct acpi_battery_hook battery_hook;
@@ -859,13 +859,28 @@ static int block_recording_acpi_set(struct samsung_galaxybook *galaxybook, const
if (err)
return err;
input_report_switch(galaxybook->camera_lens_cover_switch,
input_report_switch(galaxybook->input,
SW_CAMERA_LENS_COVER, value ? 1 : 0);
input_sync(galaxybook->camera_lens_cover_switch);
input_sync(galaxybook->input);
return 0;
}
static int galaxybook_input_init(struct samsung_galaxybook *galaxybook)
{
galaxybook->input = devm_input_allocate_device(&galaxybook->platform->dev);
if (!galaxybook->input)
return -ENOMEM;
galaxybook->input->name = "Samsung Galaxy Book Camera Lens Cover";
galaxybook->input->phys = DRIVER_NAME "/input0";
galaxybook->input->id.bustype = BUS_HOST;
input_set_capability(galaxybook->input, EV_SW, SW_CAMERA_LENS_COVER);
return input_register_device(galaxybook->input);
}
static int galaxybook_block_recording_init(struct samsung_galaxybook *galaxybook)
{
bool value;
@@ -887,24 +902,8 @@ static int galaxybook_block_recording_init(struct samsung_galaxybook *galaxybook
return GB_NOT_SUPPORTED;
}
galaxybook->camera_lens_cover_switch =
devm_input_allocate_device(&galaxybook->platform->dev);
if (!galaxybook->camera_lens_cover_switch)
return -ENOMEM;
galaxybook->camera_lens_cover_switch->name = "Samsung Galaxy Book Camera Lens Cover";
galaxybook->camera_lens_cover_switch->phys = DRIVER_NAME "/input0";
galaxybook->camera_lens_cover_switch->id.bustype = BUS_HOST;
input_set_capability(galaxybook->camera_lens_cover_switch, EV_SW, SW_CAMERA_LENS_COVER);
err = input_register_device(galaxybook->camera_lens_cover_switch);
if (err)
return err;
input_report_switch(galaxybook->camera_lens_cover_switch,
SW_CAMERA_LENS_COVER, value ? 1 : 0);
input_sync(galaxybook->camera_lens_cover_switch);
input_report_switch(galaxybook->input, SW_CAMERA_LENS_COVER, value ? 1 : 0);
input_sync(galaxybook->input);
return 0;
}
@@ -1392,6 +1391,11 @@ static int galaxybook_probe(struct platform_device *pdev)
return dev_err_probe(&galaxybook->platform->dev, err,
"failed to initialize kbd_backlight\n");
err = galaxybook_input_init(galaxybook);
if (err)
return dev_err_probe(&galaxybook->platform->dev, err,
"failed to initialize input device\n");
err = galaxybook_fw_attrs_init(galaxybook);
if (err)
return dev_err_probe(&galaxybook->platform->dev, err,