Skip to content

Commit

Permalink
device: Const-ify all device driver instance pointers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tomasz Bursztyka authored and carlescufi committed Sep 2, 2020
1 parent c8906fe commit e18fcbb
Show file tree
Hide file tree
Showing 1,426 changed files with 9,356 additions and 8,368 deletions.
2 changes: 1 addition & 1 deletion arch/arc/core/arc_smp.c
Expand Up @@ -108,7 +108,7 @@ void arch_sched_ipi(void)
}
}

static int arc_smp_init(struct device *dev)
static int arc_smp_init(const struct device *dev)
{
ARG_UNUSED(dev);
struct arc_connect_bcr bcr;
Expand Down
2 changes: 1 addition & 1 deletion arch/arc/core/cache.c
Expand Up @@ -149,7 +149,7 @@ size_t arch_cache_line_size_get(void)
#endif
}

static int init_dcache(struct device *unused)
static int init_dcache(const struct device *unused)
{
ARG_UNUSED(unused);

Expand Down
2 changes: 1 addition & 1 deletion arch/arc/core/mpu/arc_mpu_v2_internal.h
Expand Up @@ -374,7 +374,7 @@ int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
* This function provides the default configuration mechanism for the Memory
* Protection Unit (MPU).
*/
static int arc_mpu_init(struct device *arg)
static int arc_mpu_init(const struct device *arg)
{
ARG_UNUSED(arg);

Expand Down
2 changes: 1 addition & 1 deletion arch/arc/core/mpu/arc_mpu_v3_internal.h
Expand Up @@ -824,7 +824,7 @@ int arc_core_mpu_buffer_validate(void *addr, size_t size, int write)
* This function provides the default configuration mechanism for the Memory
* Protection Unit (MPU).
*/
static int arc_mpu_init(struct device *arg)
static int arc_mpu_init(const struct device *arg)
{
ARG_UNUSED(arg);
uint32_t num_regions;
Expand Down
2 changes: 1 addition & 1 deletion arch/arc/core/secureshield/arc_sjli.c
Expand Up @@ -48,7 +48,7 @@ static void sjli_table_init(void)
/*
* @brief initializaiton of secureshield related functions.
*/
static int arc_secureshield_init(struct device *arg)
static int arc_secureshield_init(const struct device *arg)
{
sjli_table_init();

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/core/aarch32/cortex_m/mpu/arm_mpu.c
Expand Up @@ -300,7 +300,7 @@ void arm_core_mpu_configure_dynamic_mpu_regions(const struct k_mem_partition
* This function provides the default configuration mechanism for the Memory
* Protection Unit (MPU).
*/
static int arm_mpu_init(struct device *arg)
static int arm_mpu_init(const struct device *arg)
{
uint32_t r_index;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/core/aarch32/cortex_m/mpu/nxp_mpu.c
Expand Up @@ -598,7 +598,7 @@ void arm_core_mpu_configure_dynamic_mpu_regions(const struct k_mem_partition
* This function provides the default configuration mechanism for the Memory
* Protection Unit (MPU).
*/
static int nxp_mpu_init(struct device *arg)
static int nxp_mpu_init(const struct device *arg)
{
ARG_UNUSED(arg);

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/core/aarch64/arm_mmu.c
Expand Up @@ -426,7 +426,7 @@ static void enable_mmu_el1(unsigned int flags)
* This function provides the default configuration mechanism for the Memory
* Management Unit (MMU).
*/
static int arm_mmu_init(struct device *arg)
static int arm_mmu_init(const struct device *arg)
{
uint64_t val;
unsigned int idx, flags = 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/core/ia32/cache.c
Expand Up @@ -86,7 +86,7 @@ size_t arch_cache_line_size_get(void)
#endif
}

static int init_cache(struct device *unused)
static int init_cache(const struct device *unused)
{
ARG_UNUSED(unused);

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/core/multiboot.c
Expand Up @@ -109,7 +109,7 @@ static struct framebuf_dev_data multiboot_framebuf_data = {
.height = CONFIG_MULTIBOOT_FRAMEBUF_Y
};

static int multiboot_framebuf_init(struct device *dev)
static int multiboot_framebuf_init(const struct device *dev)
{
struct framebuf_dev_data *data = FRAMEBUF_DATA(dev);
struct multiboot_info *info = &multiboot_info;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/core/spec_ctrl.c
Expand Up @@ -37,7 +37,7 @@ static uint32_t cpuid_extended_features(void)
return edx;
}

static int spec_ctrl_init(struct device *dev)
static int spec_ctrl_init(const struct device *dev)
{
ARG_UNUSED(dev);

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/core/x86_mmu.c
Expand Up @@ -408,7 +408,7 @@ void z_x86_dump_page_tables(pentry_t *ptables)
#define DUMP_PAGE_TABLES 0

#if DUMP_PAGE_TABLES
static int dump_kernel_tables(struct device *unused)
static int dump_kernel_tables(const struct device *unused)
{
z_x86_dump_page_tables(&z_x86_kernel_ptables);

Expand Down
2 changes: 1 addition & 1 deletion boards/arc/em_starterkit/pmodmux.c
Expand Up @@ -124,7 +124,7 @@
#define PM6_LR_CSS_STAT ((1 << BIT2) << PM6_OFFSET)


static int pmod_mux_init(struct device *device)
static int pmod_mux_init(const struct device *device)
{
volatile uint32_t *mux_regs = (uint32_t *)(PMODMUX_BASE_ADDR);

Expand Down
4 changes: 2 additions & 2 deletions boards/arc/hsdk/pinmux.c
Expand Up @@ -8,11 +8,11 @@
#include <init.h>
#include <drivers/pinmux.h>

static int board_pinmux_init(struct device *device)
static int board_pinmux_init(const struct device *device)
{
ARG_UNUSED(device);

struct device *pinmux = device_get_binding(CONFIG_PINMUX_NAME);
const struct device *pinmux = device_get_binding(CONFIG_PINMUX_NAME);

if (pinmux == NULL) {
return -ENXIO;
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_aerocore2/pinmux.c
Expand Up @@ -98,7 +98,7 @@ static const struct pin_config pinconf[] = {
#endif /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_argonkey/pinmux.c
Expand Up @@ -56,7 +56,7 @@ static const struct pin_config pinconf[] = {
#endif
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_avenger96/pinmux.c
Expand Up @@ -24,7 +24,7 @@ static const struct pin_config pinconf[] = {
#endif
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_carbon/pinmux.c
Expand Up @@ -56,7 +56,7 @@ static const struct pin_config pinconf[] = {
#endif /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_meerkat96/pinmux.c
Expand Up @@ -7,7 +7,7 @@
#include <init.h>
#include "device_imx.h"

static int meerakt96_pinmux_init(struct device *dev)
static int meerakt96_pinmux_init(const struct device *dev)
{
ARG_UNUSED(dev);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_neonkey/pinmux.c
Expand Up @@ -40,7 +40,7 @@ static const struct pin_config pinconf[] = {
#endif
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/96b_stm32_sensor_mez/pinmux.c
Expand Up @@ -86,7 +86,7 @@ static const struct pin_config pinconf[] = {
#endif
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
4 changes: 2 additions & 2 deletions boards/arm/96b_wistrio/pinmux.c
Expand Up @@ -40,10 +40,10 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PB7, STM32_PUSHPULL_PULLUP},
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);
struct device *gpioa, *gpiob, *gpioh;
const struct device *gpioa, *gpiob, *gpioh;

stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));

Expand Down
4 changes: 2 additions & 2 deletions boards/arm/actinius_icarus/board.c
Expand Up @@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(board_control, CONFIG_BOARD_ICARUS_LOG_LEVEL);

static void select_sim(void)
{
struct device *port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0)));
const struct device *port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0)));

if (!port) {
LOG_ERR("Could not get GPIO Device Binding");
Expand All @@ -31,7 +31,7 @@ static void select_sim(void)
#endif
}

static int board_actinius_icarus_init(struct device *dev)
static int board_actinius_icarus_init(const struct device *dev)
{
ARG_UNUSED(dev);

Expand Down
6 changes: 3 additions & 3 deletions boards/arm/adafruit_feather_m0_basic_proto/pinmux.c
Expand Up @@ -8,11 +8,11 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
#if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_spi) && CONFIG_SPI_SAM0)
struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
#endif
ARG_UNUSED(dev);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/adafruit_feather_stm32f405/pinmux.c
Expand Up @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = {
#endif /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
6 changes: 3 additions & 3 deletions boards/arm/adafruit_itsybitsy_m4_express/pinmux.c
Expand Up @@ -8,11 +8,11 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa =
const struct device *muxa =
device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
struct device *muxb =
const struct device *muxb =
device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

ARG_UNUSED(dev);
Expand Down
4 changes: 2 additions & 2 deletions boards/arm/adafruit_trinket_m0/pinmux.c
Expand Up @@ -8,9 +8,9 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

ARG_UNUSED(dev);

Expand Down
6 changes: 3 additions & 3 deletions boards/arm/arduino_nano_33_iot/pinmux.c
Expand Up @@ -8,11 +8,11 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa =
const struct device *muxa =
device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
struct device *muxb =
const struct device *muxb =
device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

ARG_UNUSED(dev);
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/arduino_zero/pinmux.c
Expand Up @@ -8,10 +8,10 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

ARG_UNUSED(dev);

Expand Down
6 changes: 3 additions & 3 deletions boards/arm/atsamd20_xpro/pinmux.c
Expand Up @@ -8,10 +8,10 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

ARG_UNUSED(dev);

Expand Down
6 changes: 3 additions & 3 deletions boards/arm/atsamd21_xpro/pinmux.c
Expand Up @@ -8,10 +8,10 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

ARG_UNUSED(dev);

Expand Down
10 changes: 5 additions & 5 deletions boards/arm/atsame54_xpro/pinmux.c
Expand Up @@ -8,12 +8,12 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding("PINMUX_A");
struct device *muxb = device_get_binding("PINMUX_B");
struct device *muxc = device_get_binding("PINMUX_C");
struct device *muxd = device_get_binding("PINMUX_D");
const struct device *muxa = device_get_binding("PINMUX_A");
const struct device *muxb = device_get_binding("PINMUX_B");
const struct device *muxc = device_get_binding("PINMUX_C");
const struct device *muxd = device_get_binding("PINMUX_D");

ARG_UNUSED(dev);
ARG_UNUSED(muxa);
Expand Down
8 changes: 4 additions & 4 deletions boards/arm/atsamr21_xpro/pinmux.c
Expand Up @@ -9,11 +9,11 @@
#include <drivers/pinmux.h>
#include <soc.h>

static int board_pinmux_init(struct device *dev)
static int board_pinmux_init(const struct device *dev)
{
struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
struct device *muxc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_c)));
const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));
const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));
const struct device *muxc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_c)));

ARG_UNUSED(dev);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/b_l072z_lrwan1/pinmux.c
Expand Up @@ -48,7 +48,7 @@ static const struct pin_config pinconf[] = {
#endif /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/b_l4s5i_iot01a/pinmux.c
Expand Up @@ -53,7 +53,7 @@ static const struct pin_config pinconf[] = {
#endif /* CONFIG_USB_DC_STM32 */
};

static int pinmux_stm32_init(struct device *port)
static int pinmux_stm32_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down
2 changes: 1 addition & 1 deletion boards/arm/black_f407ve/pinmux.c
Expand Up @@ -49,7 +49,7 @@ static const struct pin_config pinconf[] = {
#endif
};

static int pinmux_black_f407ve_init(struct device *port)
static int pinmux_black_f407ve_init(const struct device *port)
{
ARG_UNUSED(port);

Expand Down

0 comments on commit e18fcbb

Please sign in to comment.