This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit fcde8211023a8346522461244650f6e8ca6fd96c Author: dongjiuzhu1 <[email protected]> AuthorDate: Tue May 13 16:22:55 2025 +0800 !drivers/sensors: Replace nonwakeup with wakeup. Non-wakeup has been the initial state of every sensor user and upper half since the "wakeup mode optimization" change, so the only useful request left is to turn wakeup on. Expressing that as "set nonwakeup to false" is a double negation in the ioctl, the lower half callback and the state fields. Rename the interface to describe the wakeup capability directly: * SNIOC_SET_NONWAKEUP -> SNIOC_SET_WAKEUP, argument true enables wakeup. * sensor_ops_s::set_nonwakeup -> set_wakeup. * sensor_state_s::nonwakeup and sensor_ustate_s::nonwakeup -> wakeup, initialized to false. * Update the sensor upper half, sensor_rpmsg and the ops comments of the uORB drivers accordingly. The ioctl number and the default behavior are unchanged. BREAKING CHANGE: SNIOC_SET_NONWAKEUP, sensor_ops_s::set_nonwakeup and the nonwakeup state fields are removed and code using them no longer builds. To fix, use SNIOC_SET_WAKEUP with the inverted argument (ioctl(fd, SNIOC_SET_WAKEUP, true) to enable wakeup, false to disable it), rename set_nonwakeup to set_wakeup in sensor_ops_s initializers and invert the bool argument in the callback, and read state.wakeup instead of !state.nonwakeup. In nuttx-apps, system/uorb must be updated at the same time to use SNIOC_SET_WAKEUP. The ioctl keeps its number with the argument inverted and is forwarded over rpmsg, so all cores that share sensor topics must be updated together. Signed-off-by: dongjiuzhu1 <[email protected]> --- drivers/sensors/adxl362_uorb.c | 2 +- drivers/sensors/adxl372_uorb.c | 2 +- drivers/sensors/bh1749nuc_uorb.c | 2 +- drivers/sensors/bme680_uorb.c | 2 +- drivers/sensors/bme688_uorb.c | 2 +- drivers/sensors/bmi270_uorb.c | 2 +- drivers/sensors/bmm150_uorb.c | 2 +- drivers/sensors/fs3000_uorb.c | 2 +- drivers/sensors/lsm9ds1_uorb.c | 2 +- drivers/sensors/ltr308_uorb.c | 2 +- drivers/sensors/mpu9250_uorb.c | 2 +- drivers/sensors/qmi8658_uorb.c | 2 +- drivers/sensors/scl3300_uorb.c | 2 +- drivers/sensors/sensor.c | 36 ++++++++++++++++++------------------ drivers/sensors/sensor_rpmsg.c | 34 +++++++++++++++++----------------- include/nuttx/sensors/ioctl.h | 8 ++++---- include/nuttx/sensors/sensor.h | 12 ++++++------ include/nuttx/uorb.h | 4 ++-- 18 files changed, 60 insertions(+), 60 deletions(-) diff --git a/drivers/sensors/adxl362_uorb.c b/drivers/sensors/adxl362_uorb.c index 5b9dea79cc1..f762d3256ee 100644 --- a/drivers/sensors/adxl362_uorb.c +++ b/drivers/sensors/adxl362_uorb.c @@ -164,7 +164,7 @@ static const struct sensor_ops_s g_adxl362_accel_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ NULL, /* control */ }; diff --git a/drivers/sensors/adxl372_uorb.c b/drivers/sensors/adxl372_uorb.c index d9267755f1c..3b860cd5370 100644 --- a/drivers/sensors/adxl372_uorb.c +++ b/drivers/sensors/adxl372_uorb.c @@ -112,7 +112,7 @@ static const struct sensor_ops_s g_adxl372_accel_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ NULL /* control */ }; diff --git a/drivers/sensors/bh1749nuc_uorb.c b/drivers/sensors/bh1749nuc_uorb.c index 301d751eadb..a60196dc518 100644 --- a/drivers/sensors/bh1749nuc_uorb.c +++ b/drivers/sensors/bh1749nuc_uorb.c @@ -113,7 +113,7 @@ static const struct sensor_ops_s g_bh1749nuc_sensor_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ bh1749nuc_control }; diff --git a/drivers/sensors/bme680_uorb.c b/drivers/sensors/bme680_uorb.c index f7a65e49dee..d1cf770f2d2 100644 --- a/drivers/sensors/bme680_uorb.c +++ b/drivers/sensors/bme680_uorb.c @@ -441,7 +441,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ bme680_calibrate, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ bme680_control /* control */ }; diff --git a/drivers/sensors/bme688_uorb.c b/drivers/sensors/bme688_uorb.c index c1f7e6a509e..4365cf2c497 100644 --- a/drivers/sensors/bme688_uorb.c +++ b/drivers/sensors/bme688_uorb.c @@ -389,7 +389,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ bme688_calibrate, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ bme688_control /* control */ }; diff --git a/drivers/sensors/bmi270_uorb.c b/drivers/sensors/bmi270_uorb.c index b3bc63652f9..7db22a64eab 100644 --- a/drivers/sensors/bmi270_uorb.c +++ b/drivers/sensors/bmi270_uorb.c @@ -133,7 +133,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ bmi270_control }; diff --git a/drivers/sensors/bmm150_uorb.c b/drivers/sensors/bmm150_uorb.c index 3a8922149f3..208b03587bf 100644 --- a/drivers/sensors/bmm150_uorb.c +++ b/drivers/sensors/bmm150_uorb.c @@ -188,7 +188,7 @@ static const struct sensor_ops_s g_bmm150_sensor_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ NULL, /* control */ }; diff --git a/drivers/sensors/fs3000_uorb.c b/drivers/sensors/fs3000_uorb.c index 7c7bca4deee..3096c1d719e 100644 --- a/drivers/sensors/fs3000_uorb.c +++ b/drivers/sensors/fs3000_uorb.c @@ -87,7 +87,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ NULL /* control */ }; diff --git a/drivers/sensors/lsm9ds1_uorb.c b/drivers/sensors/lsm9ds1_uorb.c index ab335615d27..ab058813b88 100644 --- a/drivers/sensors/lsm9ds1_uorb.c +++ b/drivers/sensors/lsm9ds1_uorb.c @@ -142,7 +142,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ .control = lsm9ds1_control }; diff --git a/drivers/sensors/ltr308_uorb.c b/drivers/sensors/ltr308_uorb.c index 75ed30a40fd..8f2b5a0cf96 100644 --- a/drivers/sensors/ltr308_uorb.c +++ b/drivers/sensors/ltr308_uorb.c @@ -109,7 +109,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ ltr308_calibrate, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ NULL /* control */ }; diff --git a/drivers/sensors/mpu9250_uorb.c b/drivers/sensors/mpu9250_uorb.c index c1b21591e76..92e5be1540a 100644 --- a/drivers/sensors/mpu9250_uorb.c +++ b/drivers/sensors/mpu9250_uorb.c @@ -387,7 +387,7 @@ static const struct sensor_ops_s g_mpu9250_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ mpu9250_control /* control */ }; diff --git a/drivers/sensors/qmi8658_uorb.c b/drivers/sensors/qmi8658_uorb.c index 4f4fd53fb3d..6869180de37 100644 --- a/drivers/sensors/qmi8658_uorb.c +++ b/drivers/sensors/qmi8658_uorb.c @@ -364,7 +364,7 @@ static const struct sensor_ops_s g_sensor_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ NULL, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ NULL, /* control */ }; diff --git a/drivers/sensors/scl3300_uorb.c b/drivers/sensors/scl3300_uorb.c index da845bacb21..35b4ebdc107 100644 --- a/drivers/sensors/scl3300_uorb.c +++ b/drivers/sensors/scl3300_uorb.c @@ -299,7 +299,7 @@ static const struct sensor_ops_s g_scl3300_ops = NULL, /* set_calibvalue */ NULL, /* calibrate */ scl3300_get_info, /* get_info */ - NULL, /* set_nonwakeup */ + NULL, /* set_wakeup */ scl3300_control, /* control */ }; diff --git a/drivers/sensors/sensor.c b/drivers/sensors/sensor.c index eac2d66a672..68b7064c7eb 100644 --- a/drivers/sensors/sensor.c +++ b/drivers/sensors/sensor.c @@ -462,38 +462,38 @@ update: return ret; } -static void sensor_update_nonwakeup(FAR struct file *filep, - FAR struct sensor_upperhalf_s *upper, - FAR struct sensor_user_s *user, - bool nonwakeup) +static void sensor_update_wakeup(FAR struct file *filep, + FAR struct sensor_upperhalf_s *upper, + FAR struct sensor_user_s *user, + bool wakeup) { FAR struct sensor_lowerhalf_s *lower = upper->lower; - if (nonwakeup == user->state.nonwakeup) + if (wakeup == user->state.wakeup) { return; } - user->state.nonwakeup = nonwakeup; + user->state.wakeup = wakeup; nxrmutex_lock(&upper->lock); list_for_every_entry(&upper->userlist, user, struct sensor_user_s, node) { - if (!user->state.nonwakeup) + if (user->state.wakeup) { - nonwakeup = false; + wakeup = true; break; } } - if (nonwakeup != upper->state.nonwakeup) + if (wakeup != upper->state.wakeup) { - upper->state.nonwakeup = nonwakeup; - sminfo(upper->name, "update nonwakeup %d", nonwakeup); + upper->state.wakeup = wakeup; + sminfo(upper->name, "update wakeup %d", wakeup); nxrmutex_unlock(&upper->lock); - if (lower->ops->set_nonwakeup) + if (lower->ops->set_wakeup) { - lower->ops->set_nonwakeup(lower, filep, nonwakeup); + lower->ops->set_wakeup(lower, filep, wakeup); } } else @@ -808,7 +808,7 @@ static int sensor_open(FAR struct file *filep) user->state.interval = UINT32_MAX; user->state.esize = upper->state.esize; - user->state.nonwakeup = true; + user->state.wakeup = false; list_add_tail(&upper->userlist, &user->node); /* The new user generation, notify to other users */ @@ -841,7 +841,7 @@ static int sensor_close(FAR struct file *filep) sensor_update_interval(filep, upper, user, UINT32_MAX); sensor_update_latency(filep, upper, user, UINT32_MAX); - sensor_update_nonwakeup(filep, upper, user, true); + sensor_update_wakeup(filep, upper, user, false); nxrmutex_lock(&upper->lock); @@ -1054,9 +1054,9 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; - case SNIOC_SET_NONWAKEUP: + case SNIOC_SET_WAKEUP: { - sensor_update_nonwakeup(filep, upper, user, (bool)arg); + sensor_update_wakeup(filep, upper, user, (bool)arg); } break; @@ -1479,7 +1479,7 @@ int sensor_custom_register(FAR struct sensor_lowerhalf_s *lower, list_initialize(&upper->userlist); upper->state.esize = esize; upper->state.min_interval = UINT32_MAX; - upper->state.nonwakeup = true; + upper->state.wakeup = false; if (lower->ops->activate) { upper->state.nadvertisers = 1; diff --git a/drivers/sensors/sensor_rpmsg.c b/drivers/sensors/sensor_rpmsg.c index 8607a362436..d2a750cc5f3 100644 --- a/drivers/sensors/sensor_rpmsg.c +++ b/drivers/sensors/sensor_rpmsg.c @@ -125,7 +125,7 @@ struct sensor_rpmsg_stub_s uint64_t cookie; struct file file; bool flushing; - bool nonwakeup; + bool wakeup; }; /* This structure describes the proxy info about remote advertisers. */ @@ -230,9 +230,9 @@ static int sensor_rpmsg_calibrate(FAR struct sensor_lowerhalf_s *lower, static int sensor_rpmsg_get_info(FAR struct sensor_lowerhalf_s *lower, FAR struct file *filep, FAR struct sensor_device_info_s *info); -static int sensor_rpmsg_set_nonwakeup(FAR struct sensor_lowerhalf_s *lower, - FAR struct file *filep, - bool nonwakeup); +static int sensor_rpmsg_set_wakeup(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, + bool wakeup); static int sensor_rpmsg_control(FAR struct sensor_lowerhalf_s *lower, FAR struct file *filep, int cmd, unsigned long arg); @@ -280,7 +280,7 @@ static const struct sensor_ops_s g_sensor_rpmsg_ops = .set_calibvalue = sensor_rpmsg_set_calibvalue, .calibrate = sensor_rpmsg_calibrate, .get_info = sensor_rpmsg_get_info, - .set_nonwakeup = sensor_rpmsg_set_nonwakeup, + .set_wakeup = sensor_rpmsg_set_wakeup, .control = sensor_rpmsg_control }; @@ -853,24 +853,24 @@ static int sensor_rpmsg_flush(FAR struct sensor_lowerhalf_s *lower, return ret; } -static int sensor_rpmsg_set_nonwakeup(FAR struct sensor_lowerhalf_s *lower, - FAR struct file *filep, - bool nonwakeup) +static int sensor_rpmsg_set_wakeup(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, + bool wakeup) { FAR struct sensor_rpmsg_dev_s *dev = lower->priv; FAR struct sensor_lowerhalf_s *drv = dev->drv; int ret = -ENOTTY; - if (drv->ops->set_nonwakeup) + if (drv->ops->set_wakeup) { - ret = drv->ops->set_nonwakeup(drv, filep, nonwakeup); + ret = drv->ops->set_wakeup(drv, filep, wakeup); } else if ((filep->f_oflags & SENSOR_REMOTE) || dev->nadvertisers > 0) { - /* If the driver (drv) does not support the nonwakeup operation, + /* If the driver (drv) does not support the wakeup operation, * and the caller is a remote invocation or the current device - * is an advertiser, then you can still consider the nonwakeup + * is an advertiser, then you can still consider the wakeup * operation as unsupported and therefore return ENOTSUP */ @@ -878,8 +878,8 @@ static int sensor_rpmsg_set_nonwakeup(FAR struct sensor_lowerhalf_s *lower, } else { - ret = sensor_rpmsg_ioctl(dev, SNIOC_SET_NONWAKEUP, - nonwakeup, 0, true); + ret = sensor_rpmsg_ioctl(dev, SNIOC_SET_WAKEUP, + wakeup, 0, true); } return ret; @@ -971,7 +971,7 @@ static void sensor_rpmsg_push_event_one(FAR struct sensor_rpmsg_dev_s *dev, */ sre = container_of(stub->ept, struct sensor_rpmsg_ept_s, ept); - if (stub->nonwakeup && !rpmsg_is_running(sre->ept.rdev)) + if (!stub->wakeup && !rpmsg_is_running(sre->ept.rdev)) { return; } @@ -1414,9 +1414,9 @@ static int sensor_rpmsg_ioctl_handler(FAR struct rpmsg_endpoint *ept, stub->flushing = true; } - if (msg->request == SNIOC_SET_NONWAKEUP) + if (msg->request == SNIOC_SET_WAKEUP) { - stub->nonwakeup = arg; + stub->wakeup = arg; } if (msg->cookie) diff --git a/include/nuttx/sensors/ioctl.h b/include/nuttx/sensors/ioctl.h index 3dab1ac975e..6fef65c879a 100644 --- a/include/nuttx/sensors/ioctl.h +++ b/include/nuttx/sensors/ioctl.h @@ -517,12 +517,12 @@ #define SNIOC_COLD_START _SNIOC(0X00A7) #define SNIOC_FULL_COLD_START _SNIOC(0X00A8) -/* Command: SNIOC_SET_NONWAKEUP - * Description: Set non-wakeup flag for user. - * Argument: True is non-wakeup, false is wakeup. +/* Command: SNIOC_SET_WAKEUP + * Description: Set wakeup flag for user. + * Argument: True is wakeup, false is non-wakeup. */ -#define SNIOC_SET_NONWAKEUP _SNIOC(0x00A9) +#define SNIOC_SET_WAKEUP _SNIOC(0x00A9) /* Command: SNIOC_GNSS_SET_PRIORITY * Description: Give GNSS priority over other radio activity (e.g. LTE idle) diff --git a/include/nuttx/sensors/sensor.h b/include/nuttx/sensors/sensor.h index 4255dae45e1..69ff24a1287 100644 --- a/include/nuttx/sensors/sensor.h +++ b/include/nuttx/sensors/sensor.h @@ -500,23 +500,23 @@ struct sensor_ops_s FAR struct sensor_device_info_s *info); /************************************************************************** - * Name: set_nonwakeup + * Name: set_wakeup * - * With this method, the user can disable wakeup capacity for the sensor - * when data or fifo ready to avoid wakeup cpu, and save power. + * With this method, the user can enable wakeup capacity for the sensor + * when data or fifo ready to wakeup cpu. * * Input Parameters: * lower - The instance of lower half sensor driver. * filep - The pointer of file, represents each user using sensor. - * nonwakeup - true(nonwakeup) and false(wakeup) + * wakeup - true(wakeup) and false(non-wakeup) * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * **************************************************************************/ - CODE int (*set_nonwakeup)(FAR struct sensor_lowerhalf_s *lower, - FAR struct file *filep, bool nonwakeup); + CODE int (*set_wakeup)(FAR struct sensor_lowerhalf_s *lower, + FAR struct file *filep, bool wakeup); /************************************************************************** * Name: control diff --git a/include/nuttx/uorb.h b/include/nuttx/uorb.h index ee3225391cb..f884910bc1b 100644 --- a/include/nuttx/uorb.h +++ b/include/nuttx/uorb.h @@ -1469,7 +1469,7 @@ struct sensor_state_s uint32_t nsubscribers; /* The number of subscribers */ uint32_t nadvertisers; /* The number of advertisers */ uint32_t generation; /* The recent generation of circular buffer */ - uint32_t nonwakeup; /* The non wakeup state of sensor device */ + uint32_t wakeup; /* The wakeup state of sensor device */ uint64_t priv; /* The pointer to private data of userspace user */ }; @@ -1480,7 +1480,7 @@ struct sensor_ustate_s uint32_t esize; /* The element size of circular buffer */ uint32_t latency; /* The batch latency for user, in us */ uint32_t interval; /* The subscription interval for user, in us */ - uint32_t nonwakeup; /* The non wakeup state of sensor user */ + uint32_t wakeup; /* The wakeup state of sensor user */ uint32_t generation; /* The recent generation of circular buffer */ };
