drivers: serial: 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
e8c15f68b2
commit
1674fec5b6
26 changed files with 700 additions and 623 deletions
|
@ -13,13 +13,10 @@
|
|||
|
||||
#include "uart_lpc11u6x.h"
|
||||
|
||||
#define DEV_CFG(dev) ((dev)->config)
|
||||
#define DEV_DATA(dev) ((dev)->data)
|
||||
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(uart0), okay)
|
||||
static int lpc11u6x_uart0_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
if (!(cfg->uart0->lsr & LPC11U6X_UART0_LSR_RDR)) {
|
||||
return -1;
|
||||
|
@ -31,7 +28,7 @@ static int lpc11u6x_uart0_poll_in(const struct device *dev, unsigned char *c)
|
|||
|
||||
static void lpc11u6x_uart0_poll_out(const struct device *dev, unsigned char c)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
while (!(cfg->uart0->lsr & LPC11U6X_UART0_LSR_THRE)) {
|
||||
}
|
||||
|
@ -40,7 +37,7 @@ static void lpc11u6x_uart0_poll_out(const struct device *dev, unsigned char c)
|
|||
|
||||
static int lpc11u6x_uart0_err_check(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
uint32_t lsr;
|
||||
int ret = 0;
|
||||
|
||||
|
@ -104,8 +101,8 @@ static void lpc11u6x_uart0_config_baudrate(const struct device *clk_drv,
|
|||
static int lpc11u6x_uart0_configure(const struct device *dev,
|
||||
const struct uart_config *cfg)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *dev_cfg = DEV_CFG(dev);
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
const struct lpc11u6x_uart0_config *dev_cfg = dev->config;
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
const struct device *clk_dev;
|
||||
uint32_t flags = 0;
|
||||
|
||||
|
@ -190,7 +187,7 @@ static int lpc11u6x_uart0_configure(const struct device *dev,
|
|||
static int lpc11u6x_uart0_config_get(const struct device *dev,
|
||||
struct uart_config *cfg)
|
||||
{
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
|
||||
cfg->baudrate = data->baudrate;
|
||||
cfg->parity = data->parity;
|
||||
|
@ -207,7 +204,7 @@ static int lpc11u6x_uart0_fifo_fill(const struct device *dev,
|
|||
const uint8_t *data,
|
||||
const int size)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
int nr_sent = 0;
|
||||
|
||||
while (nr_sent < size && (cfg->uart0->lsr & LPC11U6X_UART0_LSR_THRE)) {
|
||||
|
@ -220,7 +217,7 @@ static int lpc11u6x_uart0_fifo_fill(const struct device *dev,
|
|||
static int lpc11u6x_uart0_fifo_read(const struct device *dev, uint8_t *data,
|
||||
const int size)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
int nr_rx = 0;
|
||||
|
||||
while (nr_rx < size && (cfg->uart0->lsr & LPC11U6X_UART0_LSR_RDR)) {
|
||||
|
@ -232,7 +229,7 @@ static int lpc11u6x_uart0_fifo_read(const struct device *dev, uint8_t *data,
|
|||
|
||||
static void lpc11u6x_uart0_irq_tx_enable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
cfg->uart0->ier = (cfg->uart0->ier & LPC11U6X_UART0_IER_MASK) |
|
||||
LPC11U6X_UART0_IER_THREINTEN;
|
||||
|
@ -245,7 +242,7 @@ static void lpc11u6x_uart0_irq_tx_enable(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uart0_irq_tx_disable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
cfg->uart0->ier = (cfg->uart0->ier & LPC11U6X_UART0_IER_MASK) &
|
||||
~LPC11U6X_UART0_IER_THREINTEN;
|
||||
|
@ -253,14 +250,14 @@ static void lpc11u6x_uart0_irq_tx_disable(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uart0_irq_tx_complete(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
return (cfg->uart0->lsr & LPC11U6X_UART0_LSR_TEMT) != 0;
|
||||
}
|
||||
|
||||
static int lpc11u6x_uart0_irq_tx_ready(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
return (cfg->uart0->lsr & LPC11U6X_UART0_LSR_THRE) &&
|
||||
(cfg->uart0->ier & LPC11U6X_UART0_IER_THREINTEN);
|
||||
|
@ -268,7 +265,7 @@ static int lpc11u6x_uart0_irq_tx_ready(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uart0_irq_rx_enable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
cfg->uart0->ier = (cfg->uart0->ier & LPC11U6X_UART0_IER_MASK) |
|
||||
LPC11U6X_UART0_IER_RBRINTEN;
|
||||
|
@ -276,7 +273,7 @@ static void lpc11u6x_uart0_irq_rx_enable(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uart0_irq_rx_disable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
cfg->uart0->ier = (cfg->uart0->ier & LPC11U6X_UART0_IER_MASK) &
|
||||
~LPC11U6X_UART0_IER_RBRINTEN;
|
||||
|
@ -284,7 +281,7 @@ static void lpc11u6x_uart0_irq_rx_disable(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uart0_irq_rx_ready(const struct device *dev)
|
||||
{
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
|
||||
return (LPC11U6X_UART0_IIR_INTID(data->cached_iir) ==
|
||||
LPC11U6X_UART0_IIR_INTID_RDA) ||
|
||||
|
@ -294,7 +291,7 @@ static int lpc11u6x_uart0_irq_rx_ready(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uart0_irq_err_enable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
cfg->uart0->ier = (cfg->uart0->ier & LPC11U6X_UART0_IER_MASK) |
|
||||
LPC11U6X_UART0_IER_RLSINTEN;
|
||||
|
@ -302,7 +299,7 @@ static void lpc11u6x_uart0_irq_err_enable(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uart0_irq_err_disable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
|
||||
cfg->uart0->ier = (cfg->uart0->ier & LPC11U6X_UART0_IER_MASK) &
|
||||
~LPC11U6X_UART0_IER_RLSINTEN;
|
||||
|
@ -310,15 +307,15 @@ static void lpc11u6x_uart0_irq_err_disable(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uart0_irq_is_pending(const struct device *dev)
|
||||
{
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
|
||||
return !(data->cached_iir & LPC11U6X_UART0_IIR_STATUS);
|
||||
}
|
||||
|
||||
static int lpc11u6x_uart0_irq_update(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
|
||||
data->cached_iir = cfg->uart0->iir;
|
||||
return 1;
|
||||
|
@ -328,7 +325,7 @@ static void lpc11u6x_uart0_irq_callback_set(const struct device *dev,
|
|||
uart_irq_callback_user_data_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
|
||||
data->cb = cb;
|
||||
data->cb_data = user_data;
|
||||
|
@ -336,7 +333,7 @@ static void lpc11u6x_uart0_irq_callback_set(const struct device *dev,
|
|||
|
||||
static void lpc11u6x_uart0_isr(const struct device *dev)
|
||||
{
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
|
||||
if (data->cb) {
|
||||
data->cb(dev, data->cb_data);
|
||||
|
@ -346,8 +343,8 @@ static void lpc11u6x_uart0_isr(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uart0_init(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev);
|
||||
struct lpc11u6x_uart0_data *data = DEV_DATA(dev);
|
||||
const struct lpc11u6x_uart0_config *cfg = dev->config;
|
||||
struct lpc11u6x_uart0_data *data = dev->data;
|
||||
const struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv;
|
||||
|
||||
/* Configure RX and TX pin via the pinmux driver */
|
||||
|
@ -469,7 +466,7 @@ static void lpc11u6x_uart0_isr_config(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uartx_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
if (!(cfg->base->stat & LPC11U6X_UARTX_STAT_RXRDY)) {
|
||||
return -1;
|
||||
|
@ -480,7 +477,7 @@ static int lpc11u6x_uartx_poll_in(const struct device *dev, unsigned char *c)
|
|||
|
||||
static void lpc11u6x_uartx_poll_out(const struct device *dev, unsigned char c)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
while (!(cfg->base->stat & LPC11U6X_UARTX_STAT_TXRDY)) {
|
||||
}
|
||||
|
@ -489,7 +486,7 @@ static void lpc11u6x_uartx_poll_out(const struct device *dev, unsigned char c)
|
|||
|
||||
static int lpc11u6x_uartx_err_check(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
int ret = 0;
|
||||
|
||||
if (cfg->base->stat & LPC11U6X_UARTX_STAT_OVERRUNINT) {
|
||||
|
@ -526,8 +523,8 @@ static void lpc11u6x_uartx_config_baud(const struct lpc11u6x_uartx_config *cfg,
|
|||
static int lpc11u6x_uartx_configure(const struct device *dev,
|
||||
const struct uart_config *cfg)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *dev_cfg = DEV_CFG(dev);
|
||||
struct lpc11u6x_uartx_data *data = DEV_DATA(dev);
|
||||
const struct lpc11u6x_uartx_config *dev_cfg = dev->config;
|
||||
struct lpc11u6x_uartx_data *data = dev->data;
|
||||
const struct device *clk_dev;
|
||||
uint32_t flags = 0;
|
||||
|
||||
|
@ -617,7 +614,7 @@ static int lpc11u6x_uartx_configure(const struct device *dev,
|
|||
static int lpc11u6x_uartx_config_get(const struct device *dev,
|
||||
struct uart_config *cfg)
|
||||
{
|
||||
const struct lpc11u6x_uartx_data *data = DEV_DATA(dev);
|
||||
const struct lpc11u6x_uartx_data *data = dev->data;
|
||||
|
||||
cfg->baudrate = data->baudrate;
|
||||
cfg->parity = data->parity;
|
||||
|
@ -634,7 +631,7 @@ static int lpc11u6x_uartx_fifo_fill(const struct device *dev,
|
|||
const uint8_t *data,
|
||||
int size)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
int tx_size = 0;
|
||||
|
||||
while (tx_size < size &&
|
||||
|
@ -647,7 +644,7 @@ static int lpc11u6x_uartx_fifo_fill(const struct device *dev,
|
|||
static int lpc11u6x_uartx_fifo_read(const struct device *dev, uint8_t *data,
|
||||
int size)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
int rx_size = 0;
|
||||
|
||||
while (rx_size < size &&
|
||||
|
@ -659,7 +656,7 @@ static int lpc11u6x_uartx_fifo_read(const struct device *dev, uint8_t *data,
|
|||
|
||||
static void lpc11u6x_uartx_irq_tx_enable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
cfg->base->int_en_set = (cfg->base->int_en_set &
|
||||
LPC11U6X_UARTX_INT_EN_SET_MASK) |
|
||||
|
@ -668,14 +665,14 @@ static void lpc11u6x_uartx_irq_tx_enable(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uartx_irq_tx_disable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
cfg->base->int_en_clr = LPC11U6X_UARTX_INT_EN_CLR_TXRDYCLR;
|
||||
}
|
||||
|
||||
static int lpc11u6x_uartx_irq_tx_ready(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
return (cfg->base->stat & LPC11U6X_UARTX_STAT_TXRDY) &&
|
||||
(cfg->base->int_en_set & LPC11U6X_UARTX_INT_EN_SET_TXRDYEN);
|
||||
|
@ -683,14 +680,14 @@ static int lpc11u6x_uartx_irq_tx_ready(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uartx_irq_tx_complete(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
return (cfg->base->stat & LPC11U6X_UARTX_STAT_TXIDLE) != 0;
|
||||
}
|
||||
|
||||
static void lpc11u6x_uartx_irq_rx_enable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
cfg->base->int_en_set = (cfg->base->int_en_set &
|
||||
LPC11U6X_UARTX_INT_EN_SET_MASK) |
|
||||
|
@ -699,14 +696,14 @@ static void lpc11u6x_uartx_irq_rx_enable(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uartx_irq_rx_disable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
cfg->base->int_en_clr = LPC11U6X_UARTX_INT_EN_CLR_RXRDYCLR;
|
||||
}
|
||||
|
||||
static int lpc11u6x_uartx_irq_rx_ready(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
return (cfg->base->stat & LPC11U6X_UARTX_STAT_RXRDY) &&
|
||||
(cfg->base->int_en_set & LPC11U6X_UARTX_INT_EN_SET_RXRDYEN);
|
||||
|
@ -714,7 +711,7 @@ static int lpc11u6x_uartx_irq_rx_ready(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uartx_irq_err_enable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
cfg->base->int_en_set = (cfg->base->int_en_set &
|
||||
LPC11U6X_UARTX_INT_EN_SET_MASK) |
|
||||
|
@ -725,7 +722,7 @@ static void lpc11u6x_uartx_irq_err_enable(const struct device *dev)
|
|||
|
||||
static void lpc11u6x_uartx_irq_err_disable(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
cfg->base->int_en_clr = LPC11U6X_UARTX_INT_EN_CLR_OVERRUNCLR |
|
||||
LPC11U6X_UARTX_INT_EN_CLR_FRAMERRCLR |
|
||||
|
@ -734,7 +731,7 @@ static void lpc11u6x_uartx_irq_err_disable(const struct device *dev)
|
|||
|
||||
static int lpc11u6x_uartx_irq_is_pending(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
|
||||
if ((cfg->base->stat & LPC11U6X_UARTX_STAT_RXRDY) &&
|
||||
(cfg->base->int_stat & LPC11U6X_UARTX_INT_STAT_RXRDY)) {
|
||||
|
@ -761,7 +758,7 @@ static void lpc11u6x_uartx_irq_callback_set(const struct device *dev,
|
|||
uart_irq_callback_user_data_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
struct lpc11u6x_uartx_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uartx_data *data = dev->data;
|
||||
|
||||
data->cb = cb;
|
||||
data->cb_data = user_data;
|
||||
|
@ -769,7 +766,7 @@ static void lpc11u6x_uartx_irq_callback_set(const struct device *dev,
|
|||
|
||||
static void lpc11u6x_uartx_isr(const struct device *dev)
|
||||
{
|
||||
struct lpc11u6x_uartx_data *data = DEV_DATA(dev);
|
||||
struct lpc11u6x_uartx_data *data = dev->data;
|
||||
|
||||
if (data->cb) {
|
||||
data->cb(dev, data->cb_data);
|
||||
|
@ -792,8 +789,8 @@ static void lpc11u6x_uartx_shared_isr(const void *arg)
|
|||
|
||||
static int lpc11u6x_uartx_init(const struct device *dev)
|
||||
{
|
||||
const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev);
|
||||
struct lpc11u6x_uartx_data *data = DEV_DATA(dev);
|
||||
const struct lpc11u6x_uartx_config *cfg = dev->config;
|
||||
struct lpc11u6x_uartx_data *data = dev->data;
|
||||
const struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv;
|
||||
|
||||
/* Configure RX and TX pin via the pinmux driver */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue