drivers: adc: adc_context: add optional context_on_complete
This optional function allows a driver to do operations
after a complete sampling sequence is completed.
@@ -38,6 +38,15 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx,
static void adc_context_enable_timer(struct adc_context *ctx);
static void adc_context_disable_timer(struct adc_context *ctx);
+/*
+ * If a driver needs to do something after a context complete then
+ * then this optional function can be overwritten. This will be called
+ * after a sequence has ended, and *not* when restarted with ADC_ACTION_REPEAT.
+ * To enable this function define ADC_CONTEXT_ENABLE_ON_COMPLETE.
+ */
+#ifdef ADC_CONTEXT_ENABLE_ON_COMPLETE
+static void adc_context_on_complete(struct adc_context *ctx, int status);
+#endif /* ADC_CONTEXT_ENABLE_ON_COMPLETE */
struct adc_context {
atomic_t sampling_requested;
@@ -165,6 +174,10 @@ static inline int adc_context_wait_for_completion(struct adc_context *ctx)
static inline void adc_context_complete(struct adc_context *ctx, int status)
{
+#ifdef ADC_CONTEXT_ENABLE_ON_COMPLETE
+ adc_context_on_complete(ctx, status);
+#endif /* ADC_CONTEXT_ENABLE_ON_COMPLETE */
+
#ifdef CONFIG_ADC_ASYNC
if (ctx->asynchronous) {
if (ctx->signal) {
