[alsa-devel] [PATCH v4] ASoC: rt5645: Check if codec is initialized in workqueue handler
This fixes kernel panic on boot, if rt5645->codec is NULL when rt5645_jack_detect_work is first called.
rt5645_jack_detect_work needs rt5645->codec to be initialized to setup dapm pins. Also, reporting jack events is useless, as the jacks cannot be set before the codec is ready.
Since we manually call the interrupt handler in rt5645_set_jack_detect, the initial jack state will be reported correctly, and dapm pins will be setup at that time.
Signed-off-by: Nicolas Boichat drinkcat@chromium.org --- This replaces 3c2234569cfff83718792f810a9bb855b78c2473, and applies on top of Linux 4.2-rc1, so that this patch can be applied in its own branch, without triggering a compile warning.
Also, reworded the message to make it more obvious this can cause a kernel panic.
Thanks!
sound/soc/codecs/rt5645.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 9ce311e..e9cc3aa 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -2943,6 +2943,9 @@ static int rt5645_irq_detection(struct rt5645_priv *rt5645) { int val, btn_type, gpio_state = 0, report = 0;
+ if (!rt5645->codec) + return -EINVAL; + switch (rt5645->pdata.jd_mode) { case 0: /* Not using rt5645 JD */ if (rt5645->gpiod_hp_det) {
On Fri, Jul 17, 2015 at 10:36:57AM +0800, Nicolas Boichat wrote:
This replaces 3c2234569cfff83718792f810a9bb855b78c2473, and applies on top of Linux 4.2-rc1, so that this patch can be applied in its own branch, without triggering a compile warning.
Please provide human readable descriptions of commits so your mails are directly readable.
On Fri, Jul 17, 2015 at 7:12 PM, Mark Brown broonie@kernel.org wrote:
On Fri, Jul 17, 2015 at 10:36:57AM +0800, Nicolas Boichat wrote:
This replaces 3c2234569cfff83718792f810a9bb855b78c2473, and applies on top of Linux 4.2-rc1, so that this patch can be applied in its own branch, without triggering a compile warning.
Please provide human readable descriptions of commits so your mails are directly readable.
Noted, sorry about that.
3c2234569cfff83718792f810a9bb855b78c2473 is "ASoC: rt5645: Check if codec is initialized in workqueue handler" (same commit title), which you applied yesterday on fix/rt5645, and, as it stands, triggers a compile-time warning as it depends on "ASoC: rt5645: Remove irq_jack_detection function", which you applied on topic/rt5645 3 days ago.
Note that, after you replace the commit in fix/rt5645, and merge topic/rt5645, we'll need to remove the return value, as the hunk above will have moved from irq_jack_detection to rt5645_jack_detect_work, which returns void (this probably won't appear as an obvious merge conflict...).
I'll provide a patch for that, if you are ok with replacing the commit above (otherwise we'll need 2 short patches: one in fix/rt5645, and revert it in topic/rt5645).
Thanks!
On Fri, Jul 17, 2015 at 08:07:50PM +0800, Nicolas Boichat wrote:
Note that, after you replace the commit in fix/rt5645, and merge topic/rt5645, we'll need to remove the return value, as the hunk above
That's already been done.
will have moved from irq_jack_detection to rt5645_jack_detect_work, which returns void (this probably won't appear as an obvious merge conflict...).
I'll provide a patch for that, if you are ok with replacing the commit above (otherwise we'll need 2 short patches: one in fix/rt5645, and revert it in topic/rt5645).
Yes, please send those patches.
participants (2)
-
Mark Brown
-
Nicolas Boichat