interconnect: qcom: sdm845: Walk the list safely on node removal
[linux/fpc-iii.git] / sound / pci / hda / thinkpad_helper.c
blob4089feb8c68e339fc33bbbb26591a13b909daf0f
1 // SPDX-License-Identifier: GPL-2.0
2 /* Helper functions for Thinkpad LED control;
3 * to be included from codec driver
4 */
6 #if IS_ENABLED(CONFIG_THINKPAD_ACPI) && IS_REACHABLE(CONFIG_LEDS_TRIGGER_AUDIO)
8 #include <linux/acpi.h>
9 #include <linux/leds.h>
11 static void (*old_vmaster_hook)(void *, int);
13 static bool is_thinkpad(struct hda_codec *codec)
15 return (codec->core.subsystem_id >> 16 == 0x17aa) &&
16 (acpi_dev_found("LEN0068") || acpi_dev_found("LEN0268") ||
17 acpi_dev_found("IBM0068"));
20 static void update_tpacpi_mute_led(void *private_data, int enabled)
22 if (old_vmaster_hook)
23 old_vmaster_hook(private_data, enabled);
25 ledtrig_audio_set(LED_AUDIO_MUTE, enabled ? LED_OFF : LED_ON);
28 static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
29 const struct hda_fixup *fix, int action)
31 struct hda_gen_spec *spec = codec->spec;
33 if (action == HDA_FIXUP_ACT_PROBE) {
34 if (!is_thinkpad(codec))
35 return;
36 old_vmaster_hook = spec->vmaster_mute.hook;
37 spec->vmaster_mute.hook = update_tpacpi_mute_led;
38 snd_hda_gen_fixup_micmute_led(codec, fix, action);
42 #else /* CONFIG_THINKPAD_ACPI */
44 static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
45 const struct hda_fixup *fix, int action)
49 #endif /* CONFIG_THINKPAD_ACPI */