From patchwork Wed Jul 13 00:15:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 71892 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp734790qga; Tue, 12 Jul 2016 17:16:56 -0700 (PDT) X-Received: by 10.98.89.23 with SMTP id n23mr31215724pfb.34.1468369016432; Tue, 12 Jul 2016 17:16:56 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si5284604pfa.0.2016.07.12.17.16.56; Tue, 12 Jul 2016 17:16:56 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751466AbcGMAQO (ORCPT + 30 others); Tue, 12 Jul 2016 20:16:14 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34324 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750829AbcGMAQF (ORCPT ); Tue, 12 Jul 2016 20:16:05 -0400 Received: by mail-pa0-f45.google.com with SMTP id fi15so11512451pac.1 for ; Tue, 12 Jul 2016 17:15:59 -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=0ndbDQ5SNYmL3sZQovyoKtH1DyUUjyjjo3Ejxj83910=; b=OhBnyVmb46j2ZDCKnxkNrg/hKXJ2TlqA3ma3johog55MEubPlH4XLms8qVh6OpfNKq ouR4YKhAGYHs4Ntsr06RmPrn26polj+fREF+bjclj4XxLwEQI3ZrzlcdAryXCyTRh9AG f03oNmVcXb52RvTg8xXb/52+hYd4Vvpos0c68= 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=0ndbDQ5SNYmL3sZQovyoKtH1DyUUjyjjo3Ejxj83910=; b=DYe4A8uisrpTDz8vqABua/ZSKP9Jj8nED/cWhg3/RLewhKceomrKosKvrzhD/7+Q9k ln1IXElNuLtODOqrz3fGm9OLxtFr5cCUzK7QhOsli/gFl12/KPP7sNlQNIX3QG2CsHt4 YP11Uybchjjt9v9u+a4HEUChHLTgDzqP4gZYekpaqkQPzzJqiHNc3fA2IFQ9W7PCXtir NzhP0IJRBAhQDntZMsD3FeX5LB6/b2x1k8yqqfqYgGw4qYLMsZo1wMfLTnmQYMEUJ7PI ML5nAxOaM6Ah9sI4eb/nLxxjvOzq30m9o291lkHZLxIOmr3H8IA3BCX2L/7r/lquiLDc eB8A== X-Gm-Message-State: ALyK8tKvavLbSSppiT6lofREenxudvZFpAMrqhHKQZbLEoBRMGynUyLGbyxFf6f92GNNIBE5 X-Received: by 10.66.146.69 with SMTP id ta5mr3963315pab.157.1468368947942; Tue, 12 Jul 2016 17:15:47 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id 6sm4281618pfs.29.2016.07.12.17.15.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jul 2016 17:15:47 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: Dan Carpenter , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] remoteproc: qcom: hexagon: Clean up mpss validation Date: Tue, 12 Jul 2016 17:15:45 -0700 Message-Id: <1468368945-9482-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As reported by Dan the unsigned "val" can't be negative. But instead correcting the check for early errors here followed by a wait for the validation result to show the error or success we can consolidate these two parts of the validation process into the validation function. Reported-by: Dan Carpenter Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_q6v5_pil.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) -- 2.5.0 diff --git a/drivers/remoteproc/qcom_q6v5_pil.c b/drivers/remoteproc/qcom_q6v5_pil.c index 63406ee689d9..b8fba4dc2447 100644 --- a/drivers/remoteproc/qcom_q6v5_pil.c +++ b/drivers/remoteproc/qcom_q6v5_pil.c @@ -386,7 +386,6 @@ static int q6v5_mpss_validate(struct q6v5 *qproc, const struct firmware *fw) phys_addr_t fw_addr; bool relocate; size_t size; - u32 val; int ret; int i; @@ -425,8 +424,13 @@ static int q6v5_mpss_validate(struct q6v5 *qproc, const struct firmware *fw) writel(size, qproc->rmb_base + RMB_PMI_CODE_LENGTH_REG); } - val = readl(qproc->rmb_base + RMB_MBA_STATUS_REG); - return val < 0 ? val : 0; + ret = q6v5_rmb_mba_wait(qproc, RMB_MBA_AUTH_COMPLETE, 10000); + if (ret == -ETIMEDOUT) + dev_err(qproc->dev, "MPSS authentication timed out\n"); + else if (ret < 0) + dev_err(qproc->dev, "MPSS authentication failed: %d\n", ret); + + return ret < 0 ? ret : 0; } static int q6v5_mpss_load(struct q6v5 *qproc) @@ -463,14 +467,6 @@ static int q6v5_mpss_load(struct q6v5 *qproc) goto release_firmware; ret = q6v5_mpss_validate(qproc, fw); - if (ret) - goto release_firmware; - - ret = q6v5_rmb_mba_wait(qproc, RMB_MBA_AUTH_COMPLETE, 10000); - if (ret == -ETIMEDOUT) - dev_err(qproc->dev, "MPSS authentication timed out\n"); - else if (ret < 0) - dev_err(qproc->dev, "MPSS authentication failed: %d\n", ret); release_firmware: release_firmware(fw);