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

@ -61,7 +61,8 @@ static int opt3001_reg_update(struct opt3001_data *drv_data, uint8_t reg,
return opt3001_reg_write(drv_data, reg, new_val);
}
static int opt3001_sample_fetch(struct device *dev, enum sensor_channel chan)
static int opt3001_sample_fetch(const struct device *dev,
enum sensor_channel chan)
{
struct opt3001_data *drv_data = dev->data;
uint16_t value;
@ -79,7 +80,8 @@ static int opt3001_sample_fetch(struct device *dev, enum sensor_channel chan)
return 0;
}
static int opt3001_channel_get(struct device *dev, enum sensor_channel chan,
static int opt3001_channel_get(const struct device *dev,
enum sensor_channel chan,
struct sensor_value *val)
{
struct opt3001_data *drv_data = dev->data;
@ -110,7 +112,7 @@ static const struct sensor_driver_api opt3001_driver_api = {
.channel_get = opt3001_channel_get,
};
static int opt3001_chip_init(struct device *dev)
static int opt3001_chip_init(const struct device *dev)
{
struct opt3001_data *drv_data = dev->data;
uint16_t value;
@ -152,7 +154,7 @@ static int opt3001_chip_init(struct device *dev)
return 0;
}
int opt3001_init(struct device *dev)
int opt3001_init(const struct device *dev)
{
if (opt3001_chip_init(dev) < 0) {
return -EINVAL;

View file

@ -24,7 +24,7 @@
#define OPT3001_MANTISSA_MASK 0xfff
struct opt3001_data {
struct device *i2c;
const struct device *i2c;
uint16_t sample;
};