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:
Gerard Marull-Paretas 2022-01-18 16:58:32 +01:00 committed by Carles Cufí
commit 1674fec5b6
26 changed files with 700 additions and 623 deletions

View file

@ -142,12 +142,9 @@ struct pl011_data {
PL011_IMSC_RXIM | PL011_IMSC_TXIM | \
PL011_IMSC_RTIM)
#define DEV_CFG(dev) \
((const struct uart_device_config * const)(dev)->config)
#define DEV_DATA(dev) \
((struct pl011_data *)(dev)->data)
#define PL011_REGS(dev) \
((volatile struct pl011_regs *)(DEV_CFG(dev))->base)
((volatile struct pl011_regs *) \
((const struct uart_device_config * const)(dev)->config)->base)
static void pl011_enable(const struct device *dev)
{
@ -201,7 +198,9 @@ static int pl011_set_baudrate(const struct device *dev,
static bool pl011_is_readable(const struct device *dev)
{
if (!DEV_DATA(dev)->sbsa &&
struct pl011_data *data = dev->data;
if (!data->sbsa &&
(!(PL011_REGS(dev)->cr & PL011_CR_UARTEN) ||
!(PL011_REGS(dev)->cr & PL011_CR_RXE)))
return false;
@ -277,7 +276,9 @@ static int pl011_irq_tx_complete(const struct device *dev)
static int pl011_irq_tx_ready(const struct device *dev)
{
if (!DEV_DATA(dev)->sbsa && !(PL011_REGS(dev)->cr & PL011_CR_TXE))
struct pl011_data *data = dev->data;
if (!data->sbsa && !(PL011_REGS(dev)->cr & PL011_CR_TXE))
return false;
return ((PL011_REGS(dev)->imsc & PL011_IMSC_TXIM) &&
@ -298,7 +299,9 @@ static void pl011_irq_rx_disable(const struct device *dev)
static int pl011_irq_rx_ready(const struct device *dev)
{
if (!DEV_DATA(dev)->sbsa && !(PL011_REGS(dev)->cr & PL011_CR_RXE))
struct pl011_data *data = dev->data;
if (!data->sbsa && !(PL011_REGS(dev)->cr & PL011_CR_RXE))
return false;
return ((PL011_REGS(dev)->imsc & PL011_IMSC_RXIM) &&
@ -330,8 +333,10 @@ static void pl011_irq_callback_set(const struct device *dev,
uart_irq_callback_user_data_t cb,
void *cb_data)
{
DEV_DATA(dev)->irq_cb = cb;
DEV_DATA(dev)->irq_cb_data = cb_data;
struct pl011_data *data = dev->data;
data->irq_cb = cb;
data->irq_cb_data = cb_data;
}
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
@ -358,6 +363,8 @@ static const struct uart_driver_api pl011_driver_api = {
static int pl011_init(const struct device *dev)
{
const struct uart_device_config *config = dev->config;
struct pl011_data *data = dev->data;
int ret;
uint32_t lcrh;
@ -366,14 +373,14 @@ static int pl011_init(const struct device *dev)
* or does not require configuration at all (if UART is emulated by
* virtualization software).
*/
if (!DEV_DATA(dev)->sbsa) {
if (!data->sbsa) {
/* disable the uart */
pl011_disable(dev);
pl011_disable_fifo(dev);
/* Set baud rate */
ret = pl011_set_baudrate(dev, DEV_CFG(dev)->sys_clk_freq,
DEV_DATA(dev)->baud_rate);
ret = pl011_set_baudrate(dev, config->sys_clk_freq,
data->baud_rate);
if (ret != 0) {
return ret;
}
@ -391,7 +398,7 @@ static int pl011_init(const struct device *dev)
PL011_REGS(dev)->imsc = 0U;
PL011_REGS(dev)->icr = PL011_IMSC_MASK_ALL;
if (!DEV_DATA(dev)->sbsa) {
if (!data->sbsa) {
PL011_REGS(dev)->dmacr = 0U;
__ISB();
PL011_REGS(dev)->cr &= ~(BIT(14) | BIT(15) | BIT(1));
@ -399,9 +406,9 @@ static int pl011_init(const struct device *dev)
__ISB();
}
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
DEV_CFG(dev)->irq_config_func(dev);
config->irq_config_func(dev);
#endif
if (!DEV_DATA(dev)->sbsa)
if (!data->sbsa)
pl011_enable(dev);
return 0;
@ -410,7 +417,7 @@ static int pl011_init(const struct device *dev)
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
void pl011_isr(const struct device *dev)
{
struct pl011_data *data = DEV_DATA(dev);
struct pl011_data *data = dev->data;
/* Verify if the callback has been registered */
if (data->irq_cb) {