drivers: comparator: update API to use DEIVCE_API macros
Update comparator API and device drivers to use DEVICE_API macros. Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
This commit is contained in:
parent
3e87587fd8
commit
957ece8bc2
5 changed files with 8 additions and 20 deletions
|
|
@ -31,7 +31,7 @@ DEFINE_FAKE_VALUE_FUNC(int,
|
||||||
comp_fake_comp_trigger_is_pending,
|
comp_fake_comp_trigger_is_pending,
|
||||||
const struct device *);
|
const struct device *);
|
||||||
|
|
||||||
static const struct comparator_driver_api fake_comp_api = {
|
static DEVICE_API(comparator, fake_comp_api) = {
|
||||||
.get_output = comp_fake_comp_get_output,
|
.get_output = comp_fake_comp_get_output,
|
||||||
.set_trigger = comp_fake_comp_set_trigger,
|
.set_trigger = comp_fake_comp_set_trigger,
|
||||||
.set_trigger_callback = comp_fake_comp_set_trigger_callback,
|
.set_trigger_callback = comp_fake_comp_set_trigger_callback,
|
||||||
|
|
|
||||||
|
|
@ -375,7 +375,7 @@ static int mcux_acmp_trigger_is_pending(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct comparator_driver_api mcux_acmp_comp_api = {
|
static DEVICE_API(comparator, mcux_acmp_comp_api) = {
|
||||||
.get_output = mcux_acmp_get_output,
|
.get_output = mcux_acmp_get_output,
|
||||||
.set_trigger = mcux_acmp_set_trigger,
|
.set_trigger = mcux_acmp_set_trigger,
|
||||||
.set_trigger_callback = mcux_acmp_set_trigger_callback,
|
.set_trigger_callback = mcux_acmp_set_trigger_callback,
|
||||||
|
|
|
||||||
|
|
@ -666,7 +666,7 @@ static int shim_nrf_comp_trigger_is_pending(const struct device *dev)
|
||||||
return atomic_test_and_clear_bit(&shim_nrf_comp_data0.triggered, 0);
|
return atomic_test_and_clear_bit(&shim_nrf_comp_data0.triggered, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct comparator_driver_api shim_nrf_comp_api = {
|
static DEVICE_API(comparator, shim_nrf_comp_api) = {
|
||||||
.get_output = shim_nrf_comp_get_output,
|
.get_output = shim_nrf_comp_get_output,
|
||||||
.set_trigger = shim_nrf_comp_set_trigger,
|
.set_trigger = shim_nrf_comp_set_trigger,
|
||||||
.set_trigger_callback = shim_nrf_comp_set_trigger_callback,
|
.set_trigger_callback = shim_nrf_comp_set_trigger_callback,
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ static int shim_nrf_lpcomp_trigger_is_pending(const struct device *dev)
|
||||||
return atomic_test_and_clear_bit(&shim_nrf_lpcomp_data0.triggered, 0);
|
return atomic_test_and_clear_bit(&shim_nrf_lpcomp_data0.triggered, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct comparator_driver_api shim_nrf_lpcomp_api = {
|
static DEVICE_API(comparator, shim_nrf_lpcomp_api) = {
|
||||||
.get_output = shim_nrf_lpcomp_get_output,
|
.get_output = shim_nrf_lpcomp_get_output,
|
||||||
.set_trigger = shim_nrf_lpcomp_set_trigger,
|
.set_trigger = shim_nrf_lpcomp_set_trigger,
|
||||||
.set_trigger_callback = shim_nrf_lpcomp_set_trigger_callback,
|
.set_trigger_callback = shim_nrf_lpcomp_set_trigger_callback,
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,7 @@ __syscall int comparator_get_output(const struct device *dev);
|
||||||
|
|
||||||
static inline int z_impl_comparator_get_output(const struct device *dev)
|
static inline int z_impl_comparator_get_output(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct comparator_driver_api *api =
|
return DEVICE_API_GET(comparator, dev)->get_output(dev);
|
||||||
(const struct comparator_driver_api *)dev->api;
|
|
||||||
|
|
||||||
return api->get_output(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,10 +88,7 @@ __syscall int comparator_set_trigger(const struct device *dev,
|
||||||
static inline int z_impl_comparator_set_trigger(const struct device *dev,
|
static inline int z_impl_comparator_set_trigger(const struct device *dev,
|
||||||
enum comparator_trigger trigger)
|
enum comparator_trigger trigger)
|
||||||
{
|
{
|
||||||
const struct comparator_driver_api *api =
|
return DEVICE_API_GET(comparator, dev)->set_trigger(dev, trigger);
|
||||||
(const struct comparator_driver_api *)dev->api;
|
|
||||||
|
|
||||||
return api->set_trigger(dev, trigger);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -114,10 +108,7 @@ static inline int comparator_set_trigger_callback(const struct device *dev,
|
||||||
comparator_callback_t callback,
|
comparator_callback_t callback,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
const struct comparator_driver_api *api =
|
return DEVICE_API_GET(comparator, dev)->set_trigger_callback(dev, callback, user_data);
|
||||||
(const struct comparator_driver_api *)dev->api;
|
|
||||||
|
|
||||||
return api->set_trigger_callback(dev, callback, user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -133,10 +124,7 @@ __syscall int comparator_trigger_is_pending(const struct device *dev);
|
||||||
|
|
||||||
static inline int z_impl_comparator_trigger_is_pending(const struct device *dev)
|
static inline int z_impl_comparator_trigger_is_pending(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct comparator_driver_api *api =
|
return DEVICE_API_GET(comparator, dev)->trigger_is_pending(dev);
|
||||||
(const struct comparator_driver_api *)dev->api;
|
|
||||||
|
|
||||||
return api->trigger_is_pending(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue