Skip to content

Commit 5521fc4

Browse files
ubiedanashif
authored andcommitted
sensor: bma4xx: Use RTIO workq on bma4xx_submit
To make its execution path non-blocking from the caller's perspective. Signed-off-by: Luis Ubieda <[email protected]>
1 parent 59e8919 commit 5521fc4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

drivers/sensor/bosch/bma4xx/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# BMA4XX 3-axis accelerometer config options
22
#
33
# Copyright (c) 2023 Google LLC
4+
# Copyright (c) 2024 Croxel Inc.
45
#
56
# SPDX-License-Identifier: Apache-2.0
67

@@ -10,6 +11,7 @@ config BMA4XX
1011
depends on DT_HAS_BOSCH_BMA4XX_ENABLED
1112
depends on SENSOR_ASYNC_API
1213
select I2C
14+
select RTIO_WORKQ
1315
help
1416
Enable driver for Bosch BMA4XX (I2C-based)
1517

drivers/sensor/bosch/bma4xx/bma4xx.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Bosch BMA4xx 3-axis accelerometer driver
22
*
33
* Copyright (c) 2023 Google LLC
4+
* Copyright (c) 2024 Croxel Inc.
45
*
56
* SPDX-License-Identifier: Apache-2.0
67
*/
@@ -12,6 +13,7 @@
1213
#include <zephyr/sys/__assert.h>
1314
#include <zephyr/logging/log.h>
1415
#include <zephyr/pm/device.h>
16+
#include <zephyr/rtio/work.h>
1517

1618
LOG_MODULE_REGISTER(bma4xx, CONFIG_SENSOR_LOG_LEVEL);
1719
#include "bma4xx.h"
@@ -425,9 +427,10 @@ static void bma4xx_submit_one_shot(const struct device *dev, struct rtio_iodev_s
425427
rtio_iodev_sqe_ok(iodev_sqe, 0);
426428
}
427429

428-
static void bma4xx_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
430+
static void bma4xx_submit_sync(struct rtio_iodev_sqe *iodev_sqe)
429431
{
430432
const struct sensor_read_config *cfg = iodev_sqe->sqe.iodev->data;
433+
const struct device *dev = cfg->sensor;
431434

432435
/* TODO: Add streaming support */
433436
if (!cfg->is_streaming) {
@@ -437,6 +440,15 @@ static void bma4xx_submit(const struct device *dev, struct rtio_iodev_sqe *iodev
437440
}
438441
}
439442

443+
static void bma4xx_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe)
444+
{
445+
struct rtio_work_req *req = rtio_work_req_alloc();
446+
447+
__ASSERT_NO_MSG(req);
448+
449+
rtio_work_req_submit(req, iodev_sqe, bma4xx_submit_sync);
450+
}
451+
440452
/*
441453
* RTIO decoder
442454
*/

0 commit comments

Comments
 (0)