hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/platform/x86/dell-laptop.c
....@@ -1,16 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Driver for Dell laptop extras
34 *
45 * Copyright (c) Red Hat <mjg@redhat.com>
56 * Copyright (c) 2014 Gabriele Mazzotta <gabriele.mzt@gmail.com>
6
- * Copyright (c) 2014 Pali Rohár <pali.rohar@gmail.com>
7
+ * Copyright (c) 2014 Pali Rohár <pali@kernel.org>
78 *
89 * Based on documentation in the libsmbios package:
910 * Copyright (C) 2005-2014 Dell Inc.
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License version 2 as
13
- * published by the Free Software Foundation.
1411 */
1512
1613 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -29,7 +26,6 @@
2926 #include <linux/mm.h>
3027 #include <linux/i8042.h>
3128 #include <linux/debugfs.h>
32
-#include <linux/dell-led.h>
3329 #include <linux/seq_file.h>
3430 #include <acpi/video.h>
3531 #include "dell-rbtn.h"
....@@ -1591,8 +1587,10 @@
15911587 switch (unit) {
15921588 case KBD_TIMEOUT_DAYS:
15931589 value *= 24;
1590
+ fallthrough;
15941591 case KBD_TIMEOUT_HOURS:
15951592 value *= 60;
1593
+ fallthrough;
15961594 case KBD_TIMEOUT_MINUTES:
15971595 value *= 60;
15981596 unit = KBD_TIMEOUT_SECONDS;
....@@ -2135,17 +2133,17 @@
21352133 .notifier_call = dell_laptop_notifier_call,
21362134 };
21372135
2138
-int dell_micmute_led_set(int state)
2136
+static int micmute_led_set(struct led_classdev *led_cdev,
2137
+ enum led_brightness brightness)
21392138 {
21402139 struct calling_interface_buffer buffer;
21412140 struct calling_interface_token *token;
2141
+ int state = brightness != LED_OFF;
21422142
21432143 if (state == 0)
21442144 token = dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE);
2145
- else if (state == 1)
2146
- token = dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE);
21472145 else
2148
- return -EINVAL;
2146
+ token = dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE);
21492147
21502148 if (!token)
21512149 return -ENODEV;
....@@ -2153,9 +2151,15 @@
21532151 dell_fill_request(&buffer, token->location, token->value, 0, 0);
21542152 dell_send_request(&buffer, CLASS_TOKEN_WRITE, SELECT_TOKEN_STD);
21552153
2156
- return state;
2154
+ return 0;
21572155 }
2158
-EXPORT_SYMBOL_GPL(dell_micmute_led_set);
2156
+
2157
+static struct led_classdev micmute_led_cdev = {
2158
+ .name = "platform::micmute",
2159
+ .max_brightness = 1,
2160
+ .brightness_set_blocking = micmute_led_set,
2161
+ .default_trigger = "audio-micmute",
2162
+};
21592163
21602164 static int __init dell_init(void)
21612165 {
....@@ -2195,11 +2199,18 @@
21952199 kbd_led_init(&platform_device->dev);
21962200
21972201 dell_laptop_dir = debugfs_create_dir("dell_laptop", NULL);
2198
- if (dell_laptop_dir != NULL)
2199
- debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
2200
- &dell_debugfs_fops);
2202
+ debugfs_create_file("rfkill", 0444, dell_laptop_dir, NULL,
2203
+ &dell_debugfs_fops);
22012204
22022205 dell_laptop_register_notifier(&dell_laptop_notifier);
2206
+
2207
+ if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
2208
+ dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) {
2209
+ micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
2210
+ ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev);
2211
+ if (ret < 0)
2212
+ goto fail_led;
2213
+ }
22032214
22042215 if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
22052216 return 0;
....@@ -2246,6 +2257,8 @@
22462257 fail_get_brightness:
22472258 backlight_device_unregister(dell_backlight_device);
22482259 fail_backlight:
2260
+ led_classdev_unregister(&micmute_led_cdev);
2261
+fail_led:
22492262 dell_cleanup_rfkill();
22502263 fail_rfkill:
22512264 platform_device_del(platform_device);
....@@ -2265,6 +2278,7 @@
22652278 touchpad_led_exit();
22662279 kbd_led_exit();
22672280 backlight_device_unregister(dell_backlight_device);
2281
+ led_classdev_unregister(&micmute_led_cdev);
22682282 dell_cleanup_rfkill();
22692283 if (platform_device) {
22702284 platform_device_unregister(platform_device);
....@@ -2284,6 +2298,6 @@
22842298
22852299 MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
22862300 MODULE_AUTHOR("Gabriele Mazzotta <gabriele.mzt@gmail.com>");
2287
-MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
2301
+MODULE_AUTHOR("Pali Rohár <pali@kernel.org>");
22882302 MODULE_DESCRIPTION("Dell laptop driver");
22892303 MODULE_LICENSE("GPL");