Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6851095ybi; Mon, 8 Jul 2019 09:36:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzefWACzxhVrFS8J/mE37mvaWMWw2leDP6onHiHUjpUObmUrFfavOw0Bi6pNFyv2fjC61Sw X-Received: by 2002:a17:90a:de02:: with SMTP id m2mr26933887pjv.18.1562603815244; Mon, 08 Jul 2019 09:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562603815; cv=none; d=google.com; s=arc-20160816; b=ZOylPtmgnWwr9rq6UdlvCfB79YxWI7or5n7TN8BrzbH3vhlS+2kjcszoJMw2sPChr5 Uum1Eo2sVG1zgIcRp2r8wEDRwGYt67W/SOwRmUpLQqMZlU5Ggiu1TAB/W1LMZOHrJUwI IRm22Mkzt/f+MJ4qOR8kH2QarYDSljiSXadK9w5PnG06kheTAyctEu3OfCao76EIjMfk Qthc95wtUoVIZ0lUzMjWzTxYX6LG7Qko5im0LxCdeGdy4owELCJ+fs5Oij8GawiiCDGa 0ulo7oxxkQ8eyh0837BOqa2pvp9p66aIRtR8BX0SaFZMwRzSFjkWIf6xz0QNvcvrWlvv +vKQ== 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=Cntnp9SEPAH6TMjcFYHFy/Dtz76FraqpSedF+U7vCtc=; b=WSFwx3uV7BtRCQkaY+dqmovHqW+AitrU+kiITPWZvSPNjQQQ0LDsMLJM8/eyMwTKid wrcyLuzeqpwynd5dN5K/AqFRqW0smz7LWGjIrQr5v/qJvtbftm35ByUu8iTs0KFaNr0k PQWVDxAuzfS5t54jQA/n/ErN6AqSnnlNBFCGRnikazytpZHBUsmiqKiSFm2rRKVGWI7P HY3yDFPLaF+LUW32YXuYu7ggsXTLNluFzkkhCgCo5yJSMqb81vjI/r3VKLwa3YZ6nCek eRKwWkbp+1WHiGV38XAWXWIIWTK717J4yh5o98Be1nw39MnsVhkZ3cEP3W2SyomNDXAO SESQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="Jp/gP13M"; 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 z62si19147718pgd.472.2019.07.08.09.36.40; Mon, 08 Jul 2019 09:36:55 -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="Jp/gP13M"; 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 S1730615AbfGHMdG (ORCPT + 99 others); Mon, 8 Jul 2019 08:33:06 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39819 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbfGHMdG (ORCPT ); Mon, 8 Jul 2019 08:33:06 -0400 Received: by mail-pl1-f194.google.com with SMTP id b7so8214791pls.6; Mon, 08 Jul 2019 05:33:05 -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=Cntnp9SEPAH6TMjcFYHFy/Dtz76FraqpSedF+U7vCtc=; b=Jp/gP13MfHrbwP0SyRCmDqy2TfkvrRrQhmHTO1KMNY/VkcSUq9q2C4vlZgUouoMxLF 2Rd082mZZGkgNUF57FXDCSe9U/z2qsim4x5xM4yuQeSRMDpzeQVRh4uqEx7+jmbvqsBC LR+Q0qbIZB72jfeHkMrr296f3qNkMs4wzZRcvQPBnfeAVJ+RwxyxsWUpS/DphJ2sCkCf Y5/0uQe93AGCM2bHxjpubd64BFxufURbqkJwOzQwT/DXTPLLbszKEnYdTqNY3hlQ4yyN 1eGGLRuhq3MTmoUKp9ksibnlduTZDVn4c4M7tbjaoG/5KNKDkJOIWYJGVUUsiYUjvHtk avNA== 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=Cntnp9SEPAH6TMjcFYHFy/Dtz76FraqpSedF+U7vCtc=; b=DLceoynVCHPUSfKND+8YQhnYXibtpDPbfbZIFr8q2r8YwF5Zfo0E4Sd/jYDG1eS+2B ALofk8oanwPOm0aj467mbtHBXX+rysAHIs+mqQWYkGB0W0AWTOQcxibhXZ/IwRr8Q1cU ybYlTZtVS3Xf9EHelqvOd6dCeFAGRnn6On2N9FxiYMTdGEYTKuCSsSDgPKS6L4pE9wCP /pDXFOZ+t/pf8FbcngF607CuS6PAY4+WOnZJrDIofT7x9oaq/taL4djsvu4Aak+xxpga 0TW6c86QJbSLArpzN5alwjlJsaAmXe5f62mZeCATrzNtLjxUz+2bXvkbhqb1fQc4/OO8 P7mg== X-Gm-Message-State: APjAAAWRDWIM4JK/0u6QsysDdFzoIjxdrKXkBPp6PAy3GsU6yIve2wBb s5aOZo1ik2ZSumfL51zvMBU= X-Received: by 2002:a17:902:2a27:: with SMTP id i36mr24118599plb.161.1562589185682; Mon, 08 Jul 2019 05:33:05 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id w12sm19354724pgp.56.2019.07.08.05.33.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 05:33:05 -0700 (PDT) From: Fuqian Huang Cc: Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH 04/14] power: supply: sc27xx: Replace devm_add_action() followed by failure action with devm_add_action_or_reset() Date: Mon, 8 Jul 2019 20:32:59 +0800 Message-Id: <20190708123259.11805-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/power/supply/sc27xx_fuel_gauge.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 9c184d80088b..58b2970cd359 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -1023,9 +1023,8 @@ static int sc27xx_fgu_probe(struct platform_device *pdev) return ret; } - ret = devm_add_action(dev, sc27xx_fgu_disable, data); + ret = devm_add_action_or_reset(dev, sc27xx_fgu_disable, data); if (ret) { - sc27xx_fgu_disable(data); dev_err(dev, "failed to add fgu disable action\n"); return ret; } -- 2.11.0