Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp825099pxb; Sat, 11 Sep 2021 23:45:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4mxvdn5Kfq7EBQMtmEV1GXpX5f2EzdfibcVIYqvP4+hqoEG9p6ci/09h32pMX4YIvvmVi X-Received: by 2002:a17:906:6148:: with SMTP id p8mr6226029ejl.263.1631429138342; Sat, 11 Sep 2021 23:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631429138; cv=none; d=google.com; s=arc-20160816; b=rj8BqbgDks/7FsrXCjYUPzQ4ZMKBfKHgaULZj7BWm7jJKfddbhLpT9EUKmEuPSD3sa 5CHraxFjJTeqrc00zQL4nAaytlQKrz9rQ5IZbSsIFHZo6p5ueSi/VPz4yGST8uLZLeht Kf4S7aKPE9AIuYfquJ4wiHXT7U7oEP61KcTKPmlHF/552LfIZUd/qjm7vY86zVqOkhNO xQ8XcDV4iWxSs9/PR4sgqKk/nT0dEV+m3GIbu0iCgSt9cWBfqJumx5X8uqvkleLGtqbs qYISRxqYpWF9DE6g7j/ucNCWoE7idDalhsgY04ZRR5BMLO5d++rNO8rnl60wvPl696nY IMLw== 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 :message-id:date:subject:cc:to:from; bh=cp6KKbMJieszrL07LTp/C7mW7FpoP48HV2YSVbJH8tY=; b=LJZ+EbA2JMBJRvd/mCIWsIuznkLWcdcDotviLewUBF1htVio5Gj1gBhlpVT0B0ccGR CyciGBtHNMIwrM3PzEc1K1MW4zPzhJ48ongSrMl7TTT3O6+ZY5fn9r380/9Gxoc3yEB9 WPL2IJqxunzmpCa8W3cWHNbfF+XYupWaIgf4D43JD1ZLYTmMljd4b6xKBX2ySE2OXH98 yiQXLEtKaxuVrzD2H9A/SzvdI8vjPr7xo3K+tX3+zXmUTo0jw4Y9X2bErLHxusQK5zxE 6Ndm+VDRTQxSo4/DyEuGqwvFNi7h7x9YH5XvynPsyTg3wQWT6Apuf1Uq+5f+drPqeZHM JSjw== 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 h7si4155775ejo.323.2021.09.11.23.45.14; Sat, 11 Sep 2021 23:45:38 -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 S230421AbhILGmr (ORCPT + 99 others); Sun, 12 Sep 2021 02:42:47 -0400 Received: from mx20.baidu.com ([111.202.115.85]:48466 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229535AbhILGmp (ORCPT ); Sun, 12 Sep 2021 02:42:45 -0400 Received: from BC-Mail-Ex03.internal.baidu.com (unknown [172.31.51.43]) by Forcepoint Email with ESMTPS id 4FA382798FCFEE9D74E4; Sun, 12 Sep 2021 14:41:17 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex03.internal.baidu.com (172.31.51.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Sun, 12 Sep 2021 14:41:16 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (172.31.62.11) 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; Sun, 12 Sep 2021 14:41:16 +0800 From: Cai Huoqing To: , , CC: , , Cai Huoqing Subject: [PATCH v2] iio: adc: ad799x: Add a single error handling block at the end of the function. Date: Sun, 12 Sep 2021 14:41:01 +0800 Message-ID: <20210912064101.539-1-caihuoqing@baidu.com> X-Mailer: git-send-email 2.32.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.31.62.11] X-ClientProxiedBy: BJHW-Mail-Ex05.internal.baidu.com (10.127.64.15) 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 --- v1->v2: Change the error path-error_disable_reg from "st->vref" to "st->reg". 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->reg); + + return ret; } static SIMPLE_DEV_PM_OPS(ad799x_pm_ops, ad799x_suspend, ad799x_resume); -- 2.25.1