Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp249704ybd; Tue, 25 Jun 2019 20:43:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+8BEsTHkoQfm/nTZOFIEVNSxnlChKWg2yPZ6hOtEcUmSFTM5R+L6itIO42K2qzxFUhMKB X-Received: by 2002:a17:902:6506:: with SMTP id b6mr2383282plk.253.1561520634445; Tue, 25 Jun 2019 20:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520634; cv=none; d=google.com; s=arc-20160816; b=UJXLXfhPpM4Kok8ZkUfsq2vzJLeYM1wGUVzlcmvftGuWOtvaWcPD1dFOE1wk4IVPHn DfCFY0/+nsMF5WuuxSqK5+blguar3nfPI+NrnH71KJTXSevAnK8aYpi/S6Gvk2NDMQrD eUJBn5ymfkFaY/I/DT1LbEz5f0CIJq0pIuZzA0w3pXXil8hzmyZmn7RPcnxyDB/cCAMR rm6M4Jui71chyXBeakStogQ2y20kVUZggBYXYWMSIHDlVSwAwnBQ3dsqgBOo7zeOZCtX LuaM8jle+kCdVGyXFMOA8t7dZvI+Hy3dGAiYCQgsawPqqLt+xf4aMggXZ5vhEyckKbzd pKVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tW5UqDkuWO2j0UbYAoHkgGZoRruQFo6bMhGF7D6scVc=; b=lJBGYTIo2FqKvCj/9eH88iswbz0wh4oBqoGcoHO4GAuPAXI2beAesNGH1fK6GoQ/tG gVAMDKk/T1FjrZKa3P9pjuIdD3zSKfrhLItSEAobo/uNoYyawigkeQXfEjyCqiScxiDT U8R8HfuUKnbg/YY3Ym3nJn3YSNDrGHz2WihB5ewG/McTACoGQfICkEgvVaRxFybiUsjU 3NixAhUArcQJ1DgwHFuQaA4Xnc6GCYb2KWo0bItM81PXGgmTPH3AlkSi2QDZSQohf4Mr wJmaOfLOLIkptMq1b5Ai1UT8F6Hsk8VEqmTs4X+bIzT1XvkvepnHPbzPB6Pt9r8CjIMt HzHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NxNqB5i0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13si14178758pgv.398.2019.06.25.20.43.38; Tue, 25 Jun 2019 20:43:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NxNqB5i0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727199AbfFZDm4 (ORCPT + 99 others); Tue, 25 Jun 2019 23:42:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:53862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbfFZDmv (ORCPT ); Tue, 25 Jun 2019 23:42:51 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A0B1208CB; Wed, 26 Jun 2019 03:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520570; bh=d2mos+JEfbQZ2N1S1mqLaKmvyRthD8wQuPYK08TlLjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NxNqB5i0MeO+XvgRgzwxQyn2jipAvo/0an2DKWotdf8G1jEQsxo9oZDg0mtZu8P4v 8r5UQRmqotMOfk9ARfmAjToMJoLOFTbHF9SGOCQh3s5pKCyH5gBC4DarIdjgxPiFw9 bD1y+eBAR1NG+pDOWIApJEhjkdDXGjxVCGgqD9YA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.1 33/51] SoC: rt274: Fix internal jack assignment in set_jack callback Date: Tue, 25 Jun 2019 23:40:49 -0400 Message-Id: <20190626034117.23247-33-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amadeusz Sławiński [ 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 Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/rt274.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index adf59039a3b6..cdd312db3e78 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -405,6 +405,8 @@ static int rt274_mic_detect(struct snd_soc_component *component, { struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); + rt274->jack = jack; + if (jack == NULL) { /* Disable jack detection */ regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, @@ -412,7 +414,6 @@ static int rt274_mic_detect(struct snd_soc_component *component, return 0; } - rt274->jack = jack; regmap_update_bits(rt274->regmap, RT274_EAPD_GPIO_IRQ_CTRL, RT274_IRQ_EN, RT274_IRQ_EN); -- 2.20.1