From patchwork Fri Jul 17 02:36:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 6812221 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EDB1EC05AC for ; Fri, 17 Jul 2015 02:37:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C93A20681 for ; Fri, 17 Jul 2015 02:37:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D945D20674 for ; Fri, 17 Jul 2015 02:37:25 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 17575260451; Fri, 17 Jul 2015 04:37:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id F2BF326064C; Fri, 17 Jul 2015 04:37:15 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2836B260654; Fri, 17 Jul 2015 04:37:14 +0200 (CEST) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by alsa0.perex.cz (Postfix) with ESMTP id D9840260635 for ; Fri, 17 Jul 2015 04:37:08 +0200 (CEST) Received: by pdjr16 with SMTP id r16so54325650pdj.3 for ; Thu, 16 Jul 2015 19:37:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=Ht+5qsmReLggWgppOHVW7O3l2KFEBkIRWyQCOxe+KyI=; b=DukW0mTSwCA8aFo6SEw+3XARUuOf4i1KyMTSD7QtYAk7OmmcAt+hzGsF3UbiCFDkDA fu4hdTHhcOLAz9htzsU0SLecw1ivvw4kL8RsgG12Lisoz8l9/DPeC6HMOv+RjhFqIMWM BssZNKhTCQX9yiTtAzgRQr0k69V3hpk2yvdrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ht+5qsmReLggWgppOHVW7O3l2KFEBkIRWyQCOxe+KyI=; b=TkgVXTCBO+f96YqNsLS/7Q4rwwrIYEWI+i1PP+vOUwhmL0EGPCCot4AqeQ/Y6314Ng b1MrEjkPCWaY4BKj4Jxytba3hN6C0GuYaVlTnJpMp9wAvt4gtqCXrk9kuDh746fbl3d8 bA+0YE0d71ayb0YFOSooUK6AZXDYrDMiQpfoGGD9JWN8GAp4L80KJU6ck5z6LouWh1oA lYZKEMYVamfirIHrJ1+qL6jtbazAjGrfKTlQYbAUe7CiQrrqzsLapavzIkGsZgfDTJfZ vX42P/6utj4Sd4El/Bgs6mXE2KY4uV2G1EXii6HzQbJPMeZcsU/GmO6LVX1ful9PGKVK bqBg== X-Gm-Message-State: ALoCoQm1wfRpQrWC9RA9oG9o860vU521CCqkUJwcJGlRNAP71nr+TnlTjwsDw4QtgmvMhao1L4mu X-Received: by 10.68.193.232 with SMTP id hr8mr24663068pbc.145.1437100627833; Thu, 16 Jul 2015 19:37:07 -0700 (PDT) Received: from drinkcat.tpe.corp.google.com ([172.30.210.53]) by smtp.gmail.com with ESMTPSA id ht9sm9380986pdb.0.2015.07.16.19.37.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jul 2015 19:37:07 -0700 (PDT) From: Nicolas Boichat To: Mark Brown Date: Fri, 17 Jul 2015 10:36:57 +0800 Message-Id: <1437100617-37845-1-git-send-email-drinkcat@chromium.org> X-Mailer: git-send-email 2.4.3.573.g4eafbef Cc: Oder Chiou , alsa-devel@alsa-project.org, drinkcat@chromium.org, Takashi Iwai , Liam Girdwood , Bard Liao Subject: [alsa-devel] [PATCH v4] ASoC: rt5645: Check if codec is initialized in workqueue handler X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) {