From patchwork Mon Jul 8 12:32:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuqian Huang X-Patchwork-Id: 11034953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34697912 for ; Mon, 8 Jul 2019 12:33:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 253682856E for ; Mon, 8 Jul 2019 12:33:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19E3C285F2; Mon, 8 Jul 2019 12:33:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0111F285ED for ; Mon, 8 Jul 2019 12:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbfGHMc7 (ORCPT ); Mon, 8 Jul 2019 08:32:59 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40007 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727373AbfGHMc7 (ORCPT ); Mon, 8 Jul 2019 08:32:59 -0400 Received: by mail-pf1-f194.google.com with SMTP id p184so7541014pfp.7; Mon, 08 Jul 2019 05:32:58 -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=C46gDCEdVWA7PE5DmuJRnFXdq5VAUrqxIItEhNnGUCE=; b=phgfree2DeZ5s/cqczYCpHvxhnyT2Y0/aYepBWKg76sPL6H4DoF6PjeZGW3ER7n16+ skQCXD7vF/NRCzECOyXGOp8Hsa8VEqVSqczaRLx+eJx5BfF5Ag7OpZLXUzbum3cM3mAi QoTxBc/kfPDPBhy4xE9QZUl7ikZo5ExOrvMPfZ/RxMJkyeW/cPl5USbhGBc1ubgyV+qI 5BSAHkNPc5PYHEEIYPNbpA/svU3PDJgTuEtBICgxUf3JggPyDI9GzCQo2qP4VdDf7p7o Kue0AxMpI1W8w0ULHBxGjOWyLzwvngNZ30PBmcz23uGXGC46yfUaNPwuw7+o9XDuhfyU lJyg== 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=C46gDCEdVWA7PE5DmuJRnFXdq5VAUrqxIItEhNnGUCE=; b=I6GrJBOAnmkYi87e5IgIhZQQslW99kyEuttYvWVYAh0h9dXBZ+XuSqaxlvtK2u/nWd fgMn56lz33h07tCX3I8ow/oDBVgNyUb3n0G4smoNOJMng7UY1BZ2MX3LRXItaXlBqgUt kyaCRn8G5v/x3RB34LmxyK0URp7EnA843eLr+vmmXUQdKXEbuF31FKbMLKHuloQJEhca o5CKveSEP7uhyo6QiRLLhevNlwqnFTou37+HOH6eKiAXAseDoIjvzwBTRFd0zYUJXZP1 K5m2rjYN5scHzVTIuovX1ABfyRjHJQxnyRcabDvoBjemW5lK4HrKtMpGfYOH3cCPX5MS oGfA== X-Gm-Message-State: APjAAAUWSrB1dMV0qzO9aq6mOwRIjQb3hKTbogtSQDkB/AVkViTw1OXK 8lT2JXoHYEXnyUDLTpRvZ0kFo4xrtvI= X-Google-Smtp-Source: APXvYqyuRcskUUW5YTcw79udTgLkJ/6QNlFR3T+5HznvVabkz4Vj34HXD9mk1YmTvs+tPSrnUo/uMw== X-Received: by 2002:a65:6401:: with SMTP id a1mr23580780pgv.42.1562589177838; Mon, 08 Jul 2019 05:32:57 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id w3sm15929528pgl.31.2019.07.08.05.32.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 05:32:57 -0700 (PDT) From: Fuqian Huang Cc: Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH 03/14] power: supply: sc27xx: Introduce local variable 'struct device *dev' Date: Mon, 8 Jul 2019 20:32:51 +0800 Message-Id: <20190708123251.11759-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatly. Signed-off-by: Fuqian Huang Reviewed-by: Baolin Wang --- drivers/power/supply/sc27xx_fuel_gauge.c | 47 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c index 24895cc3b41e..9c184d80088b 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -957,81 +957,82 @@ static int sc27xx_fgu_hw_init(struct sc27xx_fgu_data *data) static int sc27xx_fgu_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct power_supply_config fgu_cfg = { }; struct sc27xx_fgu_data *data; int ret, irq; - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; - data->regmap = dev_get_regmap(pdev->dev.parent, NULL); + data->regmap = dev_get_regmap(dev->parent, NULL); if (!data->regmap) { - dev_err(&pdev->dev, "failed to get regmap\n"); + dev_err(dev, "failed to get regmap\n"); return -ENODEV; } - ret = device_property_read_u32(&pdev->dev, "reg", &data->base); + ret = device_property_read_u32(dev, "reg", &data->base); if (ret) { - dev_err(&pdev->dev, "failed to get fgu address\n"); + dev_err(dev, "failed to get fgu address\n"); return ret; } - data->channel = devm_iio_channel_get(&pdev->dev, "bat-temp"); + data->channel = devm_iio_channel_get(dev, "bat-temp"); if (IS_ERR(data->channel)) { - dev_err(&pdev->dev, "failed to get IIO channel\n"); + dev_err(dev, "failed to get IIO channel\n"); return PTR_ERR(data->channel); } - data->charge_chan = devm_iio_channel_get(&pdev->dev, "charge-vol"); + data->charge_chan = devm_iio_channel_get(dev, "charge-vol"); if (IS_ERR(data->charge_chan)) { - dev_err(&pdev->dev, "failed to get charge IIO channel\n"); + dev_err(dev, "failed to get charge IIO channel\n"); return PTR_ERR(data->charge_chan); } - data->gpiod = devm_gpiod_get(&pdev->dev, "bat-detect", GPIOD_IN); + data->gpiod = devm_gpiod_get(dev, "bat-detect", GPIOD_IN); if (IS_ERR(data->gpiod)) { - dev_err(&pdev->dev, "failed to get battery detection GPIO\n"); + dev_err(dev, "failed to get battery detection GPIO\n"); return PTR_ERR(data->gpiod); } ret = gpiod_get_value_cansleep(data->gpiod); if (ret < 0) { - dev_err(&pdev->dev, "failed to get gpio state\n"); + dev_err(dev, "failed to get gpio state\n"); return ret; } data->bat_present = !!ret; mutex_init(&data->lock); - data->dev = &pdev->dev; + data->dev = dev; platform_set_drvdata(pdev, data); fgu_cfg.drv_data = data; fgu_cfg.of_node = np; - data->battery = devm_power_supply_register(&pdev->dev, &sc27xx_fgu_desc, + data->battery = devm_power_supply_register(dev, &sc27xx_fgu_desc, &fgu_cfg); if (IS_ERR(data->battery)) { - dev_err(&pdev->dev, "failed to register power supply\n"); + dev_err(dev, "failed to register power supply\n"); return PTR_ERR(data->battery); } ret = sc27xx_fgu_hw_init(data); if (ret) { - dev_err(&pdev->dev, "failed to initialize fgu hardware\n"); + dev_err(dev, "failed to initialize fgu hardware\n"); return ret; } - ret = devm_add_action(&pdev->dev, sc27xx_fgu_disable, data); + ret = devm_add_action(dev, sc27xx_fgu_disable, data); if (ret) { sc27xx_fgu_disable(data); - dev_err(&pdev->dev, "failed to add fgu disable action\n"); + dev_err(dev, "failed to add fgu disable action\n"); return ret; } irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "no irq resource specified\n"); + dev_err(dev, "no irq resource specified\n"); return irq; } @@ -1046,17 +1047,17 @@ static int sc27xx_fgu_probe(struct platform_device *pdev) irq = gpiod_to_irq(data->gpiod); if (irq < 0) { - dev_err(&pdev->dev, "failed to translate GPIO to IRQ\n"); + dev_err(dev, "failed to translate GPIO to IRQ\n"); return irq; } - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, + ret = devm_request_threaded_irq(dev, irq, NULL, sc27xx_fgu_bat_detection, IRQF_ONESHOT | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, pdev->name, data); if (ret) { - dev_err(&pdev->dev, "failed to request IRQ\n"); + dev_err(dev, "failed to request IRQ\n"); return ret; } From patchwork Mon Jul 8 12:32:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuqian Huang X-Patchwork-Id: 11034955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9340C13B1 for ; Mon, 8 Jul 2019 12:33:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8561D285EA for ; Mon, 8 Jul 2019 12:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A188285ED; Mon, 8 Jul 2019 12:33:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B54B285F2 for ; Mon, 8 Jul 2019 12:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730609AbfGHMdG (ORCPT ); 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-Google-Smtp-Source: APXvYqzYWjFP+nhZ470GYs56Hyj6CIw1WicGs+mdOLgv7qbpWHyytpIcf6Zz2U/mY84c7QAcuslyYw== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Baolin Wang --- 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; } From patchwork Mon Jul 8 12:34:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuqian Huang X-Patchwork-Id: 11034969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0178E13B1 for ; Mon, 8 Jul 2019 12:34:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6E07285D5 for ; Mon, 8 Jul 2019 12:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB33E285ED; Mon, 8 Jul 2019 12:34:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91CA2285D5 for ; Mon, 8 Jul 2019 12:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729546AbfGHMeQ (ORCPT ); Mon, 8 Jul 2019 08:34:16 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36979 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbfGHMeQ (ORCPT ); Mon, 8 Jul 2019 08:34:16 -0400 Received: by mail-pg1-f196.google.com with SMTP id g15so7624730pgi.4; Mon, 08 Jul 2019 05:34:16 -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=NjnqLo3iz545x+S/KElhJPXTzOJzfZJMgeETAvhK2LU=; b=ZOSKOH9ptz42APtzNxr/4fxHNtLoWbGY1peNF/bZjQqe6lKg5MN560m0wpvTf/9EJx B+TG/tCXqG7H4/QoHftgxuWTZshzZVclaaR6T+yfQeRx4F6ZIR30GzHeEBrclcl53PJX bKwEwHg/H6JrvHZ2gu3Sb8zxI8wyuorntaxWeQ42Q2vAYIRSTt+f38PoKJTz5bNJ4Fx5 B2/Yze+0Q3nVnZxnS2ewedrjHHpn68RPTWghoQFznhqkA6GlZEQCIyYha0Xj0HdpNfQz rS6dIDFHNCVWU7gNeg9xu9GauI/5bXhQ4nef7sfUVTEvgeozM07QBiauuKiDmtDj6Uot WHAQ== 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=NjnqLo3iz545x+S/KElhJPXTzOJzfZJMgeETAvhK2LU=; b=XqwD8Q89fSwlVEcQVYeC9SQHWQ7AAC1ltZR3Hz+v5wV/2QNjx3njTgrAX7Cw+YI8+q rkxGKKysDNFYNyMGM9BlO0d7T+HeczFEWKX5yUd1aTfYTyI6qdcL1M3ZeyIHQKUsl9GX fDp7V5kmMwx8JtZh0TbqFK5JU0R/fF/gSx2HAFw06B8BW3xdxoUVtxkD7UiUvYjRB7eB 5eNRszlldEaZs9B5+esTuTEQG5eHuf4PRZe2rNQ/3aiY2/MuGR46VCQAarXYmtXjenbz c/Em1ehsHvYTrL4WOa9x5665GQJ1W5OsS7hbEMXF79SlaTcnpmibhjq8o8PD9VtjcI4M 2lqg== X-Gm-Message-State: APjAAAWBUaX1uItqvSly8KAepvFzBWOliufq9IoPFjHypTvepX57Kqiq zgfvaCUGSsRtvUpL5wcsMgGUK9mZgL4= X-Google-Smtp-Source: APXvYqwptuU442FRVbw38exDDtoo5AIEoLjyAxxfOmUHmqr8wOOLnRnMFNTXHshFtLuvManYWC/0ug== X-Received: by 2002:a63:6f8f:: with SMTP id k137mr23414666pgc.90.1562589255980; Mon, 08 Jul 2019 05:34:15 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id br18sm14785970pjb.20.2019.07.08.05.34.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jul 2019 05:34:15 -0700 (PDT) From: Fuqian Huang Cc: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH 13/14] thermal: rcar_gen3_thermal: Replace devm_add_action() followed by failure action with devm_add_action_or_reset() Date: Mon, 8 Jul 2019 20:34:09 +0800 Message-Id: <20190708123409.12219-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/thermal/rcar_gen3_thermal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index a56463308694..755d2b5bd2c2 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -443,9 +443,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) if (ret) goto error_unregister; - ret = devm_add_action(dev, rcar_gen3_hwmon_action, zone); + ret = devm_add_action_or_reset(dev, rcar_gen3_hwmon_action, zone); if (ret) { - rcar_gen3_hwmon_action(zone); goto error_unregister; }