xref: /linux/drivers/interconnect/qcom/icc-common.c (revision 170aafe35cb98e0f3fbacb446ea86389fbce22ea)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2022 Linaro Ltd.
4  */
5 
6 #include <linux/of.h>
7 #include <linux/slab.h>
8 #include <linux/module.h>
9 
10 #include "icc-common.h"
11 
12 struct icc_node_data *qcom_icc_xlate_extended(const struct of_phandle_args *spec,
13 					      void *data)
14 {
15 	struct icc_node_data *ndata;
16 	struct icc_node *node;
17 
18 	node = of_icc_xlate_onecell(spec, data);
19 	if (IS_ERR(node))
20 		return ERR_CAST(node);
21 
22 	ndata = kzalloc(sizeof(*ndata), GFP_KERNEL);
23 	if (!ndata)
24 		return ERR_PTR(-ENOMEM);
25 
26 	ndata->node = node;
27 
28 	if (spec->args_count == 2)
29 		ndata->tag = spec->args[1];
30 
31 	if (spec->args_count > 2)
32 		pr_warn("%pOF: Too many arguments, path tag is not parsed\n", spec->np);
33 
34 	return ndata;
35 }
36 EXPORT_SYMBOL_GPL(qcom_icc_xlate_extended);
37 
38 MODULE_DESCRIPTION("Qualcomm interconnect common functions");
39 MODULE_LICENSE("GPL");
40