Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp49153imm; Tue, 5 Jun 2018 14:50:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLrzS/ZaVmaTUVbZ5pp7zARtAUAg/qzogVSnqjfC0w40qz8lBSPEojfjle+/+Ixri8As8wY X-Received: by 2002:a63:b041:: with SMTP id z1-v6mr257872pgo.397.1528235405937; Tue, 05 Jun 2018 14:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528235405; cv=none; d=google.com; s=arc-20160816; b=SczdF+82w+MthWfZCOL2FRqDaUKCzvaYpQrOIuTQIRnxGNN6vGwthqIcBEF8zJ+cmB bEUJbpOdKgDr0YnmEaj0eIiYTkbymCL0Jqsdg38z5qvdALWToXF2PVyTKvSJoVYZwk2L psmQaBbNjB86fuNIftBf0t+1R27BTVC91M9esgABN7kWY9Cf8tq1qoJACUWHPva4gQBu bh0VW+7H591VR8LpgAOknbQXafq+x79VIX8h4TBT2BMGgYqBWeirc/5NWRJKwrlZ1LPl Riod6kk2/7eF6y0avnqkvpLRTzxEjXpOnz4neGi/OcjnAoa5MvSWgf+GaKwAKmYoT76+ bl2g== 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:arc-authentication-results; bh=qUsapzPcWGTiq+3OH1xjx9YK+b+IsN4WKgqqMiCGxrU=; b=Jf9kQA6BiUwOJJgx8zvTMTehb6/JkTqBsWkeGSts2LhFM6aWVeAVNAMfEsT5hNu/Nj wgz5sp0nDLmaa8oWixPgepeBRp7VkV0luxVAIBvYgGnHf/E5m8xpTbLi5EYUktJgeoQ9 BDv2SkPZb8w0Vdn288D4EfRJjWOa5ciuC2TJ8GjdZuFHmbjAJszqdc1pktjY+EOTIPHL lNx3eZfBJcneoAIAF/pc4i82fkvYO7ovPTIMIHJ3mciycXbrUGmY/pdhiOLtPONIPzML 3m/PBcOstfOFs/hbLv2B4DkKqWIGSwkX29MVA7JjcLRKTgJa/HEgwHVEdcXnzlJ30UFO H9SQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si14795349plb.100.2018.06.05.14.49.51; Tue, 05 Jun 2018 14:50:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753079AbeFEVsh (ORCPT + 99 others); Tue, 5 Jun 2018 17:48:37 -0400 Received: from foss.arm.com ([217.140.101.70]:34486 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751796AbeFEVpB (ORCPT ); Tue, 5 Jun 2018 17:45:01 -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 174981529; Tue, 5 Jun 2018 14:45:01 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 918B33F59D; Tue, 5 Jun 2018 14:44:58 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, robh@kernel.org, frowand.list@gmail.com, mark.rutland@arm.com, sudeep.holla@arm.com, arm@kernel.org, linux-kernel@vger.kernel.org, matt.sealey@arm.com, john.horley@arm.com, charles.garcia-tobin@arm.com, coresight@lists.linaro.org, devicetree@vger.kernel.org, mike.leach@linaro.org, Suzuki K Poulose Subject: [PATCH 06/20] coresight: Handle errors in finding input/output ports Date: Tue, 5 Jun 2018 22:43:17 +0100 Message-Id: <1528235011-30691-7-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> References: <1528235011-30691-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we fail to find the input / output port for a LINK component while enabling a path, we should fail gracefully rather than assuming port "0". Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 69e9136..3c1c058 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -107,7 +107,7 @@ static int coresight_find_link_inport(struct coresight_device *csdev, dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n", dev_name(&parent->dev), dev_name(&csdev->dev)); - return 0; + return -ENODEV; } static int coresight_find_link_outport(struct coresight_device *csdev, @@ -125,7 +125,7 @@ static int coresight_find_link_outport(struct coresight_device *csdev, dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n", dev_name(&csdev->dev), dev_name(&child->dev)); - return 0; + return -ENODEV; } static int coresight_enable_sink(struct coresight_device *csdev, u32 mode) @@ -178,6 +178,9 @@ static int coresight_enable_link(struct coresight_device *csdev, else refport = 0; + if (refport < 0) + return refport; + if (atomic_inc_return(&csdev->refcnt[refport]) == 1) { if (link_ops(csdev)->enable) { ret = link_ops(csdev)->enable(csdev, inport, outport); -- 2.7.4