From patchwork Fri Sep 9 10:18:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 9322891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16B596077F for ; Fri, 9 Sep 2016 10:20:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 086FC29D56 for ; Fri, 9 Sep 2016 10:20:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0C4F29D93; Fri, 9 Sep 2016 10:20:50 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D8AA29D56 for ; Fri, 9 Sep 2016 10:20:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1biIu2-0002eU-0x; Fri, 09 Sep 2016 10:19:22 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1biItv-0002b9-Pz for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2016 10:19:17 +0000 Received: by mail-pf0-x22c.google.com with SMTP id g202so28307736pfb.0 for ; Fri, 09 Sep 2016 03:18:55 -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; bh=TXjQ2ppzyfddIfh4j9cQn+OI4R0E8PdZRc1tF1t1huk=; b=cM3B1FiMVHfrNFmrUF6ybw89hxE5fB/OHp99yGv6qZfz3nU/pP5RbYo9JsAw+UIQer AEsRatKAIo5wu1UL06b5/smafqOSJShlB4HCuhNloWOXXHKjwBTglH/e0HT+lVi2tnEE b+x6E9Prv6R8dgwhRQUdPYyrs828lfPD/6j/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TXjQ2ppzyfddIfh4j9cQn+OI4R0E8PdZRc1tF1t1huk=; b=JEATjnPX5i/T/SR/mXcrBSx32GFPXV4XrWjU+hWRghxafitQCg+mq9fE919JYGqf/f e02ZhUEhUlmkUD99pMgecUrVoRAlGZzwxBrC3LAm8ItWPes7SjphsS90H/ZolxynrbBl LnQeRCUg/NK62zbHgAOeZj6Dehmo4GMZdemaOdB0Blz+9AP4ranNnUfMtCOcFWt+BsiQ cJ0jWs3K//Fl2VY2HcSweLiEOLI997D4KUPJDOdipvckX9l7c/+M4+RVSl2mS+UH1eid Jehlgl08cyn2f8pwSk03A1MV8OuEQo1Yr5EFq0FYMRRXBGfQ2GiEUopAKyEFC95k1PS/ pGKg== X-Gm-Message-State: AE9vXwOWskRsI1f86xtFihEgkZIpVGLm4DuI1LjM0yz+ahWkCb7q+FkUFLecCDoae6P16tIk X-Received: by 10.98.46.199 with SMTP id u190mr5067130pfu.160.1473416334830; Fri, 09 Sep 2016 03:18:54 -0700 (PDT) Received: from ubuntu16.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id y3sm4117256pfy.36.2016.09.09.03.18.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 03:18:54 -0700 (PDT) From: Chunyan Zhang To: mathieu.poirier@linaro.org Subject: [PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop Date: Fri, 9 Sep 2016 18:18:09 +0800 Message-Id: <1473416289-30882-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160909_031915_928367_461B934C X-CRM114-Status: GOOD ( 11.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhang.lyra@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In STM framework driver, the trace data writing loop would keep running until it received a negative return value or the whole trace packet has been written to STM device. So if the .packet() of STM device always returns zero since the device is not enabled or the parameter isn't supported, STM framework driver will stall into a dead loop. Returning -EACCES (Permission denied) in .packet() if the device is disabled makes more sense, and this is the same for returning -EINVAL if the channel passed into is not supported. Signed-off-by: Chunyan Zhang --- drivers/hwtracing/coresight/coresight-stm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 73be58a..6291ce1 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -399,10 +399,10 @@ static ssize_t stm_generic_packet(struct stm_data *stm_data, struct stm_drvdata, stm); if (!(drvdata && local_read(&drvdata->mode))) - return 0; + return -EACCES; if (channel >= drvdata->numsp) - return 0; + return -EINVAL; ch_addr = (unsigned long)stm_channel_addr(drvdata, channel);