driver/sensor: change protype of set_interval, batch to follow ioctl

1. change unsigned int to unsigned long

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong 2022-03-11 11:03:02 +08:00 committed by Xiang Xiao
parent 8f39c5f11b
commit 8d971101cd
8 changed files with 35 additions and 36 deletions

View File

@ -160,7 +160,7 @@ static int bmp280_putreg8(FAR struct bmp280_dev_s *priv, uint8_t regaddr,
/* Sensor methods */ /* Sensor methods */
static int bmp280_set_interval(FAR struct sensor_lowerhalf_s *lower, static int bmp280_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us); FAR unsigned long *period_us);
static int bmp280_activate(FAR struct sensor_lowerhalf_s *lower, static int bmp280_activate(FAR struct sensor_lowerhalf_s *lower,
bool enable); bool enable);
static int bmp280_fetch(FAR struct sensor_lowerhalf_s *lower, static int bmp280_fetch(FAR struct sensor_lowerhalf_s *lower,
@ -504,7 +504,7 @@ static uint32_t bmp280_compensate_press(FAR struct bmp280_dev_s *priv,
****************************************************************************/ ****************************************************************************/
static int bmp280_set_interval(FAR struct sensor_lowerhalf_s *lower, static int bmp280_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us) FAR unsigned long *period_us)
{ {
FAR struct bmp280_dev_s *priv = container_of(lower, FAR struct bmp280_dev_s *priv = container_of(lower,
FAR struct bmp280_dev_s, FAR struct bmp280_dev_s,

View File

@ -146,7 +146,7 @@ struct ds18b20_dev_s
struct onewire_config_s config; /* 1wire device configuration */ struct onewire_config_s config; /* 1wire device configuration */
struct ds18b20_config_s reg; /* Sensor resolution */ struct ds18b20_config_s reg; /* Sensor resolution */
#ifdef CONFIG_SENSORS_DS18B20_POLL #ifdef CONFIG_SENSORS_DS18B20_POLL
unsigned int interval; /* Polling interval */ unsigned long interval; /* Polling interval */
sem_t run; /* Locks sensor thread */ sem_t run; /* Locks sensor thread */
#endif #endif
}; };
@ -168,7 +168,7 @@ static int ds18b20_control(FAR struct sensor_lowerhalf_s *lower,
#ifdef CONFIG_SENSORS_DS18B20_POLL #ifdef CONFIG_SENSORS_DS18B20_POLL
static int ds18b20_set_interval(FAR struct sensor_lowerhalf_s *lower, static int ds18b20_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us); FAR unsigned long *period_us);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -778,7 +778,7 @@ static int ds18b20_active(FAR struct sensor_lowerhalf_s *lower,
#ifdef CONFIG_SENSORS_DS18B20_POLL #ifdef CONFIG_SENSORS_DS18B20_POLL
static int ds18b20_set_interval(FAR struct sensor_lowerhalf_s *lower, static int ds18b20_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us) FAR unsigned long *period_us)
{ {
FAR struct ds18b20_dev_s *priv = (FAR struct ds18b20_dev_s *)lower; FAR struct ds18b20_dev_s *priv = (FAR struct ds18b20_dev_s *)lower;
priv->interval = *period_us; priv->interval = *period_us;

View File

@ -47,8 +47,8 @@ struct fakesensor_s
{ {
struct sensor_lowerhalf_s lower; struct sensor_lowerhalf_s lower;
struct file data; struct file data;
unsigned int interval; unsigned long interval;
unsigned int batch; unsigned long batch;
int raw_start; int raw_start;
FAR const char *file_path; FAR const char *file_path;
sem_t wakeup; sem_t wakeup;
@ -62,9 +62,9 @@ struct fakesensor_s
static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower, static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower,
bool sw); bool sw);
static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower, static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us); FAR unsigned long *period_us);
static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower, static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *latency_us); FAR unsigned long *latency_us);
static void fakesensor_push_event(FAR struct sensor_lowerhalf_s *lower); static void fakesensor_push_event(FAR struct sensor_lowerhalf_s *lower);
static int fakesensor_thread(int argc, char** argv); static int fakesensor_thread(int argc, char** argv);
@ -120,7 +120,7 @@ static int fakesensor_read_csv_header(FAR struct fakesensor_s *sensor)
fakesensor_read_csv_line(&sensor->data, buffer, sizeof(buffer), 0); fakesensor_read_csv_line(&sensor->data, buffer, sizeof(buffer), 0);
if (sensor->interval == 0) if (sensor->interval == 0)
{ {
sscanf(buffer, "interval:%d\n", &sensor->interval); sscanf(buffer, "interval:%lu\n", &sensor->interval);
sensor->interval *= 1000; sensor->interval *= 1000;
} }
@ -234,7 +234,7 @@ static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower, bool sw)
} }
static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower, static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us) FAR unsigned long *period_us)
{ {
FAR struct fakesensor_s *sensor = container_of(lower, FAR struct fakesensor_s *sensor = container_of(lower,
struct fakesensor_s, lower); struct fakesensor_s, lower);
@ -243,11 +243,11 @@ static int fakesensor_set_interval(FAR struct sensor_lowerhalf_s *lower,
} }
static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower, static int fakesensor_batch(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *latency_us) FAR unsigned long *latency_us)
{ {
FAR struct fakesensor_s *sensor = container_of(lower, FAR struct fakesensor_s *sensor = container_of(lower,
struct fakesensor_s, lower); struct fakesensor_s, lower);
uint32_t max_latency = sensor->lower.buffer_number * sensor->interval; unsigned long max_latency = sensor->lower.buffer_number * sensor->interval;
if (*latency_us > max_latency) if (*latency_us > max_latency)
{ {
*latency_us = max_latency; *latency_us = max_latency;

View File

@ -96,7 +96,7 @@ struct hyt271_dev_s
sem_t lock_measure_cycle; /* Locks measure cycle */ sem_t lock_measure_cycle; /* Locks measure cycle */
uint32_t freq; /* I2C Frequency */ uint32_t freq; /* I2C Frequency */
#ifdef CONFIG_SENSORS_HYT271_POLL #ifdef CONFIG_SENSORS_HYT271_POLL
unsigned int interval; /* Polling interval */ unsigned long interval; /* Polling interval */
sem_t run; /* Locks sensor thread */ sem_t run; /* Locks sensor thread */
bool initial_read; /* Already read */ bool initial_read; /* Already read */
#endif #endif
@ -120,7 +120,7 @@ static int hyt271_control(FAR struct sensor_lowerhalf_s *lower,
#ifdef CONFIG_SENSORS_HYT271_POLL #ifdef CONFIG_SENSORS_HYT271_POLL
static int hyt271_set_interval(FAR struct sensor_lowerhalf_s *lower, static int hyt271_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us); FAR unsigned long *period_us);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -751,7 +751,7 @@ static int hyt271_active(FAR struct sensor_lowerhalf_s *lower,
#ifdef CONFIG_SENSORS_HYT271_POLL #ifdef CONFIG_SENSORS_HYT271_POLL
static int hyt271_set_interval(FAR struct sensor_lowerhalf_s *lower, static int hyt271_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us) FAR unsigned long *period_us)
{ {
FAR struct hyt271_sensor_s *priv = (FAR struct hyt271_sensor_s *)lower; FAR struct hyt271_sensor_s *priv = (FAR struct hyt271_sensor_s *)lower;
priv->dev->interval = *period_us; priv->dev->interval = *period_us;

View File

@ -94,7 +94,7 @@ struct ms5611_dev_s
uint32_t freq; /* Bus Frequency I2C/SPI */ uint32_t freq; /* Bus Frequency I2C/SPI */
struct ms5611_calib_s calib; /* Calib. params from ROM */ struct ms5611_calib_s calib; /* Calib. params from ROM */
unsigned int interval; /* Polling interval */ unsigned long interval; /* Polling interval */
bool enabled; /* Enable/Disable MS5611 */ bool enabled; /* Enable/Disable MS5611 */
sem_t run; /* Locks measure cycle */ sem_t run; /* Locks measure cycle */
sem_t exclsem; /* Manages exclusive to device */ sem_t exclsem; /* Manages exclusive to device */
@ -121,7 +121,7 @@ static unsigned long ms5611_curtime(void);
/* Sensor methods */ /* Sensor methods */
static int ms5611_set_interval(FAR struct sensor_lowerhalf_s *lower, static int ms5611_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us); FAR unsigned long *period_us);
static int ms5611_activate(FAR struct sensor_lowerhalf_s *lower, static int ms5611_activate(FAR struct sensor_lowerhalf_s *lower,
bool enable); bool enable);
@ -540,7 +540,7 @@ static uint32_t ms5611_compensate_press(FAR struct ms5611_dev_s *priv,
****************************************************************************/ ****************************************************************************/
static int ms5611_set_interval(FAR struct sensor_lowerhalf_s *lower, static int ms5611_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us) FAR unsigned long *period_us)
{ {
FAR struct ms5611_dev_s *priv = container_of(lower, FAR struct ms5611_dev_s *priv = container_of(lower,
FAR struct ms5611_dev_s, FAR struct ms5611_dev_s,

View File

@ -75,8 +75,8 @@ struct sensor_upperhalf_s
sem_t exclsem; /* Manages exclusive access to file operations */ sem_t exclsem; /* Manages exclusive access to file operations */
sem_t buffersem; /* Wakeup user waiting for data in circular buffer */ sem_t buffersem; /* Wakeup user waiting for data in circular buffer */
bool enabled; /* The status of sensor enable or disable */ bool enabled; /* The status of sensor enable or disable */
unsigned int interval; /* The sample interval for sensor, in us */ unsigned long interval; /* The sample interval for sensor, in us */
unsigned int latency; /* The batch latency for sensor, in us */ unsigned long latency; /* The batch latency for sensor, in us */
}; };
/**************************************************************************** /****************************************************************************
@ -340,7 +340,6 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR struct sensor_upperhalf_s *upper = inode->i_private; FAR struct sensor_upperhalf_s *upper = inode->i_private;
FAR struct sensor_lowerhalf_s *lower = upper->lower; FAR struct sensor_lowerhalf_s *lower = upper->lower;
FAR unsigned int *val = (unsigned int *)(uintptr_t)arg;
int ret; int ret;
sninfo("cmd=%x arg=%08lx\n", cmd, arg); sninfo("cmd=%x arg=%08lx\n", cmd, arg);
@ -382,15 +381,15 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break; break;
} }
if (upper->interval == *val) if (upper->interval == arg)
{ {
break; break;
} }
ret = lower->ops->set_interval(lower, val); ret = lower->ops->set_interval(lower, &arg);
if (ret >= 0) if (ret >= 0)
{ {
upper->interval = *val; upper->interval = arg;
} }
} }
break; break;
@ -409,15 +408,15 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
break; break;
} }
if (upper->latency == *val) if (upper->latency == arg)
{ {
break; break;
} }
ret = lower->ops->batch(lower, val); ret = lower->ops->batch(lower, &arg);
if (ret >= 0) if (ret >= 0)
{ {
upper->latency = *val; upper->latency = arg;
} }
} }
break; break;
@ -460,7 +459,7 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
case SNIOC_GET_NEVENTBUF: case SNIOC_GET_NEVENTBUF:
{ {
*val = lower->buffer_number; *(FAR uint32_t *)(uintptr_t)arg = lower->buffer_number;
} }
break; break;

View File

@ -73,8 +73,8 @@
struct wtgahrs2_sensor_s struct wtgahrs2_sensor_s
{ {
struct sensor_lowerhalf_s lower; struct sensor_lowerhalf_s lower;
unsigned int interval; unsigned long interval;
unsigned int last_update; uint64_t last_update;
bool enable; bool enable;
}; };
@ -97,7 +97,7 @@ struct wtgahrs2_dev_s
static int wtgahrs2_activate(FAR struct sensor_lowerhalf_s *lower, bool sw); static int wtgahrs2_activate(FAR struct sensor_lowerhalf_s *lower, bool sw);
static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower, static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *interval); FAR unsigned long *interval);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -105,7 +105,7 @@ static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower,
/* in microseconds */ /* in microseconds */
static const unsigned int g_wtgahrs2_interval[] = static const unsigned long g_wtgahrs2_interval[] =
{ {
10000000, /* 0.1 hz */ 10000000, /* 0.1 hz */
2000000, /* 0.5 hz */ 2000000, /* 0.5 hz */
@ -161,7 +161,7 @@ static int wtgahrs2_activate(FAR struct sensor_lowerhalf_s *lower, bool sw)
} }
static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower, static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *interval) FAR unsigned long *interval)
{ {
FAR struct wtgahrs2_sensor_s *dev = (FAR struct wtgahrs2_sensor_s *)lower; FAR struct wtgahrs2_sensor_s *dev = (FAR struct wtgahrs2_sensor_s *)lower;
int idx = 0; int idx = 0;

View File

@ -628,7 +628,7 @@ struct sensor_ops_s
**************************************************************************/ **************************************************************************/
CODE int (*set_interval)(FAR struct sensor_lowerhalf_s *lower, CODE int (*set_interval)(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *period_us); FAR unsigned long *period_us);
/************************************************************************** /**************************************************************************
* Name: batch * Name: batch
@ -672,7 +672,7 @@ struct sensor_ops_s
**************************************************************************/ **************************************************************************/
CODE int (*batch)(FAR struct sensor_lowerhalf_s *lower, CODE int (*batch)(FAR struct sensor_lowerhalf_s *lower,
FAR unsigned int *latency_us); FAR unsigned long *latency_us);
/************************************************************************** /**************************************************************************
* Name: fetch * Name: fetch