device: Const-ify all device driver instance pointers

Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-04-30 20:33:38 +02:00 committed by Carles Cufí
commit e18fcbba5a
1426 changed files with 9356 additions and 8368 deletions

View file

@ -27,7 +27,7 @@ struct mcux_flexcomm_config {
uint32_t clock_source;
uint32_t baud_rate;
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
void (*irq_config_func)(struct device *dev);
void (*irq_config_func)(const struct device *dev);
#endif
};
@ -38,7 +38,7 @@ struct mcux_flexcomm_data {
#endif
};
static int mcux_flexcomm_poll_in(struct device *dev, unsigned char *c)
static int mcux_flexcomm_poll_in(const struct device *dev, unsigned char *c)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t flags = USART_GetStatusFlags(config->base);
@ -52,7 +52,7 @@ static int mcux_flexcomm_poll_in(struct device *dev, unsigned char *c)
return ret;
}
static void mcux_flexcomm_poll_out(struct device *dev,
static void mcux_flexcomm_poll_out(const struct device *dev,
unsigned char c)
{
const struct mcux_flexcomm_config *config = dev->config;
@ -64,7 +64,7 @@ static void mcux_flexcomm_poll_out(struct device *dev,
USART_WriteByte(config->base, c);
}
static int mcux_flexcomm_err_check(struct device *dev)
static int mcux_flexcomm_err_check(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t flags = USART_GetStatusFlags(config->base);
@ -91,8 +91,9 @@ static int mcux_flexcomm_err_check(struct device *dev)
}
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static int mcux_flexcomm_fifo_fill(struct device *dev, const uint8_t *tx_data,
int len)
static int mcux_flexcomm_fifo_fill(const struct device *dev,
const uint8_t *tx_data,
int len)
{
const struct mcux_flexcomm_config *config = dev->config;
uint8_t num_tx = 0U;
@ -107,8 +108,8 @@ static int mcux_flexcomm_fifo_fill(struct device *dev, const uint8_t *tx_data,
return num_tx;
}
static int mcux_flexcomm_fifo_read(struct device *dev, uint8_t *rx_data,
const int len)
static int mcux_flexcomm_fifo_read(const struct device *dev, uint8_t *rx_data,
const int len)
{
const struct mcux_flexcomm_config *config = dev->config;
uint8_t num_rx = 0U;
@ -123,7 +124,7 @@ static int mcux_flexcomm_fifo_read(struct device *dev, uint8_t *rx_data,
return num_rx;
}
static void mcux_flexcomm_irq_tx_enable(struct device *dev)
static void mcux_flexcomm_irq_tx_enable(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kUSART_TxLevelInterruptEnable;
@ -131,7 +132,7 @@ static void mcux_flexcomm_irq_tx_enable(struct device *dev)
USART_EnableInterrupts(config->base, mask);
}
static void mcux_flexcomm_irq_tx_disable(struct device *dev)
static void mcux_flexcomm_irq_tx_disable(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kUSART_TxLevelInterruptEnable;
@ -139,14 +140,14 @@ static void mcux_flexcomm_irq_tx_disable(struct device *dev)
USART_DisableInterrupts(config->base, mask);
}
static int mcux_flexcomm_irq_tx_complete(struct device *dev)
static int mcux_flexcomm_irq_tx_complete(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
return (config->base->STAT & USART_STAT_TXIDLE_MASK) != 0;
}
static int mcux_flexcomm_irq_tx_ready(struct device *dev)
static int mcux_flexcomm_irq_tx_ready(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kUSART_TxLevelInterruptEnable;
@ -156,7 +157,7 @@ static int mcux_flexcomm_irq_tx_ready(struct device *dev)
&& (flags & kUSART_TxFifoEmptyFlag);
}
static void mcux_flexcomm_irq_rx_enable(struct device *dev)
static void mcux_flexcomm_irq_rx_enable(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kUSART_RxLevelInterruptEnable;
@ -164,7 +165,7 @@ static void mcux_flexcomm_irq_rx_enable(struct device *dev)
USART_EnableInterrupts(config->base, mask);
}
static void mcux_flexcomm_irq_rx_disable(struct device *dev)
static void mcux_flexcomm_irq_rx_disable(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kUSART_RxLevelInterruptEnable;
@ -172,7 +173,7 @@ static void mcux_flexcomm_irq_rx_disable(struct device *dev)
USART_DisableInterrupts(config->base, mask);
}
static int mcux_flexcomm_irq_rx_full(struct device *dev)
static int mcux_flexcomm_irq_rx_full(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t flags = USART_GetStatusFlags(config->base);
@ -180,7 +181,7 @@ static int mcux_flexcomm_irq_rx_full(struct device *dev)
return (flags & kUSART_RxFifoNotEmptyFlag) != 0U;
}
static int mcux_flexcomm_irq_rx_ready(struct device *dev)
static int mcux_flexcomm_irq_rx_ready(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kUSART_RxLevelInterruptEnable;
@ -189,7 +190,7 @@ static int mcux_flexcomm_irq_rx_ready(struct device *dev)
&& mcux_flexcomm_irq_rx_full(dev);
}
static void mcux_flexcomm_irq_err_enable(struct device *dev)
static void mcux_flexcomm_irq_err_enable(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kStatus_USART_NoiseError |
@ -199,7 +200,7 @@ static void mcux_flexcomm_irq_err_enable(struct device *dev)
USART_EnableInterrupts(config->base, mask);
}
static void mcux_flexcomm_irq_err_disable(struct device *dev)
static void mcux_flexcomm_irq_err_disable(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
uint32_t mask = kStatus_USART_NoiseError |
@ -209,20 +210,20 @@ static void mcux_flexcomm_irq_err_disable(struct device *dev)
USART_DisableInterrupts(config->base, mask);
}
static int mcux_flexcomm_irq_is_pending(struct device *dev)
static int mcux_flexcomm_irq_is_pending(const struct device *dev)
{
return (mcux_flexcomm_irq_tx_ready(dev)
|| mcux_flexcomm_irq_rx_ready(dev));
}
static int mcux_flexcomm_irq_update(struct device *dev)
static int mcux_flexcomm_irq_update(const struct device *dev)
{
return 1;
}
static void mcux_flexcomm_irq_callback_set(struct device *dev,
uart_irq_callback_user_data_t cb,
void *cb_data)
static void mcux_flexcomm_irq_callback_set(const struct device *dev,
uart_irq_callback_user_data_t cb,
void *cb_data)
{
struct mcux_flexcomm_data *data = dev->data;
@ -232,7 +233,7 @@ static void mcux_flexcomm_irq_callback_set(struct device *dev,
static void mcux_flexcomm_isr(void *arg)
{
struct device *dev = arg;
const struct device *dev = arg;
struct mcux_flexcomm_data *data = dev->data;
if (data->callback) {
@ -242,7 +243,7 @@ static void mcux_flexcomm_isr(void *arg)
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
static int mcux_flexcomm_init(struct device *dev)
static int mcux_flexcomm_init(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
usart_config_t usart_config;
@ -289,7 +290,7 @@ static const struct uart_driver_api mcux_flexcomm_driver_api = {
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
#define UART_MCUX_FLEXCOMM_CONFIG_FUNC(n) \
static void mcux_flexcomm_config_func_##n(struct device *dev) \
static void mcux_flexcomm_config_func_##n(const struct device *dev) \
{ \
IRQ_CONNECT(DT_INST_IRQN(n), \
DT_INST_IRQ(n, priority), \