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

@ -412,7 +412,7 @@ struct net_traffic_class {
*/
struct net_if_dev {
/** The actually device driver instance the net_if is related to */
struct device *dev;
const struct device *dev;
/** Interface's L2 layer */
const struct net_l2 * const l2;
@ -587,7 +587,7 @@ static inline void *net_if_l2_data(struct net_if *iface)
*
* @return a pointer to the device driver instance
*/
static inline struct device *net_if_get_device(struct net_if *iface)
static inline const struct device *net_if_get_device(struct net_if *iface)
{
return iface->if_dev->dev;
}
@ -792,7 +792,7 @@ struct net_if *net_if_get_by_link_addr(struct net_linkaddr *ll_addr);
*
* @return a valid struct net_if pointer on success, NULL otherwise
*/
struct net_if *net_if_lookup_by_dev(struct device *dev);
struct net_if *net_if_lookup_by_dev(const struct device *dev);
/**
* @brief Get network interface IP config