mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 03:27:03 +02:00
coresight: add support for device names
Add support to read device names from device tree entries. This allows using same names for CoreSight devices across different targets. Change-Id: I58d39c9e313a513ee1728b0437419661e33767b9 Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
This commit is contained in:
parent
17a880d7fb
commit
1efe267018
|
|
@ -1989,28 +1989,32 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict,
|
|||
{
|
||||
int idx;
|
||||
char *name = NULL;
|
||||
const char *coresight_name = NULL;
|
||||
struct fwnode_handle **list;
|
||||
struct device_node *node = dev->of_node;
|
||||
|
||||
mutex_lock(&coresight_mutex);
|
||||
|
||||
idx = coresight_search_device_idx(dict, dev_fwnode(dev));
|
||||
if (idx < 0) {
|
||||
/* Make space for the new entry */
|
||||
idx = dict->nr_idx;
|
||||
list = krealloc_array(dict->fwnode_list,
|
||||
idx + 1, sizeof(*dict->fwnode_list),
|
||||
GFP_KERNEL);
|
||||
if (ZERO_OR_NULL_PTR(list)) {
|
||||
idx = -ENOMEM;
|
||||
goto done;
|
||||
if (!of_property_read_string(node, "coresight-name", &coresight_name))
|
||||
name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
|
||||
else {
|
||||
idx = coresight_search_device_idx(dict, dev_fwnode(dev));
|
||||
if (idx < 0) {
|
||||
/* Make space for the new entry */
|
||||
idx = dict->nr_idx;
|
||||
list = krealloc_array(dict->fwnode_list,
|
||||
idx + 1, sizeof(*dict->fwnode_list),
|
||||
GFP_KERNEL);
|
||||
if (ZERO_OR_NULL_PTR(list))
|
||||
goto done;
|
||||
|
||||
list[idx] = dev_fwnode(dev);
|
||||
dict->fwnode_list = list;
|
||||
dict->nr_idx = idx + 1;
|
||||
}
|
||||
|
||||
list[idx] = dev_fwnode(dev);
|
||||
dict->fwnode_list = list;
|
||||
dict->nr_idx = idx + 1;
|
||||
name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
|
||||
}
|
||||
|
||||
name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
|
||||
done:
|
||||
mutex_unlock(&coresight_mutex);
|
||||
return name;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user