Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1843846pxb; Mon, 13 Sep 2021 06:46:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY8Ii95l69v88oOk3K3wXnEQ2BEz5CEkVbAXXEV03lxA2OudIxEs7DurmhRa3Smm4rTPfW X-Received: by 2002:a02:6646:: with SMTP id l6mr8436615jaf.51.1631540816224; Mon, 13 Sep 2021 06:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631540816; cv=none; d=google.com; s=arc-20160816; b=0JL8MOfIsUxDuWWM2BEzWAGwF+uvKD5yak2MpIdx0HQMpocyvtTSbAngMhnDXyiFEv 6fRAhC6CTJcU56frgaPisbkdksyAI+YMZ61CdkF64ljY0P2+ToExa+r6UgP+dBj60cSi ycEwwvuCclwDRBuOOArOvDBHyMGYUAcAg/jaDWRRnD5pQ3Jqn6mSphdSfHPWCkCS2c10 mrup3rlCA50V0y2YtldJeS5gcvKohncUSj2WS5BJzcJMGFNobBtoL4S5ns9evLguZX3W MkKyOMGqFFku8VDNP4F/J7lj9nsam0gX5eXLOWGA7aeit8AxJfJ2o1Ol1dKbnIlve1AG sBdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k4JWuJ7mz0dAY61AnB/7oDP5SlICUL66fgm7dfySiA4=; b=VYxVV4jxuJCvQoOFLvY/ms7jXQ9dlfNSAw2OlDt4CCZvoJfBs3PR3OBh47oCJe477l p9J7QpxT0pA6RLToNbc56SH8BF2FoMNHOHh29FftCXX+iNxGYDF1a007zd0sNuY7xEOG YNi5ptR6CHQItnmpvbwuoqzDC4f6BqaLnf5ZrsBeuBMlUAAEAZsFo6PA6XGUZ1DGVXPN 0f1ztKuq8RT1b0lAXl7JGLHuXGrcS6slVW4sAYvPYthXYeIIlvR/CRCTWDgU6Wr/n9Xh +Uqe/ode38GQ94XRXbC93QxeuVP0kIpFsFiuZ/faPmfU/2ZTjUEXT8hYtLiEtxzknpP4 zVrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WPaaZ4tt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si6898978ilu.98.2021.09.13.06.46.43; Mon, 13 Sep 2021 06:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WPaaZ4tt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243889AbhIMNpB (ORCPT + 99 others); Mon, 13 Sep 2021 09:45:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:37702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243782AbhIMNkD (ORCPT ); Mon, 13 Sep 2021 09:40:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98368613D1; Mon, 13 Sep 2021 13:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539749; bh=4YOQnS4ETvRx6ZhZiLS3v+/7wJoYeybLOXRZEFvpdco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WPaaZ4ttmOjyc//c9SFQE97ny0+SGCUtK30ovDIteA9+ks7hWNNDy6ph27c+lSL4R QNmRpNUovD/LDKjSzmf64Kw5dVgYG4J6vf/YUHgdPtAe+nm67PFi1YIqZiJYeeqLZf TEMkN6c4N82ppSwQoeJNPdgzGKA+WUlCbuOy7odI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Anderson , Stephen Boyd , Mark Brown , Sasha Levin Subject: [PATCH 5.10 146/236] ASoC: rt5682: Properly turn off regulators if wrong device ID Date: Mon, 13 Sep 2021 15:14:11 +0200 Message-Id: <20210913131105.331220002@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Anderson [ Upstream commit 772d44526e203c062171786e514373f129616278 ] When I booted up on a board that had a slightly different codec stuffed on it, I got this message at bootup: rt5682 9-001a: Device with ID register 6749 is not rt5682 That's normal/expected, but what wasn't normal was the splat that I got after: WARNING: CPU: 7 PID: 176 at drivers/regulator/core.c:2151 _regulator_put+0x150/0x158 pc : _regulator_put+0x150/0x158 ... Call trace: _regulator_put+0x150/0x158 regulator_bulk_free+0x48/0x70 devm_regulator_bulk_release+0x20/0x2c release_nodes+0x1cc/0x244 devres_release_all+0x44/0x60 really_probe+0x17c/0x378 ... This is because the error paths don't turn off the regulator. Let's fix that. Fixes: 0ddce71c21f0 ("ASoC: rt5682: add rt5682 codec driver") Fixes: 87b42abae99d ("ASoC: rt5682: Implement remove callback") Signed-off-by: Douglas Anderson Reviewed-by: Stephen Boyd Link: https://lore.kernel.org/r/20210811081751.v2.1.I4a1d9aa5d99e05aeee15c2768db600158d76cab8@changeid Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/rt5682-i2c.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c index e2b4b10e679a..464f2c27f71a 100644 --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -117,6 +117,13 @@ static struct snd_soc_dai_driver rt5682_dai[] = { }, }; +static void rt5682_i2c_disable_regulators(void *data) +{ + struct rt5682_priv *rt5682 = data; + + regulator_bulk_disable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies); +} + static int rt5682_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -157,6 +164,11 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, return ret; } + ret = devm_add_action_or_reset(&i2c->dev, rt5682_i2c_disable_regulators, + rt5682); + if (ret) + return ret; + ret = regulator_bulk_enable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies); if (ret) { @@ -280,7 +292,6 @@ static int rt5682_i2c_remove(struct i2c_client *client) struct rt5682_priv *rt5682 = i2c_get_clientdata(client); rt5682_i2c_shutdown(client); - regulator_bulk_disable(ARRAY_SIZE(rt5682->supplies), rt5682->supplies); return 0; } -- 2.30.2