Received: by 10.192.165.156 with SMTP id m28csp76148imm; Tue, 10 Apr 2018 16:47:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+i5xkCva1EqFN74Y97IeiRWbtUkjSubsQ/6KEbMApxQrTvWyyhF63553EhbO+RtNfmqC14 X-Received: by 10.99.106.67 with SMTP id f64mr1705900pgc.218.1523404033575; Tue, 10 Apr 2018 16:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404033; cv=none; d=google.com; s=arc-20160816; b=s1Xyk3hwahr/9C7JYfiQ1RVdMbhF5gMX8cdYlj5W9bL8zjaX1yHBk3nsGc6KhaAf+/ Q23d0uqsVnCFmVtG2lgqK82vCLQVGpz/9B4PzP3d68urnE3cZYUXXyiw2edHzOpT9/xO /8ep+kXh6H0X1TGl2emmTNsHlHbN9eFwQpSzwTPWHVg5Hn+XJ0S1taroDCG3ulK//lTq N+w9dvAmr7uos4Kb8jsjSEVQ7Z7wgwgwAn7igFt+jbGtddmOz5cYJ7yGienkNpMdNlHd M8/n+CdEHAKGHlNb6SWj0F0Bq59oUPnuJjIHgRsGYlUfts4z6o5cYZzghmaaDxaGNcew gklQ== 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:dkim-signature:arc-authentication-results; bh=5wlkiebE+lt8D2K+rDYtdKU2imQTARWjqvZM2UydGD8=; b=I29SwW2qzXM0dS4emnuIbtqvo9YjK7mAmL9m17P07PQO3n54eA4hkJAhRfr3hOoe56 2cAyJhBCK/IvQqXO5KQ5AVZ1MxmdWX9U32cn6xEIcjvbo5L2Wp9KT9QEWmShpg5Y98V+ rhajrTad7stY3rc0sxxe3eJhnQrwzNgaJA9cjXVxuQcBKV4AImESP5HEw1Lcj4sdM6MS oYsA8YoIA3b4qcWe1p7ro+P93WhRodzON60+nYVKgQCRiuTNiuOX2mkcW0OM7T7ZOi8P G5WZbtAgkzU+SczbbaK0cpZCFJhTs3kxSCJ3Pw6VXujm/KKBC7ZDUx6xQ6TtST3bSpgV 0D9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OqTCwApj; 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 n6-v6si3223333plp.194.2018.04.10.16.46.36; Tue, 10 Apr 2018 16:47:13 -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=OqTCwApj; 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 S1753088AbeDJW0R (ORCPT + 99 others); Tue, 10 Apr 2018 18:26:17 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:37308 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbeDJW0M (ORCPT ); Tue, 10 Apr 2018 18:26:12 -0400 Received: by mail-it0-f66.google.com with SMTP id 71-v6so255437ith.2 for ; Tue, 10 Apr 2018 15:26:12 -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; bh=5wlkiebE+lt8D2K+rDYtdKU2imQTARWjqvZM2UydGD8=; b=OqTCwApjGkfP65S9dpNe+mI/xbYC7MIA7uNTmueb76zGBUKYZ6XJTHaUNqIpHkpGR/ Wnm/RnvftTzlE5B6sPU7LSUXK9m006TA5LO/0iUdPHe/yAvhyTcmxbCjB4JKhJ+IWG9V qOLgd9dffr92EL1Jh47jgCxMcf1kvsbrtvT5o= 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; bh=5wlkiebE+lt8D2K+rDYtdKU2imQTARWjqvZM2UydGD8=; b=sm3shjccE1lqXbzq73TIR+lsHZUKyrZwSftK8Opt0S8bWtp7PFuC5yRYhpbc/LBjeo TDa8z09F5AJr+42SSQ/vTybDohlyf2zYxay7MIuU1iA0+5CJr2ag9bfJqwThBkkgfG8t XRh6cagfvXYtTU4qYODlHWrIY4LMtIXDt2BQ8S4OGGb0WHuYCM1CjwiYcjgKQ6GjMW3C ULoNMKYNZLA+ZLhv2FGtGWFP86fuXlgyTn3U8fkSMyZbPJZfsWjR2C1YL8+SDt/A8hb6 vaU/dxfhCEaxGfxfyCfi/Sn4UQ7d1pBQ3FCygyKpT6K4B4dfN/W0CY1cTx2iZh9t5B4Z OcBA== X-Gm-Message-State: ALQs6tCZehEYQQLkDkJDL5unPcFJDJqYYEzgVTMesmPO34PU3wjI/hs6 /O0EqYTw/pWO8PbTvysebvlixA== X-Received: by 2002:a24:5f45:: with SMTP id r66-v6mr1432180itb.126.1523399171632; Tue, 10 Apr 2018 15:26:11 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id l16-v6sm1373640iti.18.2018.04.10.15.26.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:11 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] soc: qcom: smem: check sooner in qcom_smem_set_global_partition() Date: Tue, 10 Apr 2018 17:25:42 -0500 Message-Id: <20180410222542.29474-7-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180410222542.29474-1-elder@linaro.org> References: <20180410222542.29474-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's no sense in scanning the partition table again if we know the global partition has already been discovered. Check for a non-null global_partition pointer in qcom_smem_set_global_partition() immediately. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 6e42599b70d4..7d9a43da5084 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -364,6 +364,11 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem, end = phdr_to_last_uncached_entry(phdr); cached = phdr_to_last_cached_entry(phdr); + if (smem->global_partition) { + dev_err(smem->dev, "Already found the global partition\n"); + return -EINVAL; + } + while (hdr < end) { if (hdr->canary != SMEM_PRIVATE_CANARY) goto bad_canary; @@ -729,11 +734,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (smem->global_partition) { - dev_err(smem->dev, "Already found the global partition\n"); - return -EINVAL; - } - header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); host0 = le16_to_cpu(header->host0); host1 = le16_to_cpu(header->host1); -- 2.14.1