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
|
@ -151,7 +151,7 @@ struct i2s_cavs_config {
|
|||
/* Device run time data */
|
||||
struct i2s_cavs_dev_data {
|
||||
struct i2s_config cfg;
|
||||
struct device *dev_dma;
|
||||
const struct device *dev_dma;
|
||||
struct stream tx;
|
||||
struct stream rx;
|
||||
};
|
||||
|
@ -166,11 +166,11 @@ I2S_DEVICE_OBJECT_DECLARE(1);
|
|||
I2S_DEVICE_OBJECT_DECLARE(2);
|
||||
I2S_DEVICE_OBJECT_DECLARE(3);
|
||||
|
||||
static void i2s_dma_tx_callback(struct device *, void *, uint32_t, int);
|
||||
static void i2s_dma_tx_callback(const struct device *, void *, uint32_t, int);
|
||||
static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *,
|
||||
volatile struct i2s_cavs_ssp *const, struct device *);
|
||||
volatile struct i2s_cavs_ssp *const, const struct device *);
|
||||
static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *,
|
||||
volatile struct i2s_cavs_ssp *const, struct device *);
|
||||
volatile struct i2s_cavs_ssp *const, const struct device *);
|
||||
|
||||
static inline void i2s_purge_stream_buffers(struct stream *strm,
|
||||
struct k_mem_slab *mem_slab)
|
||||
|
@ -186,10 +186,10 @@ static inline void i2s_purge_stream_buffers(struct stream *strm,
|
|||
}
|
||||
|
||||
/* This function is executed in the interrupt context */
|
||||
static void i2s_dma_tx_callback(struct device *dma_dev, void *arg,
|
||||
static void i2s_dma_tx_callback(const struct device *dma_dev, void *arg,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev);
|
||||
|
||||
|
@ -242,10 +242,10 @@ static void i2s_dma_tx_callback(struct device *dma_dev, void *arg,
|
|||
}
|
||||
}
|
||||
|
||||
static void i2s_dma_rx_callback(struct device *dma_dev, void *arg,
|
||||
static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev);
|
||||
volatile struct i2s_cavs_ssp *const ssp = dev_cfg->regs;
|
||||
|
@ -301,7 +301,7 @@ static void i2s_dma_rx_callback(struct device *dma_dev, void *arg,
|
|||
}
|
||||
}
|
||||
|
||||
static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_cavs_configure(const struct device *dev, enum i2s_dir dir,
|
||||
struct i2s_config *i2s_cfg)
|
||||
{
|
||||
const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev);
|
||||
|
@ -566,7 +566,7 @@ static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir,
|
|||
|
||||
static int i2s_tx_stream_start(struct i2s_cavs_dev_data *dev_data,
|
||||
volatile struct i2s_cavs_ssp *const ssp,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
int ret = 0;
|
||||
void *buffer;
|
||||
|
@ -611,7 +611,8 @@ static int i2s_tx_stream_start(struct i2s_cavs_dev_data *dev_data,
|
|||
}
|
||||
|
||||
static int i2s_rx_stream_start(struct i2s_cavs_dev_data *dev_data,
|
||||
volatile struct i2s_cavs_ssp *const ssp, struct device *dev_dma)
|
||||
volatile struct i2s_cavs_ssp *const ssp,
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
int ret = 0;
|
||||
void *buffer;
|
||||
|
@ -660,7 +661,7 @@ static int i2s_rx_stream_start(struct i2s_cavs_dev_data *dev_data,
|
|||
|
||||
static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *dev_data,
|
||||
volatile struct i2s_cavs_ssp *const ssp,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
struct stream *strm = &dev_data->tx;
|
||||
unsigned int key;
|
||||
|
@ -683,7 +684,7 @@ static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *dev_data,
|
|||
|
||||
static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *dev_data,
|
||||
volatile struct i2s_cavs_ssp *const ssp,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
struct stream *strm = &dev_data->rx;
|
||||
uint32_t data;
|
||||
|
@ -706,7 +707,7 @@ static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *dev_data,
|
|||
i2s_purge_stream_buffers(strm, dev_data->cfg.mem_slab);
|
||||
}
|
||||
|
||||
static int i2s_cavs_trigger(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_cavs_trigger(const struct device *dev, enum i2s_dir dir,
|
||||
enum i2s_trigger_cmd cmd)
|
||||
{
|
||||
const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev);
|
||||
|
@ -768,7 +769,8 @@ static int i2s_cavs_trigger(struct device *dev, enum i2s_dir dir,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int i2s_cavs_read(struct device *dev, void **mem_block, size_t *size)
|
||||
static int i2s_cavs_read(const struct device *dev, void **mem_block,
|
||||
size_t *size)
|
||||
{
|
||||
struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev);
|
||||
struct stream *strm = &dev_data->rx;
|
||||
|
@ -791,7 +793,8 @@ static int i2s_cavs_read(struct device *dev, void **mem_block, size_t *size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_cavs_write(struct device *dev, void *mem_block, size_t size)
|
||||
static int i2s_cavs_write(const struct device *dev, void *mem_block,
|
||||
size_t size)
|
||||
{
|
||||
struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev);
|
||||
struct stream *strm = &dev_data->tx;
|
||||
|
@ -818,7 +821,7 @@ static int i2s_cavs_write(struct device *dev, void *mem_block, size_t size)
|
|||
/* clear IRQ sources atm */
|
||||
static void i2s_cavs_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev);
|
||||
volatile struct i2s_cavs_ssp *const ssp = dev_cfg->regs;
|
||||
struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -840,7 +843,7 @@ static void i2s_cavs_isr(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
static int i2s_cavs_initialize(struct device *dev)
|
||||
static int i2s_cavs_initialize(const struct device *dev)
|
||||
{
|
||||
const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev);
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
#include <string.h>
|
||||
#include <drivers/i2s.h>
|
||||
|
||||
int z_impl_i2s_buf_read(struct device *dev, void *buf, size_t *size)
|
||||
int z_impl_i2s_buf_read(const struct device *dev, void *buf, size_t *size)
|
||||
{
|
||||
void *mem_block;
|
||||
int ret;
|
||||
|
||||
ret = i2s_read((struct device *)dev, &mem_block, size);
|
||||
ret = i2s_read((const struct device *)dev, &mem_block, size);
|
||||
|
||||
if (!ret) {
|
||||
struct i2s_config *rx_cfg =
|
||||
i2s_config_get((struct device *)dev, I2S_DIR_RX);
|
||||
i2s_config_get((const struct device *)dev, I2S_DIR_RX);
|
||||
|
||||
memcpy(buf, mem_block, *size);
|
||||
k_mem_slab_free(rx_cfg->mem_slab, &mem_block);
|
||||
|
@ -26,13 +26,13 @@ int z_impl_i2s_buf_read(struct device *dev, void *buf, size_t *size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int z_impl_i2s_buf_write(struct device *dev, void *buf, size_t size)
|
||||
int z_impl_i2s_buf_write(const struct device *dev, void *buf, size_t size)
|
||||
{
|
||||
int ret;
|
||||
struct i2s_config *tx_cfg;
|
||||
void *mem_block;
|
||||
|
||||
tx_cfg = i2s_config_get((struct device *)dev, I2S_DIR_TX);
|
||||
tx_cfg = i2s_config_get((const struct device *)dev, I2S_DIR_TX);
|
||||
if (!tx_cfg) {
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ int z_impl_i2s_buf_write(struct device *dev, void *buf, size_t size)
|
|||
|
||||
memcpy(mem_block, (void *)buf, size);
|
||||
|
||||
ret = i2s_write((struct device *)dev, mem_block, size);
|
||||
ret = i2s_write((const struct device *)dev, mem_block, size);
|
||||
if (ret != 0) {
|
||||
k_mem_slab_free(tx_cfg->mem_slab, &mem_block);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
#include <drivers/i2s.h>
|
||||
|
||||
|
||||
static inline int z_vrfy_i2s_configure(struct device *dev, enum i2s_dir dir,
|
||||
struct i2s_config *cfg_ptr)
|
||||
static inline int z_vrfy_i2s_configure(const struct device *dev,
|
||||
enum i2s_dir dir,
|
||||
struct i2s_config *cfg_ptr)
|
||||
{
|
||||
struct i2s_config config;
|
||||
int ret = -EINVAL;
|
||||
|
@ -36,13 +37,13 @@ static inline int z_vrfy_i2s_configure(struct device *dev, enum i2s_dir dir,
|
|||
goto out;
|
||||
}
|
||||
|
||||
ret = z_impl_i2s_configure((struct device *)dev, dir, &config);
|
||||
ret = z_impl_i2s_configure((const struct device *)dev, dir, &config);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
#include <syscalls/i2s_configure_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_i2s_buf_read(struct device *dev,
|
||||
static inline int z_vrfy_i2s_buf_read(const struct device *dev,
|
||||
void *buf, size_t *size)
|
||||
{
|
||||
void *mem_block;
|
||||
|
@ -51,7 +52,7 @@ static inline int z_vrfy_i2s_buf_read(struct device *dev,
|
|||
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, read));
|
||||
|
||||
ret = i2s_read((struct device *)dev, &mem_block, &data_size);
|
||||
ret = i2s_read((const struct device *)dev, &mem_block, &data_size);
|
||||
|
||||
if (!ret) {
|
||||
struct i2s_config *rx_cfg;
|
||||
|
@ -60,7 +61,8 @@ static inline int z_vrfy_i2s_buf_read(struct device *dev,
|
|||
/* Presumed to be configured otherwise the i2s_read() call
|
||||
* would have failed.
|
||||
*/
|
||||
rx_cfg = i2s_config_get((struct device *)dev, I2S_DIR_RX);
|
||||
rx_cfg = i2s_config_get((const struct device *)dev,
|
||||
I2S_DIR_RX);
|
||||
|
||||
copy_success = z_user_to_copy((void *)buf, mem_block,
|
||||
data_size);
|
||||
|
@ -75,7 +77,7 @@ static inline int z_vrfy_i2s_buf_read(struct device *dev,
|
|||
}
|
||||
#include <syscalls/i2s_buf_read_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_i2s_buf_write(struct device *dev,
|
||||
static inline int z_vrfy_i2s_buf_write(const struct device *dev,
|
||||
void *buf, size_t size)
|
||||
{
|
||||
int ret;
|
||||
|
@ -83,7 +85,7 @@ static inline int z_vrfy_i2s_buf_write(struct device *dev,
|
|||
void *mem_block;
|
||||
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, write));
|
||||
tx_cfg = i2s_config_get((struct device *)dev, I2S_DIR_TX);
|
||||
tx_cfg = i2s_config_get((const struct device *)dev, I2S_DIR_TX);
|
||||
if (!tx_cfg) {
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -103,7 +105,7 @@ static inline int z_vrfy_i2s_buf_write(struct device *dev,
|
|||
Z_OOPS(ret);
|
||||
}
|
||||
|
||||
ret = i2s_write((struct device *)dev, mem_block, size);
|
||||
ret = i2s_write((const struct device *)dev, mem_block, size);
|
||||
if (ret != 0) {
|
||||
k_mem_slab_free(tx_cfg->mem_slab, &mem_block);
|
||||
}
|
||||
|
@ -112,11 +114,12 @@ static inline int z_vrfy_i2s_buf_write(struct device *dev,
|
|||
}
|
||||
#include <syscalls/i2s_buf_write_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_i2s_trigger(struct device *dev, enum i2s_dir dir,
|
||||
static inline int z_vrfy_i2s_trigger(const struct device *dev,
|
||||
enum i2s_dir dir,
|
||||
enum i2s_trigger_cmd cmd)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, trigger));
|
||||
|
||||
return z_impl_i2s_trigger((struct device *)dev, dir, cmd);
|
||||
return z_impl_i2s_trigger((const struct device *)dev, dir, cmd);
|
||||
}
|
||||
#include <syscalls/i2s_trigger_mrsh.c>
|
||||
|
|
|
@ -320,7 +320,7 @@ static int queue_put(struct ring_buf *rb, void *mem_block, size_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_litex_initialize(struct device *dev)
|
||||
static int i2s_litex_initialize(const struct device *dev)
|
||||
{
|
||||
struct i2s_litex_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_litex_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -333,7 +333,7 @@ static int i2s_litex_initialize(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_litex_configure(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_litex_configure(const struct device *dev, enum i2s_dir dir,
|
||||
struct i2s_config *i2s_cfg)
|
||||
{
|
||||
struct i2s_litex_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -436,7 +436,8 @@ static int i2s_litex_configure(struct device *dev, enum i2s_dir dir,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_litex_read(struct device *dev, void **mem_block, size_t *size)
|
||||
static int i2s_litex_read(const struct device *dev, void **mem_block,
|
||||
size_t *size)
|
||||
{
|
||||
struct i2s_litex_data *const dev_data = DEV_DATA(dev);
|
||||
int ret;
|
||||
|
@ -455,7 +456,8 @@ static int i2s_litex_read(struct device *dev, void **mem_block, size_t *size)
|
|||
return queue_get(&dev_data->rx.mem_block_queue, mem_block, size);
|
||||
}
|
||||
|
||||
static int i2s_litex_write(struct device *dev, void *mem_block, size_t size)
|
||||
static int i2s_litex_write(const struct device *dev, void *mem_block,
|
||||
size_t size)
|
||||
{
|
||||
struct i2s_litex_data *const dev_data = DEV_DATA(dev);
|
||||
const struct i2s_litex_cfg *cfg = DEV_CFG(dev);
|
||||
|
@ -485,7 +487,7 @@ static int i2s_litex_write(struct device *dev, void *mem_block, size_t size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int i2s_litex_trigger(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_litex_trigger(const struct device *dev, enum i2s_dir dir,
|
||||
enum i2s_trigger_cmd cmd)
|
||||
{
|
||||
struct i2s_litex_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -543,7 +545,7 @@ static inline void clear_rx_fifo(const struct i2s_litex_cfg *cfg)
|
|||
|
||||
static void i2s_litex_isr_rx(void *arg)
|
||||
{
|
||||
struct device *const dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct i2s_litex_cfg *cfg = DEV_CFG(dev);
|
||||
struct stream *stream = &DEV_DATA(dev)->rx;
|
||||
int ret;
|
||||
|
@ -574,7 +576,7 @@ static void i2s_litex_isr_rx(void *arg)
|
|||
|
||||
static void i2s_litex_isr_tx(void *arg)
|
||||
{
|
||||
struct device *const dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct i2s_litex_cfg *cfg = DEV_CFG(dev);
|
||||
size_t mem_block_size;
|
||||
struct stream *stream = &DEV_DATA(dev)->tx;
|
||||
|
|
|
@ -104,7 +104,7 @@ struct i2s_litex_cfg {
|
|||
uint32_t base;
|
||||
uint32_t fifo_base;
|
||||
uint16_t fifo_depth;
|
||||
void (*irq_config)(struct device *dev);
|
||||
void (*irq_config)(const struct device *dev);
|
||||
};
|
||||
|
||||
#endif /* _I2S_LITEI2S__H */
|
||||
|
|
|
@ -91,10 +91,10 @@ static int queue_put(struct ring_buf *rb, void *mem_block, size_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_stm32_enable_clock(struct device *dev)
|
||||
static int i2s_stm32_enable_clock(const struct device *dev)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct device *clk;
|
||||
const struct device *clk;
|
||||
int ret;
|
||||
|
||||
clk = device_get_binding(STM32_CLOCK_CONTROL_NAME);
|
||||
|
@ -117,7 +117,8 @@ static uint16_t plli2s_ms_count;
|
|||
#define pllr(v) z_pllr(v)
|
||||
#endif
|
||||
|
||||
static int i2s_stm32_set_clock(struct device *dev, uint32_t bit_clk_freq)
|
||||
static int i2s_stm32_set_clock(const struct device *dev,
|
||||
uint32_t bit_clk_freq)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
uint32_t pll_src = LL_RCC_PLL_GetMainSource();
|
||||
|
@ -177,7 +178,7 @@ static int i2s_stm32_set_clock(struct device *dev, uint32_t bit_clk_freq)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_stm32_configure(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_stm32_configure(const struct device *dev, enum i2s_dir dir,
|
||||
struct i2s_config *i2s_cfg)
|
||||
{
|
||||
const struct i2s_stm32_cfg *const cfg = DEV_CFG(dev);
|
||||
|
@ -281,7 +282,7 @@ static int i2s_stm32_configure(struct device *dev, enum i2s_dir dir,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_stm32_trigger(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_stm32_trigger(const struct device *dev, enum i2s_dir dir,
|
||||
enum i2s_trigger_cmd cmd)
|
||||
{
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -372,7 +373,8 @@ static int i2s_stm32_trigger(struct device *dev, enum i2s_dir dir,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_stm32_read(struct device *dev, void **mem_block, size_t *size)
|
||||
static int i2s_stm32_read(const struct device *dev, void **mem_block,
|
||||
size_t *size)
|
||||
{
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
int ret;
|
||||
|
@ -399,7 +401,8 @@ static int i2s_stm32_read(struct device *dev, void **mem_block, size_t *size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_stm32_write(struct device *dev, void *mem_block, size_t size)
|
||||
static int i2s_stm32_write(const struct device *dev, void *mem_block,
|
||||
size_t size)
|
||||
{
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
int ret;
|
||||
|
@ -430,10 +433,10 @@ static const struct i2s_driver_api i2s_stm32_driver_api = {
|
|||
};
|
||||
|
||||
#define STM32_DMA_NUM_CHANNELS 8
|
||||
static struct device *active_dma_rx_channel[STM32_DMA_NUM_CHANNELS];
|
||||
static struct device *active_dma_tx_channel[STM32_DMA_NUM_CHANNELS];
|
||||
static const struct device *active_dma_rx_channel[STM32_DMA_NUM_CHANNELS];
|
||||
static const struct device *active_dma_tx_channel[STM32_DMA_NUM_CHANNELS];
|
||||
|
||||
static int reload_dma(struct device *dev_dma, uint32_t channel,
|
||||
static int reload_dma(const struct device *dev_dma, uint32_t channel,
|
||||
struct dma_config *dcfg, void *src, void *dst,
|
||||
uint32_t blk_size)
|
||||
{
|
||||
|
@ -449,7 +452,7 @@ static int reload_dma(struct device *dev_dma, uint32_t channel,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int start_dma(struct device *dev_dma, uint32_t channel,
|
||||
static int start_dma(const struct device *dev_dma, uint32_t channel,
|
||||
struct dma_config *dcfg, void *src,
|
||||
bool src_addr_increment, void *dst,
|
||||
bool dst_addr_increment, uint8_t fifo_threshold,
|
||||
|
@ -486,16 +489,16 @@ static int start_dma(struct device *dev_dma, uint32_t channel,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel);
|
||||
static struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel);
|
||||
static void rx_stream_disable(struct stream *stream, struct device *dev);
|
||||
static void tx_stream_disable(struct stream *stream, struct device *dev);
|
||||
static const struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel);
|
||||
static const struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel);
|
||||
static void rx_stream_disable(struct stream *stream, const struct device *dev);
|
||||
static void tx_stream_disable(struct stream *stream, const struct device *dev);
|
||||
|
||||
/* This function is executed in the interrupt context */
|
||||
static void dma_rx_callback(struct device *dma_dev, void *arg,
|
||||
static void dma_rx_callback(const struct device *dma_dev, void *arg,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
struct device *dev = get_dev_from_rx_dma_channel(channel);
|
||||
const struct device *dev = get_dev_from_rx_dma_channel(channel);
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct stream *stream = &dev_data->rx;
|
||||
|
@ -559,10 +562,10 @@ rx_disable:
|
|||
rx_stream_disable(stream, dev);
|
||||
}
|
||||
|
||||
static void dma_tx_callback(struct device *dma_dev, void *arg,
|
||||
static void dma_tx_callback(const struct device *dma_dev, void *arg,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
struct device *dev = get_dev_from_tx_dma_channel(channel);
|
||||
const struct device *dev = get_dev_from_tx_dma_channel(channel);
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct stream *stream = &dev_data->tx;
|
||||
|
@ -630,7 +633,7 @@ static uint32_t i2s_stm32_irq_ovr_count;
|
|||
|
||||
static void i2s_stm32_isr(void *arg)
|
||||
{
|
||||
struct device *const dev = (struct device *) arg;
|
||||
const struct device *dev = (const struct device *) arg;
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct stream *stream = &dev_data->rx;
|
||||
|
@ -647,7 +650,7 @@ static void i2s_stm32_isr(void *arg)
|
|||
i2s_stm32_irq_count++;
|
||||
}
|
||||
|
||||
static int i2s_stm32_initialize(struct device *dev)
|
||||
static int i2s_stm32_initialize(const struct device *dev)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -688,7 +691,7 @@ static int i2s_stm32_initialize(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rx_stream_start(struct stream *stream, struct device *dev)
|
||||
static int rx_stream_start(struct stream *stream, const struct device *dev)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -728,7 +731,7 @@ static int rx_stream_start(struct stream *stream, struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int tx_stream_start(struct stream *stream, struct device *dev)
|
||||
static int tx_stream_start(struct stream *stream, const struct device *dev)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -773,11 +776,11 @@ static int tx_stream_start(struct stream *stream, struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void rx_stream_disable(struct stream *stream, struct device *dev)
|
||||
static void rx_stream_disable(struct stream *stream, const struct device *dev)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct device *dev_dma = dev_data->dev_dma_rx;
|
||||
const struct device *dev_dma = dev_data->dev_dma_rx;
|
||||
|
||||
LL_I2S_DisableDMAReq_RX(cfg->i2s);
|
||||
LL_I2S_DisableIT_ERR(cfg->i2s);
|
||||
|
@ -793,11 +796,11 @@ static void rx_stream_disable(struct stream *stream, struct device *dev)
|
|||
active_dma_rx_channel[stream->dma_channel] = NULL;
|
||||
}
|
||||
|
||||
static void tx_stream_disable(struct stream *stream, struct device *dev)
|
||||
static void tx_stream_disable(struct stream *stream, const struct device *dev)
|
||||
{
|
||||
const struct i2s_stm32_cfg *cfg = DEV_CFG(dev);
|
||||
struct i2s_stm32_data *const dev_data = DEV_DATA(dev);
|
||||
struct device *dev_dma = dev_data->dev_dma_tx;
|
||||
const struct device *dev_dma = dev_data->dev_dma_tx;
|
||||
|
||||
LL_I2S_DisableDMAReq_TX(cfg->i2s);
|
||||
LL_I2S_DisableIT_ERR(cfg->i2s);
|
||||
|
@ -841,12 +844,12 @@ static void tx_queue_drop(struct stream *stream)
|
|||
}
|
||||
}
|
||||
|
||||
static struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel)
|
||||
static const struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel)
|
||||
{
|
||||
return active_dma_rx_channel[dma_channel];
|
||||
}
|
||||
|
||||
static struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel)
|
||||
static const struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel)
|
||||
{
|
||||
return active_dma_tx_channel[dma_channel];
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ struct i2s_stm32_cfg {
|
|||
SPI_TypeDef *i2s;
|
||||
struct stm32_pclken pclken;
|
||||
uint32_t i2s_clk_sel;
|
||||
void (*irq_config)(struct device *dev);
|
||||
void (*irq_config)(const struct device *dev);
|
||||
};
|
||||
|
||||
struct stream {
|
||||
|
@ -92,15 +92,15 @@ struct stream {
|
|||
void *mem_block;
|
||||
bool last_block;
|
||||
bool master;
|
||||
int (*stream_start)(struct stream *, struct device *dev);
|
||||
void (*stream_disable)(struct stream *, struct device *dev);
|
||||
int (*stream_start)(struct stream *, const struct device *dev);
|
||||
void (*stream_disable)(struct stream *, const struct device *dev);
|
||||
void (*queue_drop)(struct stream *);
|
||||
};
|
||||
|
||||
/* Device run time data */
|
||||
struct i2s_stm32_data {
|
||||
struct device *dev_dma_tx;
|
||||
struct device *dev_dma_rx;
|
||||
const struct device *dev_dma_tx;
|
||||
const struct device *dev_dma_rx;
|
||||
struct stream rx;
|
||||
struct stream tx;
|
||||
};
|
||||
|
|
|
@ -81,8 +81,10 @@ struct stream {
|
|||
struct ring_buf mem_block_queue;
|
||||
void *mem_block;
|
||||
bool last_block;
|
||||
int (*stream_start)(struct stream *, Ssc *const, struct device *);
|
||||
void (*stream_disable)(struct stream *, Ssc *const, struct device *);
|
||||
int (*stream_start)(struct stream *, Ssc *const,
|
||||
const struct device *);
|
||||
void (*stream_disable)(struct stream *, Ssc *const,
|
||||
const struct device *);
|
||||
void (*queue_drop)(struct stream *);
|
||||
int (*set_data_format)(const struct i2s_sam_dev_cfg *const,
|
||||
struct i2s_config *);
|
||||
|
@ -90,7 +92,7 @@ struct stream {
|
|||
|
||||
/* Device run time data */
|
||||
struct i2s_sam_dev_data {
|
||||
struct device *dev_dma;
|
||||
const struct device *dev_dma;
|
||||
struct stream rx;
|
||||
struct stream tx;
|
||||
};
|
||||
|
@ -103,11 +105,13 @@ struct i2s_sam_dev_data {
|
|||
|
||||
#define MODULO_INC(val, max) { val = (++val < max) ? val : 0; }
|
||||
|
||||
static struct device *get_dev_from_dma_channel(uint32_t dma_channel);
|
||||
static void dma_rx_callback(struct device *, void *, uint32_t, int);
|
||||
static void dma_tx_callback(struct device *, void *, uint32_t, int);
|
||||
static void rx_stream_disable(struct stream *, Ssc *const, struct device *);
|
||||
static void tx_stream_disable(struct stream *, Ssc *const, struct device *);
|
||||
static const struct device *get_dev_from_dma_channel(uint32_t dma_channel);
|
||||
static void dma_rx_callback(const struct device *, void *, uint32_t, int);
|
||||
static void dma_tx_callback(const struct device *, void *, uint32_t, int);
|
||||
static void rx_stream_disable(struct stream *, Ssc *const,
|
||||
const struct device *);
|
||||
static void tx_stream_disable(struct stream *, Ssc *const,
|
||||
const struct device *);
|
||||
|
||||
/*
|
||||
* Get data from the queue
|
||||
|
@ -161,7 +165,7 @@ static int queue_put(struct ring_buf *rb, void *mem_block, size_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int start_dma(struct device *dev_dma, uint32_t channel,
|
||||
static int start_dma(const struct device *dev_dma, uint32_t channel,
|
||||
struct dma_config *cfg, void *src, void *dst,
|
||||
uint32_t blk_size)
|
||||
{
|
||||
|
@ -186,10 +190,10 @@ static int start_dma(struct device *dev_dma, uint32_t channel,
|
|||
}
|
||||
|
||||
/* This function is executed in the interrupt context */
|
||||
static void dma_rx_callback(struct device *dma_dev, void *user_data,
|
||||
static void dma_rx_callback(const struct device *dma_dev, void *user_data,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
struct device *dev = get_dev_from_dma_channel(channel);
|
||||
const struct device *dev = get_dev_from_dma_channel(channel);
|
||||
const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
Ssc *const ssc = dev_cfg->regs;
|
||||
|
@ -246,10 +250,10 @@ rx_disable:
|
|||
}
|
||||
|
||||
/* This function is executed in the interrupt context */
|
||||
static void dma_tx_callback(struct device *dma_dev, void *user_data,
|
||||
static void dma_tx_callback(const struct device *dma_dev, void *user_data,
|
||||
uint32_t channel, int status)
|
||||
{
|
||||
struct device *dev = get_dev_from_dma_channel(channel);
|
||||
const struct device *dev = get_dev_from_dma_channel(channel);
|
||||
const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
Ssc *const ssc = dev_cfg->regs;
|
||||
|
@ -511,7 +515,7 @@ static int bit_clock_set(Ssc *const ssc, uint32_t bit_clk_freq)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct i2s_config *i2s_sam_config_get(struct device *dev,
|
||||
static struct i2s_config *i2s_sam_config_get(const struct device *dev,
|
||||
enum i2s_dir dir)
|
||||
{
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -530,7 +534,7 @@ static struct i2s_config *i2s_sam_config_get(struct device *dev,
|
|||
return &stream->cfg;
|
||||
}
|
||||
|
||||
static int i2s_sam_configure(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_sam_configure(const struct device *dev, enum i2s_dir dir,
|
||||
struct i2s_config *i2s_cfg)
|
||||
{
|
||||
const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
|
||||
|
@ -618,7 +622,7 @@ static int i2s_sam_configure(struct device *dev, enum i2s_dir dir,
|
|||
}
|
||||
|
||||
static int rx_stream_start(struct stream *stream, Ssc *const ssc,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -653,7 +657,7 @@ static int rx_stream_start(struct stream *stream, Ssc *const ssc,
|
|||
}
|
||||
|
||||
static int tx_stream_start(struct stream *stream, Ssc *const ssc,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
size_t mem_block_size;
|
||||
int ret;
|
||||
|
@ -694,7 +698,7 @@ static int tx_stream_start(struct stream *stream, Ssc *const ssc,
|
|||
}
|
||||
|
||||
static void rx_stream_disable(struct stream *stream, Ssc *const ssc,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
ssc->SSC_CR = SSC_CR_RXDIS;
|
||||
ssc->SSC_IDR = SSC_IDR_OVRUN;
|
||||
|
@ -706,7 +710,7 @@ static void rx_stream_disable(struct stream *stream, Ssc *const ssc,
|
|||
}
|
||||
|
||||
static void tx_stream_disable(struct stream *stream, Ssc *const ssc,
|
||||
struct device *dev_dma)
|
||||
const struct device *dev_dma)
|
||||
{
|
||||
ssc->SSC_CR = SSC_CR_TXDIS;
|
||||
ssc->SSC_IDR = SSC_IDR_TXEMPTY;
|
||||
|
@ -745,7 +749,7 @@ static void tx_queue_drop(struct stream *stream)
|
|||
}
|
||||
}
|
||||
|
||||
static int i2s_sam_trigger(struct device *dev, enum i2s_dir dir,
|
||||
static int i2s_sam_trigger(const struct device *dev, enum i2s_dir dir,
|
||||
enum i2s_trigger_cmd cmd)
|
||||
{
|
||||
const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
|
||||
|
@ -833,7 +837,8 @@ static int i2s_sam_trigger(struct device *dev, enum i2s_dir dir,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_sam_read(struct device *dev, void **mem_block, size_t *size)
|
||||
static int i2s_sam_read(const struct device *dev, void **mem_block,
|
||||
size_t *size)
|
||||
{
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
int ret;
|
||||
|
@ -860,7 +865,8 @@ static int i2s_sam_read(struct device *dev, void **mem_block, size_t *size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int i2s_sam_write(struct device *dev, void *mem_block, size_t size)
|
||||
static int i2s_sam_write(const struct device *dev, void *mem_block,
|
||||
size_t size)
|
||||
{
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
int ret;
|
||||
|
@ -885,7 +891,7 @@ static int i2s_sam_write(struct device *dev, void *mem_block, size_t size)
|
|||
|
||||
static void i2s_sam_isr(void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
const struct device *dev = (const struct device *)arg;
|
||||
const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
Ssc *const ssc = dev_cfg->regs;
|
||||
|
@ -910,7 +916,7 @@ static void i2s_sam_isr(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
static int i2s_sam_initialize(struct device *dev)
|
||||
static int i2s_sam_initialize(const struct device *dev)
|
||||
{
|
||||
const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
|
||||
struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev);
|
||||
|
@ -959,7 +965,7 @@ static const struct i2s_driver_api i2s_sam_driver_api = {
|
|||
|
||||
DEVICE_DECLARE(i2s0_sam);
|
||||
|
||||
static struct device *get_dev_from_dma_channel(uint32_t dma_channel)
|
||||
static const struct device *get_dev_from_dma_channel(uint32_t dma_channel)
|
||||
{
|
||||
return &DEVICE_NAME_GET(i2s0_sam);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue