From patchwork Wed May 2 01:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134812 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp125553lji; Tue, 1 May 2018 18:13:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZojj6XhZDe22vXOqrrPztfRhLeA6gU9yu/9/e3jw3cZhbdUeACsbrDvk3YMVH6YIf6WhaKZ X-Received: by 2002:a17:902:1744:: with SMTP id i62-v6mr18356675pli.267.1525223587934; Tue, 01 May 2018 18:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223587; cv=none; d=google.com; s=arc-20160816; b=BRih+B6S0e3z5ijpuZlnZ+j2SDWNkQuHKXFokIKoZb5ObaC6WsLjJPCiXytJgOw4l9 fr9ZGUs8+Tq5YuWApCyO2w3MHK0l8FvFowHBXiSBgIYhxqk6hUPCOAK6DkAfai8kOrUW hwDOqJUX+xyWUltbz/bHAv+TowL9X87R/aZR7dEr8HxeDa+U5ALG2pqPXGi2nCH/3dW2 pAhsiFD0vgA4NRg+LVaWLaLpCmvpeZSSqMgxFLt3AwY+Jq3kaTgXboGEY+NIjSFLQm+O JvbcqXauNWHDRgZsPbgSdEupu51tyy3f8PYXrnjFXwhQJeTTWePyl1F7aeDWiMP6R74p x0pA== 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=1RXDSFOq1f1QYWFkcgyfUNldmkjn1WJSH/OCHWOfUjs=; b=ggDRJybYVNzkWLUb679siioczg6xGhaksj9P6V2VYo9HTaGh2Sakww02Wvo8hOi7vs lTxp6LB0WDelpknhdL4oKLADU4wcTSU/03D02Be02afousVeURj8PBZ45kd0n8YC2D9s TIOgeD69ol+5aroUsfEznmI/6R1jNbWNoKkb3caBAWqBVZYBlZRQ/u9K03UI34eeb3h8 ZNio+DxOBibNlrLpY3A/aOQ4pUCFd2OCCYTxPYWeJc+ueXVQpZtDyblwicuL5l8xqnDY AlWH1EfWvcy7A+Rko3d8wlOVoAi61391t/S5zDBDzmnxUG8+hv4PhG/QjcmjxoU+S54t L2pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jkA1uNbF; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 h61-v6si10141052pld.228.2018.05.01.18.13.07; Tue, 01 May 2018 18:13:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jkA1uNbF; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751455AbeEBBNG (ORCPT + 12 others); Tue, 1 May 2018 21:13:06 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:34646 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbeEBBKa (ORCPT ); Tue, 1 May 2018 21:10:30 -0400 Received: by mail-io0-f194.google.com with SMTP id p124-v6so15604253iod.1 for ; Tue, 01 May 2018 18:10:30 -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=ZZzu3l8jcgZvq4ndJoB14BgCndafFixyKtg8Nan0A8g=; b=jkA1uNbFxd+k5Wsc3tstDS1Ky2VRlQZqz3G4X9V+ABDrK0iB/UuDcbLsTTKTYmmtuq JrIwYAmXTCIU6+CtghUv7k7ndrjUPepkPgj2TIQmPkjIbTDBmXLmH0SmKQDgrHfyhBg9 UdBTnCpGqX4Sp63/JXmVXvDXak0TohX+JbTg0= 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=ZZzu3l8jcgZvq4ndJoB14BgCndafFixyKtg8Nan0A8g=; b=L5ZLOdcOlY+UX+O1d4eiPwQsotqTQ7gleUIBdo5co2B7sywV4MWEOkZzuBiTixsa5b UrjqhAER0h2642tvYEqt5EtmTPtyvE/njYwooeJfCUFOn5PDnkkm0xKavRlC35sAllfn lkDJ8e0JEzGeERsyF8zWemKVtr9s0nJlN5VV7cY4+3vurpU40iFSMp8FGak7eNXyfJww ko6oHygMlMsTYxfXjZ6xNPfqDbG5lH2YTnUxSxhSro9a6pZsJea2VejfdaY+3dmfvtT3 47Ox0F9AAtcZQlZrwFMIdrsAGAYCE8LI1VxJ2+XmnVeMEUw5UVEz2CntNSCGJxstW0nM GpEA== X-Gm-Message-State: ALQs6tC8P3+7ly2ODjhnMq80O9QE5fFxCj1ScJ9mcIigO6NqSDxDXAmL bXVsIg51cjBp7rXWJHH7Gohbtg== X-Received: by 2002:a6b:298f:: with SMTP id p137-v6mr19516412iop.288.1525223429668; Tue, 01 May 2018 18:10:29 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:28 -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 02/12] soc: qcom: smem: initialize region struct only when successful Date: Tue, 1 May 2018 20:10:09 -0500 Message-Id: <20180502011019.22812-3-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }