|
20 | 20 |
|
21 | 21 | #include "internal.h" |
22 | 22 |
|
23 | | -#define ICC_DYN_ID_START 10000 |
| 23 | +#define ICC_DYN_ID_START 100000 |
24 | 24 |
|
25 | 25 | #define CREATE_TRACE_POINTS |
26 | 26 | #include "trace.h" |
@@ -819,6 +819,9 @@ static struct icc_node *icc_node_create_nolock(int id) |
819 | 819 | { |
820 | 820 | struct icc_node *node; |
821 | 821 |
|
| 822 | + if (id >= ICC_DYN_ID_START) |
| 823 | + return ERR_PTR(-EINVAL); |
| 824 | + |
822 | 825 | /* check if node already exists */ |
823 | 826 | node = node_find(id); |
824 | 827 | if (node) |
@@ -906,10 +909,35 @@ void icc_node_destroy(int id) |
906 | 909 | return; |
907 | 910 |
|
908 | 911 | kfree(node->links); |
| 912 | + if (node->id >= ICC_DYN_ID_START) |
| 913 | + kfree(node->name); |
909 | 914 | kfree(node); |
910 | 915 | } |
911 | 916 | EXPORT_SYMBOL_GPL(icc_node_destroy); |
912 | 917 |
|
| 918 | +/** |
| 919 | + * icc_node_set_name() - set node name |
| 920 | + * @node: node |
| 921 | + * @provider: node provider |
| 922 | + * @name: node name |
| 923 | + * |
| 924 | + * Return: 0 on success, or -ENOMEM on allocation failure |
| 925 | + */ |
| 926 | +int icc_node_set_name(struct icc_node *node, const struct icc_provider *provider, const char *name) |
| 927 | +{ |
| 928 | + if (node->id >= ICC_DYN_ID_START) { |
| 929 | + node->name = kasprintf(GFP_KERNEL, "%s@%s", name, |
| 930 | + dev_name(provider->dev)); |
| 931 | + if (!node->name) |
| 932 | + return -ENOMEM; |
| 933 | + } else { |
| 934 | + node->name = name; |
| 935 | + } |
| 936 | + |
| 937 | + return 0; |
| 938 | +} |
| 939 | +EXPORT_SYMBOL_GPL(icc_node_set_name); |
| 940 | + |
913 | 941 | /** |
914 | 942 | * icc_link_nodes() - create link between two nodes |
915 | 943 | * @src_node: source node |
@@ -1038,10 +1066,6 @@ void icc_node_add(struct icc_node *node, struct icc_provider *provider) |
1038 | 1066 | node->avg_bw = node->init_avg; |
1039 | 1067 | node->peak_bw = node->init_peak; |
1040 | 1068 |
|
1041 | | - if (node->id >= ICC_DYN_ID_START) |
1042 | | - node->name = devm_kasprintf(provider->dev, GFP_KERNEL, "%s@%s", |
1043 | | - node->name, dev_name(provider->dev)); |
1044 | | - |
1045 | 1069 | if (node->avg_bw || node->peak_bw) { |
1046 | 1070 | if (provider->pre_aggregate) |
1047 | 1071 | provider->pre_aggregate(node); |
|
0 commit comments