This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e9a382953a6ceb0879c6ba9b8cad3037e87c6694 Author: likun17 <[email protected]> AuthorDate: Fri Aug 29 15:48:51 2025 +0800 drivers/sensors: Log register failures and successful unregisters. sensor_custom_register() printed "Registering" before calling register_driver(), so a failed registration of an already existing path looked successful in the log, and sensor_custom_unregister() printed "UnRegistering" even when it then returned -EBUSY. Print an error when register_driver() fails, and print the info messages only after the operation has actually started. Signed-off-by: likun17 <[email protected]> --- drivers/sensors/sensor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c index 00c365d13a7..00ec388405a 100644 --- a/drivers/sensors/sensor.c +++ b/drivers/sensors/sensor.c @@ -1521,13 +1521,14 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower, strlcpy(upper->name, basename((char *)path), sizeof(upper->name)); upper->state.nbuffer = lower->nbuffer; upper->lower = lower; - sminfo(upper->name, "Registering %s", path); ret = register_driver(path, &g_sensor_fops, 0600, upper); if (ret) { + snerr("ERROR: register failed! path:%s\n", path); goto drv_err; } + sminfo(upper->name, "Registering %s", path); return ret; drv_err: @@ -1616,7 +1617,6 @@ int sensor_custom_unregister(FAR struct sensor_lowerhalf_s *lower, #endif upper = lower->priv; - sminfo(upper->name, "UnRegistering"); /* A physical sensor is its own advertiser, see sensor_custom_register */ @@ -1626,6 +1626,7 @@ int sensor_custom_unregister(FAR struct sensor_lowerhalf_s *lower, return -EBUSY; } + sminfo(upper->name, "UnRegistering"); unregister_driver(path); nxrmutex_destroy(&upper->lock); if (circbuf_is_init(&upper->buffer))
