Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp455422pxb; Wed, 22 Sep 2021 06:03:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhUN3HfllBojpCyM7mzcdM/IDdugxOg5552emyDWoGcmOqlVY3hQMcOIqU2FH+Mt1SCbqM X-Received: by 2002:a5d:8844:: with SMTP id t4mr4364175ios.186.1632315833662; Wed, 22 Sep 2021 06:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632315833; cv=none; d=google.com; s=arc-20160816; b=j6sjCEnFer0+OfIpj8BM9DQxh2I2MPIJjfIT9NQcy7Hb+2Qu18gCSNiPLaQga7igE1 bfEAtg8h78343WhMCfpmCYYTtYmdkVHdxvGLXb5SW2cfxvScKNoANaLbb9L6ZuYxxy/7 xT7+mt0wvE0d654/PENA969j2VO8dVWwFo0hx+HPqmQWpuf786hFBQag+kp4VIaQPZM/ XT2EoVZ6Ss4VaSFRjMWt3ZnvqAKa1Bl0EhtSbI10z/QifiqCw/ji3OMSxzVMD3K/Wx78 K6/pyYCfud775WGfnEX9a2LWascN/g1mTYVQUcUbOH359vg/hLsqK+U7M5rnbLgwbgxY X5+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=98adHOzc1l3FGmIhs1IrJsM5aiXzfuQj53RFSugJu5U=; b=VEclaXSNccAqxxxfhVfriz5ff6ftv34Dow4YjoymUbY22O+y/c+eYvk3O9qxb3IQ/1 v8cBLcVtXz48RyNVGtqftbYLm7JRlVVMQV68YlOHTZLgszDgXmndVI6cuboa3JCwpe6+ 25rioNzsf2+aHlPw4xNef8f+iRF5zeVxuoD+bc3JuBpqFAMNXffbE1zDQw+YmKIGBLWq 2VWCnlZ2mfe9sD6VZ63Mrj5a3NY4vqNLcJe+IAD3jXigCWqFcPr9KmMErzJOmIqWXCaJ UXXS+c9MrKaqsaR/rvy6skV3QC/5zj6civYuiDRDR+Sf6YqaZ3BdOVqjzZ/iZlLeFRxO QeTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l6si2511120ilh.90.2021.09.22.06.03.38; Wed, 22 Sep 2021 06:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbhIVNBl (ORCPT + 99 others); Wed, 22 Sep 2021 09:01:41 -0400 Received: from mx24.baidu.com ([111.206.215.185]:55230 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229969AbhIVNBk (ORCPT ); Wed, 22 Sep 2021 09:01:40 -0400 Received: from BC-Mail-Ex19.internal.baidu.com (unknown [172.31.51.13]) by Forcepoint Email with ESMTPS id 11A6131257EC5A8E3D44; Wed, 22 Sep 2021 21:00:09 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-Ex19.internal.baidu.com (172.31.51.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Wed, 22 Sep 2021 21:00:08 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 22 Sep 2021 21:00:08 +0800 From: Cai Huoqing To: CC: Krzysztof Kozlowski , Thierry Reding , Jonathan Hunter , , Subject: [PATCH] memory: tegra: Make use of the helper function devm_add_action_or_reset() Date: Wed, 22 Sep 2021 21:00:01 +0800 Message-ID: <20210922130002.586-1-caihuoqing@baidu.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BJHW-Mail-Ex09.internal.baidu.com (10.127.64.32) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The helper function devm_add_action_or_reset() will internally call devm_add_action(), and if devm_add_action() fails then it will execute the action mentioned and return the error code. So use devm_add_action_or_reset() instead of devm_add_action() to simplify the error handling, reduce the code. Signed-off-by: Cai Huoqing --- drivers/memory/tegra/mc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 6b710c204799..44b4a4080920 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -87,11 +87,9 @@ struct tegra_mc *devm_tegra_memory_controller_get(struct device *dev) return ERR_PTR(-EPROBE_DEFER); } - err = devm_add_action(dev, tegra_mc_devm_action_put_device, mc); - if (err) { - put_device(mc->dev); + err = devm_add_action_or_reset(dev, tegra_mc_devm_action_put_device, mc); + if (err) return ERR_PTR(err); - } return mc; } -- 2.25.1