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

@ -76,13 +76,13 @@ struct ht16k33_cfg {
};
struct ht16k33_data {
struct device *i2c;
const struct device *i2c;
struct led_data dev_data;
/* Shadow buffer for the display data RAM */
uint8_t buffer[HT16K33_DISP_DATA_SIZE];
#ifdef CONFIG_HT16K33_KEYSCAN
struct k_mutex lock;
struct device *children[HT16K33_KEYSCAN_ROWS];
const struct device *children[HT16K33_KEYSCAN_ROWS];
struct gpio_callback irq_cb;
struct k_thread irq_thread;
struct k_sem irq_sem;
@ -94,7 +94,7 @@ struct ht16k33_data {
#endif /* CONFIG_HT16K33_KEYSCAN */
};
static int ht16k33_led_blink(struct device *dev, uint32_t led,
static int ht16k33_led_blink(const struct device *dev, uint32_t led,
uint32_t delay_on, uint32_t delay_off)
{
/* The HT16K33 blinks all LEDs at the same frequency */
@ -130,7 +130,7 @@ static int ht16k33_led_blink(struct device *dev, uint32_t led,
return 0;
}
static int ht16k33_led_set_brightness(struct device *dev, uint32_t led,
static int ht16k33_led_set_brightness(const struct device *dev, uint32_t led,
uint8_t value)
{
ARG_UNUSED(led);
@ -157,7 +157,8 @@ static int ht16k33_led_set_brightness(struct device *dev, uint32_t led,
return 0;
}
static int ht16k33_led_set_state(struct device *dev, uint32_t led, bool on)
static int ht16k33_led_set_state(const struct device *dev, uint32_t led,
bool on)
{
const struct ht16k33_cfg *config = dev->config;
struct ht16k33_data *data = dev->data;
@ -193,18 +194,18 @@ static int ht16k33_led_set_state(struct device *dev, uint32_t led, bool on)
return 0;
}
static int ht16k33_led_on(struct device *dev, uint32_t led)
static int ht16k33_led_on(const struct device *dev, uint32_t led)
{
return ht16k33_led_set_state(dev, led, true);
}
static int ht16k33_led_off(struct device *dev, uint32_t led)
static int ht16k33_led_off(const struct device *dev, uint32_t led)
{
return ht16k33_led_set_state(dev, led, false);
}
#ifdef CONFIG_HT16K33_KEYSCAN
uint32_t ht16k33_get_pending_int(struct device *dev)
uint32_t ht16k33_get_pending_int(const struct device *dev)
{
const struct ht16k33_cfg *config = dev->config;
struct ht16k33_data *data = dev->data;
@ -223,7 +224,7 @@ uint32_t ht16k33_get_pending_int(struct device *dev)
return (flag ? 1 : 0);
}
static bool ht16k33_process_keyscan_data(struct device *dev)
static bool ht16k33_process_keyscan_data(const struct device *dev)
{
const struct ht16k33_cfg *config = dev->config;
struct ht16k33_data *data = dev->data;
@ -261,7 +262,7 @@ static bool ht16k33_process_keyscan_data(struct device *dev)
return pressed;
}
static void ht16k33_irq_thread(struct device *dev)
static void ht16k33_irq_thread(const struct device *dev)
{
struct ht16k33_data *data = dev->data;
bool pressed;
@ -277,7 +278,7 @@ static void ht16k33_irq_thread(struct device *dev)
}
}
static void ht16k33_irq_callback(struct device *gpiob,
static void ht16k33_irq_callback(const struct device *gpiob,
struct gpio_callback *cb, uint32_t pins)
{
struct ht16k33_data *data;
@ -297,8 +298,8 @@ static void ht16k33_timer_callback(struct k_timer *timer)
k_sem_give(&data->irq_sem);
}
int ht16k33_register_keyscan_device(struct device *parent,
struct device *child,
int ht16k33_register_keyscan_device(const struct device *parent,
const struct device *child,
uint8_t keyscan_idx)
{
struct ht16k33_data *data = parent->data;
@ -319,7 +320,7 @@ int ht16k33_register_keyscan_device(struct device *parent,
}
#endif /* CONFIG_HT16K33_KEYSCAN */
static int ht16k33_init(struct device *dev)
static int ht16k33_init(const struct device *dev)
{
const struct ht16k33_cfg *config = dev->config;
struct ht16k33_data *data = dev->data;
@ -382,7 +383,7 @@ static int ht16k33_init(struct device *dev)
/* Configure interrupt */
if (config->irq_enabled) {
struct device *irq_dev;
const struct device *irq_dev;
uint8_t keys[HT16K33_KEYSCAN_DATA_SIZE];
irq_dev = device_get_binding(config->irq_dev_name);