Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp231894imu; Fri, 16 Nov 2018 01:31:57 -0800 (PST) X-Google-Smtp-Source: AJdET5feXc4aJpujfS/FTap4+rYR7RmoK3065k6zC7tzZwWy/w++spoKpvVx4TIYqluVZdribfYj X-Received: by 2002:a63:e247:: with SMTP id y7mr8850158pgj.84.1542360717831; Fri, 16 Nov 2018 01:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542360717; cv=none; d=google.com; s=arc-20160816; b=k3Ouo8XZCy7eFYrs7j4TBxJfN1pDSLsorB59OHNaQ90SgwZ9JBALyJ1BxeO0KcQlH2 37BvkRQIdhRjf1Oya9XLC3hprzECskXGyfaACfgwH/OJUOvEk07Z2QLR6hftaEWU8s1d YpSYN+j5LHOEjUKb12K8B8lQoJ7CFdyFwmYA8Z9j1/rShD45TIErLKA0bx0hVlMBGD0z mptN26+E/Mfs4ffBfLYlLlX2UHLK4QjuumbZ529ECFkSW1nhwNh5yr5xuqiXdQx3ykoW i9b2i3AtcUF8aYcOFXhUewBVhit1QrfjuQfFItrLgR3Vle3P5TyIjXvIWQ++g3VIHTJd obew== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=qKH8Hl64xPry9TSPR7Kx7uMh8CbXMJi4RqdKTbzaB9A=; b=ASRbiOpy9xPdramzysbo6k5ft14xGL8Lkuhg2Zf5BYpbpDsEtZ7NknSdhzHcDxdGrV EVhcAjsiQFE99ilpLeclXt5nHbgVB6qNIhYvxq1ffdIPvTVltdqHAFmrLT9LMeIEWhOR KiQKY5FB5cYCF6hFW3ZX0N3v888BVtpSSzmqf9CnewlEBgkp0FYYELvLXccRcY8ZUrKK DKEqMrsopcfmC2ZnUxxavUr0CweqQC9SmZtggcJeufZtgOSk+ZSEXS4ICBTSfP0+tY+B 0fo26oeXWGe4SNkA6VVHKKBl8T/Vas5nOmxLRzHqyzMVo7ffCDxEMOJIfLbaHvI1rnux dWrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ldmNKdc4; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si28137286pgv.38.2018.11.16.01.31.41; Fri, 16 Nov 2018 01:31:57 -0800 (PST) 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=@chromium.org header.s=google header.b=ldmNKdc4; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727644AbeKPTlO (ORCPT + 99 others); Fri, 16 Nov 2018 14:41:14 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36177 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727398AbeKPTlO (ORCPT ); Fri, 16 Nov 2018 14:41:14 -0500 Received: by mail-pl1-f193.google.com with SMTP id y6-v6so3327967plt.3 for ; Fri, 16 Nov 2018 01:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qKH8Hl64xPry9TSPR7Kx7uMh8CbXMJi4RqdKTbzaB9A=; b=ldmNKdc4yRORustAFhg41+J8f0Vy5jC0cUsP1vwyZEde9KV1L9jsfAHNAEahK59SN3 ayuGSfhVznv04hPYEiZtpPIvKsnHnXR6hUBj8o2fHLs19Zscmw5Fr3f9t6ZZRp6JCC2s oRFvkz4o8YzuX+BNQgwK9oh4romPUTDHfkWxI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qKH8Hl64xPry9TSPR7Kx7uMh8CbXMJi4RqdKTbzaB9A=; b=igVQQogGazuKLe7HyT7oZ7ECjBxG5GH9hIQm4dLyUeBRwFFZ8BRZvFoLTjdi7XV93B +3zkhT+XSvBpcy0pYmmhjDOajCS5UOcPXXIhRnjxUeodA/b8Wbt2nsA6Cq1LnZf+BTRG gTW4aBUrLDhXD+Akl2asQDnGmUWpHNRmD7leTpAoX1puVxZOfS1+x6QgCkD33Ey2ncI4 XI5YZCbuMOg+rfKEX+tko0X0sQxN/X0UtrXeyIEg0NkFHod02qum1+i+ltdJlxYzb8us s4mH9lAKzMMN0NBxGzhleRx6Lv2PDrApfcwm+L+6aS+Nq+KVyMiV5s2zYVUvgchrm1fA 4FsQ== X-Gm-Message-State: AGRZ1gIPOSA6AQWlRnG+U1gSeTaquWGrdo8U4GURxCUCkZdld7gIdnRw bjHS+CO9HEvQQUlW265sfhqcl/0Zd7c= X-Received: by 2002:a17:902:654a:: with SMTP id d10-v6mr9612238pln.302.1542360584421; Fri, 16 Nov 2018 01:29:44 -0800 (PST) Received: from cychiang-z840.tpe.corp.google.com ([2401:fa00:1:b:e688:dfd2:a1a7:2956]) by smtp.gmail.com with ESMTPSA id h7-v6sm50820180pfd.35.2018.11.16.01.29.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 01:29:43 -0800 (PST) From: Cheng-Yi Chiang To: linux-kernel@vger.kernel.org Cc: Mark Brown , oder_chiou@realtek.com, alsa-devel@alsa-project.org, dgreid@chromium.org, tzungbi@chromium.org, Cheng-Yi Chiang Subject: [PATCH] ASoC: rt5663: Fix error handling of regulator_set_load Date: Fri, 16 Nov 2018 17:28:56 +0800 Message-Id: <20181116092856.47815-1-cychiang@chromium.org> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The default implementation of regulator_set_load returns REGULATOR_MODE_NORMAL, which is positive. rt5663_i2c_probe should only do error handling when return value of regulator_set_load is negative. In this case, rt5663_i2c_probe should return error. Also, consolidate err_irq into err_enable. Fix the missing goto for temporary regmap and rt5663->regmap. Signed-off-by: Cheng-Yi Chiang --- This patch is the fixup of the patch e81a2a6d12e85 ASoC: rt5663: Add regulator support sound/soc/codecs/rt5663.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index bb2c1ee4a836f..473a54d1ae2c5 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -3522,10 +3522,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) { ret = regulator_set_load(rt5663->supplies[i].consumer, RT5663_SUPPLY_CURRENT_UA); - if (ret) { + if (ret < 0) { dev_err(&i2c->dev, - "Failed to set regulator %s, ret: %d\n", + "Failed to set regulator load on %s, ret: %d\n", rt5663->supplies[i].supply, ret); + return ret; } } @@ -3543,7 +3544,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret = PTR_ERR(regmap); dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n", ret); - return ret; + goto err_enable; } ret = regmap_read(regmap, RT5663_VENDOR_ID_2, &val); @@ -3576,7 +3577,7 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ret = PTR_ERR(rt5663->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); - return ret; + goto err_enable; } /* reset and calibrate */ @@ -3686,17 +3687,19 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, rt5663_dai, ARRAY_SIZE(rt5663_dai)); if (ret) - goto err_irq; + goto err_enable; return 0; -err_irq: + + /* + * Error after enabling regulators should goto err_enable + * to disable regulators. + */ +err_enable: if (i2c->irq) free_irq(i2c->irq, rt5663); -err_enable: - dev_err(&i2c->dev, - "%s: Disable regulator after probe error\n", __func__); regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies); return ret; } -- 2.19.1.1215.g8438c0b245-goog