zephyr: Const-ify struct device instance pointers.

Zephyr v2.4.0 added a const qualifier to usages of struct device to
allow storing device driver instances exclusively in flash and thereby
reduce ram footprint.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
pull/6470/merge
Maureen Helm 2020-09-12 14:50:21 -05:00 zatwierdzone przez Damien George
rodzic ce49be43b1
commit f842e32155
5 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -42,7 +42,7 @@ STATIC const mp_obj_type_t machine_hard_i2c_type;
typedef struct _machine_hard_i2c_obj_t {
mp_obj_base_t base;
struct device *dev;
const struct device *dev;
bool restart;
} machine_hard_i2c_obj_t;
@ -65,7 +65,7 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const char *dev_name = mp_obj_str_get_str(args[ARG_id].u_obj);
struct device *dev = device_get_binding(dev_name);
const struct device *dev = device_get_binding(dev_name);
if (dev == NULL) {
mp_raise_ValueError(MP_ERROR_TEXT("device not found"));

Wyświetl plik

@ -58,7 +58,7 @@ void machine_pin_deinit(void) {
MP_STATE_PORT(machine_pin_irq_list) = NULL;
}
STATIC void gpio_callback_handler(struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins) {
STATIC void gpio_callback_handler(const struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins) {
machine_pin_irq_obj_t *irq = CONTAINER_OF(cb, machine_pin_irq_obj_t, callback);
#if MICROPY_STACK_CHECK
@ -132,7 +132,7 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
mp_obj_get_array_fixed_n(args[0], 2, &items);
const char *drv_name = mp_obj_str_get_str(items[0]);
int wanted_pin = mp_obj_get_int(items[1]);
struct device *wanted_port = device_get_binding(drv_name);
const struct device *wanted_port = device_get_binding(drv_name);
if (!wanted_port) {
mp_raise_ValueError(MP_ERROR_TEXT("invalid port"));
}

Wyświetl plik

@ -9,7 +9,7 @@ MP_DECLARE_CONST_FUN_OBJ_0(machine_info_obj);
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
struct device *port;
const struct device *port;
uint32_t pin;
struct _machine_pin_irq_obj_t *irq;
} machine_pin_obj_t;

Wyświetl plik

@ -35,7 +35,7 @@
typedef struct _mp_obj_sensor_t {
mp_obj_base_t base;
struct device *dev;
const struct device *dev;
} mp_obj_sensor_t;
STATIC mp_obj_t sensor_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {

Wyświetl plik

@ -53,7 +53,7 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
}
}
#else
static struct device *uart_console_dev;
static const struct device *uart_console_dev;
if (uart_console_dev == NULL) {
uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
}