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:
parent
c8906fef79
commit
e18fcbba5a
1426 changed files with 9356 additions and 8368 deletions
|
@ -23,7 +23,7 @@ struct rv32m1_lpuart_config {
|
|||
uint32_t baud_rate;
|
||||
uint8_t hw_flow_control;
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
void (*irq_config_func)(struct device *dev);
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ struct rv32m1_lpuart_data {
|
|||
#endif
|
||||
};
|
||||
|
||||
static int rv32m1_lpuart_poll_in(struct device *dev, unsigned char *c)
|
||||
static int rv32m1_lpuart_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t flags = LPUART_GetStatusFlags(config->base);
|
||||
|
@ -48,7 +48,7 @@ static int rv32m1_lpuart_poll_in(struct device *dev, unsigned char *c)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_poll_out(struct device *dev, unsigned char c)
|
||||
static void rv32m1_lpuart_poll_out(const struct device *dev, unsigned char c)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
|
||||
|
@ -59,7 +59,7 @@ static void rv32m1_lpuart_poll_out(struct device *dev, unsigned char c)
|
|||
LPUART_WriteByte(config->base, c);
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_err_check(struct device *dev)
|
||||
static int rv32m1_lpuart_err_check(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t flags = LPUART_GetStatusFlags(config->base);
|
||||
|
@ -85,8 +85,9 @@ static int rv32m1_lpuart_err_check(struct device *dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static int rv32m1_lpuart_fifo_fill(struct device *dev, const uint8_t *tx_data,
|
||||
int len)
|
||||
static int rv32m1_lpuart_fifo_fill(const struct device *dev,
|
||||
const uint8_t *tx_data,
|
||||
int len)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint8_t num_tx = 0U;
|
||||
|
@ -101,8 +102,8 @@ static int rv32m1_lpuart_fifo_fill(struct device *dev, const uint8_t *tx_data,
|
|||
return num_tx;
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_fifo_read(struct device *dev, uint8_t *rx_data,
|
||||
const int len)
|
||||
static int rv32m1_lpuart_fifo_read(const struct device *dev, uint8_t *rx_data,
|
||||
const int len)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint8_t num_rx = 0U;
|
||||
|
@ -117,7 +118,7 @@ static int rv32m1_lpuart_fifo_read(struct device *dev, uint8_t *rx_data,
|
|||
return num_rx;
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_tx_enable(struct device *dev)
|
||||
static void rv32m1_lpuart_irq_tx_enable(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable;
|
||||
|
@ -125,7 +126,7 @@ static void rv32m1_lpuart_irq_tx_enable(struct device *dev)
|
|||
LPUART_EnableInterrupts(config->base, mask);
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_tx_disable(struct device *dev)
|
||||
static void rv32m1_lpuart_irq_tx_disable(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable;
|
||||
|
@ -133,7 +134,7 @@ static void rv32m1_lpuart_irq_tx_disable(struct device *dev)
|
|||
LPUART_DisableInterrupts(config->base, mask);
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_irq_tx_complete(struct device *dev)
|
||||
static int rv32m1_lpuart_irq_tx_complete(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t flags = LPUART_GetStatusFlags(config->base);
|
||||
|
@ -141,7 +142,7 @@ static int rv32m1_lpuart_irq_tx_complete(struct device *dev)
|
|||
return (flags & kLPUART_TxDataRegEmptyFlag) != 0U;
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_irq_tx_ready(struct device *dev)
|
||||
static int rv32m1_lpuart_irq_tx_ready(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable;
|
||||
|
@ -150,7 +151,7 @@ static int rv32m1_lpuart_irq_tx_ready(struct device *dev)
|
|||
&& rv32m1_lpuart_irq_tx_complete(dev);
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_rx_enable(struct device *dev)
|
||||
static void rv32m1_lpuart_irq_rx_enable(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_RxDataRegFullInterruptEnable;
|
||||
|
@ -158,7 +159,7 @@ static void rv32m1_lpuart_irq_rx_enable(struct device *dev)
|
|||
LPUART_EnableInterrupts(config->base, mask);
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_rx_disable(struct device *dev)
|
||||
static void rv32m1_lpuart_irq_rx_disable(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_RxDataRegFullInterruptEnable;
|
||||
|
@ -166,7 +167,7 @@ static void rv32m1_lpuart_irq_rx_disable(struct device *dev)
|
|||
LPUART_DisableInterrupts(config->base, mask);
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_irq_rx_full(struct device *dev)
|
||||
static int rv32m1_lpuart_irq_rx_full(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t flags = LPUART_GetStatusFlags(config->base);
|
||||
|
@ -174,7 +175,7 @@ static int rv32m1_lpuart_irq_rx_full(struct device *dev)
|
|||
return (flags & kLPUART_RxDataRegFullFlag) != 0U;
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_irq_rx_ready(struct device *dev)
|
||||
static int rv32m1_lpuart_irq_rx_ready(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_RxDataRegFullInterruptEnable;
|
||||
|
@ -183,7 +184,7 @@ static int rv32m1_lpuart_irq_rx_ready(struct device *dev)
|
|||
&& rv32m1_lpuart_irq_rx_full(dev);
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_err_enable(struct device *dev)
|
||||
static void rv32m1_lpuart_irq_err_enable(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_NoiseErrorInterruptEnable |
|
||||
|
@ -193,7 +194,7 @@ static void rv32m1_lpuart_irq_err_enable(struct device *dev)
|
|||
LPUART_EnableInterrupts(config->base, mask);
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_err_disable(struct device *dev)
|
||||
static void rv32m1_lpuart_irq_err_disable(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
uint32_t mask = kLPUART_NoiseErrorInterruptEnable |
|
||||
|
@ -203,20 +204,20 @@ static void rv32m1_lpuart_irq_err_disable(struct device *dev)
|
|||
LPUART_DisableInterrupts(config->base, mask);
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_irq_is_pending(struct device *dev)
|
||||
static int rv32m1_lpuart_irq_is_pending(const struct device *dev)
|
||||
{
|
||||
return (rv32m1_lpuart_irq_tx_ready(dev)
|
||||
|| rv32m1_lpuart_irq_rx_ready(dev));
|
||||
}
|
||||
|
||||
static int rv32m1_lpuart_irq_update(struct device *dev)
|
||||
static int rv32m1_lpuart_irq_update(const struct device *dev)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void rv32m1_lpuart_irq_callback_set(struct device *dev,
|
||||
uart_irq_callback_user_data_t cb,
|
||||
void *cb_data)
|
||||
static void rv32m1_lpuart_irq_callback_set(const struct device *dev,
|
||||
uart_irq_callback_user_data_t cb,
|
||||
void *cb_data)
|
||||
{
|
||||
struct rv32m1_lpuart_data *data = dev->data;
|
||||
|
||||
|
@ -226,7 +227,7 @@ static void rv32m1_lpuart_irq_callback_set(struct device *dev,
|
|||
|
||||
static void rv32m1_lpuart_isr(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
const struct device *dev = arg;
|
||||
struct rv32m1_lpuart_data *data = dev->data;
|
||||
|
||||
if (data->callback) {
|
||||
|
@ -235,11 +236,11 @@ static void rv32m1_lpuart_isr(void *arg)
|
|||
}
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
static int rv32m1_lpuart_init(struct device *dev)
|
||||
static int rv32m1_lpuart_init(const struct device *dev)
|
||||
{
|
||||
const struct rv32m1_lpuart_config *config = dev->config;
|
||||
lpuart_config_t uart_config;
|
||||
struct device *clock_dev;
|
||||
const struct device *clock_dev;
|
||||
uint32_t clock_freq;
|
||||
|
||||
/* set clock source */
|
||||
|
@ -311,7 +312,7 @@ static const struct uart_driver_api rv32m1_lpuart_driver_api = {
|
|||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
#define RV32M1_LPUART_CONFIG_FUNC(n) \
|
||||
static void rv32m1_lpuart_config_func_##n(struct device *dev) \
|
||||
static void rv32m1_lpuart_config_func_##n(const struct device *dev) \
|
||||
{ \
|
||||
IRQ_CONNECT(DT_INST_IRQN(n), 0, rv32m1_lpuart_isr, \
|
||||
DEVICE_GET(uart_0), 0); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue