driver/sensor: move register_driver to end to avoid race condition
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
bf6063cc04
commit
38393cfc94
@ -1048,14 +1048,6 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower,
|
||||
lower->nbuffer = 0;
|
||||
}
|
||||
|
||||
upper->state.nbuffer = lower->nbuffer;
|
||||
sninfo("Registering %s\n", path);
|
||||
ret = register_driver(path, &g_sensor_fops, 0666, upper);
|
||||
if (ret)
|
||||
{
|
||||
goto drv_err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SENSORS_RPMSG
|
||||
lower = sensor_rpmsg_register(lower, path);
|
||||
if (lower == NULL)
|
||||
@ -1065,7 +1057,15 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower,
|
||||
}
|
||||
#endif
|
||||
|
||||
upper->state.nbuffer = lower->nbuffer;
|
||||
upper->lower = lower;
|
||||
sninfo("Registering %s\n", path);
|
||||
ret = register_driver(path, &g_sensor_fops, 0666, upper);
|
||||
if (ret)
|
||||
{
|
||||
goto drv_err;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
drv_err:
|
||||
|
Loading…
Reference in New Issue
Block a user