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 @@ SHELL_DEFINE(shell_uart, CONFIG_SHELL_PROMPT_UART, &shell_transport_uart,
SHELL_FLAG_OLF_CRLF);
#ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
static void uart_rx_handle(struct device *dev,
static void uart_rx_handle(const struct device *dev,
const struct shell_uart *sh_uart)
{
uint8_t *data;
@ -99,7 +99,8 @@ static void uart_rx_handle(struct device *dev,
}
}
static void uart_tx_handle(struct device *dev, const struct shell_uart *sh_uart)
static void uart_tx_handle(const struct device *dev,
const struct shell_uart *sh_uart)
{
uint32_t len;
int err;
@ -120,7 +121,7 @@ static void uart_tx_handle(struct device *dev, const struct shell_uart *sh_uart)
sh_uart->ctrl_blk->context);
}
static void uart_callback(struct device *dev, void *user_data)
static void uart_callback(const struct device *dev, void *user_data)
{
const struct shell_uart *sh_uart = (struct shell_uart *)user_data;
@ -139,7 +140,7 @@ static void uart_callback(struct device *dev, void *user_data)
static void uart_irq_init(const struct shell_uart *sh_uart)
{
#ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN
struct device *dev = sh_uart->ctrl_blk->dev;
const struct device *dev = sh_uart->ctrl_blk->dev;
uart_irq_callback_user_data_set(dev, uart_callback, (void *)sh_uart);
uart_irq_rx_enable(dev);
@ -168,7 +169,7 @@ static int init(const struct shell_transport *transport,
{
const struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
sh_uart->ctrl_blk->dev = (struct device *)config;
sh_uart->ctrl_blk->dev = (const struct device *)config;
sh_uart->ctrl_blk->handler = evt_handler;
sh_uart->ctrl_blk->context = context;
@ -188,7 +189,7 @@ static int uninit(const struct shell_transport *transport)
const struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx;
if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN)) {
struct device *dev = sh_uart->ctrl_blk->dev;
const struct device *dev = sh_uart->ctrl_blk->dev;
uart_irq_rx_disable(dev);
} else {
@ -278,10 +279,10 @@ const struct shell_transport_api shell_uart_transport_api = {
#endif /* CONFIG_MCUMGR_SMP_SHELL */
};
static int enable_shell_uart(struct device *arg)
static int enable_shell_uart(const struct device *arg)
{
ARG_UNUSED(arg);
struct device *dev =
const struct device *dev =
device_get_binding(CONFIG_UART_SHELL_ON_DEV_NAME);
bool log_backend = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > 0;
uint32_t level =