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
|
@ -14,7 +14,7 @@ struct dummy_display_data {
|
|||
|
||||
static struct dummy_display_data dummy_display_data;
|
||||
|
||||
static int dummy_display_init(struct device *dev)
|
||||
static int dummy_display_init(const struct device *dev)
|
||||
{
|
||||
struct dummy_display_data *disp_data =
|
||||
(struct dummy_display_data *)dev->data;
|
||||
|
|
|
@ -21,10 +21,10 @@ LOG_MODULE_REGISTER(display_ili9340);
|
|||
|
||||
struct ili9340_data {
|
||||
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
|
||||
struct device *reset_gpio;
|
||||
const struct device *reset_gpio;
|
||||
#endif
|
||||
struct device *command_data_gpio;
|
||||
struct device *spi_dev;
|
||||
const struct device *command_data_gpio;
|
||||
const struct device *spi_dev;
|
||||
struct spi_config spi_config;
|
||||
#if DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
|
||||
struct spi_cs_control cs_ctrl;
|
||||
|
@ -47,7 +47,7 @@ static void ili9340_exit_sleep(struct ili9340_data *data)
|
|||
k_sleep(K_MSEC(120));
|
||||
}
|
||||
|
||||
static int ili9340_init(struct device *dev)
|
||||
static int ili9340_init(const struct device *dev)
|
||||
{
|
||||
struct ili9340_data *data = (struct ili9340_data *)dev->data;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ K_MEM_POOL_DEFINE(mcux_elcdif_pool,
|
|||
|
||||
struct mcux_elcdif_config {
|
||||
LCDIF_Type *base;
|
||||
void (*irq_config_func)(struct device *dev);
|
||||
void (*irq_config_func)(const struct device *dev);
|
||||
elcdif_rgb_mode_config_t rgb_mode;
|
||||
enum display_pixel_format pixel_format;
|
||||
uint8_t bits_per_pixel;
|
||||
|
@ -166,7 +166,7 @@ static void mcux_elcdif_get_capabilities(const struct device *dev,
|
|||
|
||||
static void mcux_elcdif_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct mcux_elcdif_config *config = dev->config;
|
||||
struct mcux_elcdif_data *data = dev->data;
|
||||
uint32_t status;
|
||||
|
@ -177,7 +177,7 @@ static void mcux_elcdif_isr(void *arg)
|
|||
k_sem_give(&data->sem);
|
||||
}
|
||||
|
||||
static int mcux_elcdif_init(struct device *dev)
|
||||
static int mcux_elcdif_init(const struct device *dev)
|
||||
{
|
||||
const struct mcux_elcdif_config *config = dev->config;
|
||||
struct mcux_elcdif_data *data = dev->data;
|
||||
|
@ -225,7 +225,7 @@ static const struct display_driver_api mcux_elcdif_api = {
|
|||
.set_orientation = mcux_elcdif_set_orientation,
|
||||
};
|
||||
|
||||
static void mcux_elcdif_config_func_1(struct device *dev);
|
||||
static void mcux_elcdif_config_func_1(const struct device *dev);
|
||||
|
||||
static struct mcux_elcdif_config mcux_elcdif_config_1 = {
|
||||
.base = (LCDIF_Type *) DT_INST_REG_ADDR(0),
|
||||
|
@ -260,7 +260,7 @@ DEVICE_AND_API_INIT(mcux_elcdif_1, DT_INST_LABEL(0),
|
|||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&mcux_elcdif_api);
|
||||
|
||||
static void mcux_elcdif_config_func_1(struct device *dev)
|
||||
static void mcux_elcdif_config_func_1(const struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(DT_INST_IRQN(0),
|
||||
DT_INST_IRQ(0, priority),
|
||||
|
|
|
@ -26,7 +26,7 @@ struct sdl_display_data {
|
|||
|
||||
static struct sdl_display_data sdl_display_data;
|
||||
|
||||
static int sdl_display_init(struct device *dev)
|
||||
static int sdl_display_init(const struct device *dev)
|
||||
{
|
||||
struct sdl_display_data *disp_data =
|
||||
(struct sdl_display_data *)dev->data;
|
||||
|
|
|
@ -37,16 +37,16 @@ static uint8_t st7789v_ram_param[] = DT_INST_PROP(0, ram_param);
|
|||
static uint8_t st7789v_rgb_param[] = DT_INST_PROP(0, rgb_param);
|
||||
|
||||
struct st7789v_data {
|
||||
struct device *spi_dev;
|
||||
const struct device *spi_dev;
|
||||
struct spi_config spi_config;
|
||||
#if DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
|
||||
struct spi_cs_control cs_ctrl;
|
||||
#endif
|
||||
|
||||
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
|
||||
struct device *reset_gpio;
|
||||
const struct device *reset_gpio;
|
||||
#endif
|
||||
struct device *cmd_data_gpio;
|
||||
const struct device *cmd_data_gpio;
|
||||
|
||||
uint16_t height;
|
||||
uint16_t width;
|
||||
|
@ -334,7 +334,7 @@ static void st7789v_lcd_init(struct st7789v_data *p_st7789v)
|
|||
sizeof(st7789v_rgb_param));
|
||||
}
|
||||
|
||||
static int st7789v_init(struct device *dev)
|
||||
static int st7789v_init(const struct device *dev)
|
||||
{
|
||||
struct st7789v_data *data = (struct st7789v_data *)dev->data;
|
||||
|
||||
|
@ -408,7 +408,7 @@ static void st7789v_enter_sleep(struct st7789v_data *data)
|
|||
st7789v_transmit(data, ST7789V_CMD_SLEEP_IN, NULL, 0);
|
||||
}
|
||||
|
||||
static int st7789v_pm_control(struct device *dev, uint32_t ctrl_command,
|
||||
static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command,
|
||||
void *context, device_pm_cb cb, void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
|
@ -57,10 +57,10 @@ LOG_MODULE_REGISTER(gd7965, CONFIG_DISPLAY_LOG_LEVEL);
|
|||
|
||||
|
||||
struct gd7965_data {
|
||||
struct device *reset;
|
||||
struct device *dc;
|
||||
struct device *busy;
|
||||
struct device *spi_dev;
|
||||
const struct device *reset;
|
||||
const struct device *dc;
|
||||
const struct device *busy;
|
||||
const struct device *spi_dev;
|
||||
struct spi_config spi_config;
|
||||
#if defined(GD7965_CS_CNTRL)
|
||||
struct spi_cs_control cs_ctrl;
|
||||
|
@ -280,7 +280,7 @@ static int gd7965_set_pixel_format(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int gd7965_clear_and_write_buffer(struct device *dev,
|
||||
static int gd7965_clear_and_write_buffer(const struct device *dev,
|
||||
uint8_t pattern, bool update)
|
||||
{
|
||||
struct display_buffer_descriptor desc = {
|
||||
|
@ -312,7 +312,7 @@ static int gd7965_clear_and_write_buffer(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gd7965_controller_init(struct device *dev)
|
||||
static int gd7965_controller_init(const struct device *dev)
|
||||
{
|
||||
struct gd7965_data *driver = dev->data;
|
||||
uint8_t tmp[GD7965_TRES_REG_LENGTH];
|
||||
|
@ -390,7 +390,7 @@ static int gd7965_controller_init(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gd7965_init(struct device *dev)
|
||||
static int gd7965_init(const struct device *dev)
|
||||
{
|
||||
struct gd7965_data *driver = dev->data;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ struct command {
|
|||
};
|
||||
|
||||
struct glcd_data {
|
||||
struct device *i2c;
|
||||
const struct device *i2c;
|
||||
uint8_t input_set;
|
||||
uint8_t display_switch;
|
||||
uint8_t function;
|
||||
|
@ -85,7 +85,7 @@ static uint8_t color_define[][3] = {
|
|||
/********************************************
|
||||
* PRIVATE FUNCTIONS
|
||||
*******************************************/
|
||||
static void rgb_reg_set(struct device * const i2c, uint8_t addr, uint8_t dta)
|
||||
static void rgb_reg_set(const struct device *i2c, uint8_t addr, uint8_t dta)
|
||||
{
|
||||
uint8_t data[2] = { addr, dta };
|
||||
|
||||
|
@ -102,7 +102,7 @@ static inline void sleep(uint32_t sleep_in_ms)
|
|||
/********************************************
|
||||
* PUBLIC FUNCTIONS
|
||||
*******************************************/
|
||||
void glcd_print(struct device *port, char *data, uint32_t size)
|
||||
void glcd_print(const struct device *port, char *data, uint32_t size)
|
||||
{
|
||||
const struct glcd_driver * const rom = (const struct glcd_driver *)
|
||||
port->config;
|
||||
|
@ -117,7 +117,7 @@ void glcd_print(struct device *port, char *data, uint32_t size)
|
|||
}
|
||||
|
||||
|
||||
void glcd_cursor_pos_set(struct device *port, uint8_t col, uint8_t row)
|
||||
void glcd_cursor_pos_set(const struct device *port, uint8_t col, uint8_t row)
|
||||
{
|
||||
const struct glcd_driver * const rom = (const struct glcd_driver *)
|
||||
port->config;
|
||||
|
@ -138,7 +138,7 @@ void glcd_cursor_pos_set(struct device *port, uint8_t col, uint8_t row)
|
|||
}
|
||||
|
||||
|
||||
void glcd_clear(struct device *port)
|
||||
void glcd_clear(const struct device *port)
|
||||
{
|
||||
const struct glcd_driver * const rom = (const struct glcd_driver *)
|
||||
port->config;
|
||||
|
@ -151,7 +151,7 @@ void glcd_clear(struct device *port)
|
|||
}
|
||||
|
||||
|
||||
void glcd_display_state_set(struct device *port, uint8_t opt)
|
||||
void glcd_display_state_set(const struct device *port, uint8_t opt)
|
||||
{
|
||||
const struct glcd_driver * const rom = (const struct glcd_driver *)
|
||||
port->config;
|
||||
|
@ -168,7 +168,7 @@ void glcd_display_state_set(struct device *port, uint8_t opt)
|
|||
}
|
||||
|
||||
|
||||
uint8_t glcd_display_state_get(struct device *port)
|
||||
uint8_t glcd_display_state_get(const struct device *port)
|
||||
{
|
||||
struct glcd_data *dev = port->data;
|
||||
|
||||
|
@ -176,7 +176,7 @@ uint8_t glcd_display_state_get(struct device *port)
|
|||
}
|
||||
|
||||
|
||||
void glcd_input_state_set(struct device *port, uint8_t opt)
|
||||
void glcd_input_state_set(const struct device *port, uint8_t opt)
|
||||
{
|
||||
const struct glcd_driver * const rom = port->config;
|
||||
struct glcd_data *dev = port->data;
|
||||
|
@ -191,7 +191,7 @@ void glcd_input_state_set(struct device *port, uint8_t opt)
|
|||
}
|
||||
|
||||
|
||||
uint8_t glcd_input_state_get(struct device *port)
|
||||
uint8_t glcd_input_state_get(const struct device *port)
|
||||
{
|
||||
struct glcd_data *dev = port->data;
|
||||
|
||||
|
@ -199,7 +199,7 @@ uint8_t glcd_input_state_get(struct device *port)
|
|||
}
|
||||
|
||||
|
||||
void glcd_color_select(struct device *port, uint8_t color)
|
||||
void glcd_color_select(const struct device *port, uint8_t color)
|
||||
{
|
||||
if (color > 3) {
|
||||
LOG_WRN("selected color is too high a value");
|
||||
|
@ -211,7 +211,8 @@ void glcd_color_select(struct device *port, uint8_t color)
|
|||
}
|
||||
|
||||
|
||||
void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b)
|
||||
void glcd_color_set(const struct device *port, uint8_t r, uint8_t g,
|
||||
uint8_t b)
|
||||
{
|
||||
struct glcd_data * const dev = port->data;
|
||||
|
||||
|
@ -221,7 +222,7 @@ void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b)
|
|||
}
|
||||
|
||||
|
||||
void glcd_function_set(struct device *port, uint8_t opt)
|
||||
void glcd_function_set(const struct device *port, uint8_t opt)
|
||||
{
|
||||
const struct glcd_driver * const rom = port->config;
|
||||
struct glcd_data *dev = port->data;
|
||||
|
@ -237,7 +238,7 @@ void glcd_function_set(struct device *port, uint8_t opt)
|
|||
}
|
||||
|
||||
|
||||
uint8_t glcd_function_get(struct device *port)
|
||||
uint8_t glcd_function_get(const struct device *port)
|
||||
{
|
||||
struct glcd_data *dev = port->data;
|
||||
|
||||
|
@ -245,7 +246,7 @@ uint8_t glcd_function_get(struct device *port)
|
|||
}
|
||||
|
||||
|
||||
int glcd_initialize(struct device *port)
|
||||
int glcd_initialize(const struct device *port)
|
||||
{
|
||||
struct glcd_data *dev = port->data;
|
||||
uint8_t cmd;
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
#define SCROLL_DEFAULT_DURATION_MS 80
|
||||
|
||||
struct mb_display {
|
||||
struct device *dev; /* GPIO device */
|
||||
const struct device *dev; /* GPIO device */
|
||||
|
||||
struct k_timer timer; /* Rendering timer */
|
||||
|
||||
|
@ -426,7 +426,7 @@ struct mb_display *mb_display_get(void)
|
|||
return &display;
|
||||
}
|
||||
|
||||
static int mb_display_init(struct device *dev)
|
||||
static int mb_display_init(const struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ LOG_MODULE_REGISTER(ssd1306, CONFIG_DISPLAY_LOG_LEVEL);
|
|||
#endif
|
||||
|
||||
struct ssd1306_data {
|
||||
struct device *reset;
|
||||
struct device *i2c;
|
||||
const struct device *reset;
|
||||
const struct device *i2c;
|
||||
uint8_t contrast;
|
||||
uint8_t scan_mode;
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ static inline int ssd1306_reg_update(struct ssd1306_data *driver, uint8_t reg,
|
|||
reg, mask, val);
|
||||
}
|
||||
|
||||
static inline int ssd1306_set_panel_orientation(struct device *dev)
|
||||
static inline int ssd1306_set_panel_orientation(const struct device *dev)
|
||||
{
|
||||
struct ssd1306_data *driver = dev->data;
|
||||
uint8_t cmd_buf[] = {
|
||||
|
@ -95,7 +95,7 @@ static inline int ssd1306_set_panel_orientation(struct device *dev)
|
|||
DT_INST_REG_ADDR(0));
|
||||
}
|
||||
|
||||
static inline int ssd1306_set_timing_setting(struct device *dev)
|
||||
static inline int ssd1306_set_timing_setting(const struct device *dev)
|
||||
{
|
||||
struct ssd1306_data *driver = dev->data;
|
||||
uint8_t cmd_buf[] = {
|
||||
|
@ -117,7 +117,7 @@ static inline int ssd1306_set_timing_setting(struct device *dev)
|
|||
DT_INST_REG_ADDR(0));
|
||||
}
|
||||
|
||||
static inline int ssd1306_set_hardware_config(struct device *dev)
|
||||
static inline int ssd1306_set_hardware_config(const struct device *dev)
|
||||
{
|
||||
struct ssd1306_data *driver = dev->data;
|
||||
uint8_t cmd_buf[] = {
|
||||
|
@ -350,7 +350,7 @@ static int ssd1306_set_pixel_format(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int ssd1306_init_device(struct device *dev)
|
||||
static int ssd1306_init_device(const struct device *dev)
|
||||
{
|
||||
struct ssd1306_data *driver = dev->data;
|
||||
|
||||
|
@ -410,7 +410,7 @@ static int ssd1306_init_device(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ssd1306_init(struct device *dev)
|
||||
static int ssd1306_init(const struct device *dev)
|
||||
{
|
||||
struct ssd1306_data *driver = dev->data;
|
||||
|
||||
|
|
|
@ -59,10 +59,10 @@ LOG_MODULE_REGISTER(ssd16xx);
|
|||
#define SSD16XX_TR_SCALE_FACTOR 256U
|
||||
|
||||
struct ssd16xx_data {
|
||||
struct device *reset;
|
||||
struct device *dc;
|
||||
struct device *busy;
|
||||
struct device *spi_dev;
|
||||
const struct device *reset;
|
||||
const struct device *dc;
|
||||
const struct device *busy;
|
||||
const struct device *spi_dev;
|
||||
struct spi_config spi_config;
|
||||
#if defined(SSD16XX_CS_CNTRL)
|
||||
struct spi_cs_control cs_ctrl;
|
||||
|
@ -384,7 +384,7 @@ static int ssd16xx_set_pixel_format(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int ssd16xx_clear_cntlr_mem(struct device *dev, uint8_t ram_cmd,
|
||||
static int ssd16xx_clear_cntlr_mem(const struct device *dev, uint8_t ram_cmd,
|
||||
bool update)
|
||||
{
|
||||
struct ssd16xx_data *driver = dev->data;
|
||||
|
@ -433,7 +433,7 @@ static int ssd16xx_clear_cntlr_mem(struct device *dev, uint8_t ram_cmd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int ssd16xx_load_ws_from_otp(struct device *dev)
|
||||
static inline int ssd16xx_load_ws_from_otp(const struct device *dev)
|
||||
{
|
||||
struct ssd16xx_data *driver = dev->data;
|
||||
uint8_t tmp[2];
|
||||
|
@ -500,7 +500,7 @@ static inline int ssd16xx_load_ws_from_otp(struct device *dev)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int ssd16xx_load_ws_initial(struct device *dev)
|
||||
static int ssd16xx_load_ws_initial(const struct device *dev)
|
||||
{
|
||||
#if DT_INST_NODE_HAS_PROP(0, lut_initial)
|
||||
struct ssd16xx_data *driver = dev->data;
|
||||
|
@ -519,7 +519,7 @@ static int ssd16xx_load_ws_initial(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ssd16xx_load_ws_default(struct device *dev)
|
||||
static int ssd16xx_load_ws_default(const struct device *dev)
|
||||
{
|
||||
#if DT_INST_NODE_HAS_PROP(0, lut_default)
|
||||
struct ssd16xx_data *driver = dev->data;
|
||||
|
@ -536,7 +536,7 @@ static int ssd16xx_load_ws_default(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ssd16xx_controller_init(struct device *dev)
|
||||
static int ssd16xx_controller_init(const struct device *dev)
|
||||
{
|
||||
int err;
|
||||
uint8_t tmp[3];
|
||||
|
@ -641,7 +641,7 @@ static int ssd16xx_controller_init(struct device *dev)
|
|||
return ssd16xx_clear_cntlr_mem(dev, SSD16XX_CMD_WRITE_RAM, true);
|
||||
}
|
||||
|
||||
static int ssd16xx_init(struct device *dev)
|
||||
static int ssd16xx_init(const struct device *dev)
|
||||
{
|
||||
struct ssd16xx_data *driver = dev->data;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue