Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8eaa8ee authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ion: msm: Assume devicetree support"

parents 6dad06cc 1b851a56
Loading
Loading
Loading
Loading
+10 −30
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ struct ion_heap_desc {
	const char *name;
};

#ifdef CONFIG_OF
static struct ion_heap_desc ion_heap_meta[] = {
	{
		.id	= ION_SYSTEM_HEAP_ID,
@@ -79,9 +78,7 @@ static struct ion_heap_desc ion_heap_meta[] = {
		.name	= ION_SECURE_CARVEOUT_HEAP_NAME,
	}
};
#endif

#ifdef CONFIG_OF
#define MAKE_HEAP_TYPE_MAPPING(h) { .name = #h, \
			.heap_type = ION_HEAP_TYPE_##h, }

@@ -330,13 +327,13 @@ static int msm_ion_get_heap_dt_data(struct device_node *node,

static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
{
	struct ion_platform_data *pdata = 0;
	struct ion_platform_data *pdata = NULL;
	struct ion_platform_heap *heaps = NULL;
	struct device_node *node;
	struct platform_device *new_dev = NULL;
	const struct device_node *dt_node = pdev->dev.of_node;
	const __be32 *val;
	int ret = -EINVAL;
	int ret;
	u32 num_heaps = 0;
	int idx = 0;

@@ -364,6 +361,7 @@ static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
		new_dev = of_platform_device_create(node, NULL, &pdev->dev);
		if (!new_dev) {
			pr_err("Failed to create device %s\n", node->name);
			ret = -EINVAL;
			goto free_heaps;
		}
		of_dma_configure(&new_dev->dev, node, true);
@@ -372,6 +370,7 @@ static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
		val = of_get_address(node, 0, NULL, NULL);
		if (!val) {
			pr_err("%s: Unable to find reg key\n", __func__);
			ret = -EINVAL;
			goto free_heaps;
		}
		pdata->heaps[idx].id = (u32)of_read_number(val, 1);
@@ -393,16 +392,6 @@ static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
	free_pdata(pdata);
	return ERR_PTR(ret);
}
#else
static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
{
	return NULL;
}

static void free_pdata(const struct ion_platform_data *pdata)
{
}
#endif

struct ion_heap *get_ion_heap(int heap_id)
{
@@ -424,21 +413,14 @@ struct ion_heap *get_ion_heap(int heap_id)
static int msm_ion_probe(struct platform_device *pdev)
{
	struct ion_platform_data *pdata;
	unsigned int pdata_needs_to_be_freed;
	int err = -1;
	int i;

	if (pdev->dev.of_node) {
	pdata = msm_ion_parse_dt(pdev);
	if (IS_ERR(pdata)) {
		status = ION_INIT_FAILURE;
		return PTR_ERR(pdata);
	}
		pdata_needs_to_be_freed = 1;
	} else {
		pdata = pdev->dev.platform_data;
		pdata_needs_to_be_freed = 0;
	}

	num_heaps = pdata->nr;

@@ -470,7 +452,6 @@ static int msm_ion_probe(struct platform_device *pdev)

		ion_device_add_heap(heaps[i]);
	}
	if (pdata_needs_to_be_freed)
	free_pdata(pdata);

	/*
@@ -483,7 +464,6 @@ static int msm_ion_probe(struct platform_device *pdev)

out:
	kfree(heaps);
	if (pdata_needs_to_be_freed)
	free_pdata(pdata);
	status = ION_INIT_FAILURE;
	return err;