Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp3466152pxb; Mon, 6 Sep 2021 23:27:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJKteV4u2YUebnJ1Bg/NsBTpfoKL5XGEu6JsKNsO8aGAnmUNT7w3+A/OsBF4pPbIFU2u70 X-Received: by 2002:a05:6402:27d4:: with SMTP id c20mr16733505ede.332.1630996077244; Mon, 06 Sep 2021 23:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630996077; cv=none; d=google.com; s=arc-20160816; b=CuXmaLUcG9r5NUmRRMvRhaL0APR/PG10snirHa38ssvApUsjY+Q/FckSkhW6CKiJ9N 2jtrMsbV5mfErwxTBLnnvcBPNdYOwxPzH3FBDO/8lNGqf7zddim2J1beX/ecvikYZRVX xgejAsvRJOfADq81ICW9AQzra0a9M2uuznlZXYlYszX52ydZ+fGUfOHfpNjouw1pWlbP FTnizaYspHYDKw/+F8sHiSNtPKadRd2C4trteieU4zNg0V3R0EuQ+G+sf78yF21MUhc4 dBlv27V8Ibp3pk0UMMzk+CN984xv8gveIR23kRmV0MT5YDUYtrG6qg3O76EOmNPEooHc 0uzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=fYnLTC0J1vaxJjNiXaY+U+mai58i6StKHfzik+cwbrQ=; b=VJ9ISMF0qxMLTYeAutehWOMxKikfdRWFeo7IOI2glYaJA2uQEx5ayHmG4X6QjkhZgZ 8WazhR6N3VWwpo0wzH8z84hpt3Dd1Hg1xhbtHHOp2mpDfREZCfOVQjf+nyTOTafMGiWs 78uZrryoMT3FXEBLM2CxxPH7SuHCIn21E6hEUf+BywmoBdPBbwjqgBW8Tifp9gn/cpbI gu710mwpFHmIX+ZN1YNgJPtZbIVDwJQXB78VoaTmArIJOuolltnLMXEkBvlagjPxLPiq TPiM/d8cZFqmTBsT8xDuR6D3wSWEXDzWHBI9VUZKp0/uW99oZPFZjmD1YtYCaEiUrDsN kKSA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch13si10281599edb.209.2021.09.06.23.27.34; Mon, 06 Sep 2021 23:27:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232916AbhIGGZU (ORCPT + 99 others); Tue, 7 Sep 2021 02:25:20 -0400 Received: from mx21.baidu.com ([220.181.3.85]:54486 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231828AbhIGGZU (ORCPT ); Tue, 7 Sep 2021 02:25:20 -0400 Received: from BC-Mail-Ex16.internal.baidu.com (unknown [172.31.51.56]) by Forcepoint Email with ESMTPS id 241E27BF1FE1EDA7FFB7; Tue, 7 Sep 2021 14:24:13 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex16.internal.baidu.com (172.31.51.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Tue, 7 Sep 2021 14:24:12 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Tue, 7 Sep 2021 14:24:12 +0800 From: Cai Huoqing To: CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , , Subject: [PATCH] iio: adc: ad799x: Add a single error handling block at the end of the function. Date: Tue, 7 Sep 2021 14:24:06 +0800 Message-ID: <20210907062407.1930-1-caihuoqing@baidu.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BC-Mail-Ex30.internal.baidu.com (172.31.51.24) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A single error handling block at the end of the function could be brought in to make code a little more concise. Signed-off-by: Cai Huoqing --- drivers/iio/adc/ad799x.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 18bf8386d50a..d3dbc4c1e375 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -891,20 +891,23 @@ static int __maybe_unused ad799x_resume(struct device *dev) } ret = regulator_enable(st->vref); if (ret) { - regulator_disable(st->reg); dev_err(dev, "Unable to enable vref regulator\n"); - return ret; + goto error_disable_reg; } /* resync config */ ret = ad799x_update_config(st, st->config); - if (ret) { - regulator_disable(st->vref); - regulator_disable(st->reg); - return ret; - } + if (ret) + goto error_disable_vref; return 0; + +error_disable_vref: + regulator_disable(st->vref); +error_disable_reg: + regulator_disable(st->vref); + + return ret; } static SIMPLE_DEV_PM_OPS(ad799x_pm_ops, ad799x_suspend, ad799x_resume); -- 2.25.1