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

@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <net/dummy.h>
int loopback_dev_init(struct device *dev)
int loopback_dev_init(const struct device *dev)
{
ARG_UNUSED(dev);
@ -38,7 +38,7 @@ static void loopback_init(struct net_if *iface)
NET_LINK_DUMMY);
}
static int loopback_send(struct device *dev, struct net_pkt *pkt)
static int loopback_send(const struct device *dev, struct net_pkt *pkt)
{
struct net_pkt *cloned;
int res;

View file

@ -50,7 +50,7 @@ enum ppp_driver_state {
K_KERNEL_STACK_DEFINE(ppp_workq, PPP_WORKQ_STACK_SIZE);
struct ppp_driver_context {
struct device *dev;
const struct device *dev;
struct net_if *iface;
/* This net_pkt contains pkt that is being read */
@ -536,7 +536,7 @@ static uint16_t ppp_escape_byte(uint8_t byte, int *offset)
return byte;
}
static int ppp_send(struct device *dev, struct net_pkt *pkt)
static int ppp_send(const struct device *dev, struct net_pkt *pkt)
{
struct ppp_driver_context *ppp = dev->data;
struct net_buf *buf = pkt->buffer;
@ -682,7 +682,7 @@ static void ppp_isr_cb_work(struct k_work *work)
}
#endif /* !CONFIG_NET_TEST */
static int ppp_driver_init(struct device *dev)
static int ppp_driver_init(const struct device *dev)
{
struct ppp_driver_context *ppp = dev->data;
@ -766,7 +766,7 @@ use_random_mac:
}
#if defined(CONFIG_NET_STATISTICS_PPP)
static struct net_stats_ppp *ppp_get_stats(struct device *dev)
static struct net_stats_ppp *ppp_get_stats(const struct device *dev)
{
struct ppp_driver_context *context = dev->data;
@ -775,7 +775,7 @@ static struct net_stats_ppp *ppp_get_stats(struct device *dev)
#endif
#if !defined(CONFIG_NET_TEST)
static void ppp_uart_flush(struct device *dev)
static void ppp_uart_flush(const struct device *dev)
{
uint8_t c;
@ -784,7 +784,7 @@ static void ppp_uart_flush(struct device *dev)
}
}
static void ppp_uart_isr(struct device *uart, void *user_data)
static void ppp_uart_isr(const struct device *uart, void *user_data)
{
struct ppp_driver_context *context = user_data;
int rx = 0, ret;
@ -809,7 +809,7 @@ static void ppp_uart_isr(struct device *uart, void *user_data)
}
#endif /* !CONFIG_NET_TEST */
static int ppp_start(struct device *dev)
static int ppp_start(const struct device *dev)
{
struct ppp_driver_context *context = dev->data;
@ -827,7 +827,7 @@ static int ppp_start(struct device *dev)
* then use our own config.
*/
#if IS_ENABLED(CONFIG_GSM_MUX)
struct device *mux;
const struct device *mux;
mux = uart_mux_find(CONFIG_GSM_MUX_DLCI_PPP);
if (mux == NULL) {
@ -869,7 +869,7 @@ static int ppp_start(struct device *dev)
return 0;
}
static int ppp_stop(struct device *dev)
static int ppp_stop(const struct device *dev)
{
struct ppp_driver_context *context = dev->data;

View file

@ -106,7 +106,7 @@ static void slip_writeb_esc(unsigned char c)
}
}
static int slip_send(struct device *dev, struct net_pkt *pkt)
static int slip_send(const struct device *dev, struct net_pkt *pkt)
{
struct net_buf *buf;
uint8_t *ptr;
@ -363,7 +363,7 @@ static uint8_t *recv_cb(uint8_t *buf, size_t *off)
return buf;
}
static int slip_init(struct device *dev)
static int slip_init(const struct device *dev)
{
struct slip_context *slip = dev->data;
@ -434,7 +434,7 @@ use_random_mac:
static struct slip_context slip_context_data;
#if defined(CONFIG_SLIP_TAP)
static enum ethernet_hw_caps eth_capabilities(struct device *dev)
static enum ethernet_hw_caps eth_capabilities(const struct device *dev)
{
ARG_UNUSED(dev);