Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6883025ybi; Mon, 8 Jul 2019 10:10:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUquR8mnamzrlR9xm16vgFNivlJQ7RWjPWUpOQZghoHA7aur1Juw16iYClZVrwOxor8mw6 X-Received: by 2002:a17:902:8f93:: with SMTP id z19mr25521948plo.97.1562605825325; Mon, 08 Jul 2019 10:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562605825; cv=none; d=google.com; s=arc-20160816; b=gok2UcteYDrokZRWq427qX/LUiLED8k1PDaYzpBdSM8rFXKNohpZ8uAsltb/yU9SZJ 3G/BQynoTNQKgmEOmVjciNhn58BppYje+HWDm/lQCIYPPfqCgu7/5NCWxN/68afQ6ccS AGfPiD0pw7DeHW3r2f7HlUjPQF6wOLKgzOynHeRhWHWWnhWdPVG4psGZGAYx8ezX4g8p P5eDuQr56Qrs3Y0VrTTa17HMqLI33/2ch31Pmv+RfXzMGkNv1FK2uR3y1aFsfj46hqhh 4fSEr7/3UUweBea5nliopeEdSijnS/uL89RMghgz+oTPQB83VXd2qfA014zdxjD7wqSz V2BA== 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=jAthm+WxbxKT3w7i0wyvJ8rNAQ4gSuwe1Onff42CQls=; b=E326hj+nTV1mw2fYY0Q6kBuD+cyHykofIWjAeucNnpbcb6jmj08y+i9XHyXLQ9kJzh udzJlW2OpCRzvnNzumVo5e4pQaIEQBll2l2zL7pIgylcjxasbDBqjKlw1Q0/XlnXLN0Z a/tXPcAoH6vBIJLoZl3zo6w9wUwYUnIpTxepmUHUrzKe+XBDo63xC/ZWbDtvmKF4gHWw a0CJIH2a5fvBcGnS6XF6vp/ohedUqL4TvX2wGri+xK8xYjXe9D1hIzkrr0UfEyRqEajo bes/xwamOvoiRNGcnUtA93fLcWh7RLAYNCVpfeKN76POgg+8CyxlUQ00kGQ2UZJrXXxY dNuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=COmFwheY; 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 q195si18777647pgq.119.2019.07.08.10.09.16; Mon, 08 Jul 2019 10:10:25 -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=COmFwheY; 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 S1730747AbfGHMdr (ORCPT + 99 others); Mon, 8 Jul 2019 08:33:47 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39897 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbfGHMdr (ORCPT ); Mon, 8 Jul 2019 08:33:47 -0400 Received: by mail-pl1-f196.google.com with SMTP id b7so8215898pls.6; Mon, 08 Jul 2019 05:33:46 -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=jAthm+WxbxKT3w7i0wyvJ8rNAQ4gSuwe1Onff42CQls=; b=COmFwheYaqCs3c7QPhN18QiYnYAtIpekULwaQLYy7zw/NDr+RwcMaHcElLMG0+11qc bw3/JczgJacs0zd1jB+chz1vURSYjchaV6sz9uQmaTZ8zak1x3tf+DEkjbA8TMfx3Kgn 4H39xsp7gJPC8z+ixSNXr1e2GXw4l+bB4l0sEYWolpQ6+9B7cI5GJlDNt3csKD8BNaVJ rwdKZmDrtoMN3oN9Bsa15LRo/Bo5vOREWMt3E9OR3inNtE/ZPSJdKcFilYHC4UI9ERpv f/z/Ozypxhn3BfQmVpsi3Jiuk1YxycWDhvBByjb6Lw765j8ZyzctfFWhC7haJK9shArV d2Vg== 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=jAthm+WxbxKT3w7i0wyvJ8rNAQ4gSuwe1Onff42CQls=; b=HOID3B30IFensHi8AyRVA80zjdXCLfqw36z+88AN/Hx9giJUNlWzTLGrfrX22ybKC4 G2rfVhvqCp5XkusEU+v5LMOsdoq7/8vRuldp3zPAefXM0E4/wTECx4nxk/oXgZ1W2I0n rvI0JDjLBXkiKV3FUofus36EfUit5K8AbneyDZzDV7RSgPDXr9ka9l6bFU12fgTpsg4B l3efiiXVadLRMrwVWdOO0PERghH5c/VrWBzUMoT2G52QwcQvQRGGgwFOyL0UxlFWMaO3 cXrIVK4lcxpwkgtSAnJgFsSRw0zmhwGC3b6i+YcCxWcrPQKaWza2Qvyb9SfEiVqj3I65 u9yg== X-Gm-Message-State: APjAAAWZlMNDrqHVQPcSBkqfPY/0FIVQ8TOsnEOx3HSz65N0mRvc17eg uACimkFTluX1D+iRqee5WwE= X-Received: by 2002:a17:902:4e25:: with SMTP id f34mr24265563ple.305.1562589226504; Mon, 08 Jul 2019 05:33:46 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id g2sm13103473pfq.88.2019.07.08.05.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 05:33:46 -0700 (PDT) From: Fuqian Huang Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH 09/14] iio: imu: mpu6050: Replace devm_add_action() followed by failure action with devm_add_action_or_reset() Date: Mon, 8 Jul 2019 20:33:41 +0800 Message-Id: <20190708123341.12035-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/imu/inv_mpu6050/inv_mpu_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 53a59957cc54..e067927317bd 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1096,10 +1096,9 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, if (result) return result; - result = devm_add_action(dev, inv_mpu_core_disable_regulator_action, + result = devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_action, st); if (result) { - inv_mpu_core_disable_regulator_action(st); dev_err(dev, "Failed to setup regulator cleanup action %d\n", result); return result; -- 2.11.0