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
|
@ -147,27 +147,27 @@ struct pl011_data {
|
|||
#define PL011_REGS(dev) \
|
||||
((volatile struct pl011_regs *)(DEV_CFG(dev))->base)
|
||||
|
||||
static void pl011_enable(struct device *dev)
|
||||
static void pl011_enable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->cr |= PL011_CR_UARTEN;
|
||||
}
|
||||
|
||||
static void pl011_disable(struct device *dev)
|
||||
static void pl011_disable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->cr &= ~PL011_CR_UARTEN;
|
||||
}
|
||||
|
||||
static void pl011_enable_fifo(struct device *dev)
|
||||
static void pl011_enable_fifo(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->lcr_h |= PL011_LCRH_FEN;
|
||||
}
|
||||
|
||||
static void pl011_disable_fifo(struct device *dev)
|
||||
static void pl011_disable_fifo(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->lcr_h &= ~PL011_LCRH_FEN;
|
||||
}
|
||||
|
||||
static int pl011_set_baudrate(struct device *dev,
|
||||
static int pl011_set_baudrate(const struct device *dev,
|
||||
uint32_t clk, uint32_t baudrate)
|
||||
{
|
||||
/* Avoiding float calculations, bauddiv is left shifted by 6 */
|
||||
|
@ -197,7 +197,7 @@ static int pl011_set_baudrate(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool pl011_is_readable(struct device *dev)
|
||||
static bool pl011_is_readable(const struct device *dev)
|
||||
{
|
||||
if ((PL011_REGS(dev)->cr & PL011_CR_UARTEN) &&
|
||||
(PL011_REGS(dev)->cr & PL011_CR_RXE) &&
|
||||
|
@ -208,7 +208,7 @@ static bool pl011_is_readable(struct device *dev)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int pl011_poll_in(struct device *dev, unsigned char *c)
|
||||
static int pl011_poll_in(const struct device *dev, unsigned char *c)
|
||||
{
|
||||
if (!pl011_is_readable(dev)) {
|
||||
return -1;
|
||||
|
@ -220,7 +220,7 @@ static int pl011_poll_in(struct device *dev, unsigned char *c)
|
|||
return PL011_REGS(dev)->rsr & PL011_RSR_ERROR_MASK;
|
||||
}
|
||||
|
||||
static void pl011_poll_out(struct device *dev,
|
||||
static void pl011_poll_out(const struct device *dev,
|
||||
unsigned char c)
|
||||
{
|
||||
/* Wait for space in FIFO */
|
||||
|
@ -233,7 +233,7 @@ static void pl011_poll_out(struct device *dev,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static int pl011_fifo_fill(struct device *dev,
|
||||
static int pl011_fifo_fill(const struct device *dev,
|
||||
const uint8_t *tx_data, int len)
|
||||
{
|
||||
uint8_t num_tx = 0U;
|
||||
|
@ -245,7 +245,7 @@ static int pl011_fifo_fill(struct device *dev,
|
|||
return num_tx;
|
||||
}
|
||||
|
||||
static int pl011_fifo_read(struct device *dev,
|
||||
static int pl011_fifo_read(const struct device *dev,
|
||||
uint8_t *rx_data, const int len)
|
||||
{
|
||||
uint8_t num_rx = 0U;
|
||||
|
@ -258,70 +258,70 @@ static int pl011_fifo_read(struct device *dev,
|
|||
return num_rx;
|
||||
}
|
||||
|
||||
static void pl011_irq_tx_enable(struct device *dev)
|
||||
static void pl011_irq_tx_enable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->imsc |= PL011_IMSC_TXIM;
|
||||
}
|
||||
|
||||
static void pl011_irq_tx_disable(struct device *dev)
|
||||
static void pl011_irq_tx_disable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->imsc &= ~PL011_IMSC_TXIM;
|
||||
}
|
||||
|
||||
static int pl011_irq_tx_complete(struct device *dev)
|
||||
static int pl011_irq_tx_complete(const struct device *dev)
|
||||
{
|
||||
/* check for TX FIFO empty */
|
||||
return PL011_REGS(dev)->fr & PL011_FR_TXFE;
|
||||
}
|
||||
|
||||
static int pl011_irq_tx_ready(struct device *dev)
|
||||
static int pl011_irq_tx_ready(const struct device *dev)
|
||||
{
|
||||
return ((PL011_REGS(dev)->cr & PL011_CR_TXE) &&
|
||||
(PL011_REGS(dev)->imsc & PL011_IMSC_TXIM) &&
|
||||
pl011_irq_tx_complete(dev));
|
||||
}
|
||||
|
||||
static void pl011_irq_rx_enable(struct device *dev)
|
||||
static void pl011_irq_rx_enable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->imsc |= PL011_IMSC_RXIM |
|
||||
PL011_IMSC_RTIM;
|
||||
}
|
||||
|
||||
static void pl011_irq_rx_disable(struct device *dev)
|
||||
static void pl011_irq_rx_disable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->imsc &= ~(PL011_IMSC_RXIM |
|
||||
PL011_IMSC_RTIM);
|
||||
}
|
||||
|
||||
static int pl011_irq_rx_ready(struct device *dev)
|
||||
static int pl011_irq_rx_ready(const struct device *dev)
|
||||
{
|
||||
return ((PL011_REGS(dev)->cr & PL011_CR_RXE) &&
|
||||
(PL011_REGS(dev)->imsc & PL011_IMSC_RXIM) &&
|
||||
(!(PL011_REGS(dev)->fr & PL011_FR_RXFE)));
|
||||
}
|
||||
|
||||
static void pl011_irq_err_enable(struct device *dev)
|
||||
static void pl011_irq_err_enable(const struct device *dev)
|
||||
{
|
||||
/* enable framing, parity, break, and overrun */
|
||||
PL011_REGS(dev)->imsc |= PL011_IMSC_ERROR_MASK;
|
||||
}
|
||||
|
||||
static void pl011_irq_err_disable(struct device *dev)
|
||||
static void pl011_irq_err_disable(const struct device *dev)
|
||||
{
|
||||
PL011_REGS(dev)->imsc &= ~PL011_IMSC_ERROR_MASK;
|
||||
}
|
||||
|
||||
static int pl011_irq_is_pending(struct device *dev)
|
||||
static int pl011_irq_is_pending(const struct device *dev)
|
||||
{
|
||||
return pl011_irq_rx_ready(dev) || pl011_irq_tx_ready(dev);
|
||||
}
|
||||
|
||||
static int pl011_irq_update(struct device *dev)
|
||||
static int pl011_irq_update(const struct device *dev)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void pl011_irq_callback_set(struct device *dev,
|
||||
static void pl011_irq_callback_set(const struct device *dev,
|
||||
uart_irq_callback_user_data_t cb,
|
||||
void *cb_data)
|
||||
{
|
||||
|
@ -351,7 +351,7 @@ static const struct uart_driver_api pl011_driver_api = {
|
|||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
};
|
||||
|
||||
static int pl011_init(struct device *dev)
|
||||
static int pl011_init(const struct device *dev)
|
||||
{
|
||||
int ret;
|
||||
uint32_t lcrh;
|
||||
|
@ -397,7 +397,7 @@ static int pl011_init(struct device *dev)
|
|||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
void pl011_isr(void *arg)
|
||||
{
|
||||
struct device *dev = arg;
|
||||
const struct device *dev = arg;
|
||||
struct pl011_data *data = DEV_DATA(dev);
|
||||
|
||||
/* Verify if the callback has been registered */
|
||||
|
@ -411,7 +411,7 @@ void pl011_isr(void *arg)
|
|||
#ifdef CONFIG_UART_PL011_PORT0
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void pl011_irq_config_func_0(struct device *dev);
|
||||
static void pl011_irq_config_func_0(const struct device *dev);
|
||||
#endif
|
||||
|
||||
static struct uart_device_config pl011_cfg_port_0 = {
|
||||
|
@ -435,7 +435,7 @@ DEVICE_AND_API_INIT(pl011_port_0,
|
|||
&pl011_driver_api);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void pl011_irq_config_func_0(struct device *dev)
|
||||
static void pl011_irq_config_func_0(const struct device *dev)
|
||||
{
|
||||
#if DT_NUM_IRQS(DT_INST(0, arm_pl011)) == 1
|
||||
IRQ_CONNECT(DT_INST_IRQN(0),
|
||||
|
@ -474,7 +474,7 @@ static void pl011_irq_config_func_0(struct device *dev)
|
|||
#ifdef CONFIG_UART_PL011_PORT1
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void pl011_irq_config_func_1(struct device *dev);
|
||||
static void pl011_irq_config_func_1(const struct device *dev);
|
||||
#endif
|
||||
|
||||
static struct uart_device_config pl011_cfg_port_1 = {
|
||||
|
@ -498,7 +498,7 @@ DEVICE_AND_API_INIT(pl011_port_1,
|
|||
&pl011_driver_api);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void pl011_irq_config_func_1(struct device *dev)
|
||||
static void pl011_irq_config_func_1(const struct device *dev)
|
||||
{
|
||||
#if DT_NUM_IRQS(DT_INST(1, arm_pl011)) == 1
|
||||
IRQ_CONNECT(DT_INST_IRQN(1),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue