Topics

[RFC PATCH 1/6] sensor: make delayed work visible in menuconfig


Vlad Dogaru <vlad.dogaru@...>
 

In preparation for migrating away from Kconfig-based configuration of
devices, make CONFIG_SENSOR_DELAYED_WORK visible to the user during
config. Previously, it was only activated when a driver needed it.

Change-Id: I36053e3052e604970fac32318b8c8ff970d06510
Signed-off-by: Vlad Dogaru <vlad.dogaru(a)intel.com>
---
drivers/sensor/Kconfig | 3 ++-
include/sensor.h | 33 ++++++++++++++++++++-------------
2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/drivers/sensor/Kconfig b/drivers/sensor/Kconfig
index 9ed914f..6a7fe09 100644
--- a/drivers/sensor/Kconfig
+++ b/drivers/sensor/Kconfig
@@ -25,7 +25,8 @@ menuconfig SENSOR

config SENSOR_DELAYED_WORK
depends on SENSOR
- bool
+ bool "Sensor delayed work support"
+ depends on SENSOR

config SENSOR_DELAYED_WORK_STACK_SIZE
int "Sensor delayed work fiber stack size"
diff --git a/include/sensor.h b/include/sensor.h
index 6cda30c..918326a 100644
--- a/include/sensor.h
+++ b/include/sensor.h
@@ -212,6 +212,20 @@ struct sensor_driver_api {
sensor_channel_get_t channel_get;
};

+typedef void (*sensor_work_handler_t)(void *arg);
+
+/**
+ * @brief Sensor delayed work descriptor.
+ *
+ * Used by sensor drivers internally to delay function calls to a fiber
+ * context.
+ */
+struct sensor_work {
+ sensor_work_handler_t handler;
+ void *arg;
+};
+
+
/**
* @brief Set an attribute for a sensor
*
@@ -320,20 +334,8 @@ static inline int sensor_channel_get(struct device *dev,
return api->channel_get(dev, chan, val);
}

-#ifdef CONFIG_SENSOR_DELAYED_WORK
-typedef void (*sensor_work_handler_t)(void *arg);
-
-/**
- * @brief Sensor delayed work descriptor.
- *
- * Used by sensor drivers internally to delay function calls to a fiber
- * context.
- */
-struct sensor_work {
- sensor_work_handler_t handler;
- void *arg;
-};

+#ifdef CONFIG_SENSOR_DELAYED_WORK
/**
* @brief Get a fifo to which sensor delayed work can be submitted
*
@@ -343,6 +345,11 @@ struct sensor_work {
* do not create their own fibers due to system resource constraints.
*/
struct nano_fifo *sensor_get_work_fifo(void);
+#else
+static inline struct nano_fifo *sensor_get_work_fifo(void)
+{
+ return NULL;
+}
#endif

/**
--
1.9.1