mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-03 05:21:57 +00:00
The integer return of sensor_submit should be void as the call is asynchronous and the response is meant to be delivered using RTIO APIs signaling that the submission completed with error or success. Change the function signature to void and fix all uses of the submit API, fixing some bugs in the process. Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
/*
|
|
* Copyright (c) 2023 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/sensing/sensing.h>
|
|
#include <zephyr/sensing/sensing_sensor.h>
|
|
#include <zephyr/sys/__assert.h>
|
|
#include <zephyr/logging/log.h>
|
|
#include "sensor_mgmt.h"
|
|
|
|
LOG_MODULE_DECLARE(sensing, CONFIG_SENSING_LOG_LEVEL);
|
|
|
|
static void sensing_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
|
|
{
|
|
struct sensing_sensor *sensor = (struct sensing_sensor *)iodev_sqe->sqe.userdata;
|
|
const struct device *dev = sensor->dev;
|
|
const struct sensor_driver_api *api = dev->api;
|
|
|
|
if (api->submit != NULL) {
|
|
api->submit(dev, iodev_sqe);
|
|
} else {
|
|
LOG_ERR("submit function not supported for device %p %s!\n", dev, dev->name);
|
|
rtio_iodev_sqe_err(iodev_sqe, -ENOTSUP);
|
|
}
|
|
}
|
|
|
|
const struct rtio_iodev_api __sensing_iodev_api = {
|
|
.submit = sensing_iodev_submit,
|
|
};
|
|
|
|
int sensing_sensor_get_reporters(const struct device *dev, int type,
|
|
sensing_sensor_handle_t *reporter_handles,
|
|
int max_handles)
|
|
{
|
|
struct sensing_sensor *sensor = get_sensor_by_dev(dev);
|
|
int i, num = 0;
|
|
|
|
for (i = 0; i < sensor->reporter_num && num < max_handles; ++i) {
|
|
if (type == sensor->conns[i].source->info->type
|
|
|| type == SENSING_SENSOR_TYPE_ALL) {
|
|
reporter_handles[num] = &sensor->conns[i];
|
|
num++;
|
|
}
|
|
}
|
|
|
|
return num;
|
|
}
|
|
|
|
int sensing_sensor_get_reporters_count(const struct device *dev, int type)
|
|
{
|
|
struct sensing_sensor *sensor = get_sensor_by_dev(dev);
|
|
int i, num = 0;
|
|
|
|
for (i = 0; i < sensor->reporter_num; ++i) {
|
|
if (type == sensor->conns[i].source->info->type
|
|
|| type == SENSING_SENSOR_TYPE_ALL) {
|
|
num++;
|
|
}
|
|
}
|
|
|
|
return num;
|
|
}
|