drivers: entropy: drop DEV_DATA/DEV_CFG usage
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and dev->config instead. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
f5effdde6c
commit
250fd0e23b
3 changed files with 13 additions and 24 deletions
|
@ -97,9 +97,6 @@ struct entropy_nrf5_dev_data {
|
|||
|
||||
static struct entropy_nrf5_dev_data entropy_nrf5_data;
|
||||
|
||||
#define DEV_DATA(dev) \
|
||||
((struct entropy_nrf5_dev_data *)(dev)->data)
|
||||
|
||||
static int random_byte_get(void)
|
||||
{
|
||||
int retval = -EAGAIN;
|
||||
|
@ -231,7 +228,7 @@ static int entropy_nrf5_get_entropy(const struct device *dev, uint8_t *buf,
|
|||
uint16_t len)
|
||||
{
|
||||
/* Check if this API is called on correct driver instance. */
|
||||
__ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(dev));
|
||||
__ASSERT_NO_MSG(&entropy_nrf5_data == dev->data);
|
||||
|
||||
while (len) {
|
||||
uint16_t bytes;
|
||||
|
@ -261,7 +258,7 @@ static int entropy_nrf5_get_entropy_isr(const struct device *dev,
|
|||
uint16_t cnt = len;
|
||||
|
||||
/* Check if this API is called on correct driver instance. */
|
||||
__ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(dev));
|
||||
__ASSERT_NO_MSG(&entropy_nrf5_data == dev->data);
|
||||
|
||||
if (likely((flags & ENTROPY_BUSYWAIT) == 0U)) {
|
||||
return rng_pool_get((struct rng_pool *)(entropy_nrf5_data.isr),
|
||||
|
@ -340,7 +337,7 @@ DEVICE_DT_INST_DEFINE(0,
|
|||
static int entropy_nrf5_init(const struct device *dev)
|
||||
{
|
||||
/* Check if this API is called on correct driver instance. */
|
||||
__ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(dev));
|
||||
__ASSERT_NO_MSG(&entropy_nrf5_data == dev->data);
|
||||
|
||||
/* Locking semaphore initialized to 1 (unlocked) */
|
||||
k_sem_init(&entropy_nrf5_data.sem_lock, 1, 1);
|
||||
|
|
|
@ -17,9 +17,6 @@ struct trng_sam_dev_cfg {
|
|||
Trng *regs;
|
||||
};
|
||||
|
||||
#define DEV_CFG(dev) \
|
||||
((const struct trng_sam_dev_cfg *const)(dev)->config)
|
||||
|
||||
static inline bool _ready(Trng * const trng)
|
||||
{
|
||||
#ifdef TRNG_ISR_DATRDY
|
||||
|
@ -76,7 +73,8 @@ static int entropy_sam_get_entropy_internal(const struct device *dev,
|
|||
uint8_t *buffer,
|
||||
uint16_t length, uint32_t flags)
|
||||
{
|
||||
Trng *const trng = DEV_CFG(dev)->regs;
|
||||
const struct trng_sam_dev_cfg *config = dev->config;
|
||||
Trng *const trng = config->regs;
|
||||
|
||||
while (length > 0) {
|
||||
size_t to_copy;
|
||||
|
@ -113,10 +111,10 @@ static int entropy_sam_get_entropy_isr(const struct device *dev,
|
|||
|
||||
|
||||
if ((flags & ENTROPY_BUSYWAIT) == 0U) {
|
||||
|
||||
const struct trng_sam_dev_cfg *config = dev->config;
|
||||
/* No busy wait; return whatever data is available. */
|
||||
|
||||
Trng * const trng = DEV_CFG(dev)->regs;
|
||||
Trng * const trng = config->regs;
|
||||
|
||||
do {
|
||||
size_t to_copy;
|
||||
|
@ -156,7 +154,8 @@ static int entropy_sam_get_entropy_isr(const struct device *dev,
|
|||
|
||||
static int entropy_sam_init(const struct device *dev)
|
||||
{
|
||||
Trng *const trng = DEV_CFG(dev)->regs;
|
||||
const struct trng_sam_dev_cfg *config = dev->config;
|
||||
Trng *const trng = config->regs;
|
||||
|
||||
#ifdef MCLK
|
||||
/* Enable the MCLK */
|
||||
|
|
|
@ -87,13 +87,6 @@ struct entropy_stm32_rng_dev_data {
|
|||
RNG_POOL_DEFINE(thr, CONFIG_ENTROPY_STM32_THR_POOL_SIZE);
|
||||
};
|
||||
|
||||
#define DEV_DATA(dev) \
|
||||
((struct entropy_stm32_rng_dev_data *)(dev)->data)
|
||||
|
||||
#define DEV_CFG(dev) \
|
||||
((const struct entropy_stm32_rng_dev_cfg *)(dev)->config)
|
||||
|
||||
|
||||
static const struct entropy_stm32_rng_dev_cfg entropy_stm32_rng_config = {
|
||||
.pclken = { .bus = DT_INST_CLOCKS_CELL(0, bus),
|
||||
.enr = DT_INST_CLOCKS_CELL(0, bits) },
|
||||
|
@ -315,7 +308,7 @@ static int entropy_stm32_rng_get_entropy(const struct device *dev,
|
|||
uint16_t len)
|
||||
{
|
||||
/* Check if this API is called on correct driver instance. */
|
||||
__ASSERT_NO_MSG(&entropy_stm32_rng_data == DEV_DATA(dev));
|
||||
__ASSERT_NO_MSG(&entropy_stm32_rng_data == dev->data);
|
||||
|
||||
while (len) {
|
||||
uint16_t bytes;
|
||||
|
@ -347,7 +340,7 @@ static int entropy_stm32_rng_get_entropy_isr(const struct device *dev,
|
|||
uint16_t cnt = len;
|
||||
|
||||
/* Check if this API is called on correct driver instance. */
|
||||
__ASSERT_NO_MSG(&entropy_stm32_rng_data == DEV_DATA(dev));
|
||||
__ASSERT_NO_MSG(&entropy_stm32_rng_data == dev->data);
|
||||
|
||||
if (likely((flags & ENTROPY_BUSYWAIT) == 0U)) {
|
||||
return rng_pool_get(
|
||||
|
@ -416,8 +409,8 @@ static int entropy_stm32_rng_init(const struct device *dev)
|
|||
|
||||
__ASSERT_NO_MSG(dev != NULL);
|
||||
|
||||
dev_data = DEV_DATA(dev);
|
||||
dev_cfg = DEV_CFG(dev);
|
||||
dev_data = dev->data;
|
||||
dev_cfg = dev->config;
|
||||
|
||||
__ASSERT_NO_MSG(dev_data != NULL);
|
||||
__ASSERT_NO_MSG(dev_cfg != NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue