From patchwork Tue Jun 26 00:58:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139895 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4615764lji; Mon, 25 Jun 2018 17:59:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJZWqx09P6t9Ss1EU3pGA/0zoshHc8G/9rprkYM7NmsmmnIEwvo7SzjTh0o0TUU9ds9wVAk X-Received: by 2002:a62:5582:: with SMTP id j124-v6mr2847254pfb.20.1529974750246; Mon, 25 Jun 2018 17:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974750; cv=none; d=google.com; s=arc-20160816; b=n5MBIUpbCc9Z7MauMMf4RCJ7SXcXoBnSmdGtZ1g/WErmPPCmK315szUhOkxIMDFCnU V9hh9TMiNROOqQbIQuQxvGiLrtpX+c1EA5TfhypckJFhVpP1SRo+jv9lY/de2PwcW0X1 ZjJWbJ0yVTFKiYVjnU6/G8ko6lp5E3qjrFGf41uYtluA1ZKh1WZdyVsaJTU5Dpp5yEva Pos1LpZkd4oJGyeO8qdkeaf2W7ZF2Tvjvv815LPE30pq4+gm64klnF+uDBygyEqr8qQK HsYK49c21CnvBbcJpzn5ZQ3N4L5jlVMU0dOEdXzEaWlMMCu1XoOZNYDSL5pGU9uvtLd0 xf7w== 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=Gb0nb2yDTdFiuOpR0M5eWYBBjXEZNg/qX7xReBdXIr0=; b=CKTYLl7jyAxEVeUlsT4D3VjfAH/CeV/1zZi34lwGdD9NELzph7r7F19yhoNvHzrZMO bZUrEvinMPaZkO3HomOeH4UtQgzX3iNjIBL8JcQz59R9nrLRV0g7LGM/QbpW1DCHE3i6 yvDYa+esKhbvQxN1f3Yfh5b8xE7+CgJClcgxtIgWJbVOt1umT53OffrJ/wec49vRkBbv WXbuIJffxZzBQHpvFHkdL03u7eH1kWSUBIvtkkyUWyGzmRV81ie57amOkVVQILC3qI5g SxquErhmMNQk/7nQKCpKgKNxL3vBSlNDmqR5ywTyEi31zgE3q/wyJHLJIpVOT7PfJ3TH a2lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KbbcVmT2; 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 n10-v6si288453pgs.485.2018.06.25.17.59.09; Mon, 25 Jun 2018 17:59:10 -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=KbbcVmT2; 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 S934744AbeFZA7H (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:07 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:42778 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755764AbeFZA7E (ORCPT ); Mon, 25 Jun 2018 20:59:04 -0400 Received: by mail-io0-f196.google.com with SMTP id r24-v6so14309608ioh.9 for ; Mon, 25 Jun 2018 17:59:03 -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=Gb0nb2yDTdFiuOpR0M5eWYBBjXEZNg/qX7xReBdXIr0=; b=KbbcVmT205ORikHxa+fJHoNTiOBxXiI3YQM2Cczb6SXLZjj8XLpAXiuWBRp7K9UrGa 73oSUZ20muO/UHLR5vOAs/A0I31e/FSsGeTOxtt0H7PffOd4h8qs6DRlFtbWNEOpaoIw cWTcLch+eccaMgc0meNOEyK3Lee9qAFxAIkPE= 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=Gb0nb2yDTdFiuOpR0M5eWYBBjXEZNg/qX7xReBdXIr0=; b=NgzfQa3vaCFxe25xwfrWcXHga12Fu2fgd5+OG4ZYkqgZC76Jln4rWq1jdb8/dN68ue XV6yvaPb+3wc3YxvLcypi2vO6sfvZoKx6RAi49fxPWSRTRx1qQ9IEWJIoWiYf+aU8c6m Xg4r6Z0ti2UZqo+8eKPCDDc5AMPAijSI7wN7YHOLpWdL+CnRkzvcRfu+o8zgNfKryEnZ 6N4JK8hUVcbHbjYlImkP7YlK5CgRY57mRKHMWkef2o23/u8y6OZrIt+9z96V7dLvw4s4 pZMFI6wSF5G8khgSE8O1vnzCMfHEOV2H/N58WhdDZC9tpMoVsJvv9nZa6xjaXR6Bcasq m+yQ== X-Gm-Message-State: APt69E3+ART6UnloP+n7EB9zz8XK/g67Tzrcys96E6rq5K6FFl4quGs+ OUv1ka0sz8VTb25HBPaESuGZzQ== X-Received: by 2002:a6b:17c7:: with SMTP id 190-v6mr11392890iox.17.1529974743381; Mon, 25 Jun 2018 17:59:03 -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 f193-v6sm372556itf.9.2018.06.25.17.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:02 -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 resend 02/12] soc: qcom: smem: initialize region struct only when successful Date: Mon, 25 Jun 2018 19:58:46 -0500 Message-Id: <20180626005856.14174-3-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hold off initializing anything for the array entry representing a memory region in qcom_smem_map_memory() until we know we've successfully mapped it. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index c46bb43c0f3d..d8008bf480a4 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -887,6 +887,7 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, { struct device_node *np; struct resource r; + resource_size_t size; int ret; np = of_parse_phandle(dev->of_node, name, 0); @@ -899,12 +900,13 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, of_node_put(np); if (ret) return ret; + size = resource_size(&r); - smem->regions[i].aux_base = (u32)r.start; - smem->regions[i].size = resource_size(&r); - smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, resource_size(&r)); + smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size); if (!smem->regions[i].virt_base) return -ENOMEM; + smem->regions[i].aux_base = (u32)r.start; + smem->regions[i].size = size; return 0; }