SoC: rt274: Fix internal jack assignment in set_jack callback
authorAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Wed, 5 Jun 2019 13:45:52 +0000 (15:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jul 2019 07:54:34 +0000 (09:54 +0200)
commit3904ebeaf899354d57d66ab484e276b39d0a8682
treebe6f60f2118d1a3e520d3d083808642ee3b0f868
parentb38688abdc2e68fac0c826e8d3391b3509003d8c
SoC: rt274: Fix internal jack assignment in set_jack callback

[ Upstream commit 04268bf2757a125616b6c2140e6250f43b7b737a ]

When we call snd_soc_component_set_jack(component, NULL, NULL) we should
set rt274->jack to passed jack, so when interrupt is triggered it calls
snd_soc_jack_report(rt274->jack, ...) with proper value.

This fixes problem in machine where in register, we call
snd_soc_register(component, &headset, NULL), which just calls
rt274_mic_detect via callback.
Now when machine driver is removed "headset" will be gone, so we
need to tell codec driver that it's gone with:
snd_soc_register(component, NULL, NULL), but we also need to be able
to handle NULL jack argument here gracefully.
If we don't set it to NULL, next time the rt274_irq runs it will call
snd_soc_jack_report with first argument being invalid pointer and there
will be Oops.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/codecs/rt274.c