i2s: add i2s_configure() as a system call
Now that k_mem_slabs are tracked as kernel objects, even though they have no user facing API, we can now accept a pointer to one in the configure API. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
76a160ba38
commit
ad4df685f1
2 changed files with 37 additions and 2 deletions
|
@ -8,6 +8,38 @@
|
||||||
#include <syscall_handler.h>
|
#include <syscall_handler.h>
|
||||||
#include <i2s.h>
|
#include <i2s.h>
|
||||||
|
|
||||||
|
|
||||||
|
Z_SYSCALL_HANDLER(i2s_configure, dev, dir, cfg_ptr)
|
||||||
|
{
|
||||||
|
struct i2s_config config;
|
||||||
|
int ret = -EINVAL;
|
||||||
|
|
||||||
|
if (Z_SYSCALL_DRIVER_I2S(dev, configure)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Z_OOPS(z_user_from_copy(&config, (void *)cfg_ptr,
|
||||||
|
sizeof(struct i2s_config)));
|
||||||
|
|
||||||
|
/* Check that the k_mem_slab provided is a valid pointer and that
|
||||||
|
* the caller has permission on it
|
||||||
|
*/
|
||||||
|
if (Z_SYSCALL_OBJ(config.mem_slab, K_OBJ_MEM_SLAB)) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure that the k_mem_slab's slabs are large enough for the
|
||||||
|
* specified block size
|
||||||
|
*/
|
||||||
|
if (config.block_size > config.mem_slab->block_size) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = _impl_i2s_configure((struct device *)dev, dir, &config);
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Z_SYSCALL_HANDLER(i2s_buf_read, dev, buf, size)
|
Z_SYSCALL_HANDLER(i2s_buf_read, dev, buf, size)
|
||||||
{
|
{
|
||||||
void *mem_block;
|
void *mem_block;
|
||||||
|
|
|
@ -346,8 +346,11 @@ struct i2s_driver_api {
|
||||||
* @retval 0 If successful.
|
* @retval 0 If successful.
|
||||||
* @retval -EINVAL Invalid argument.
|
* @retval -EINVAL Invalid argument.
|
||||||
*/
|
*/
|
||||||
static inline int i2s_configure(struct device *dev, enum i2s_dir dir,
|
__syscall int i2s_configure(struct device *dev, enum i2s_dir dir,
|
||||||
struct i2s_config *cfg)
|
struct i2s_config *cfg);
|
||||||
|
|
||||||
|
static inline int _impl_i2s_configure(struct device *dev, enum i2s_dir dir,
|
||||||
|
struct i2s_config *cfg)
|
||||||
{
|
{
|
||||||
const struct i2s_driver_api *api = dev->driver_api;
|
const struct i2s_driver_api *api = dev->driver_api;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue