Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6766227ybi; Mon, 8 Jul 2019 08:18:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxp/uolwy9othLjHxwCXAXNd9AF3nQ2SqpDYpY0YS7ICtnUgrZfT7lFIbRh0pqzgve6KMCq X-Received: by 2002:a17:90a:974b:: with SMTP id i11mr19369474pjw.21.1562599129795; Mon, 08 Jul 2019 08:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562599129; cv=none; d=google.com; s=arc-20160816; b=YqX298+vYaXts+OzeKxfBeTDZ9TCZ1ooHWJK98KPAJZm97tWAuSMntsgkepY/1fyXY 5YBNI6v8ddiP8fc8GX5RpDwD2vH1cI2be8UtbThhSD+ScjU8zPmuVPwhJQXulQmanFsL FVWIQJjFzGVqJKU4BxZ6sp11uHpyss2CBTJKoe3cHQafbaRyUstB3ET0JsPbrgR0GKIm rRiAWJJ2bTMDOzpxCKdlvPLU69Xms3KXZgsrX2qednj9/n6MDw36CB+CxThwsPfxO2P3 ChDX1IkJb2WgPYKJ9KEbUoGEJD1co485eYiubD+XMYaC9teNhjM6P7mA5Hplcvq3loB3 vsdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=o/qshDkq0LPuA8wc3+fLsn0La9XV1Cl2eJ3HWiEdi04=; b=SG1rx2QdnF1ADUnadKYNyzc2/fMUs4w1YcFhoFXsmFaJGqU7pS6WcYS4oOAaU4ksX7 Q0vmcdLq4YaeuKV1nn6WRzN/1cxZ6howKaBn7iaMSzzD9e2djItEmOfVpPZ16aB2Tt1n tpgwy4/Vri+32kwiLt8aokwM3mCohwxin3rI+m9ApI80hbQU3uq+Unwc4TpsZanbBxMr +ZhxE2jYVvhumzLdCZsei0aG5fUK4MGiazYXPot6XqbdTEpHWjGZqujP8hQQqqRvny0H OHnJ6s1i/eFCzwOJ0kF9por5KCPCVqu8dZKNuXwJG5DcyHr/ZGhhkxbRnLQkgJWJNELo sJiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qwgAVI8s; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si17753786pgw.246.2019.07.08.08.18.34; Mon, 08 Jul 2019 08:18:49 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=qwgAVI8s; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730458AbfGHMcv (ORCPT + 99 others); Mon, 8 Jul 2019 08:32:51 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40860 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbfGHMcu (ORCPT ); Mon, 8 Jul 2019 08:32:50 -0400 Received: by mail-pg1-f193.google.com with SMTP id w10so7612524pgj.7; Mon, 08 Jul 2019 05:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=o/qshDkq0LPuA8wc3+fLsn0La9XV1Cl2eJ3HWiEdi04=; b=qwgAVI8slDM+OaLoeE7XQ4ewYGrdgxMMLLXpMXIagbnnEXc3KVYnFuEUavNWgipsVf iFX+EinH+YAXcqok65pe2AUkkPh6gGhImwz6wnJsxNU9sAmqM5aFQ/yjl9meqsFw8BYy 2JdlvZNZjlPGpJdnIvOJkA/5qSnWBXuI9ZKAJyVJNoz4DI7Q7O+Bxloqe3BaLFdBsFgF nV9SUDsppvfgzGuHvrbMzxv3ZxOAWSbnStH54KMG1sFF65TgbIX62ys/Fuq0xBjBZbNn go3qnHsN7sMifpJS3hFqMDe3ncyJZPMxG+tAtj2bkez4zyD7hn+/UJ+ZxU8Yc9y+bN8G Zrmg== 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; bh=o/qshDkq0LPuA8wc3+fLsn0La9XV1Cl2eJ3HWiEdi04=; b=kTMzP9pGZtlt5my8+5HptAe/hC5C+65WSAwhPDCdr3t7w+BQMWwOri79wA0P1n2DwG qIKS+SMTCF1cjaVHNzxRtCIrcUITxLeVYwsHshkQdNeL4BoV+VMnhr0eK+4RwTwBBuxD GLzXHxGpQRlCUKBDb/ECb05hIB31lcXxxyeae5BOj4z6DWvbN+OVAzgMdKtVMoq9bVWw 5DHsirek6EciMl4La4YmTI82XUr1jpGYXA2/bCq5Zs2Al5S3N0kwCTvjNyM4wqi3usoZ nWVuHVlqmjKQsQbSYNEJD7QJL6bfRzCrarscHtGPR/7uOc1PLj0p5iylawucMqWL/iSP DNLg== X-Gm-Message-State: APjAAAWXUtHrjaEzr/iVCo5GZmTLd05Lfghel2yPg/2OtNCNBWtNDEVm jLa01owc4e+84dQrkIGM5P+Cjvu8U30= X-Received: by 2002:a17:90a:1aa4:: with SMTP id p33mr25557738pjp.27.1562589169983; Mon, 08 Jul 2019 05:32:49 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id t11sm15084327pgp.1.2019.07.08.05.32.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 05:32:49 -0700 (PDT) From: Fuqian Huang Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH 02/14] iio: adc: sc27xx: Replace devm_add_action() followed by failure action with devm_add_action_or_reset() Date: Mon, 8 Jul 2019 20:32:43 +0800 Message-Id: <20190708123243.11713-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org devm_add_action_or_reset() is introduced as a helper function which internally calls devm_add_action(). If devm_add_action() fails then it will execute the action mentioned and return the error code. This reduce source code size (avoid writing the action twice) and reduce the likelyhood of bugs. Signed-off-by: Fuqian Huang --- drivers/iio/adc/sc27xx_adc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c index ec86f640e963..d7ca002cbb17 100644 --- a/drivers/iio/adc/sc27xx_adc.c +++ b/drivers/iio/adc/sc27xx_adc.c @@ -546,10 +546,9 @@ static int sc27xx_adc_probe(struct platform_device *pdev) return -ENXIO; } - ret = devm_add_action(dev, sc27xx_adc_free_hwlock, + ret = devm_add_action_or_reset(dev, sc27xx_adc_free_hwlock, sc27xx_data->hwlock); if (ret) { - sc27xx_adc_free_hwlock(sc27xx_data->hwlock); dev_err(dev, "failed to add hwspinlock action\n"); return ret; } @@ -563,9 +562,8 @@ static int sc27xx_adc_probe(struct platform_device *pdev) return ret; } - ret = devm_add_action(dev, sc27xx_adc_disable, sc27xx_data); + ret = devm_add_action_or_reset(dev, sc27xx_adc_disable, sc27xx_data); if (ret) { - sc27xx_adc_disable(sc27xx_data); dev_err(dev, "failed to add ADC disable action\n"); return ret; } -- 2.11.0