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

@ -30,7 +30,7 @@ struct leuart_gecko_config {
CMU_Clock_TypeDef clock;
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
struct soc_gpio_pin pin_rx;
struct soc_gpio_pin pin_tx;
@ -49,7 +49,7 @@ struct leuart_gecko_data {
#endif
};
static int leuart_gecko_poll_in(struct device *dev, unsigned char *c)
static int leuart_gecko_poll_in(const struct device *dev, unsigned char *c)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t flags = LEUART_StatusGet(base);
@ -62,7 +62,7 @@ static int leuart_gecko_poll_in(struct device *dev, unsigned char *c)
return -1;
}
static void leuart_gecko_poll_out(struct device *dev, unsigned char c)
static void leuart_gecko_poll_out(const struct device *dev, unsigned char c)
{
LEUART_TypeDef *base = DEV_BASE(dev);
@ -72,7 +72,7 @@ static void leuart_gecko_poll_out(struct device *dev, unsigned char c)
LEUART_Tx(base, c);
}
static int leuart_gecko_err_check(struct device *dev)
static int leuart_gecko_err_check(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t flags = LEUART_IntGet(base);
@ -98,8 +98,9 @@ static int leuart_gecko_err_check(struct device *dev)
}
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static int leuart_gecko_fifo_fill(struct device *dev, const uint8_t *tx_data,
int len)
static int leuart_gecko_fifo_fill(const struct device *dev,
const uint8_t *tx_data,
int len)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint8_t num_tx = 0U;
@ -113,8 +114,8 @@ static int leuart_gecko_fifo_fill(struct device *dev, const uint8_t *tx_data,
return num_tx;
}
static int leuart_gecko_fifo_read(struct device *dev, uint8_t *rx_data,
const int len)
static int leuart_gecko_fifo_read(const struct device *dev, uint8_t *rx_data,
const int len)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint8_t num_rx = 0U;
@ -128,7 +129,7 @@ static int leuart_gecko_fifo_read(struct device *dev, uint8_t *rx_data,
return num_rx;
}
static void leuart_gecko_irq_tx_enable(struct device *dev)
static void leuart_gecko_irq_tx_enable(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t mask = LEUART_IEN_TXBL | LEUART_IEN_TXC;
@ -136,7 +137,7 @@ static void leuart_gecko_irq_tx_enable(struct device *dev)
LEUART_IntEnable(base, mask);
}
static void leuart_gecko_irq_tx_disable(struct device *dev)
static void leuart_gecko_irq_tx_disable(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t mask = LEUART_IEN_TXBL | LEUART_IEN_TXC;
@ -144,7 +145,7 @@ static void leuart_gecko_irq_tx_disable(struct device *dev)
LEUART_IntDisable(base, mask);
}
static int leuart_gecko_irq_tx_complete(struct device *dev)
static int leuart_gecko_irq_tx_complete(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t flags = LEUART_IntGet(base);
@ -152,7 +153,7 @@ static int leuart_gecko_irq_tx_complete(struct device *dev)
return (flags & LEUART_IF_TXC) != 0U;
}
static int leuart_gecko_irq_tx_ready(struct device *dev)
static int leuart_gecko_irq_tx_ready(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t flags = LEUART_IntGet(base);
@ -160,7 +161,7 @@ static int leuart_gecko_irq_tx_ready(struct device *dev)
return (flags & LEUART_IF_TXBL) != 0U;
}
static void leuart_gecko_irq_rx_enable(struct device *dev)
static void leuart_gecko_irq_rx_enable(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t mask = LEUART_IEN_RXDATAV;
@ -168,7 +169,7 @@ static void leuart_gecko_irq_rx_enable(struct device *dev)
LEUART_IntEnable(base, mask);
}
static void leuart_gecko_irq_rx_disable(struct device *dev)
static void leuart_gecko_irq_rx_disable(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t mask = LEUART_IEN_RXDATAV;
@ -176,7 +177,7 @@ static void leuart_gecko_irq_rx_disable(struct device *dev)
LEUART_IntDisable(base, mask);
}
static int leuart_gecko_irq_rx_full(struct device *dev)
static int leuart_gecko_irq_rx_full(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t flags = LEUART_IntGet(base);
@ -184,7 +185,7 @@ static int leuart_gecko_irq_rx_full(struct device *dev)
return (flags & LEUART_IF_RXDATAV) != 0U;
}
static int leuart_gecko_irq_rx_ready(struct device *dev)
static int leuart_gecko_irq_rx_ready(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
uint32_t mask = LEUART_IEN_RXDATAV;
@ -193,7 +194,7 @@ static int leuart_gecko_irq_rx_ready(struct device *dev)
&& leuart_gecko_irq_rx_full(dev);
}
static void leuart_gecko_irq_err_enable(struct device *dev)
static void leuart_gecko_irq_err_enable(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
@ -202,7 +203,7 @@ static void leuart_gecko_irq_err_enable(struct device *dev)
LEUART_IF_FERR);
}
static void leuart_gecko_irq_err_disable(struct device *dev)
static void leuart_gecko_irq_err_disable(const struct device *dev)
{
LEUART_TypeDef *base = DEV_BASE(dev);
@ -211,17 +212,17 @@ static void leuart_gecko_irq_err_disable(struct device *dev)
LEUART_IF_FERR);
}
static int leuart_gecko_irq_is_pending(struct device *dev)
static int leuart_gecko_irq_is_pending(const struct device *dev)
{
return leuart_gecko_irq_tx_ready(dev) || leuart_gecko_irq_rx_ready(dev);
}
static int leuart_gecko_irq_update(struct device *dev)
static int leuart_gecko_irq_update(const struct device *dev)
{
return 1;
}
static void leuart_gecko_irq_callback_set(struct device *dev,
static void leuart_gecko_irq_callback_set(const struct device *dev,
uart_irq_callback_user_data_t cb,
void *cb_data)
{
@ -233,7 +234,7 @@ static void leuart_gecko_irq_callback_set(struct device *dev,
static void leuart_gecko_isr(void *arg)
{
struct device *dev = arg;
const struct device *dev = arg;
struct leuart_gecko_data *data = dev->data;
if (data->callback) {
@ -242,7 +243,7 @@ static void leuart_gecko_isr(void *arg)
}
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
static void leuart_gecko_init_pins(struct device *dev)
static void leuart_gecko_init_pins(const struct device *dev)
{
const struct leuart_gecko_config *config = DEV_CFG(dev);
LEUART_TypeDef *base = DEV_BASE(dev);
@ -261,7 +262,7 @@ static void leuart_gecko_init_pins(struct device *dev)
#endif
}
static int leuart_gecko_init(struct device *dev)
static int leuart_gecko_init(const struct device *dev)
{
const struct leuart_gecko_config *config = DEV_CFG(dev);
LEUART_TypeDef *base = DEV_BASE(dev);
@ -325,7 +326,7 @@ static const struct uart_driver_api leuart_gecko_driver_api = {
DT_INST_PROP_BY_IDX(0, location_tx, 2), gpioModePushPull, 1}
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void leuart_gecko_config_func_0(struct device *dev);
static void leuart_gecko_config_func_0(const struct device *dev);
#endif
static const struct leuart_gecko_config leuart_gecko_0_config = {
@ -358,7 +359,7 @@ DEVICE_AND_API_INIT(leuart_0, DT_INST_LABEL(0),
&leuart_gecko_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void leuart_gecko_config_func_0(struct device *dev)
static void leuart_gecko_config_func_0(const struct device *dev)
{
IRQ_CONNECT(DT_INST_IRQN(0),
DT_INST_IRQ(0, priority),
@ -378,7 +379,7 @@ static void leuart_gecko_config_func_0(struct device *dev)
DT_INST_PROP_BY_IDX(1, location_tx, 2), gpioModePushPull, 1}
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void leuart_gecko_config_func_1(struct device *dev);
static void leuart_gecko_config_func_1(const struct device *dev);
#endif
static const struct leuart_gecko_config leuart_gecko_1_config = {
@ -411,7 +412,7 @@ DEVICE_AND_API_INIT(leuart_1, DT_INST_LABEL(1),
&leuart_gecko_driver_api);
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
static void leuart_gecko_config_func_1(struct device *dev)
static void leuart_gecko_config_func_1(const struct device *dev)
{
IRQ_CONNECT(DT_INST_IRQN(1),
DT_INST_IRQ(1, priority),