Skip to content

Commit 863a766

Browse files
UrbanVibeskartben
authored andcommitted
drivers: adc: ad599x: Fix async logic error and driver breakdown
The general ADC documentation states, that it is possible to use the adc_read_async function with third parameter (k_poll_signal *async) set to NULL, in which case the callback is called when all channels have been converted. This change fixes this issue as it now also checks if a callback has been set. Signed-off-by: Torbjørn Biering Tvermosegaard <[email protected]>
1 parent d9a691c commit 863a766

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/adc/adc_ad559x.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@ static int adc_ad559x_read_async(const struct device *dev, const struct adc_sequ
222222
{
223223
struct adc_ad559x_data *data = dev->data;
224224
int ret;
225-
226-
adc_context_lock(&data->ctx, async ? true : false, async);
225+
/*
226+
* Check if either async or callback is set for asynchronous operation
227+
*/
228+
bool asynchronous = (async != NULL) ||
229+
(sequence->options && sequence->options->callback);
230+
adc_context_lock(&data->ctx, asynchronous, async);
227231
ret = adc_ad559x_start_read(dev, sequence);
228232
adc_context_release(&data->ctx, ret);
229233

0 commit comments

Comments
 (0)