drivers: ethernet: 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 15:48:18 +01:00 committed by Carles Cufí
commit 6f6a178390
13 changed files with 141 additions and 157 deletions

View file

@ -40,7 +40,6 @@ struct ksz8xxx_data {
#endif
};
#define DEV_DATA(dev) ((struct dsa_context *const)(dev)->data)
#define PRV_DATA(ctx) ((struct ksz8xxx_data *const)(ctx)->prv_data)
static void dsa_ksz8xxx_write_reg(const struct ksz8xxx_data *pdev,
@ -765,7 +764,8 @@ static void dsa_delayed_work(struct k_work *item)
int dsa_port_init(const struct device *dev)
{
struct ksz8xxx_data *pdev = PRV_DATA(DEV_DATA(dev));
struct dsa_context *data = dev->data;
struct ksz8xxx_data *pdev = PRV_DATA(data);
dsa_hw_init(pdev);
return 0;
@ -775,7 +775,8 @@ int dsa_port_init(const struct device *dev)
static int dsa_ksz8xxx_sw_write_reg(const struct device *dev, uint16_t reg_addr,
uint8_t value)
{
struct ksz8xxx_data *pdev = PRV_DATA(DEV_DATA(dev));
struct dsa_context *data = dev->data;
struct ksz8xxx_data *pdev = PRV_DATA(data);
dsa_ksz8xxx_write_reg(pdev, reg_addr, value);
return 0;
@ -785,7 +786,8 @@ static int dsa_ksz8xxx_sw_write_reg(const struct device *dev, uint16_t reg_addr,
static int dsa_ksz8xxx_sw_read_reg(const struct device *dev, uint16_t reg_addr,
uint8_t *value)
{
struct ksz8xxx_data *pdev = PRV_DATA(DEV_DATA(dev));
struct dsa_context *data = dev->data;
struct ksz8xxx_data *pdev = PRV_DATA(data);
dsa_ksz8xxx_read_reg(pdev, reg_addr, value);
return 0;
@ -808,7 +810,8 @@ static int dsa_ksz8xxx_set_mac_table_entry(const struct device *dev,
uint16_t tbl_entry_idx,
uint16_t flags)
{
struct ksz8xxx_data *pdev = PRV_DATA(DEV_DATA(dev));
struct dsa_context *data = dev->data;
struct ksz8xxx_data *pdev = PRV_DATA(data);
if (flags != 0) {
return -EINVAL;
@ -833,7 +836,8 @@ static int dsa_ksz8xxx_get_mac_table_entry(const struct device *dev,
uint8_t *buf,
uint16_t tbl_entry_idx)
{
struct ksz8xxx_data *pdev = PRV_DATA(DEV_DATA(dev));
struct dsa_context *data = dev->data;
struct ksz8xxx_data *pdev = PRV_DATA(data);
dsa_ksz8xxx_read_static_mac_table(pdev, tbl_entry_idx, buf);

View file

@ -65,7 +65,7 @@ static void link_configure(ETH_TypeDef *eth, uint32_t flags)
static void eth_gecko_setup_mac(const struct device *dev)
{
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
uint32_t link_status;
int result;
@ -136,8 +136,8 @@ static void rx_error_handler(ETH_TypeDef *eth)
static struct net_pkt *frame_get(const struct device *dev)
{
struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_gecko_dev_data *const dev_data = dev->data;
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
struct net_pkt *rx_frame = NULL;
uint16_t frag_len, total_len;
@ -236,7 +236,7 @@ static struct net_pkt *frame_get(const struct device *dev)
static void eth_rx(const struct device *dev)
{
struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev);
struct eth_gecko_dev_data *const dev_data = dev->data;
struct net_pkt *rx_frame;
int res = 0;
@ -262,8 +262,8 @@ static void eth_rx(const struct device *dev)
static int eth_tx(const struct device *dev, struct net_pkt *pkt)
{
struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_gecko_dev_data *const dev_data = dev->data;
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
uint16_t total_len;
uint8_t *dma_buffer;
@ -325,8 +325,8 @@ error:
static void rx_thread(void *arg1, void *unused1, void *unused2)
{
const struct device *dev = (const struct device *)arg1;
struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_gecko_dev_data *const dev_data = dev->data;
const struct eth_gecko_dev_cfg *const cfg = dev->config;
int res;
__ASSERT_NO_MSG(arg1 != NULL);
@ -369,8 +369,8 @@ static void rx_thread(void *arg1, void *unused1, void *unused2)
static void eth_isr(const struct device *dev)
{
struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_gecko_dev_data *const dev_data = dev->data;
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
uint32_t int_clr = 0;
uint32_t int_stat = eth->IFCR;
@ -429,7 +429,7 @@ static void eth_init_clocks(const struct device *dev)
static void eth_init_pins(const struct device *dev)
{
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
uint32_t idx;
@ -461,7 +461,7 @@ static void eth_init_pins(const struct device *dev)
static int eth_init(const struct device *dev)
{
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
__ASSERT_NO_MSG(dev != NULL);
@ -503,8 +503,8 @@ static void generate_mac(uint8_t mac_addr[6])
static void eth_iface_init(struct net_if *iface)
{
const struct device *dev = net_if_get_device(iface);
struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_gecko_dev_data *const dev_data = dev->data;
const struct eth_gecko_dev_cfg *const cfg = dev->config;
ETH_TypeDef *eth = cfg->regs;
int result;

View file

@ -95,10 +95,6 @@ struct eth_gecko_dev_data {
};
#define DEV_NAME(dev) ((dev)->name)
#define DEV_CFG(dev) \
((const struct eth_gecko_dev_cfg *)(dev)->config)
#define DEV_DATA(dev) \
((struct eth_gecko_dev_data *)(dev)->data)
/* PHY Management pins */
#define PIN_PHY_MDC {DT_INST_PROP_BY_IDX(0, location_phy_mdc, 1), \

View file

@ -1354,7 +1354,7 @@ static void eth_rx(struct gmac_queue *queue)
struct net_pkt *rx_frame;
#if defined(CONFIG_NET_GPTP)
const struct device *const dev = net_if_get_device(dev_data->iface);
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
Gmac *gmac = cfg->regs;
struct gptp_hdr *hdr;
#endif
@ -1448,8 +1448,8 @@ static int priority2queue(enum net_priority priority)
static int eth_tx(const struct device *dev, struct net_pkt *pkt)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
struct eth_sam_dev_data *const dev_data = dev->data;
Gmac *gmac = cfg->regs;
struct gmac_queue *queue;
struct gmac_desc_list *tx_desc_list;
@ -1631,8 +1631,8 @@ static int eth_tx(const struct device *dev, struct net_pkt *pkt)
static void queue0_isr(const struct device *dev)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
struct eth_sam_dev_data *const dev_data = dev->data;
Gmac *gmac = cfg->regs;
struct gmac_queue *queue;
struct gmac_desc_list *rx_desc_list;
@ -1682,8 +1682,8 @@ static void queue0_isr(const struct device *dev)
static inline void priority_queue_isr(const struct device *dev,
unsigned int queue_idx)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
struct eth_sam_dev_data *const dev_data = dev->data;
Gmac *gmac = cfg->regs;
struct gmac_queue *queue;
struct gmac_desc_list *rx_desc_list;
@ -1766,7 +1766,7 @@ static void queue5_isr(const struct device *dev)
static int eth_initialize(const struct device *dev)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
cfg->config_func();
@ -1823,8 +1823,8 @@ static void phy_link_state_changed(const struct device *pdev,
void *user_data)
{
const struct device *dev = (struct device *) user_data;
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_sam_dev_data *const dev_data = dev->data;
const struct eth_sam_dev_cfg *const cfg = dev->config;
bool is_up;
is_up = state->is_up;
@ -1852,8 +1852,8 @@ static void phy_link_state_changed(const struct device *pdev,
static void eth0_iface_init(struct net_if *iface)
{
const struct device *dev = net_if_get_device(iface);
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_sam_dev_data *const dev_data = dev->data;
const struct eth_sam_dev_cfg *const cfg = dev->config;
static bool init_done;
uint32_t gmac_ncfgr_val;
int result;
@ -1988,7 +1988,7 @@ static int eth_sam_gmac_set_qav_param(const struct device *dev,
enum ethernet_config_type type,
const struct ethernet_config *config)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
Gmac *gmac = cfg->regs;
enum ethernet_qav_param_type qav_param_type;
unsigned int delta_bandwidth;
@ -2037,8 +2037,8 @@ static int eth_sam_gmac_set_config(const struct device *dev,
#endif
case ETHERNET_CONFIG_TYPE_MAC_ADDRESS:
{
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
struct eth_sam_dev_data *const dev_data = dev->data;
const struct eth_sam_dev_cfg *const cfg = dev->config;
memcpy(dev_data->mac_addr,
config->mac_address.addr,
@ -2070,7 +2070,7 @@ static int eth_sam_gmac_get_qav_param(const struct device *dev,
enum ethernet_config_type type,
struct ethernet_config *config)
{
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev);
const struct eth_sam_dev_cfg *const cfg = dev->config;
Gmac *gmac = cfg->regs;
enum ethernet_qav_param_type qav_param_type;
int queue_id;
@ -2137,7 +2137,7 @@ static int eth_sam_gmac_get_config(const struct device *dev,
#if defined(CONFIG_PTP_CLOCK_SAM_GMAC)
static const struct device *eth_sam_gmac_get_ptp_clock(const struct device *dev)
{
struct eth_sam_dev_data *const dev_data = DEV_DATA(dev);
struct eth_sam_dev_data *const dev_data = dev->data;
return dev_data->ptp_clock;
}
@ -2401,7 +2401,7 @@ static int ptp_clock_sam_gmac_set(const struct device *dev,
struct net_ptp_time *tm)
{
struct ptp_context *ptp_context = dev->data;
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(ptp_context->eth_dev);
const struct eth_sam_dev_cfg *const cfg = ptp_context->eth_dev->config;
Gmac *gmac = cfg->regs;
gmac->GMAC_TSH = tm->_sec.high & 0xffff;
@ -2415,7 +2415,7 @@ static int ptp_clock_sam_gmac_get(const struct device *dev,
struct net_ptp_time *tm)
{
struct ptp_context *ptp_context = dev->data;
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(ptp_context->eth_dev);
const struct eth_sam_dev_cfg *const cfg = ptp_context->eth_dev->config;
Gmac *gmac = cfg->regs;
tm->second = ((uint64_t)(gmac->GMAC_TSH & 0xffff) << 32) | gmac->GMAC_TSL;
@ -2427,7 +2427,7 @@ static int ptp_clock_sam_gmac_get(const struct device *dev,
static int ptp_clock_sam_gmac_adjust(const struct device *dev, int increment)
{
struct ptp_context *ptp_context = dev->data;
const struct eth_sam_dev_cfg *const cfg = DEV_CFG(ptp_context->eth_dev);
const struct eth_sam_dev_cfg *const cfg = ptp_context->eth_dev->config;
Gmac *gmac = cfg->regs;
if ((increment <= -NSEC_PER_SEC) || (increment >= NSEC_PER_SEC)) {

View file

@ -281,9 +281,4 @@ struct eth_sam_dev_data {
struct gmac_queue queue_list[GMAC_QUEUE_NUM];
};
#define DEV_CFG(dev) \
((const struct eth_sam_dev_cfg *const)(dev)->config)
#define DEV_DATA(dev) \
((struct eth_sam_dev_data *const)(dev)->data)
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_SAM_GMAC_PRIV_H_ */

View file

@ -39,7 +39,7 @@ static void eth_stellaris_assign_mac(const struct device *dev)
static void eth_stellaris_flush(const struct device *dev)
{
struct eth_stellaris_runtime *dev_data = DEV_DATA(dev);
struct eth_stellaris_runtime *dev_data = dev->data;
if (dev_data->tx_pos != 0) {
sys_write32(dev_data->tx_word, REG_MACDATA);
@ -50,7 +50,7 @@ static void eth_stellaris_flush(const struct device *dev)
static void eth_stellaris_send_byte(const struct device *dev, uint8_t byte)
{
struct eth_stellaris_runtime *dev_data = DEV_DATA(dev);
struct eth_stellaris_runtime *dev_data = dev->data;
dev_data->tx_word |= byte << (dev_data->tx_pos * 8);
dev_data->tx_pos++;
@ -63,7 +63,7 @@ static void eth_stellaris_send_byte(const struct device *dev, uint8_t byte)
static int eth_stellaris_send(const struct device *dev, struct net_pkt *pkt)
{
struct eth_stellaris_runtime *dev_data = DEV_DATA(dev);
struct eth_stellaris_runtime *dev_data = dev->data;
struct net_buf *frag;
uint16_t i, data_len;
@ -203,7 +203,7 @@ error:
static void eth_stellaris_rx(const struct device *dev)
{
struct eth_stellaris_runtime *dev_data = DEV_DATA(dev);
struct eth_stellaris_runtime *dev_data = dev->data;
struct net_if *iface = dev_data->iface;
struct net_pkt *pkt;
@ -229,7 +229,7 @@ err_mem:
static void eth_stellaris_isr(const struct device *dev)
{
struct eth_stellaris_runtime *dev_data = DEV_DATA(dev);
struct eth_stellaris_runtime *dev_data = dev->data;
int isr_val = sys_read32(REG_MACRIS);
uint32_t lock;
@ -270,8 +270,8 @@ static void eth_stellaris_isr(const struct device *dev)
static void eth_stellaris_init(struct net_if *iface)
{
const struct device *dev = net_if_get_device(iface);
const struct eth_stellaris_config *dev_conf = DEV_CFG(dev);
struct eth_stellaris_runtime *dev_data = DEV_DATA(dev);
const struct eth_stellaris_config *dev_conf = dev->config;
struct eth_stellaris_runtime *dev_data = dev->data;
dev_data->iface = iface;
@ -291,7 +291,9 @@ static void eth_stellaris_init(struct net_if *iface)
#if defined(CONFIG_NET_STATISTICS_ETHERNET)
static struct net_stats_eth *eth_stellaris_stats(const struct device *dev)
{
return &(DEV_DATA(dev)->stats);
struct eth_stellaris_runtime *dev_data = dev->data;
return &data->stats;
}
#endif

View file

@ -8,23 +8,21 @@
#ifndef ETH_STELLARIS_PRIV_H_
#define ETH_STELLARIS_PRIV_H_
#define DEV_DATA(dev) \
((struct eth_stellaris_runtime *)(dev)->data)
#define DEV_CFG(dev) \
((const struct eth_stellaris_config *const)(dev)->config)
#define REG_BASE(dev) \
((const struct eth_stellaris_config *const)(dev)->config)->mac_base
/*
* Register mapping
*/
/* Registers for ethernet system, mac_base + offset */
#define REG_MACRIS ((DEV_CFG(dev)->mac_base) + 0x000)
#define REG_MACIM ((DEV_CFG(dev)->mac_base) + 0x004)
#define REG_MACRCTL ((DEV_CFG(dev)->mac_base) + 0x008)
#define REG_MACTCTL ((DEV_CFG(dev)->mac_base) + 0x00C)
#define REG_MACDATA ((DEV_CFG(dev)->mac_base) + 0x010)
#define REG_MACIA0 ((DEV_CFG(dev)->mac_base) + 0x014)
#define REG_MACIA1 ((DEV_CFG(dev)->mac_base) + 0x018)
#define REG_MACNP ((DEV_CFG(dev)->mac_base) + 0x034)
#define REG_MACTR ((DEV_CFG(dev)->mac_base) + 0x038)
#define REG_MACRIS (REG_BASE(dev) + 0x000)
#define REG_MACIM (REG_BASE(dev) + 0x004)
#define REG_MACRCTL (REG_BASE(dev) + 0x008)
#define REG_MACTCTL (REG_BASE(dev) + 0x00C)
#define REG_MACDATA (REG_BASE(dev) + 0x010)
#define REG_MACIA0 (REG_BASE(dev) + 0x014)
#define REG_MACIA1 (REG_BASE(dev) + 0x018)
#define REG_MACNP (REG_BASE(dev) + 0x034)
#define REG_MACTR (REG_BASE(dev) + 0x038)
/* ETH MAC Receive Control bit fields set value */
#define BIT_MACRCTL_RSTFIFO 0x10

View file

@ -202,7 +202,7 @@ static bool eth_is_ptp_pkt(struct net_if *iface, struct net_pkt *pkt)
static int eth_tx(const struct device *dev, struct net_pkt *pkt)
{
struct eth_stm32_hal_dev_data *dev_data = DEV_DATA(dev);
struct eth_stm32_hal_dev_data *dev_data = dev->data;
ETH_HandleTypeDef *heth;
uint8_t *dma_buffer;
int res;
@ -462,7 +462,7 @@ static struct net_pkt *eth_rx(const struct device *dev, uint16_t *vlan_tag)
__ASSERT_NO_MSG(dev != NULL);
dev_data = DEV_DATA(dev);
dev_data = dev->data;
__ASSERT_NO_MSG(dev_data != NULL);
@ -646,7 +646,7 @@ static void rx_thread(void *arg1, void *unused1, void *unused2)
ARG_UNUSED(unused2);
dev = (const struct device *)arg1;
dev_data = DEV_DATA(dev);
dev_data = dev->data;
__ASSERT_NO_MSG(dev_data != NULL);
@ -702,7 +702,7 @@ static void eth_isr(const struct device *dev)
__ASSERT_NO_MSG(dev != NULL);
dev_data = DEV_DATA(dev);
dev_data = dev->data;
__ASSERT_NO_MSG(dev_data != NULL);
@ -802,8 +802,8 @@ static int eth_initialize(const struct device *dev)
__ASSERT_NO_MSG(dev != NULL);
dev_data = DEV_DATA(dev);
cfg = DEV_CFG(dev);
dev_data = dev->data;
cfg = dev->config;
__ASSERT_NO_MSG(dev_data != NULL);
__ASSERT_NO_MSG(cfg != NULL);
@ -964,7 +964,7 @@ static void eth_iface_init(struct net_if *iface)
dev = net_if_get_device(iface);
__ASSERT_NO_MSG(dev != NULL);
dev_data = DEV_DATA(dev);
dev_data = dev->data;
__ASSERT_NO_MSG(dev_data != NULL);
/* For VLAN, this value is only used to get the correct L2 driver.
@ -986,9 +986,10 @@ static void eth_iface_init(struct net_if *iface)
net_if_flag_set(iface, NET_IF_NO_AUTO_START);
if (is_first_init) {
const struct eth_stm32_hal_dev_cfg *cfg = dev->config;
/* Now that the iface is setup, we are safe to enable IRQs. */
__ASSERT_NO_MSG(DEV_CFG(dev)->config_func != NULL);
DEV_CFG(dev)->config_func();
__ASSERT_NO_MSG(cfg->config_func != NULL);
cfg->config_func();
}
}
@ -1017,7 +1018,7 @@ static int eth_stm32_hal_set_config(const struct device *dev,
struct eth_stm32_hal_dev_data *dev_data;
ETH_HandleTypeDef *heth;
dev_data = DEV_DATA(dev);
dev_data = dev->data;
heth = &dev_data->heth;
switch (type) {
@ -1317,8 +1318,8 @@ static const struct ptp_clock_driver_api api = {
static int ptp_stm32_init(const struct device *port)
{
const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(mac));
struct eth_stm32_hal_dev_data *eth_dev_data = DEV_DATA(dev);
const struct eth_stm32_hal_dev_cfg *eth_cfg = DEV_CFG(dev);
struct eth_stm32_hal_dev_data *eth_dev_data = dev->data;
const struct eth_stm32_hal_dev_cfg *eth_cfg = dev->config;
struct ptp_context *ptp_context = port->data;
ETH_HandleTypeDef *heth = &eth_dev_data->heth;
int ret;

View file

@ -55,9 +55,4 @@ struct eth_stm32_hal_dev_data {
#endif /* CONFIG_PTP_CLOCK_STM32_HAL */
};
#define DEV_CFG(dev) \
((const struct eth_stm32_hal_dev_cfg *)(dev)->config)
#define DEV_DATA(dev) \
((struct eth_stm32_hal_dev_data *)(dev)->data)
#endif /* ZEPHYR_DRIVERS_ETHERNET_ETH_STM32_HAL_PRIV_H_ */

View file

@ -90,7 +90,7 @@ DT_INST_FOREACH_STATUS_OKAY(ETH_XLNX_GEM_INITIALIZE)
*/
static int eth_xlnx_gem_dev_init(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
uint32_t reg_val;
/* Precondition checks using assertions */
@ -219,8 +219,8 @@ static int eth_xlnx_gem_dev_init(const struct device *dev)
static void eth_xlnx_gem_iface_init(struct net_if *iface)
{
const struct device *dev = net_if_get_device(iface);
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
/* Set the initial contents of the current instance's run-time data */
dev_data->iface = iface;
@ -264,8 +264,8 @@ static void eth_xlnx_gem_iface_init(struct net_if *iface)
*/
static void eth_xlnx_gem_isr(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t reg_val;
/* Read the interrupt status register */
@ -344,8 +344,8 @@ static void eth_xlnx_gem_isr(const struct device *dev)
*/
static int eth_xlnx_gem_send(const struct device *dev, struct net_pkt *pkt)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t tx_data_length;
uint16_t tx_data_remaining;
@ -519,8 +519,8 @@ static int eth_xlnx_gem_send(const struct device *dev, struct net_pkt *pkt)
*/
static int eth_xlnx_gem_start_device(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t reg_val;
if (dev_data->started) {
@ -568,8 +568,8 @@ static int eth_xlnx_gem_start_device(const struct device *dev)
*/
static int eth_xlnx_gem_stop_device(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t reg_val;
if (!dev_data->started) {
@ -613,7 +613,7 @@ static int eth_xlnx_gem_stop_device(const struct device *dev)
static enum ethernet_hw_caps eth_xlnx_gem_get_capabilities(
const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
enum ethernet_hw_caps caps = (enum ethernet_hw_caps)0;
if (dev_conf->max_link_speed == LINK_1GBIT) {
@ -664,7 +664,9 @@ static enum ethernet_hw_caps eth_xlnx_gem_get_capabilities(
*/
static struct net_stats_eth *eth_xlnx_gem_stats(const struct device *dev)
{
return &(DEV_DATA(dev)->stats);
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
return &data->stats;
}
#endif
@ -677,7 +679,7 @@ static struct net_stats_eth *eth_xlnx_gem_stats(const struct device *dev)
*/
static void eth_xlnx_gem_reset_hw(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
/*
* Controller reset sequence as described in the Zynq-7000 TRM,
@ -726,8 +728,8 @@ static void eth_xlnx_gem_configure_clocks(const struct device *dev)
* values for the respective GEM's TX clock are calculated here.
*/
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t div0;
uint32_t div1;
@ -853,7 +855,7 @@ static void eth_xlnx_gem_configure_clocks(const struct device *dev)
*/
static void eth_xlnx_gem_set_initial_nwcfg(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
uint32_t reg_val = 0;
if (dev_conf->ignore_ipg_rxer) {
@ -973,8 +975,8 @@ static void eth_xlnx_gem_set_initial_nwcfg(const struct device *dev)
*/
static void eth_xlnx_gem_set_nwcfg_link_speed(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t reg_val;
/*
@ -1007,8 +1009,8 @@ static void eth_xlnx_gem_set_nwcfg_link_speed(const struct device *dev)
*/
static void eth_xlnx_gem_set_mac_address(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t regval_top;
uint32_t regval_bot;
@ -1043,7 +1045,7 @@ static void eth_xlnx_gem_set_mac_address(const struct device *dev)
*/
static void eth_xlnx_gem_set_initial_dmacr(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
uint32_t reg_val = 0;
/*
@ -1110,7 +1112,7 @@ static void eth_xlnx_gem_set_initial_dmacr(const struct device *dev)
*/
static void eth_xlnx_gem_init_phy(const struct device *dev)
{
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
int detect_rc;
LOG_DBG("%s attempting to initialize associated PHY", dev->name);
@ -1162,7 +1164,7 @@ static void eth_xlnx_gem_poll_phy(struct k_work *work)
struct eth_xlnx_gem_dev_data *dev_data = CONTAINER_OF(dwork,
struct eth_xlnx_gem_dev_data, phy_poll_delayed_work);
const struct device *dev = net_if_get_device(dev_data->iface);
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
uint16_t phy_status;
uint8_t link_status;
@ -1257,8 +1259,8 @@ static void eth_xlnx_gem_poll_phy(struct k_work *work)
*/
static void eth_xlnx_gem_configure_buffers(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
struct eth_xlnx_gem_bd *bdptr;
uint32_t buf_iter;
@ -1372,8 +1374,8 @@ static void eth_xlnx_gem_rx_pending_work(struct k_work *item)
*/
static void eth_xlnx_gem_handle_rx_pending(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t reg_addr;
uint32_t reg_ctrl;
uint32_t reg_val;
@ -1552,8 +1554,8 @@ static void eth_xlnx_gem_tx_done_work(struct k_work *item)
*/
static void eth_xlnx_gem_handle_tx_done(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint32_t reg_ctrl;
uint32_t reg_val;
uint32_t reg_val_txsr;

View file

@ -410,12 +410,6 @@
#define ETH_XLNX_GEM_PHY_MAINT_REGISTER_ID_SHIFT 18
#define ETH_XLNX_GEM_PHY_MAINT_DATA_MASK 0x0000FFFF
/* Device configuration / run-time data resolver macros */
#define DEV_CFG(dev) \
((const struct eth_xlnx_gem_dev_cfg * const)(dev->config))
#define DEV_DATA(dev) \
((struct eth_xlnx_gem_dev_data *)(dev->data))
/* Device initialization macro */
#define ETH_XLNX_GEM_NET_DEV_INIT(port) \
ETH_NET_DEVICE_DT_INST_DEFINE(port,\

View file

@ -35,9 +35,6 @@ struct phy_mii_dev_data {
};
#define DEV_NAME(dev) ((dev)->name)
#define DEV_DATA(dev) ((struct phy_mii_dev_data *const)(dev)->data)
#define DEV_CFG(dev) \
((const struct phy_mii_dev_config *const)(dev)->config)
static int phy_mii_get_link_state(const struct device *dev,
struct phy_link_state *state);
@ -45,7 +42,7 @@ static int phy_mii_get_link_state(const struct device *dev,
static inline int reg_read(const struct device *dev, uint16_t reg_addr,
uint16_t *value)
{
const struct phy_mii_dev_config *const cfg = DEV_CFG(dev);
const struct phy_mii_dev_config *const cfg = dev->config;
return mdio_read(cfg->mdio, cfg->phy_addr, reg_addr, value);
}
@ -53,7 +50,7 @@ static inline int reg_read(const struct device *dev, uint16_t reg_addr,
static inline int reg_write(const struct device *dev, uint16_t reg_addr,
uint16_t value)
{
const struct phy_mii_dev_config *const cfg = DEV_CFG(dev);
const struct phy_mii_dev_config *const cfg = dev->config;
return mdio_write(cfg->mdio, cfg->phy_addr, reg_addr, value);
}
@ -108,8 +105,8 @@ static int get_id(const struct device *dev, uint32_t *phy_id)
static int update_link_state(const struct device *dev)
{
const struct phy_mii_dev_config *const cfg = DEV_CFG(dev);
struct phy_mii_dev_data *const data = DEV_DATA(dev);
const struct phy_mii_dev_config *const cfg = dev->config;
struct phy_mii_dev_data *const data = dev->data;
bool link_up;
uint16_t anar_reg = 0;
@ -203,7 +200,7 @@ static int update_link_state(const struct device *dev)
static void invoke_link_cb(const struct device *dev)
{
struct phy_mii_dev_data *const data = DEV_DATA(dev);
struct phy_mii_dev_data *const data = dev->data;
struct phy_link_state state;
if (data->cb == NULL) {
@ -300,7 +297,7 @@ static int phy_mii_cfg_link(const struct device *dev,
static int phy_mii_get_link_state(const struct device *dev,
struct phy_link_state *state)
{
struct phy_mii_dev_data *const data = DEV_DATA(dev);
struct phy_mii_dev_data *const data = dev->data;
k_sem_take(&data->sem, K_FOREVER);
@ -314,7 +311,7 @@ static int phy_mii_get_link_state(const struct device *dev,
static int phy_mii_link_cb_set(const struct device *dev, phy_callback_t cb,
void *user_data)
{
struct phy_mii_dev_data *const data = DEV_DATA(dev);
struct phy_mii_dev_data *const data = dev->data;
data->cb = cb;
data->cb_data = user_data;
@ -330,8 +327,8 @@ static int phy_mii_link_cb_set(const struct device *dev, phy_callback_t cb,
static int phy_mii_initialize(const struct device *dev)
{
const struct phy_mii_dev_config *const cfg = DEV_CFG(dev);
struct phy_mii_dev_data *const data = DEV_DATA(dev);
const struct phy_mii_dev_config *const cfg = dev->config;
struct phy_mii_dev_data *const data = dev->data;
uint32_t phy_id;
k_sem_init(&data->sem, 1, 1);

View file

@ -192,8 +192,8 @@ static void phy_xlnx_gem_mdio_write(
*/
static void phy_xlnx_gem_marvell_alaska_reset(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
uint32_t retries = 0;
@ -227,8 +227,8 @@ static void phy_xlnx_gem_marvell_alaska_reset(const struct device *dev)
*/
static void phy_xlnx_gem_marvell_alaska_cfg(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
uint16_t phy_data_gbit;
uint32_t retries = 0;
@ -482,8 +482,8 @@ static void phy_xlnx_gem_marvell_alaska_cfg(const struct device *dev)
*/
static uint16_t phy_xlnx_gem_marvell_alaska_poll_sc(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
uint16_t phy_status = 0;
@ -530,8 +530,8 @@ static uint16_t phy_xlnx_gem_marvell_alaska_poll_sc(const struct device *dev)
*/
static uint8_t phy_xlnx_gem_marvell_alaska_poll_lsts(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
/*
@ -555,8 +555,8 @@ static uint8_t phy_xlnx_gem_marvell_alaska_poll_lsts(const struct device *dev)
static enum eth_xlnx_link_speed phy_xlnx_gem_marvell_alaska_poll_lspd(
const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
enum eth_xlnx_link_speed link_speed;
uint16_t phy_data;
@ -610,8 +610,8 @@ static enum eth_xlnx_link_speed phy_xlnx_gem_marvell_alaska_poll_lspd(
*/
static void phy_xlnx_gem_ti_dp83822_reset(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
uint32_t retries = 0;
@ -639,8 +639,8 @@ static void phy_xlnx_gem_ti_dp83822_reset(const struct device *dev)
*/
static void phy_xlnx_gem_ti_dp83822_cfg(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data = PHY_TI_ADV_SELECTOR_802_3;
/* Configure link advertisement */
@ -721,8 +721,8 @@ static void phy_xlnx_gem_ti_dp83822_cfg(const struct device *dev)
*/
static uint16_t phy_xlnx_gem_ti_dp83822_poll_sc(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
uint16_t phy_status = 0;
@ -761,8 +761,8 @@ static uint16_t phy_xlnx_gem_ti_dp83822_poll_sc(const struct device *dev)
*/
static uint8_t phy_xlnx_gem_ti_dp83822_poll_lsts(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint16_t phy_data;
/*
@ -789,8 +789,8 @@ static uint8_t phy_xlnx_gem_ti_dp83822_poll_lsts(const struct device *dev)
static enum eth_xlnx_link_speed phy_xlnx_gem_ti_dp83822_poll_lspd(
const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
enum eth_xlnx_link_speed link_speed;
uint16_t phy_data;
@ -893,8 +893,8 @@ static struct phy_xlnx_gem_supported_dev phy_xlnx_gem_supported_devs[] = {
*/
int phy_xlnx_gem_detect(const struct device *dev)
{
const struct eth_xlnx_gem_dev_cfg *dev_conf = DEV_CFG(dev);
struct eth_xlnx_gem_dev_data *dev_data = DEV_DATA(dev);
const struct eth_xlnx_gem_dev_cfg *dev_conf = dev->config;
struct eth_xlnx_gem_dev_data *dev_data = dev->data;
uint8_t phy_curr_addr;
uint8_t phy_first_addr = dev_conf->phy_mdio_addr_fix;