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:
parent
8f39c5f11b
commit
8d971101cd
@ -160,7 +160,7 @@ static int bmp280_putreg8(FAR struct bmp280_dev_s *priv, uint8_t regaddr,
|
||||
/* Sensor methods */
|
||||
|
||||
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,
|
||||
bool enable);
|
||||
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,
|
||||
FAR unsigned int *period_us)
|
||||
FAR unsigned long *period_us)
|
||||
{
|
||||
FAR struct bmp280_dev_s *priv = container_of(lower,
|
||||
FAR struct bmp280_dev_s,
|
||||
|
@ -146,7 +146,7 @@ struct ds18b20_dev_s
|
||||
struct onewire_config_s config; /* 1wire device configuration */
|
||||
struct ds18b20_config_s reg; /* Sensor resolution */
|
||||
#ifdef CONFIG_SENSORS_DS18B20_POLL
|
||||
unsigned int interval; /* Polling interval */
|
||||
unsigned long interval; /* Polling interval */
|
||||
sem_t run; /* Locks sensor thread */
|
||||
#endif
|
||||
};
|
||||
@ -168,7 +168,7 @@ static int ds18b20_control(FAR struct sensor_lowerhalf_s *lower,
|
||||
|
||||
#ifdef CONFIG_SENSORS_DS18B20_POLL
|
||||
static int ds18b20_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR unsigned int *period_us);
|
||||
FAR unsigned long *period_us);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -778,7 +778,7 @@ static int ds18b20_active(FAR struct sensor_lowerhalf_s *lower,
|
||||
|
||||
#ifdef CONFIG_SENSORS_DS18B20_POLL
|
||||
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;
|
||||
priv->interval = *period_us;
|
||||
|
@ -47,8 +47,8 @@ struct fakesensor_s
|
||||
{
|
||||
struct sensor_lowerhalf_s lower;
|
||||
struct file data;
|
||||
unsigned int interval;
|
||||
unsigned int batch;
|
||||
unsigned long interval;
|
||||
unsigned long batch;
|
||||
int raw_start;
|
||||
FAR const char *file_path;
|
||||
sem_t wakeup;
|
||||
@ -62,9 +62,9 @@ struct fakesensor_s
|
||||
static int fakesensor_activate(FAR struct sensor_lowerhalf_s *lower,
|
||||
bool sw);
|
||||
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,
|
||||
FAR unsigned int *latency_us);
|
||||
FAR unsigned long *latency_us);
|
||||
static void fakesensor_push_event(FAR struct sensor_lowerhalf_s *lower);
|
||||
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);
|
||||
if (sensor->interval == 0)
|
||||
{
|
||||
sscanf(buffer, "interval:%d\n", &sensor->interval);
|
||||
sscanf(buffer, "interval:%lu\n", &sensor->interval);
|
||||
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,
|
||||
FAR unsigned int *period_us)
|
||||
FAR unsigned long *period_us)
|
||||
{
|
||||
FAR struct fakesensor_s *sensor = container_of(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,
|
||||
FAR unsigned int *latency_us)
|
||||
FAR unsigned long *latency_us)
|
||||
{
|
||||
FAR struct fakesensor_s *sensor = container_of(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)
|
||||
{
|
||||
*latency_us = max_latency;
|
||||
|
@ -96,7 +96,7 @@ struct hyt271_dev_s
|
||||
sem_t lock_measure_cycle; /* Locks measure cycle */
|
||||
uint32_t freq; /* I2C Frequency */
|
||||
#ifdef CONFIG_SENSORS_HYT271_POLL
|
||||
unsigned int interval; /* Polling interval */
|
||||
unsigned long interval; /* Polling interval */
|
||||
sem_t run; /* Locks sensor thread */
|
||||
bool initial_read; /* Already read */
|
||||
#endif
|
||||
@ -120,7 +120,7 @@ static int hyt271_control(FAR struct sensor_lowerhalf_s *lower,
|
||||
|
||||
#ifdef CONFIG_SENSORS_HYT271_POLL
|
||||
static int hyt271_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR unsigned int *period_us);
|
||||
FAR unsigned long *period_us);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -751,7 +751,7 @@ static int hyt271_active(FAR struct sensor_lowerhalf_s *lower,
|
||||
|
||||
#ifdef CONFIG_SENSORS_HYT271_POLL
|
||||
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;
|
||||
priv->dev->interval = *period_us;
|
||||
|
@ -94,7 +94,7 @@ struct ms5611_dev_s
|
||||
|
||||
uint32_t freq; /* Bus Frequency I2C/SPI */
|
||||
struct ms5611_calib_s calib; /* Calib. params from ROM */
|
||||
unsigned int interval; /* Polling interval */
|
||||
unsigned long interval; /* Polling interval */
|
||||
bool enabled; /* Enable/Disable MS5611 */
|
||||
sem_t run; /* Locks measure cycle */
|
||||
sem_t exclsem; /* Manages exclusive to device */
|
||||
@ -121,7 +121,7 @@ static unsigned long ms5611_curtime(void);
|
||||
/* Sensor methods */
|
||||
|
||||
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,
|
||||
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,
|
||||
FAR unsigned int *period_us)
|
||||
FAR unsigned long *period_us)
|
||||
{
|
||||
FAR struct ms5611_dev_s *priv = container_of(lower,
|
||||
FAR struct ms5611_dev_s,
|
||||
|
@ -75,8 +75,8 @@ struct sensor_upperhalf_s
|
||||
sem_t exclsem; /* Manages exclusive access to file operations */
|
||||
sem_t buffersem; /* Wakeup user waiting for data in circular buffer */
|
||||
bool enabled; /* The status of sensor enable or disable */
|
||||
unsigned int interval; /* The sample interval for sensor, in us */
|
||||
unsigned int latency; /* The batch latency for sensor, in us */
|
||||
unsigned long interval; /* The sample interval 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 sensor_upperhalf_s *upper = inode->i_private;
|
||||
FAR struct sensor_lowerhalf_s *lower = upper->lower;
|
||||
FAR unsigned int *val = (unsigned int *)(uintptr_t)arg;
|
||||
int ret;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (upper->interval == *val)
|
||||
if (upper->interval == arg)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret = lower->ops->set_interval(lower, val);
|
||||
ret = lower->ops->set_interval(lower, &arg);
|
||||
if (ret >= 0)
|
||||
{
|
||||
upper->interval = *val;
|
||||
upper->interval = arg;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -409,15 +408,15 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
}
|
||||
|
||||
if (upper->latency == *val)
|
||||
if (upper->latency == arg)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret = lower->ops->batch(lower, val);
|
||||
ret = lower->ops->batch(lower, &arg);
|
||||
if (ret >= 0)
|
||||
{
|
||||
upper->latency = *val;
|
||||
upper->latency = arg;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -460,7 +459,7 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
case SNIOC_GET_NEVENTBUF:
|
||||
{
|
||||
*val = lower->buffer_number;
|
||||
*(FAR uint32_t *)(uintptr_t)arg = lower->buffer_number;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -73,8 +73,8 @@
|
||||
struct wtgahrs2_sensor_s
|
||||
{
|
||||
struct sensor_lowerhalf_s lower;
|
||||
unsigned int interval;
|
||||
unsigned int last_update;
|
||||
unsigned long interval;
|
||||
uint64_t last_update;
|
||||
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_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR unsigned int *interval);
|
||||
FAR unsigned long *interval);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -105,7 +105,7 @@ static int wtgahrs2_set_interval(FAR struct sensor_lowerhalf_s *lower,
|
||||
|
||||
/* in microseconds */
|
||||
|
||||
static const unsigned int g_wtgahrs2_interval[] =
|
||||
static const unsigned long g_wtgahrs2_interval[] =
|
||||
{
|
||||
10000000, /* 0.1 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,
|
||||
FAR unsigned int *interval)
|
||||
FAR unsigned long *interval)
|
||||
{
|
||||
FAR struct wtgahrs2_sensor_s *dev = (FAR struct wtgahrs2_sensor_s *)lower;
|
||||
int idx = 0;
|
||||
|
@ -628,7 +628,7 @@ struct sensor_ops_s
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*set_interval)(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR unsigned int *period_us);
|
||||
FAR unsigned long *period_us);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: batch
|
||||
@ -672,7 +672,7 @@ struct sensor_ops_s
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*batch)(FAR struct sensor_lowerhalf_s *lower,
|
||||
FAR unsigned int *latency_us);
|
||||
FAR unsigned long *latency_us);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: fetch
|
||||
|
Loading…
Reference in New Issue
Block a user