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

@ -222,7 +222,7 @@ static void xlnx_ps_enable_uart(uint32_t reg_base)
* @param dev UART device struct
* @param baud_rate The desired baud rate as a decimal value
*/
static void set_baudrate(struct device *dev, uint32_t baud_rate)
static void set_baudrate(const struct device *dev, uint32_t baud_rate)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t divisor, generator;
@ -281,7 +281,7 @@ static void set_baudrate(struct device *dev, uint32_t baud_rate)
*
* @return 0 if successful, failed otherwise
*/
static int uart_xlnx_ps_init(struct device *dev)
static int uart_xlnx_ps_init(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_val;
@ -335,7 +335,7 @@ static int uart_xlnx_ps_init(struct device *dev)
*
* @return 0 if a character arrived, -1 if the input buffer if empty.
*/
static int uart_xlnx_ps_poll_in(struct device *dev, unsigned char *c)
static int uart_xlnx_ps_poll_in(const struct device *dev, unsigned char *c)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_val;
@ -366,7 +366,7 @@ static int uart_xlnx_ps_poll_in(struct device *dev, unsigned char *c)
*
* @return Sent character
*/
static void uart_xlnx_ps_poll_out(struct device *dev, unsigned char c)
static void uart_xlnx_ps_poll_out(const struct device *dev, unsigned char c)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_val;
@ -595,8 +595,8 @@ static inline bool uart_xlnx_ps_cfg2ll_hwctrl(
* @return 0 if the configuration completed successfully, ENOTSUP
* error if an unsupported configuration parameter is detected.
*/
static int uart_xlnx_ps_configure(struct device *dev,
const struct uart_config *cfg)
static int uart_xlnx_ps_configure(const struct device *dev,
const struct uart_config *cfg)
{
struct uart_xlnx_ps_dev_config *dev_cfg =
(struct uart_xlnx_ps_dev_config *)DEV_CFG(dev);
@ -800,8 +800,8 @@ static inline enum uart_config_flow_control uart_xlnx_ps_ll2cfg_hwctrl(
*
* @return always 0.
*/
static int uart_xlnx_ps_config_get(struct device *dev,
struct uart_config *cfg)
static int uart_xlnx_ps_config_get(const struct device *dev,
struct uart_config *cfg)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
@ -836,7 +836,8 @@ static int uart_xlnx_ps_config_get(struct device *dev,
*
* @return Number of bytes sent
*/
static int uart_xlnx_ps_fifo_fill(struct device *dev, const uint8_t *tx_data,
static int uart_xlnx_ps_fifo_fill(const struct device *dev,
const uint8_t *tx_data,
int size)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
@ -865,7 +866,7 @@ static int uart_xlnx_ps_fifo_fill(struct device *dev, const uint8_t *tx_data,
*
* @return Number of bytes read
*/
static int uart_xlnx_ps_fifo_read(struct device *dev, uint8_t *rx_data,
static int uart_xlnx_ps_fifo_read(const struct device *dev, uint8_t *rx_data,
const int size)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
@ -893,7 +894,7 @@ static int uart_xlnx_ps_fifo_read(struct device *dev, uint8_t *rx_data,
*
* @return N/A
*/
static void uart_xlnx_ps_irq_tx_enable(struct device *dev)
static void uart_xlnx_ps_irq_tx_enable(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -911,7 +912,7 @@ static void uart_xlnx_ps_irq_tx_enable(struct device *dev)
*
* @return N/A
*/
static void uart_xlnx_ps_irq_tx_disable(struct device *dev)
static void uart_xlnx_ps_irq_tx_disable(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -929,7 +930,7 @@ static void uart_xlnx_ps_irq_tx_disable(struct device *dev)
*
* @return 1 if an IRQ is ready, 0 otherwise
*/
static int uart_xlnx_ps_irq_tx_ready(struct device *dev)
static int uart_xlnx_ps_irq_tx_ready(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -954,7 +955,7 @@ static int uart_xlnx_ps_irq_tx_ready(struct device *dev)
*
* @return 1 if nothing remains to be transmitted, 0 otherwise
*/
static int uart_xlnx_ps_irq_tx_complete(struct device *dev)
static int uart_xlnx_ps_irq_tx_complete(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -976,7 +977,7 @@ static int uart_xlnx_ps_irq_tx_complete(struct device *dev)
*
* @return N/A
*/
static void uart_xlnx_ps_irq_rx_enable(struct device *dev)
static void uart_xlnx_ps_irq_rx_enable(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -992,7 +993,7 @@ static void uart_xlnx_ps_irq_rx_enable(struct device *dev)
*
* @return N/A
*/
static void uart_xlnx_ps_irq_rx_disable(struct device *dev)
static void uart_xlnx_ps_irq_rx_disable(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -1008,7 +1009,7 @@ static void uart_xlnx_ps_irq_rx_disable(struct device *dev)
*
* @return 1 if an IRQ is ready, 0 otherwise
*/
static int uart_xlnx_ps_irq_rx_ready(struct device *dev)
static int uart_xlnx_ps_irq_rx_ready(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -1031,7 +1032,7 @@ static int uart_xlnx_ps_irq_rx_ready(struct device *dev)
*
* @return N/A
*/
static void uart_xlnx_ps_irq_err_enable(struct device *dev)
static void uart_xlnx_ps_irq_err_enable(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -1053,7 +1054,7 @@ static void uart_xlnx_ps_irq_err_enable(struct device *dev)
*
* @return 1 if an IRQ is ready, 0 otherwise
*/
static void uart_xlnx_ps_irq_err_disable(struct device *dev)
static void uart_xlnx_ps_irq_err_disable(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -1075,7 +1076,7 @@ static void uart_xlnx_ps_irq_err_disable(struct device *dev)
*
* @return 1 if an IRQ is pending, 0 otherwise
*/
static int uart_xlnx_ps_irq_is_pending(struct device *dev)
static int uart_xlnx_ps_irq_is_pending(const struct device *dev)
{
const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev);
uint32_t reg_base;
@ -1100,7 +1101,7 @@ static int uart_xlnx_ps_irq_is_pending(struct device *dev)
*
* @return Always 1
*/
static int uart_xlnx_ps_irq_update(struct device *dev)
static int uart_xlnx_ps_irq_update(const struct device *dev)
{
(void)dev;
return 1;
@ -1114,7 +1115,7 @@ static int uart_xlnx_ps_irq_update(struct device *dev)
*
* @return N/A
*/
static void uart_xlnx_ps_irq_callback_set(struct device *dev,
static void uart_xlnx_ps_irq_callback_set(const struct device *dev,
uart_irq_callback_user_data_t cb,
void *cb_data)
{
@ -1135,7 +1136,7 @@ static void uart_xlnx_ps_irq_callback_set(struct device *dev,
*/
static void uart_xlnx_ps_isr(void *arg)
{
struct device *dev = arg;
const struct device *dev = arg;
const struct uart_xlnx_ps_dev_data_t *data = DEV_DATA(dev);
if (data->user_cb) {