Commit 100d26e8 authored by Alex Elder's avatar Alex Elder Committed by Andy Gross

soc: qcom: smem: initialize region struct only when successful

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: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarAndy Gross <andy.gross@linaro.org>
parent 9f01b7a8
...@@ -888,6 +888,7 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, ...@@ -888,6 +888,7 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev,
{ {
struct device_node *np; struct device_node *np;
struct resource r; struct resource r;
resource_size_t size;
int ret; int ret;
np = of_parse_phandle(dev->of_node, name, 0); np = of_parse_phandle(dev->of_node, name, 0);
...@@ -900,12 +901,13 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, ...@@ -900,12 +901,13 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev,
of_node_put(np); of_node_put(np);
if (ret) if (ret)
return ret; return ret;
size = resource_size(&r);
smem->regions[i].aux_base = (u32)r.start; smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size);
smem->regions[i].size = resource_size(&r);
smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, resource_size(&r));
if (!smem->regions[i].virt_base) if (!smem->regions[i].virt_base)
return -ENOMEM; return -ENOMEM;
smem->regions[i].aux_base = (u32)r.start;
smem->regions[i].size = size;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment