diff --git a/drivers/coresight/coresight_core.c b/drivers/coresight/coresight_core.c index 56e056af0e..9b113123b9 100644 --- a/drivers/coresight/coresight_core.c +++ b/drivers/coresight/coresight_core.c @@ -661,6 +661,29 @@ err: return ret; } +/**************************************************************************** + * Name: coresight_find_dev + ****************************************************************************/ + +static FAR struct coresight_dev_s *coresight_find_dev(FAR const char *name) +{ + FAR struct coresight_dev_s *tempdev; + irqstate_t flags; + + flags = enter_critical_section(); + list_for_every_entry(&g_csdev_list, tempdev, struct coresight_dev_s, node) + { + if (strcmp(tempdev->name, name) == 0) + { + leave_critical_section(flags); + return tempdev; + } + } + + leave_critical_section(flags); + return NULL; +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -687,6 +710,12 @@ int coresight_register(FAR struct coresight_dev_s *csdev, irqstate_t flags; int i; + if (coresight_find_dev(desc->name) != NULL) + { + cserr("device has been registered!\n"); + return -EEXIST; + } + csdev->name = desc->name; csdev->addr = desc->addr; csdev->type = desc->type;