From patchwork Fri Sep 27 07:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 174590 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3112925ill; Fri, 27 Sep 2019 00:11:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBADSLeltSXpAotPyZJ4Ajsc6ObAIUW63PqiLHalf+rfJhPr9/7+HhwvLu1a4E8khiU7kT X-Received: by 2002:a17:906:80d9:: with SMTP id a25mr6566364ejx.222.1569568287710; Fri, 27 Sep 2019 00:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569568287; cv=none; d=google.com; s=arc-20160816; b=VyTRXt3u8Hqs6EAnK0vSmWWLncGNJvdjUN5JuqP9MDbqAkkynlnviBBoIgokEBEmD0 Do/vZPKRlnaMY17gR3s8o1cqMXjFXPezMDfMddIoPp8PoOgwvlvKEydQe4d4m1yoHEWf tgk331tQGNDZCGrQ2kDezDfaGSWJ45df6iaj9zB260h+HXXSeAK1ek7bMcW/M/csbFue ANK7mXNWTxANZ0DiMd6sm+2vYnBgw3CF/+pcRpk2cNChp8upz7oglENT+WkD6IX92V3q R5laOApUOIp7J0anqwxmcWRy9ZBf5Mo9e08mknCaoTkL3vh0rt2kBKWExsesxcWAiEoV 7nfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=rsM2uCT+H5N8frHAhYZ4xNoIMLY0pUKheXJFFZekhJ0=; b=KWxI1TJQS9MP8SbM9PFF2sZLunZL+97Wq0cKHj6VNdOQYOZoDdL2qk8L2jXo3vtZxt rXTFoPDM9a4ZOdHJADYjnXVZaqoTcq4eLueafHORa4tGG9fgr+fPceNNpPopvzZytx+0 p/z6nUYeVV/nFH6bRQ0wIKtI/s2ITl3uXeShKtiJqxZaPX5PtzKiP+nNqVh4C5L65ZQ/ o6z0x9KVHkckvv4f07tVC6WMuyakYxfjCuzdZX+Chj/YYoYqvk0cawcI4QEIMNamsxAb Pq1F6ctyd4Kw4ob0xx9NiJ5lG32aSUUEijTGG9y8YPmB1RITVkk7IzAjP1cUv/HXtQ5Z kUtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VYBbB4IX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t26si945311edd.184.2019.09.27.00.11.27; Fri, 27 Sep 2019 00:11:27 -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=pass header.i=@linaro.org header.s=google header.b=VYBbB4IX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbfI0HLX (ORCPT + 26 others); Fri, 27 Sep 2019 03:11:23 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38380 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbfI0HLX (ORCPT ); Fri, 27 Sep 2019 03:11:23 -0400 Received: by mail-pl1-f193.google.com with SMTP id w8so246085plq.5 for ; Fri, 27 Sep 2019 00:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=rsM2uCT+H5N8frHAhYZ4xNoIMLY0pUKheXJFFZekhJ0=; b=VYBbB4IXZbS8pOxmBk6Ioz1/IWOjHl0aTJCwLhy7YY2HHOvVRG5s4W2aVVxmyEKGfX LyxiwbJufXG7RI+4FuFZWzvK5XF6rm9m7oeL04AaxCK21NNiXH0opuZPvcb5XFwiAWmK sP6lF52WGe0e4yA3CKvCLEr1edRWQmh6G5HNcjd54Ybe8LkFTluD2Q/f+yN+BBjgCagH fANqi+yffexA3CyZIHB3U2vWcaBv6auX4VGErkEpk6i8tpYqwhDTlP7m06erEvBbgiq4 05La9Vf5EphZxq1KewIV2zUdaK8dJ37ec3+t+tn1fqSM5+IrOsNV8sD8e1zrpTcdacGG 50PA== 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:in-reply-to :references:in-reply-to:references; bh=rsM2uCT+H5N8frHAhYZ4xNoIMLY0pUKheXJFFZekhJ0=; b=IymKjfmExOdCazxDxX8Vkbgg+LJjoZI8fezioZqZ9sU6p+lriNwDnrJFIvobPvjXHD b865zbwxwRBlyH+RvMhn2kz2GElfksHm0IAzTa3XKY/LhLN9+eVSHhIbihdtMmIGI/f7 TN8s9DvHoiJiepg6X6PzVOuJpjsialkKCAksuHwPlk0mM8VLr5XEQ43FZCYrAvYoO9R+ uQt0wvTmUn7N0xJZzjb78qwjZjwHG3HlhvhFIvvbW+4meSyQWLz5bxetyYvd9pUTzpBw q4/qUnKAGql9vzO8AhqKBSM0/EJ3ov8W99UP9YpHjhxDWppgkcyRfX/ecTLC93xsgM6I 6Apw== X-Gm-Message-State: APjAAAWXt0BEeqhYb97dAMszSQaGewOBH1q3/F1r8/+gzdgO88+sbl94 XaWRRjel2mfEcJKD4eqrCP4gPQ== X-Received: by 2002:a17:902:7886:: with SMTP id q6mr3030571pll.323.1569568281015; Fri, 27 Sep 2019 00:11:21 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id f74sm1733288pfa.34.2019.09.27.00.11.18 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Sep 2019 00:11:20 -0700 (PDT) From: Baolin Wang To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: orsonzhai@gmail.com, baolin.wang@linaro.org, zhang.lyra@gmail.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] hwspinlock: sprd: Use devm_add_action_or_reset() for calls to clk_disable_unprepare() Date: Fri, 27 Sep 2019 15:10:46 +0800 Message-Id: <03de1c267461a6ac17cf7732404795b2fe735927.1569567749.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_add_action_or_reset() for calls to clk_disable_unprepare(), which can simplify the error handling. Signed-off-by: Baolin Wang --- drivers/hwspinlock/sprd_hwspinlock.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/drivers/hwspinlock/sprd_hwspinlock.c b/drivers/hwspinlock/sprd_hwspinlock.c index d210424..e76c702 100644 --- a/drivers/hwspinlock/sprd_hwspinlock.c +++ b/drivers/hwspinlock/sprd_hwspinlock.c @@ -79,6 +79,13 @@ static void sprd_hwspinlock_relax(struct hwspinlock *lock) .relax = sprd_hwspinlock_relax, }; +static void sprd_hwspinlock_disable(void *data) +{ + struct sprd_hwspinlock_dev *sprd_hwlock = data; + + clk_disable_unprepare(sprd_hwlock->clk); +} + static int sprd_hwspinlock_probe(struct platform_device *pdev) { struct sprd_hwspinlock_dev *sprd_hwlock; @@ -109,6 +116,14 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev) if (ret) return ret; + ret = devm_add_action_or_reset(&pdev->dev, sprd_hwspinlock_disable, + sprd_hwlock); + if (ret) { + dev_err(&pdev->dev, + "Failed to add hwspinlock disable action\n"); + return ret; + } + /* set the hwspinlock to record user id to identify subsystems */ writel(HWSPINLOCK_USER_BITS, sprd_hwlock->base + HWSPINLOCK_RECCTRL); @@ -124,7 +139,6 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev) &sprd_hwspinlock_ops, 0, SPRD_HWLOCKS_NUM); if (ret) { pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(sprd_hwlock->clk); return ret; } @@ -137,7 +151,6 @@ static int sprd_hwspinlock_remove(struct platform_device *pdev) hwspin_lock_unregister(&sprd_hwlock->bank); pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(sprd_hwlock->clk); return 0; }