[component][driver]init dm serial naming framework in a separate phase (#8971)
init dm serial naming framework in a phase
This commit is contained in:
parent
6b12bce22f
commit
adf2b35ec6
|
@ -11,11 +11,12 @@
|
||||||
#include <rtatomic.h>
|
#include <rtatomic.h>
|
||||||
#include <drivers/serial_dm.h>
|
#include <drivers/serial_dm.h>
|
||||||
|
|
||||||
|
static int uid_min = -1;
|
||||||
|
static volatile rt_atomic_t uid = 0;
|
||||||
|
|
||||||
int serial_dev_set_name(struct rt_serial_device *sdev)
|
int serial_dev_set_name(struct rt_serial_device *sdev)
|
||||||
{
|
{
|
||||||
int id = -1;
|
int id = -1;
|
||||||
static int uid_min = -1;
|
|
||||||
static volatile rt_atomic_t uid = 0;
|
|
||||||
|
|
||||||
RT_ASSERT(sdev != RT_NULL);
|
RT_ASSERT(sdev != RT_NULL);
|
||||||
|
|
||||||
|
@ -28,20 +29,6 @@ int serial_dev_set_name(struct rt_serial_device *sdev)
|
||||||
{
|
{
|
||||||
id = rt_ofw_get_alias_id(sdev->parent.ofw_node, "uart");
|
id = rt_ofw_get_alias_id(sdev->parent.ofw_node, "uart");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uid_min < 0)
|
|
||||||
{
|
|
||||||
uid_min = rt_ofw_get_alias_last_id("serial");
|
|
||||||
|
|
||||||
if (uid_min < 0)
|
|
||||||
{
|
|
||||||
uid_min = rt_ofw_get_alias_last_id("uart");
|
|
||||||
}
|
|
||||||
|
|
||||||
uid_min = uid_min < 0 ? 0 : (uid_min + 1);
|
|
||||||
|
|
||||||
rt_hw_atomic_store(&uid, uid_min);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -53,6 +40,25 @@ int serial_dev_set_name(struct rt_serial_device *sdev)
|
||||||
return rt_dm_dev_set_name(&sdev->parent, "uart%u", id);
|
return rt_dm_dev_set_name(&sdev->parent, "uart%u", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int serial_dm_naming_framework_init(void)
|
||||||
|
{
|
||||||
|
#ifdef RT_USING_OFW
|
||||||
|
uid_min = rt_ofw_get_alias_last_id("serial");
|
||||||
|
|
||||||
|
if (uid_min < 0)
|
||||||
|
{
|
||||||
|
uid_min = rt_ofw_get_alias_last_id("uart");
|
||||||
|
}
|
||||||
|
|
||||||
|
uid_min = uid_min < 0 ? 0 : (uid_min + 1);
|
||||||
|
|
||||||
|
rt_hw_atomic_store(&uid, uid_min);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
INIT_PLATFORM_EXPORT(serial_dm_naming_framework_init);
|
||||||
|
|
||||||
void *serial_base_from_args(char *str)
|
void *serial_base_from_args(char *str)
|
||||||
{
|
{
|
||||||
rt_ubase_t base = 0;
|
rt_ubase_t base = 0;
|
||||||
|
|
Loading…
Reference in New Issue