From patchwork Fri Nov 16 09:28:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-yi Chiang X-Patchwork-Id: 10685739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5726109C for ; Fri, 16 Nov 2018 09:29:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2A662CF6D for ; Fri, 16 Nov 2018 09:29:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95F472CF86; Fri, 16 Nov 2018 09:29:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4EF22CF6D for ; Fri, 16 Nov 2018 09:29:51 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 20BD3267930; Fri, 16 Nov 2018 10:29:50 +0100 (CET) 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 70BFF267949; Fri, 16 Nov 2018 10:29:48 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by alsa0.perex.cz (Postfix) with ESMTP id F077D26786E for ; Fri, 16 Nov 2018 10:29:45 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id a14so6296573plm.12 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=soNVQGEpQyUkABnkQSrXItagFRl5xwXReFIBvsqvOU2ahFo8LfhwNMPNg4i6gyhv6m DJSxHYqjtkuMZ6aoyO1WCvrZ7CKces+14+bAggaBgLHl0Vc3LCm+50oGTyMAQ5p8e+X7 hTpO6OxMkWRXDuAffLt5h/PNpxaQeoHtgcTXMSCCuboyveWPFhVFaH/TWyDBifSHAK/u wMKNCxta89RmfQ85K7n3RsUyLvatnblYTjL7A4nEuCcgIOKGG1JDQSJLkRrVin12sFDu 2uSdz/BwWAAPta+lpXziRRPcRUdPnejIg7lk3yswEziqrGpx+rkcje935WKg1M+x6bQo ZHKg== X-Gm-Message-State: AGRZ1gKbzh1n5QGHdWtfLr51nteNbTyEXS5LgmFuSIRseBon+igga6zE NRtrRz1yJbIFFkM7zCvdTyucPw== X-Google-Smtp-Source: AJdET5cbUPzrQdxNTt8AqORXOP5Up8lPIKp6rpFTWk0b83IWHEQ3Jfcnhe/4ldNatrWM3oV9RKuO5g== 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 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 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, tzungbi@chromium.org, Mark Brown , dgreid@chromium.org, Cheng-Yi Chiang Subject: [alsa-devel] [PATCH] ASoC: rt5663: Fix error handling of regulator_set_load 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }