[PATCH 4/4] sensor: Migrate drivers to the new workqueue API


Vlad Dogaru <vlad.dogaru@...>
 

Rework drivers that offer the possibility of using a system-wide
workqueue to use the new API. In a second step, these drivers can be
refactored to use their own workqueue instead of a homegrown fiber.

Change-Id: Ieddc44391e2a687e2e4f2190dc827969ebe3953f
Signed-off-by: Vlad Dogaru <vlad.dogaru(a)intel.com>
---
drivers/sensor/Kconfig.bma280 | 3 +--
drivers/sensor/Kconfig.bmi160 | 2 +-
drivers/sensor/Kconfig.isl29035 | 3 +--
drivers/sensor/Kconfig.lis3dh | 3 +--
drivers/sensor/Kconfig.mcp9808 | 3 +--
drivers/sensor/Kconfig.sht3xd | 3 +--
drivers/sensor/Kconfig.sx9500 | 3 +--
drivers/sensor/Kconfig.tmp007 | 3 +--
drivers/sensor/sensor_bma280.h | 2 +-
drivers/sensor/sensor_bma280_trigger.c | 5 ++---
drivers/sensor/sensor_bmi160.h | 2 +-
drivers/sensor/sensor_bmi160_trigger.c | 7 +++----
drivers/sensor/sensor_isl29035.h | 2 +-
drivers/sensor/sensor_isl29035_trigger.c | 5 ++---
drivers/sensor/sensor_lis3dh.h | 2 +-
drivers/sensor/sensor_lis3dh_trigger.c | 5 ++---
drivers/sensor/sensor_mcp9808.h | 2 +-
drivers/sensor/sensor_mcp9808_trigger.c | 5 ++---
drivers/sensor/sensor_sht3xd.h | 2 +-
drivers/sensor/sensor_sht3xd_trigger.c | 5 ++---
drivers/sensor/sensor_sx9500.h | 2 +-
drivers/sensor/sensor_sx9500_trigger.c | 5 ++---
drivers/sensor/sensor_tmp007.h | 2 +-
drivers/sensor/sensor_tmp007_trigger.c | 5 ++---
24 files changed, 33 insertions(+), 48 deletions(-)

diff --git a/drivers/sensor/Kconfig.bma280 b/drivers/sensor/Kconfig.bma280
index 4308a2d..3618015 100644
--- a/drivers/sensor/Kconfig.bma280
+++ b/drivers/sensor/Kconfig.bma280
@@ -138,9 +138,8 @@ config BMA280_TRIGGER_NONE
config BMA280_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select BMA280_TRIGGER
- select SENSOR_DELAYED_WORK

config BMA280_TRIGGER_OWN_FIBER
bool
diff --git a/drivers/sensor/Kconfig.bmi160 b/drivers/sensor/Kconfig.bmi160
index 1ac70c6..ab7774f 100644
--- a/drivers/sensor/Kconfig.bmi160
+++ b/drivers/sensor/Kconfig.bmi160
@@ -71,8 +71,8 @@ config BMI160_TRIGGER_NONE

config BMI160_TRIGGER_GLOBAL_FIBER
bool "Use global fiber"
+ depends on SENSOR_WORKQUEUE
select BMI160_TRIGGER
- select SENSOR_DELAYED_WORK

config BMI160_TRIGGER_OWN_FIBER
bool "Use own fiber"
diff --git a/drivers/sensor/Kconfig.isl29035 b/drivers/sensor/Kconfig.isl29035
index 1cf6f51..52de072 100644
--- a/drivers/sensor/Kconfig.isl29035
+++ b/drivers/sensor/Kconfig.isl29035
@@ -161,9 +161,8 @@ config ISL29035_TRIGGER_NONE
config ISL29035_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select ISL29035_TRIGGER
- select SENSOR_DELAYED_WORK

config ISL29035_TRIGGER_OWN_FIBER
bool
diff --git a/drivers/sensor/Kconfig.lis3dh b/drivers/sensor/Kconfig.lis3dh
index 1f4b21a..296d348 100644
--- a/drivers/sensor/Kconfig.lis3dh
+++ b/drivers/sensor/Kconfig.lis3dh
@@ -98,9 +98,8 @@ config LIS3DH_TRIGGER_NONE
config LIS3DH_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select LIS3DH_TRIGGER
- select SENSOR_DELAYED_WORK

config LIS3DH_TRIGGER_OWN_FIBER
bool
diff --git a/drivers/sensor/Kconfig.mcp9808 b/drivers/sensor/Kconfig.mcp9808
index e0a9f19..87e486e 100644
--- a/drivers/sensor/Kconfig.mcp9808
+++ b/drivers/sensor/Kconfig.mcp9808
@@ -74,9 +74,8 @@ config MCP9808_TRIGGER_NONE
bool "No trigger"

config MCP9808_TRIGGER_GLOBAL_FIBER
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select MCP9808_TRIGGER
- select SENSOR_DELAYED_WORK
bool "Use global fiber"

config MCP9808_TRIGGER_OWN_FIBER
diff --git a/drivers/sensor/Kconfig.sht3xd b/drivers/sensor/Kconfig.sht3xd
index de33c6d..cfc1f7a 100644
--- a/drivers/sensor/Kconfig.sht3xd
+++ b/drivers/sensor/Kconfig.sht3xd
@@ -98,9 +98,8 @@ config SHT3XD_TRIGGER_NONE
config SHT3XD_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select SHT3XD_TRIGGER
- select SENSOR_DELAYED_WORK

config SHT3XD_TRIGGER_OWN_FIBER
bool
diff --git a/drivers/sensor/Kconfig.sx9500 b/drivers/sensor/Kconfig.sx9500
index 46d16c2..ce98be0 100644
--- a/drivers/sensor/Kconfig.sx9500
+++ b/drivers/sensor/Kconfig.sx9500
@@ -83,9 +83,8 @@ config SX9500_TRIGGER_NONE
bool "No trigger"

config SX9500_TRIGGER_GLOBAL_FIBER
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select SX9500_TRIGGER
- select SENSOR_DELAYED_WORK
bool "Use global fiber"

config SX9500_TRIGGER_OWN_FIBER
diff --git a/drivers/sensor/Kconfig.tmp007 b/drivers/sensor/Kconfig.tmp007
index 68b3876..202e8a5 100644
--- a/drivers/sensor/Kconfig.tmp007
+++ b/drivers/sensor/Kconfig.tmp007
@@ -134,9 +134,8 @@ config TMP007_TRIGGER_NONE
config TMP007_TRIGGER_GLOBAL_FIBER
bool
prompt "Use global fiber"
- depends on GPIO
+ depends on GPIO && SENSOR_WORKQUEUE
select TMP007_TRIGGER
- select SENSOR_DELAYED_WORK

config TMP007_TRIGGER_OWN_FIBER
bool
diff --git a/drivers/sensor/sensor_bma280.h b/drivers/sensor/sensor_bma280.h
index 28a04e4..f516708 100644
--- a/drivers/sensor/sensor_bma280.h
+++ b/drivers/sensor/sensor_bma280.h
@@ -152,7 +152,7 @@ struct bma280_data {
char __stack fiber_stack[CONFIG_BMA280_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
- struct sensor_work work;
+ struct nano_work work;
#endif

#endif /* CONFIG_BMA280_TRIGGER */
diff --git a/drivers/sensor/sensor_bma280_trigger.c b/drivers/sensor/sensor_bma280_trigger.c
index 467b484..7c5cbfe 100644
--- a/drivers/sensor/sensor_bma280_trigger.c
+++ b/drivers/sensor/sensor_bma280_trigger.c
@@ -74,7 +74,7 @@ static void bma280_gpio_callback(struct device *dev,
#if defined(CONFIG_BMA280_TRIGGER_OWN_FIBER)
nano_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &drv_data->work);
+ sensor_work_submit(&drv_data->work);
#endif
}

@@ -272,8 +272,7 @@ int bma280_init_interrupt(struct device *dev)
(nano_fiber_entry_t)bma280_fiber, POINTER_TO_INT(dev),
0, CONFIG_BMA280_FIBER_PRIORITY, 0);
#elif defined(CONFIG_BMA280_TRIGGER_GLOBAL_FIBER)
- drv_data->work.handler = bma280_fiber_cb;
- drv_data->work.arg = dev;
+ nano_work_init(&drv_data->work, bma280_fiber_cb, dev);
#endif

gpio_pin_enable_callback(drv_data->gpio, CONFIG_BMA280_GPIO_PIN_NUM);
diff --git a/drivers/sensor/sensor_bmi160.h b/drivers/sensor/sensor_bmi160.h
index d89a09d..78046cc 100644
--- a/drivers/sensor/sensor_bmi160.h
+++ b/drivers/sensor/sensor_bmi160.h
@@ -457,7 +457,7 @@ struct bmi160_device_data {
#endif

#ifdef CONFIG_BMI160_TRIGGER_GLOBAL_FIBER
- struct sensor_work work;
+ struct nano_work work;
#endif

#ifdef CONFIG_BMI160_TRIGGER
diff --git a/drivers/sensor/sensor_bmi160_trigger.c b/drivers/sensor/sensor_bmi160_trigger.c
index 8c0eff2..e077772 100644
--- a/drivers/sensor/sensor_bmi160_trigger.c
+++ b/drivers/sensor/sensor_bmi160_trigger.c
@@ -118,7 +118,7 @@ static void bmi160_gpio_callback(struct device *port,
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
nano_sem_give(&bmi160->sem);
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &bmi160->work);
+ sensor_work_submit(&bmi160->work);
#endif
}
#else
@@ -131,7 +131,7 @@ static void bmi160_ipm_callback(void *context, uint32_t id, volatile void *data)
#if defined(CONFIG_BMI160_TRIGGER_OWN_FIBER)
nano_sem_give(&bmi160->sem);
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &bmi160->work);
+ sensor_work_submit(&bmi160->work);
#endif
}
#endif
@@ -316,8 +316,7 @@ int bmi160_trigger_mode_init(struct device *dev)
bmi160_fiber_main, (int)dev, 0,
CONFIG_BMI160_FIBER_PRIORITY, 0);
#elif defined(CONFIG_BMI160_TRIGGER_GLOBAL_FIBER)
- bmi160->work.handler = bmi160_handle_interrupts;
- bmi160->work.arg = dev;
+ nano_work_init(&bmi160->work, bmi160_handle_interrupts, dev);
#endif

/* map all interrupts to INT1 pin */
diff --git a/drivers/sensor/sensor_isl29035.h b/drivers/sensor/sensor_isl29035.h
index 5dcc304..86ef353 100644
--- a/drivers/sensor/sensor_isl29035.h
+++ b/drivers/sensor/sensor_isl29035.h
@@ -135,7 +135,7 @@ struct isl29035_driver_data {
char __stack fiber_stack[CONFIG_ISL29035_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
- struct sensor_work work;
+ struct nano_work work;
#endif

#endif /* CONFIG_ISL29035_TRIGGER */
diff --git a/drivers/sensor/sensor_isl29035_trigger.c b/drivers/sensor/sensor_isl29035_trigger.c
index e36f338b..cf2a324 100644
--- a/drivers/sensor/sensor_isl29035_trigger.c
+++ b/drivers/sensor/sensor_isl29035_trigger.c
@@ -87,7 +87,7 @@ static void isl29035_gpio_callback(struct device *dev,
#if defined(CONFIG_ISL29035_TRIGGER_OWN_FIBER)
nano_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &drv_data->work);
+ sensor_work_submit(&drv_data->work);
#endif
}

@@ -184,8 +184,7 @@ int isl29035_init_interrupt(struct device *dev)
(nano_fiber_entry_t)isl29035_fiber, POINTER_TO_INT(dev),
0, CONFIG_ISL29035_FIBER_PRIORITY, 0);
#elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_FIBER)
- drv_data->work.handler = isl29035_fiber_cb;
- drv_data->work.arg = dev;
+ nano_work_init(&drv_data->work, isl29035_fiber_cb, dev);
#endif

return 0;
diff --git a/drivers/sensor/sensor_lis3dh.h b/drivers/sensor/sensor_lis3dh.h
index 13262a7..0aeb65a 100644
--- a/drivers/sensor/sensor_lis3dh.h
+++ b/drivers/sensor/sensor_lis3dh.h
@@ -110,7 +110,7 @@ struct lis3dh_data {
char __stack fiber_stack[CONFIG_LIS3DH_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
- struct sensor_work work;
+ struct nano_work work;
#endif

#endif /* CONFIG_LIS3DH_TRIGGER */
diff --git a/drivers/sensor/sensor_lis3dh_trigger.c b/drivers/sensor/sensor_lis3dh_trigger.c
index 6e90440..150c263 100644
--- a/drivers/sensor/sensor_lis3dh_trigger.c
+++ b/drivers/sensor/sensor_lis3dh_trigger.c
@@ -58,7 +58,7 @@ static void lis3dh_gpio_callback(struct device *dev,
#if defined(CONFIG_LIS3DH_TRIGGER_OWN_FIBER)
nano_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &drv_data->work);
+ sensor_work_submit(&drv_data->work);
#endif
}

@@ -139,8 +139,7 @@ int lis3dh_init_interrupt(struct device *dev)
(nano_fiber_entry_t)lis3dh_fiber, POINTER_TO_INT(dev),
0, CONFIG_LIS3DH_FIBER_PRIORITY, 0);
#elif defined(CONFIG_LIS3DH_TRIGGER_GLOBAL_FIBER)
- drv_data->work.handler = lis3dh_fiber_cb;
- drv_data->work.arg = dev;
+ nano_work_init(&drv_data->work, lis3dh_fiber_cb, dev);
#endif

gpio_pin_enable_callback(drv_data->gpio, CONFIG_LIS3DH_GPIO_PIN_NUM);
diff --git a/drivers/sensor/sensor_mcp9808.h b/drivers/sensor/sensor_mcp9808.h
index e1e0b1a..473ae3e 100644
--- a/drivers/sensor/sensor_mcp9808.h
+++ b/drivers/sensor/sensor_mcp9808.h
@@ -55,7 +55,7 @@ struct mcp9808_data {
#endif

#ifdef CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER
- struct sensor_work work;
+ struct nano_work work;
#endif

#ifdef CONFIG_MCP9808_TRIGGER
diff --git a/drivers/sensor/sensor_mcp9808_trigger.c b/drivers/sensor/sensor_mcp9808_trigger.c
index 21fda1d..f5958cd 100644
--- a/drivers/sensor/sensor_mcp9808_trigger.c
+++ b/drivers/sensor/sensor_mcp9808_trigger.c
@@ -161,7 +161,7 @@ static void mcp9808_gpio_cb(struct device *dev,

ARG_UNUSED(pins);

- nano_isr_fifo_put(sensor_get_work_fifo(), &data->work);
+ sensor_work_submit(&data->work);
}

static void mcp9808_gpio_fiber_cb(void *arg)
@@ -195,8 +195,7 @@ void mcp9808_setup_interrupt(struct device *dev)
mcp9808_fiber_main, POINTER_TO_INT(dev), 0,
CONFIG_MCP9808_FIBER_PRIORITY, 0);
#else /* CONFIG_MCP9808_TRIGGER_GLOBAL_FIBER */
- data->work.handler = mcp9808_gpio_fiber_cb;
- data->work.arg = dev;
+ nano_work_init(&data->work, mcp9808_gpio_fiber_cb, dev);
#endif

gpio = device_get_binding(CONFIG_MCP9808_GPIO_CONTROLLER);
diff --git a/drivers/sensor/sensor_sht3xd.h b/drivers/sensor/sensor_sht3xd.h
index bb3d9f3..629066b 100644
--- a/drivers/sensor/sensor_sht3xd.h
+++ b/drivers/sensor/sensor_sht3xd.h
@@ -92,7 +92,7 @@ struct sht3xd_data {
char __stack fiber_stack[CONFIG_SHT3XD_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
- struct sensor_work work;
+ struct nano_work work;
#endif

#endif /* CONFIG_SHT3XD_TRIGGER */
diff --git a/drivers/sensor/sensor_sht3xd_trigger.c b/drivers/sensor/sensor_sht3xd_trigger.c
index 1aea4da..f945741 100644
--- a/drivers/sensor/sensor_sht3xd_trigger.c
+++ b/drivers/sensor/sensor_sht3xd_trigger.c
@@ -120,7 +120,7 @@ static void sht3xd_gpio_callback(struct device *dev,
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_FIBER)
nano_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &drv_data->work);
+ sensor_work_submit(&drv_data->work);
#endif
}

@@ -234,8 +234,7 @@ int sht3xd_init_interrupt(struct device *dev)
(nano_fiber_entry_t)sht3xd_fiber, POINTER_TO_INT(dev),
0, CONFIG_SHT3XD_FIBER_PRIORITY, 0);
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_FIBER)
- drv_data->work.handler = sht3xd_fiber_cb;
- drv_data->work.arg = dev;
+ nano_work_init(&drv_data->work, sht3xd_fiber_cb, dev);
#endif

return 0;
diff --git a/drivers/sensor/sensor_sx9500.h b/drivers/sensor/sensor_sx9500.h
index 4ce0de6..ea08e18 100644
--- a/drivers/sensor/sensor_sx9500.h
+++ b/drivers/sensor/sensor_sx9500.h
@@ -46,7 +46,7 @@ struct sx9500_data {
#endif

#ifdef CONFIG_SX9500_TRIGGER_GLOBAL_FIBER
- struct sensor_work work;
+ struct nano_work work;
#endif

#ifdef CONFIG_SX9500_TRIGGER
diff --git a/drivers/sensor/sensor_sx9500_trigger.c b/drivers/sensor/sensor_sx9500_trigger.c
index b38dcbd..aaaf56d 100644
--- a/drivers/sensor/sensor_sx9500_trigger.c
+++ b/drivers/sensor/sensor_sx9500_trigger.c
@@ -118,7 +118,7 @@ static void sx9500_gpio_cb(struct device *port,

ARG_UNUSED(pins);

- nano_isr_fifo_put(sensor_get_work_fifo(), &data->work);
+ sensor_work_submit(&data->work);
}

static void sx9500_gpio_fiber_cb(void *arg)
@@ -153,8 +153,7 @@ int sx9500_setup_interrupt(struct device *dev)
#ifdef CONFIG_SX9500_TRIGGER_OWN_FIBER
nano_sem_init(&data->sem);
#else
- data->work.handler = sx9500_gpio_fiber_cb;
- data->work.arg = dev;
+ nano_work_init(&data->work, sx9500_gpio_fiber_cb, dev);
#endif

gpio = device_get_binding(CONFIG_SX9500_GPIO_CONTROLLER);
diff --git a/drivers/sensor/sensor_tmp007.h b/drivers/sensor/sensor_tmp007.h
index 7b74bed..5833e54 100644
--- a/drivers/sensor/sensor_tmp007.h
+++ b/drivers/sensor/sensor_tmp007.h
@@ -77,7 +77,7 @@ struct tmp007_data {
char __stack fiber_stack[CONFIG_TMP007_FIBER_STACK_SIZE];
struct nano_sem gpio_sem;
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
- struct sensor_work work;
+ struct nano_work work;
#endif

#endif /* CONFIG_TMP007_TRIGGER */
diff --git a/drivers/sensor/sensor_tmp007_trigger.c b/drivers/sensor/sensor_tmp007_trigger.c
index 6272c51..9fdc0a0 100644
--- a/drivers/sensor/sensor_tmp007_trigger.c
+++ b/drivers/sensor/sensor_tmp007_trigger.c
@@ -67,7 +67,7 @@ static void tmp007_gpio_callback(struct device *dev,
#if defined(CONFIG_TMP007_TRIGGER_OWN_FIBER)
nano_sem_give(&drv_data->gpio_sem);
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
- nano_isr_fifo_put(sensor_get_work_fifo(), &drv_data->work);
+ sensor_work_submit(&drv_data->work);
#endif
}

@@ -171,8 +171,7 @@ int tmp007_init_interrupt(struct device *dev)
(nano_fiber_entry_t)tmp007_fiber, POINTER_TO_INT(dev),
0, CONFIG_TMP007_FIBER_PRIORITY, 0);
#elif defined(CONFIG_TMP007_TRIGGER_GLOBAL_FIBER)
- drv_data->work.handler = tmp007_fiber_cb;
- drv_data->work.arg = dev;
+ nano_work_init(&drv_data->work, tmp007_fiber_cb, dev);
#endif

return 0;
--
1.9.1

Join devel@lists.zephyrproject.org to automatically receive all group messages.