Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1864437pxb; Mon, 13 Sep 2021 07:10:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznKq+me4CQGEEfJZGhxzOxWTjSrXA3wUZSp5SCbpCR1hOuMBBRRJyHblaYOOtvw/auW0BZ X-Received: by 2002:a92:90a:: with SMTP id y10mr2192505ilg.108.1631542226593; Mon, 13 Sep 2021 07:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542226; cv=none; d=google.com; s=arc-20160816; b=kNFB9vOiR4g8UgIMcbQiQT2hBV1hBMhrVvOmlYCMh16R5es+Grp55x/24Q50DkVomw w2cUWuTtiV2EmqjHdZAsU6tBHyP+Yl4qTfB3UddMANqFUibSVjsFwBxGW55WE0Eake4Y 1lBslzKsXaZFzxCdyAr2Rrp3ZSvX+4nDcxksJTkBAGJZ5mvHbvGSZGICbtIGQGKbtDaS 6UpCjOe4AYt4VYcBrCmNkeYEylFTnykcjc/giAlkDi7Xrtr9AMVM3GiEm6yV/KK3k8wx Ft1IV+AbLslb9OwBbdud+aVxqD7vNp84imlnbu9ZPpO5WMapzKIUH5qtM2g9f+MkRaon btpg== 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=2IQwrRcp6EzyU+BhCAs9Wrji/uHuGDQSBNyuP2EJ7pc=; b=QP7vWA5PeL6G59BSSNAhkgPe1oChliR71/FfHsjkdx9+Fu3clzhFmvYtGHkgPo90KN iD6dGgpZ4Jb02CpIj2Btrx0zoKgKjOcm1NZDyjav6raG0WD4oqEBSEQCNxBlXASjoSC2 QoNB2biz4KGEBdJz7sQH/qeSJe48xbIyzuHagrPE5iT6xwRp8haDJnX0CMkG/2w7xYHU 1HVmrT8uFzK1ZbAzMObwyFOCWO56VDiBXE2M0OVPiom0vy/SQjGqJDeuwagW66ZQ2U8z 6DGt8WiGUYjNq1FBIB1iOXXqiJ6e+MRhfITO/Wp9GQA9B2pVhB4XRMULbnLuS5ApWMkQ kOVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2M4INBKX; 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 r195si6801731ior.17.2021.09.13.07.10.14; Mon, 13 Sep 2021 07:10:26 -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=2M4INBKX; 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 S1345032AbhIMOJl (ORCPT + 99 others); Mon, 13 Sep 2021 10:09:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343708AbhIMOGp (ORCPT ); Mon, 13 Sep 2021 10:06:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6EB716127B; Mon, 13 Sep 2021 13:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540402; bh=rRx3NDe80nk8bVQz81/OKq3+2X6WDqoLCmczXwRbQBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2M4INBKXC4uSdlkIz/tvQLblOKXr1OusDmx/6EYb/rZASUq5/b+C2p0Ltio6y4gi8 0BbgltqDbDgRXw9TPZxgK9WcScj0gbWKTiUrC+9ASuSHMN0pXtTWEttWLezzgwsGM5 6kBu0VKZS9D7zCMgnzONffbOwAcUGVybKiyTisG0= 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.13 178/300] ASoC: rt5682: Properly turn off regulators if wrong device ID Date: Mon, 13 Sep 2021 15:13:59 +0200 Message-Id: <20210913131115.406282797@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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 4a56a52adab5..e559b965a0a6 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) { @@ -285,7 +297,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