[PATCH 4/4] FIXUP platform/x86: dell-privacy: Add support for Dell hardware privacy

From: Hans de Goede
Date: Tue May 18 2021 - 06:56:13 EST


More fixups for "platform/x86: dell-privacy: Add support for
Dell hardware privacy":

1. The remove function of a wmi_driver returns void now.

2. Rename dell_privacy_present() to dell_privacy_has_mic_mute() to better
reflect what it does (it returns:
priv && (priv->features_present & BIT(DELL_PRIVACY_TYPE_AUDIO)))
Also make the stub for it return false, rather then -ENODEV which will
be interpreted as true, breaking dell-laptop micmute-LED support when
CONFIG_DELL_WMI_PRIVACY is not set.

3. Update the comment about the mic-mute flow to remove the reference to the
no longer existing dell-privacy-acpi driver.

4. Add a MAINTAINERS entry for dell-wmi-privacy.c

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
MAINTAINERS | 7 +++++++
drivers/platform/x86/dell/dell-laptop.c | 2 +-
drivers/platform/x86/dell/dell-wmi-privacy.c | 21 ++++++++------------
drivers/platform/x86/dell/dell-wmi-privacy.h | 6 +++---
4 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index f4bb5a101989..9d8ba41b7de8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5172,6 +5172,13 @@ M: Pali Rohár <pali@xxxxxxxxxx>
S: Maintained
F: drivers/platform/x86/dell/dell-wmi-base.c

+DELL WMI HARDWARE PRIVACY SUPPORT
+M: Perry Yuan <Perry.Yuan@xxxxxxxx>
+L: Dell.Client.Kernel@xxxxxxxx
+L: platform-driver-x86@xxxxxxxxxxxxxxx
+S: Maintained
+F: drivers/platform/x86/dell/dell-wmi-privacy.c
+
DELTA ST MEDIA DRIVER
M: Hugues Fruchet <hugues.fruchet@xxxxxxxxxxx>
L: linux-media@xxxxxxxxxxxxxxx
diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
index 63874982cadb..8230e7a68a5e 100644
--- a/drivers/platform/x86/dell/dell-laptop.c
+++ b/drivers/platform/x86/dell/dell-laptop.c
@@ -2209,7 +2209,7 @@ static int __init dell_init(void)

if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE) &&
- !dell_privacy_present()) {
+ !dell_privacy_has_mic_mute()) {
micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
ret = led_classdev_register(&platform_device->dev, &micmute_led_cdev);
if (ret < 0)
diff --git a/drivers/platform/x86/dell/dell-wmi-privacy.c b/drivers/platform/x86/dell/dell-wmi-privacy.c
index 9a36b110a314..074b7e68c227 100644
--- a/drivers/platform/x86/dell/dell-wmi-privacy.c
+++ b/drivers/platform/x86/dell/dell-wmi-privacy.c
@@ -65,11 +65,7 @@ static const struct key_entry dell_wmi_keymap_type_0012[] = {
{ KE_END, 0},
};

-/*
- * global privacy state for other modules to query if the privacy driver loaded successfully
- * or no privacy WMI device was detected at initial probe phase
- */
-bool dell_privacy_present(void)
+bool dell_privacy_has_mic_mute(void)
{
struct privacy_wmi_data *priv;

@@ -81,7 +77,7 @@ bool dell_privacy_present(void)

return priv && (priv->features_present & BIT(DELL_PRIVACY_TYPE_AUDIO));
}
-EXPORT_SYMBOL_GPL(dell_privacy_present);
+EXPORT_SYMBOL_GPL(dell_privacy_has_mic_mute);

/*
* The flow of privacy event:
@@ -90,11 +86,11 @@ EXPORT_SYMBOL_GPL(dell_privacy_present);
* 3) WMI event is received by dell-privacy
* 4) KEY_MICMUTE emitted from dell-privacy
* 5) Userland picks up key and modifies kcontrol for SW mute
- * 6) Codec kernel driver catches and calls ledtrig_audio_set defined by
- * dell-privacy-acpi driver. Codec driver will call like this to switch micmute led state.
- * ledtrig_audio_set(LED_AUDIO_MICMUTE, micmute_led ? LED_ON :LED_OFF);
- * 7) If "LED" is set to on dell-privacy notifies EC,and timeout is cancelled,
- * HW mic mute activated.
+ * 6) Codec kernel driver catches and calls ledtrig_audio_set which will call
+ * led_set_brightness() on the LED registered by dell_privacy_leds_setup()
+ * 7) dell-privacy notifies EC, the timeout is cancelled and the HW mute activates.
+ * If the EC is not notified then the HW mic mute will activate when the timeout
+ * triggers, just a bit later than with the active ack.
*/
bool dell_privacy_process_event(int type, int code, int status)
{
@@ -361,14 +357,13 @@ static int dell_privacy_wmi_probe(struct wmi_device *wdev, const void *context)
return 0;
}

-static int dell_privacy_wmi_remove(struct wmi_device *wdev)
+static void dell_privacy_wmi_remove(struct wmi_device *wdev)
{
struct privacy_wmi_data *priv = dev_get_drvdata(&wdev->dev);

mutex_lock(&list_mutex);
list_del(&priv->list);
mutex_unlock(&list_mutex);
- return 0;
}

static const struct wmi_device_id dell_wmi_privacy_wmi_id_table[] = {
diff --git a/drivers/platform/x86/dell/dell-wmi-privacy.h b/drivers/platform/x86/dell/dell-wmi-privacy.h
index b139b644f004..50c9b943dd47 100644
--- a/drivers/platform/x86/dell/dell-wmi-privacy.h
+++ b/drivers/platform/x86/dell/dell-wmi-privacy.h
@@ -9,14 +9,14 @@
#define _DELL_PRIVACY_WMI_H_

#if IS_ENABLED(CONFIG_DELL_WMI_PRIVACY)
-bool dell_privacy_present(void);
+bool dell_privacy_has_mic_mute(void);
bool dell_privacy_process_event(int type, int code, int status);
int dell_privacy_register_driver(void);
void dell_privacy_unregister_driver(void);
#else /* CONFIG_DELL_PRIVACY */
-static inline bool dell_privacy_present(void)
+static inline bool dell_privacy_has_mic_mute(void)
{
- return -ENODEV;
+ return false;
}

static inline bool dell_privacy_process_event(int type, int code, int status)
--
2.31.1


--------------F32F92C122EA19D8A3A8554E--