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
|
@ -57,9 +57,9 @@ static struct gsm_modem {
|
|||
size_t ppp_recv_buf_len;
|
||||
|
||||
enum setup_state state;
|
||||
struct device *ppp_dev;
|
||||
struct device *at_dev;
|
||||
struct device *control_dev;
|
||||
const struct device *ppp_dev;
|
||||
const struct device *at_dev;
|
||||
const struct device *control_dev;
|
||||
|
||||
bool mux_enabled : 1;
|
||||
bool mux_setup_done : 1;
|
||||
|
@ -293,7 +293,7 @@ static int gsm_setup_mccmno(struct gsm_modem *gsm)
|
|||
|
||||
static void set_ppp_carrier_on(struct gsm_modem *gsm)
|
||||
{
|
||||
struct device *ppp_dev = device_get_binding(CONFIG_NET_PPP_DRV_NAME);
|
||||
const struct device *ppp_dev = device_get_binding(CONFIG_NET_PPP_DRV_NAME);
|
||||
const struct ppp_api *api;
|
||||
|
||||
if (!ppp_dev) {
|
||||
|
@ -442,7 +442,7 @@ static void mux_setup_next(struct gsm_modem *gsm)
|
|||
(void)k_delayed_work_submit(&gsm->gsm_configure_work, K_MSEC(1));
|
||||
}
|
||||
|
||||
static void mux_attach_cb(struct device *mux, int dlci_address,
|
||||
static void mux_attach_cb(const struct device *mux, int dlci_address,
|
||||
bool connected, void *user_data)
|
||||
{
|
||||
LOG_DBG("DLCI %d to %s %s", dlci_address, mux->name,
|
||||
|
@ -456,7 +456,7 @@ static void mux_attach_cb(struct device *mux, int dlci_address,
|
|||
mux_setup_next(user_data);
|
||||
}
|
||||
|
||||
static int mux_attach(struct device *mux, struct device *uart,
|
||||
static int mux_attach(const struct device *mux, const struct device *uart,
|
||||
int dlci_address, void *user_data)
|
||||
{
|
||||
int ret = uart_mux_attach(mux, uart, dlci_address, mux_attach_cb,
|
||||
|
@ -474,7 +474,7 @@ static void mux_setup(struct k_work *work)
|
|||
{
|
||||
struct gsm_modem *gsm = CONTAINER_OF(work, struct gsm_modem,
|
||||
gsm_configure_work);
|
||||
struct device *uart = device_get_binding(CONFIG_MODEM_GSM_UART_NAME);
|
||||
const struct device *uart = device_get_binding(CONFIG_MODEM_GSM_UART_NAME);
|
||||
int ret;
|
||||
|
||||
switch (gsm->state) {
|
||||
|
@ -609,7 +609,7 @@ static void gsm_configure(struct k_work *work)
|
|||
gsm_finalize_connection(gsm);
|
||||
}
|
||||
|
||||
static int gsm_init(struct device *device)
|
||||
static int gsm_init(const struct device *device)
|
||||
{
|
||||
struct gsm_modem *gsm = device->data;
|
||||
int r;
|
||||
|
|
|
@ -444,7 +444,7 @@ struct hl7800_iface_ctx {
|
|||
bool search_no_id_resp;
|
||||
|
||||
/* GPIO PORT devices */
|
||||
struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS];
|
||||
const struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS];
|
||||
struct gpio_callback mdm_vgpio_cb;
|
||||
struct gpio_callback mdm_uart_dsr_cb;
|
||||
struct gpio_callback mdm_gpio6_cb;
|
||||
|
@ -3528,7 +3528,8 @@ static void mdm_vgpio_work_cb(struct k_work *item)
|
|||
hl7800_unlock();
|
||||
}
|
||||
|
||||
void mdm_vgpio_callback_isr(struct device *port, struct gpio_callback *cb,
|
||||
void mdm_vgpio_callback_isr(const struct device *port,
|
||||
struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
{
|
||||
ictx.vgpio_state = (uint32_t)gpio_pin_get(ictx.gpio_port_dev[MDM_VGPIO],
|
||||
|
@ -3556,7 +3557,8 @@ void mdm_vgpio_callback_isr(struct device *port, struct gpio_callback *cb,
|
|||
k_work_submit_to_queue(&hl7800_workq, &ictx.mdm_vgpio_work);
|
||||
}
|
||||
|
||||
void mdm_uart_dsr_callback_isr(struct device *port, struct gpio_callback *cb,
|
||||
void mdm_uart_dsr_callback_isr(const struct device *port,
|
||||
struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
{
|
||||
ictx.dsr_state = (uint32_t)gpio_pin_get(
|
||||
|
@ -3581,7 +3583,8 @@ static void mark_sockets_for_reconfig(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void mdm_gpio6_callback_isr(struct device *port, struct gpio_callback *cb,
|
||||
void mdm_gpio6_callback_isr(const struct device *port,
|
||||
struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
{
|
||||
#ifdef CONFIG_MODEM_HL7800_LOW_POWER_MODE
|
||||
|
@ -3607,7 +3610,8 @@ void mdm_gpio6_callback_isr(struct device *port, struct gpio_callback *cb,
|
|||
#endif
|
||||
}
|
||||
|
||||
void mdm_uart_cts_callback(struct device *port, struct gpio_callback *cb,
|
||||
void mdm_uart_cts_callback(const struct device *port,
|
||||
struct gpio_callback *cb,
|
||||
uint32_t pins)
|
||||
{
|
||||
ictx.cts_state = (uint32_t)gpio_pin_get(
|
||||
|
@ -4625,7 +4629,7 @@ static struct net_offload offload_funcs = {
|
|||
.put = offload_put,
|
||||
};
|
||||
|
||||
static inline uint8_t *hl7800_get_mac(struct device *dev)
|
||||
static inline uint8_t *hl7800_get_mac(const struct device *dev)
|
||||
{
|
||||
struct hl7800_iface_ctx *ctx = dev->driver_data;
|
||||
|
||||
|
@ -4696,7 +4700,7 @@ done:
|
|||
}
|
||||
#endif
|
||||
|
||||
static int hl7800_init(struct device *dev)
|
||||
static int hl7800_init(const struct device *dev)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
|
@ -4883,7 +4887,7 @@ static int hl7800_init(struct device *dev)
|
|||
|
||||
static void offload_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct device *dev = net_if_get_device(iface);
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
struct hl7800_iface_ctx *ctx = dev->driver_data;
|
||||
|
||||
iface->if_dev->offload = &offload_funcs;
|
||||
|
|
|
@ -63,7 +63,7 @@ int modem_context_get_addr_port(const struct sockaddr *addr, uint16_t *port)
|
|||
*
|
||||
* @retval Modem context or NULL.
|
||||
*/
|
||||
struct modem_context *modem_context_from_iface_dev(struct device *dev)
|
||||
struct modem_context *modem_context_from_iface_dev(const struct device *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
}
|
||||
|
||||
struct modem_iface {
|
||||
struct device *dev;
|
||||
const struct device *dev;
|
||||
|
||||
int (*read)(struct modem_iface *iface, uint8_t *buf, size_t size,
|
||||
size_t *bytes_read);
|
||||
|
@ -50,7 +50,7 @@ struct modem_cmd_handler {
|
|||
};
|
||||
|
||||
struct modem_pin {
|
||||
struct device *gpio_port_dev;
|
||||
const struct device *gpio_port_dev;
|
||||
char *dev_name;
|
||||
gpio_pin_t pin;
|
||||
gpio_flags_t init_flags;
|
||||
|
@ -117,7 +117,7 @@ struct modem_context *modem_context_from_id(int id);
|
|||
*
|
||||
* @retval Modem context or NULL.
|
||||
*/
|
||||
struct modem_context *modem_context_from_iface_dev(struct device *dev);
|
||||
struct modem_context *modem_context_from_iface_dev(const struct device *dev);
|
||||
|
||||
/**
|
||||
* @brief Registers modem context.
|
||||
|
|
|
@ -47,7 +47,8 @@ static void modem_iface_uart_flush(struct modem_iface *iface)
|
|||
*
|
||||
* @retval None.
|
||||
*/
|
||||
static void modem_iface_uart_isr(struct device *uart_dev, void *user_data)
|
||||
static void modem_iface_uart_isr(const struct device *uart_dev,
|
||||
void *user_data)
|
||||
{
|
||||
struct modem_context *ctx;
|
||||
struct modem_iface_uart_data *data;
|
||||
|
|
|
@ -33,7 +33,7 @@ static struct mdm_receiver_context *contexts[MAX_MDM_CTX];
|
|||
*
|
||||
* @retval Receiver context or NULL.
|
||||
*/
|
||||
static struct mdm_receiver_context *context_from_dev(struct device *dev)
|
||||
static struct mdm_receiver_context *context_from_dev(const struct device *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -101,7 +101,7 @@ static void mdm_receiver_flush(struct mdm_receiver_context *ctx)
|
|||
*
|
||||
* @retval None.
|
||||
*/
|
||||
static void mdm_receiver_isr(struct device *uart_dev, void *user_data)
|
||||
static void mdm_receiver_isr(const struct device *uart_dev, void *user_data)
|
||||
{
|
||||
struct mdm_receiver_context *ctx;
|
||||
int rx, ret;
|
||||
|
|
|
@ -22,7 +22,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
struct mdm_receiver_context {
|
||||
struct device *uart_dev;
|
||||
const struct device *uart_dev;
|
||||
|
||||
/* rx data */
|
||||
struct ring_buf rx_rb;
|
||||
|
|
|
@ -142,7 +142,7 @@ static int cmd_modem_send(const struct shell *shell, size_t argc,
|
|||
}
|
||||
|
||||
#if defined(CONFIG_GSM_MUX)
|
||||
static void uart_mux_cb(struct device *uart, struct device *dev,
|
||||
static void uart_mux_cb(const struct device *uart, const struct device *dev,
|
||||
int dlci_address, void *user_data)
|
||||
{
|
||||
struct modem_shell_user_data *data = user_data;
|
||||
|
|
|
@ -1663,7 +1663,7 @@ static uint32_t hash32(char *str, int len)
|
|||
return h;
|
||||
}
|
||||
|
||||
static inline uint8_t *modem_get_mac(struct device *dev)
|
||||
static inline uint8_t *modem_get_mac(const struct device *dev)
|
||||
{
|
||||
struct modem_data *data = dev->data;
|
||||
uint32_t hash_value;
|
||||
|
@ -1681,7 +1681,7 @@ static inline uint8_t *modem_get_mac(struct device *dev)
|
|||
|
||||
static void modem_net_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct device *dev = net_if_get_device(iface);
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
struct modem_data *data = dev->data;
|
||||
|
||||
/* Direct socket offload used instead of net offload: */
|
||||
|
@ -1712,7 +1712,7 @@ static struct modem_cmd unsol_cmds[] = {
|
|||
MODEM_CMD("+CREG: ", on_cmd_socknotifycreg, 1U, ""),
|
||||
};
|
||||
|
||||
static int modem_init(struct device *dev)
|
||||
static int modem_init(const struct device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ struct wncm14a2a_iface_ctx {
|
|||
uint8_t mac_addr[6];
|
||||
|
||||
/* GPIO PORT devices */
|
||||
struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS];
|
||||
const struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS];
|
||||
|
||||
/* RX specific attributes */
|
||||
struct mdm_receiver_context mdm_ctx;
|
||||
|
@ -1441,7 +1441,7 @@ error:
|
|||
return;
|
||||
}
|
||||
|
||||
static int wncm14a2a_init(struct device *dev)
|
||||
static int wncm14a2a_init(const struct device *dev)
|
||||
{
|
||||
int i, ret = 0;
|
||||
|
||||
|
@ -1818,7 +1818,7 @@ static struct net_offload offload_funcs = {
|
|||
.put = offload_put,
|
||||
};
|
||||
|
||||
static inline uint8_t *wncm14a2a_get_mac(struct device *dev)
|
||||
static inline uint8_t *wncm14a2a_get_mac(const struct device *dev)
|
||||
{
|
||||
struct wncm14a2a_iface_ctx *ctx = dev->data;
|
||||
|
||||
|
@ -1833,7 +1833,7 @@ static inline uint8_t *wncm14a2a_get_mac(struct device *dev)
|
|||
|
||||
static void offload_iface_init(struct net_if *iface)
|
||||
{
|
||||
struct device *dev = net_if_get_device(iface);
|
||||
const struct device *dev = net_if_get_device(iface);
|
||||
struct wncm14a2a_iface_ctx *ctx = dev->data;
|
||||
|
||||
iface->if_dev->offload = &offload_funcs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue