From patchwork Wed Mar 20 18:49:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 160703 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp625559jan; Wed, 20 Mar 2019 11:50:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpfL/mAvZutAogJj4K+hX3oP4w4kMXEQ4LPPCbJZZVt0eucLZJwU9qGTHd4LMZB3XOMq+n X-Received: by 2002:a17:902:32b:: with SMTP id 40mr9586553pld.122.1553107815261; Wed, 20 Mar 2019 11:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553107815; cv=none; d=google.com; s=arc-20160816; b=wOIBcKrTUW7kC2xHQXssyiqkfcvWCWKzg28/0n81CjSCdURKcMruwF4u+HRUmm0pQR cQV4vhSmUrsuPCn8yYRZNKyGIOXaQ4Fi5BqO0ANr0mS13tQY2nQkhZTPHaDGnZaavI2E +duFMudk1GgQQTBlmxCOZkM9/SHMn3KsNgt47UHiAmDqOgV5XuOXVSfavz06tBcORSvN +DEqGQDpZ/ML0b0Dss9phonFHwJ54SpvdcAovd3bZ57tOg7GQW+JbqeYhaQX6AtSNHPx 6TKI6dAZ+qoGc0GSLqnj5tGIQo38/wgMJ6FYETd84eEy6tdIiBCivDNTcP+51r6QbrxI Izdg== 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:message-id:date :subject:cc:to:from; bh=rpT1yVcSWqbJ93x+B67NGP5csap9zF5bWFaygSUlMXM=; b=QOoOGt9A9/FkyzwRgyRHfpPpkQ9Mhf3ad4D9D6xziAuvneYacHiF0SqJgOMuiubLuu k2RJIa/PeATa7ttx/TMSlUpthrWhgbxiscQAAKf3YW311NftBjcHqZNha6GZfkEgbCYn vqRQRYDV7/TMusggqy3eDSabUJfZMmlsGri1hAHcUSIpWsn2YnO6T1fBGCN1i7QSuTPH C/zHrsGnWbqYE7NTUSJ6DU/7bEVwaR7GbyNJS93626MOTO3EaQ3BYbGBbEu7enfaVzGT SamMbugqK/4p1HNWTGe1X0sbTedbHghXCrJXuIiH22LVeUyWVIdJ5t5ynDKw4q1c0625 qbVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x18si2244808pfa.52.2019.03.20.11.50.15; Wed, 20 Mar 2019 11:50:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727479AbfCTSuO (ORCPT + 9 others); Wed, 20 Mar 2019 14:50:14 -0400 Received: from foss.arm.com ([217.140.101.70]:44792 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbfCTSuM (ORCPT ); Wed, 20 Mar 2019 14:50:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 97611168F; Wed, 20 Mar 2019 11:50:12 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1C1A43F59C; Wed, 20 Mar 2019 11:50:10 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, coresight@lists.linaro.org, mike.leach@linaro.org, robert.walker@arm.com, Suzuki K Poulose , Mathieu Poirier Subject: [PATCH 02/25] coresight: dynamic-replicator: Clean up error handling Date: Wed, 20 Mar 2019 18:49:19 +0000 Message-Id: <1553107783-3340-3-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553107783-3340-1-git-send-email-suzuki.poulose@arm.com> References: <1553107783-3340-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org We fail to disable the clock in case of a failure during the probe. Clean this up. Also, we are supposed to drop the pm reference only when the probing is successful. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- .../coresight/coresight-dynamic-replicator.c | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c index 299667b..fe176b9 100644 --- a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c +++ b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c @@ -150,7 +150,7 @@ static const struct attribute_group *replicator_groups[] = { static int replicator_probe(struct amba_device *adev, const struct amba_id *id) { - int ret; + int ret = 0; struct device *dev = &adev->dev; struct resource *res = &adev->res; struct coresight_platform_data *pdata = NULL; @@ -180,12 +180,13 @@ static int replicator_probe(struct amba_device *adev, const struct amba_id *id) /* Validity for the resource is already checked by the AMBA core */ base = devm_ioremap_resource(dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + if (IS_ERR(base)) { + ret = PTR_ERR(base); + goto out_disable_clk; + } drvdata->base = base; dev_set_drvdata(dev, drvdata); - pm_runtime_put(&adev->dev); desc.type = CORESIGHT_DEV_TYPE_LINK; desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; @@ -195,11 +196,18 @@ static int replicator_probe(struct amba_device *adev, const struct amba_id *id) desc.groups = replicator_groups; drvdata->csdev = coresight_register(&desc); - if (!IS_ERR(drvdata->csdev)) { - replicator_reset(drvdata); - return 0; + if (IS_ERR(drvdata->csdev)) { + ret = PTR_ERR(drvdata->csdev); + goto out_disable_clk; } - return PTR_ERR(drvdata->csdev); + + replicator_reset(drvdata); + pm_runtime_put(&adev->dev); + +out_disable_clk: + if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) + clk_disable_unprepare(drvdata->atclk); + return ret; } #ifdef CONFIG_PM