Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6883026ybi; Mon, 8 Jul 2019 10:10:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0YVuUTaZqOrt8nJoANcDF8ksuA+fLgwbhiJ3sNffEA922LHT4VDGo9QobN1aKr75E5Bbf X-Received: by 2002:a17:902:f216:: with SMTP id gn22mr25816707plb.118.1562605825323; 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=uzKHhanxAgAscxvNBDgS8bduM5/yBmiN7up3URjPLNo7+SNcWtV47R9JIpUPEF0OJv /xBSCobuoNRMlYCc4czntuRjSBGdcX/U1iu28u1bogRDAz88gG0k9eyxmg3Wm75XkyxE lcBc9VRHhI9zCPhiQk7U8HNsu4UntLCEhm/Xw4wBVXJmBy/bE6H0BVshxz/uH/ZfQ77o 1XHO5Ulrh8fQFQF8Vou+ip1ac76PWxDKexYn00O40Lc2YarapXJU6n8d5BcFmOg1hQJV 1r4CfZK3XDP+jSEhAE9paZxBSFYnRJ5BHbGwGgfuk4CCNv7H//4zjByecgVu63qTzlYI 9yzA== 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=KBezzKXC+quBmYtuOLs/KQOhhcAej9/sFp0EhMpVed4=; b=pjVj+kMnBi4t7MYaJLt5NACCosaYHZMxYI5S7QkPmEAJvgbZL4Ew83eE9kHTi9AojZ 5ePMV59meq1JtApNi6bSsfMIcS0RPjeWfRkJ8MeQFhwFSZYmbTNCm2uRK0MQ+rfLYeOA Q+7oPJmcGcs18nX7dg/a0G4ewB1jSAc94SLclF9u7sWZPKqwhjdpPO8CjcmDaDNB0RrC cmsM2QSHpGYMgZTpa+/iea15wPPPaylLB0SrAmqdEd8Bi60N+lvKH9fkulDZnXpjHRUB kvDKF1odBiE091T5gFCtLt1mSdlXJ5omWJeHFNn3oRaRMvFieBMucmllPgDX0oY+p7WW jXYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=lbiuTy4N; 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 t16si12573047ply.133.2019.07.08.10.09.13; 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=lbiuTy4N; 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 S1730723AbfGHMdc (ORCPT + 99 others); Mon, 8 Jul 2019 08:33:32 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33868 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbfGHMdc (ORCPT ); Mon, 8 Jul 2019 08:33:32 -0400 Received: by mail-pl1-f196.google.com with SMTP id i2so8218054plt.1; Mon, 08 Jul 2019 05:33:31 -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=KBezzKXC+quBmYtuOLs/KQOhhcAej9/sFp0EhMpVed4=; b=lbiuTy4NTNKv7+lo/RiO5xjrasMyJSle7JXu4HwcBCnmxVuYZm1ZKinniHnW7atbW/ F4go8xH1I+droR2rm3k4ju1BcKA10vQxv23tCsaBNROc6sjh0Qa6grNQe5sBhO+p87pX 4Fgtxg4RXC5sTlTyPpSd09lGUcY9ebXKXpO8PzCNUiQWpkh9jVB71kfNSQoEUi7UxZ4f e7UG0BJpIQdE/Ix2ghhZ+EoIIqWmxVVtNbNhqaeLpkqP3kMq4QicPL5K0Kuh8TvyQlbH FGSuXotNb2lUABwbMEPSWhp474/U5pzXb4ehG7oyrSvvYFDvvkRHQLGtjgPwU6N++5aH y37w== 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=KBezzKXC+quBmYtuOLs/KQOhhcAej9/sFp0EhMpVed4=; b=mmFRkMvll1dWzjbQ3+wKjQRcloNiLisxD92ulyJIz2CUzSj6hxEOrI/4iD5BvJ8Nbh A9Udqx8VAsD7Hl6qC+u/oGHdUHaV8tcW/RPE0rv+/ZC/h9UYBZG1lrszTsfo4JYLXLxw lJhewPMkEUm0fQPBBX8MRDsV8h21ieOuLlnjE/IoYpcj3LLUhmXtl/d7tUPt8VLY7CVV nZ0Kr0r3xx+EQR9gCwMEF9nXC+/bO0jdjqLAhRoAzlOrPHRUxWMB340y7ROIYYDaV8/k t8ADNztnM8RhXRAEWhmKJNS1zutpi2dO/ETnELCO54FaKASe/rNfqzKMrVOrB/46Hfp7 /Sbg== X-Gm-Message-State: APjAAAVXSgB8PB4ydidN5jmOn41XCJREMcCESIz5u98CpiEZwAGDnlqq 9bhtHx3wsEix+4ykeoo7b7U= X-Received: by 2002:a17:902:e2:: with SMTP id a89mr24664291pla.210.1562589211477; Mon, 08 Jul 2019 05:33:31 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id t10sm17102282pjr.13.2019.07.08.05.33.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 05:33:31 -0700 (PDT) From: Fuqian Huang Cc: Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH 07/14] Input: cyapa - Replace devm_add_action() followed by failure action with devm_add_action_or_reset() Date: Mon, 8 Jul 2019 20:33:23 +0800 Message-Id: <20190708123323.11943-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/input/mouse/cyapa.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse/cyapa.c index dfd3873513e4..e1d9ab558ecf 100644 --- a/drivers/input/mouse/cyapa.c +++ b/drivers/input/mouse/cyapa.c @@ -840,10 +840,9 @@ static int cyapa_prepare_wakeup_controls(struct cyapa *cyapa) return error; } - error = devm_add_action(dev, + error = devm_add_action_or_reset(dev, cyapa_remove_power_wakeup_group, cyapa); if (error) { - cyapa_remove_power_wakeup_group(cyapa); dev_err(dev, "failed to add power cleanup action: %d\n", error); return error; @@ -957,9 +956,8 @@ static int cyapa_start_runtime(struct cyapa *cyapa) return error; } - error = devm_add_action(dev, cyapa_remove_power_runtime_group, cyapa); + error = devm_add_action_or_reset(dev, cyapa_remove_power_runtime_group, cyapa); if (error) { - cyapa_remove_power_runtime_group(cyapa); dev_err(dev, "failed to add power runtime cleanup action: %d\n", error); @@ -1298,9 +1296,8 @@ static int cyapa_probe(struct i2c_client *client, return error; } - error = devm_add_action(dev, cyapa_disable_regulator, cyapa); + error = devm_add_action_or_reset(dev, cyapa_disable_regulator, cyapa); if (error) { - cyapa_disable_regulator(cyapa); dev_err(dev, "failed to add disable regulator action: %d\n", error); return error; @@ -1318,9 +1315,8 @@ static int cyapa_probe(struct i2c_client *client, return error; } - error = devm_add_action(dev, cyapa_remove_sysfs_group, cyapa); + error = devm_add_action_or_reset(dev, cyapa_remove_sysfs_group, cyapa); if (error) { - cyapa_remove_sysfs_group(cyapa); dev_err(dev, "failed to add sysfs cleanup action: %d\n", error); return error; } -- 2.11.0