zephyr/drivers/pwm/pwm_handlers.c
Leandro Pereira c200367b68 drivers: Perform a runtime check if a driver is capable of an operation
Driver APIs might not implement all operations, making it possible for
a user thread to get the kernel to execute a function at 0x00000000.

Perform runtime checks in all the driver handlers, checking if they're
capable of performing the requested operation.

Fixes #6907.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-04-26 02:57:12 +05:30

24 lines
569 B
C

/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <syscall_handler.h>
#include <pwm.h>
_SYSCALL_HANDLER(pwm_pin_set_cycles, dev, pwm, period, pulse)
{
_SYSCALL_DRIVER_PWM(dev, pin_set);
return _impl_pwm_pin_set_cycles((struct device *)dev, pwm, period,
pulse);
}
_SYSCALL_HANDLER(pwm_get_cycles_per_sec, dev, pwm, cycles)
{
_SYSCALL_DRIVER_PWM(dev, get_cycles_per_sec);
_SYSCALL_MEMORY_WRITE(cycles, sizeof(u64_t));
return _impl_pwm_get_cycles_per_sec((struct device *)dev,
pwm, (u64_t *)cycles);
}