drivers: can: 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:
Gerard Marull-Paretas 2022-01-18 12:50:32 +01:00 committed by Carles Cufí
commit 6378fcd0be
6 changed files with 84 additions and 76 deletions

View file

@ -201,8 +201,8 @@ static void can_stm32_isr(const struct device *dev)
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
data = dev->data;
cfg = dev->config;
can = cfg->can;
can_stm32_tx_isr_handler(can, data);
@ -221,8 +221,8 @@ static void can_stm32_rx_isr(const struct device *dev)
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
data = dev->data;
cfg = dev->config;
can = cfg->can;
can_stm32_rx_isr_handler(can, data);
@ -234,8 +234,8 @@ static void can_stm32_tx_isr(const struct device *dev)
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
data = dev->data;
cfg = dev->config;
can = cfg->can;
can_stm32_tx_isr_handler(can, data);
@ -247,8 +247,8 @@ static void can_stm32_state_change_isr(const struct device *dev)
const struct can_stm32_config *cfg;
CAN_TypeDef *can;
data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
data = dev->data;
cfg = dev->config;
can = cfg->can;
@ -313,9 +313,9 @@ static int can_leave_sleep_mode(CAN_TypeDef *can)
int can_stm32_set_mode(const struct device *dev, enum can_mode mode)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
const struct can_stm32_config *cfg = dev->config;
CAN_TypeDef *can = cfg->can;
struct can_stm32_data *data = DEV_DATA(dev);
struct can_stm32_data *data = dev->data;
int ret;
LOG_DBG("Set mode %d", mode);
@ -359,9 +359,9 @@ int can_stm32_set_timing(const struct device *dev,
const struct can_timing *timing,
const struct can_timing *timing_data)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
const struct can_stm32_config *cfg = dev->config;
CAN_TypeDef *can = cfg->can;
struct can_stm32_data *data = DEV_DATA(dev);
struct can_stm32_data *data = dev->data;
int ret = -EIO;
ARG_UNUSED(timing_data);
@ -397,7 +397,7 @@ done:
int can_stm32_get_core_clock(const struct device *dev, uint32_t *rate)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
const struct can_stm32_config *cfg = dev->config;
const struct device *clock;
int ret;
@ -423,8 +423,8 @@ int can_stm32_get_max_filters(const struct device *dev, enum can_ide id_type)
static int can_stm32_init(const struct device *dev)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
const struct can_stm32_config *cfg = dev->config;
struct can_stm32_data *data = dev->data;
CAN_TypeDef *can = cfg->can;
struct can_timing timing;
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can2), okay)
@ -534,8 +534,8 @@ static void can_stm32_set_state_change_callback(const struct device *dev,
can_state_change_callback_t cb,
void *user_data)
{
struct can_stm32_data *data = DEV_DATA(dev);
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = dev->data;
const struct can_stm32_config *cfg = dev->config;
CAN_TypeDef *can = cfg->can;
data->state_change_cb = cb;
@ -551,7 +551,7 @@ static void can_stm32_set_state_change_callback(const struct device *dev,
static enum can_state can_stm32_get_state(const struct device *dev,
struct can_bus_err_cnt *err_cnt)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
const struct can_stm32_config *cfg = dev->config;
CAN_TypeDef *can = cfg->can;
if (err_cnt) {
@ -576,8 +576,8 @@ static enum can_state can_stm32_get_state(const struct device *dev,
#ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY
int can_stm32_recover(const struct device *dev, k_timeout_t timeout)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
const struct can_stm32_config *cfg = dev->config;
struct can_stm32_data *data = dev->data;
CAN_TypeDef *can = cfg->can;
int ret = -EAGAIN;
int64_t start_time;
@ -619,8 +619,8 @@ int can_stm32_send(const struct device *dev, const struct zcan_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
const struct can_stm32_config *cfg = dev->config;
struct can_stm32_data *data = dev->data;
CAN_TypeDef *can = cfg->can;
uint32_t transmit_status_register = can->TSR;
CAN_TxMailBox_TypeDef *mailbox = NULL;
@ -1029,8 +1029,8 @@ static inline int can_stm32_add_rx_filter_unlocked(const struct device *dev,
void *cb_arg,
const struct zcan_filter *filter)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
const struct can_stm32_config *cfg = dev->config;
struct can_stm32_data *data = dev->data;
CAN_TypeDef *can = cfg->master_can;
int filter_index = 0;
int filter_id;
@ -1048,7 +1048,7 @@ int can_stm32_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
void *cb_arg,
const struct zcan_filter *filter)
{
struct can_stm32_data *data = DEV_DATA(dev);
struct can_stm32_data *data = dev->data;
int filter_id;
k_mutex_lock(&data->inst_mutex, K_FOREVER);
@ -1060,8 +1060,8 @@ int can_stm32_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
void can_stm32_remove_rx_filter(const struct device *dev, int filter_id)
{
const struct can_stm32_config *cfg = DEV_CFG(dev);
struct can_stm32_data *data = DEV_DATA(dev);
const struct can_stm32_config *cfg = dev->config;
struct can_stm32_data *data = dev->data;
CAN_TypeDef *can = cfg->master_can;
int bank_nr;
int filter_index;