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
|
@ -133,7 +133,7 @@ static struct _dmic_pdata {
|
|||
uint8_t num_streams;
|
||||
uint8_t reserved;
|
||||
struct _stream_data streams[DMIC_MAX_STREAMS];
|
||||
struct device *dma_dev;
|
||||
const struct device *dma_dev;
|
||||
} dmic_private;
|
||||
|
||||
static inline void dmic_parse_channel_map(uint32_t channel_map_lo,
|
||||
|
@ -714,8 +714,9 @@ static int source_ipm_helper(struct pdm_chan_cfg *config, uint32_t *source_mask,
|
|||
return ipm;
|
||||
}
|
||||
|
||||
static int configure_registers(struct device *dev,
|
||||
struct dmic_configuration *hw_cfg, struct dmic_cfg *config)
|
||||
static int configure_registers(const struct device *dev,
|
||||
struct dmic_configuration *hw_cfg,
|
||||
struct dmic_cfg *config)
|
||||
{
|
||||
uint8_t skew;
|
||||
uint8_t swap_mask;
|
||||
|
@ -949,7 +950,7 @@ static int configure_registers(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void dmic_dma_callback(struct device *dev, void *arg,
|
||||
static void dmic_dma_callback(const struct device *dev, void *arg,
|
||||
uint32_t chan, int err_code)
|
||||
{
|
||||
void *buffer;
|
||||
|
@ -1005,7 +1006,7 @@ static void dmic_dma_callback(struct device *dev, void *arg,
|
|||
}
|
||||
}
|
||||
|
||||
static int dmic_set_config(struct device *dev, struct dmic_cfg *config)
|
||||
static int dmic_set_config(const struct device *dev, struct dmic_cfg *config)
|
||||
{
|
||||
struct decim_modes modes_a;
|
||||
struct decim_modes modes_b;
|
||||
|
@ -1108,7 +1109,7 @@ static int dmic_set_config(struct device *dev, struct dmic_cfg *config)
|
|||
}
|
||||
|
||||
/* start the DMIC for capture */
|
||||
static void dmic_start(struct device *dev)
|
||||
static void dmic_start(const struct device *dev)
|
||||
{
|
||||
struct _stream_data *stream;
|
||||
unsigned int key;
|
||||
|
@ -1258,7 +1259,8 @@ static void dmic_stop(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int dmic_trigger_device(struct device *dev, enum dmic_trigger cmd)
|
||||
static int dmic_trigger_device(const struct device *dev,
|
||||
enum dmic_trigger cmd)
|
||||
{
|
||||
unsigned int key;
|
||||
|
||||
|
@ -1293,7 +1295,7 @@ static inline uint8_t dmic_parse_clk_skew_map(uint32_t skew_map, uint8_t pdm)
|
|||
return (uint8_t)((skew_map >> ((pdm & BIT_MASK(3)) * 4U)) & BIT_MASK(4));
|
||||
}
|
||||
|
||||
static int dmic_initialize_device(struct device *dev)
|
||||
static int dmic_initialize_device(const struct device *dev)
|
||||
{
|
||||
int stream;
|
||||
struct _stream_data *stream_data;
|
||||
|
@ -1316,7 +1318,8 @@ static int dmic_initialize_device(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dmic_configure_device(struct device *dev, struct dmic_cfg *config)
|
||||
static int dmic_configure_device(const struct device *dev,
|
||||
struct dmic_cfg *config)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
@ -1334,8 +1337,8 @@ static int dmic_configure_device(struct device *dev, struct dmic_cfg *config)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int dmic_read_device(struct device *dev, uint8_t stream,
|
||||
void **buffer, size_t *size, int32_t timeout)
|
||||
static int dmic_read_device(const struct device *dev, uint8_t stream,
|
||||
void **buffer, size_t *size, int32_t timeout)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(mpxxdtyy);
|
|||
|
||||
K_MEM_SLAB_DEFINE(rx_pdm_i2s_mslab, PDM_BLOCK_MAX_SIZE_BYTES, NUM_RX_BLOCKS, 1);
|
||||
|
||||
int mpxxdtyy_i2s_read(struct device *dev, uint8_t stream, void **buffer,
|
||||
int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer,
|
||||
size_t *size, int32_t timeout)
|
||||
{
|
||||
int ret;
|
||||
|
@ -51,7 +51,7 @@ int mpxxdtyy_i2s_read(struct device *dev, uint8_t stream, void **buffer,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mpxxdtyy_i2s_trigger(struct device *dev, enum dmic_trigger cmd)
|
||||
int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd)
|
||||
{
|
||||
int ret;
|
||||
struct mpxxdtyy_data *const data = DEV_DATA(dev);
|
||||
|
@ -89,7 +89,7 @@ int mpxxdtyy_i2s_trigger(struct device *dev, enum dmic_trigger cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mpxxdtyy_i2s_configure(struct device *dev, struct dmic_cfg *cfg)
|
||||
int mpxxdtyy_i2s_configure(const struct device *dev, struct dmic_cfg *cfg)
|
||||
{
|
||||
int ret;
|
||||
struct mpxxdtyy_data *const data = DEV_DATA(dev);
|
||||
|
|
|
@ -45,7 +45,7 @@ static uint8_t right_channel(uint8_t a, uint8_t b)
|
|||
return ch_demux[a & CHANNEL_MASK] | (ch_demux[b & CHANNEL_MASK] << 4);
|
||||
}
|
||||
|
||||
uint16_t sw_filter_lib_init(struct device *dev, struct dmic_cfg *cfg)
|
||||
uint16_t sw_filter_lib_init(const struct device *dev, struct dmic_cfg *cfg)
|
||||
{
|
||||
struct mpxxdtyy_data *const data = DEV_DATA(dev);
|
||||
TPDMFilter_InitStruct *pdm_filter = &data->pdm_filter[0];
|
||||
|
@ -148,7 +148,7 @@ static const struct _dmic_ops mpxxdtyy_driver_api = {
|
|||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) */
|
||||
};
|
||||
|
||||
static int mpxxdtyy_initialize(struct device *dev)
|
||||
static int mpxxdtyy_initialize(const struct device *dev)
|
||||
{
|
||||
struct mpxxdtyy_data *const data = DEV_DATA(dev);
|
||||
|
||||
|
|
|
@ -25,23 +25,23 @@ extern "C" {
|
|||
((struct mpxxdtyy_data *const)(dev)->data)
|
||||
|
||||
struct mpxxdtyy_data {
|
||||
struct device *comm_master;
|
||||
const struct device *comm_master;
|
||||
enum dmic_state state;
|
||||
TPDMFilter_InitStruct pdm_filter[2];
|
||||
size_t pcm_mem_size;
|
||||
struct k_mem_slab *pcm_mem_slab;
|
||||
};
|
||||
|
||||
uint16_t sw_filter_lib_init(struct device *dev, struct dmic_cfg *cfg);
|
||||
uint16_t sw_filter_lib_init(const struct device *dev, struct dmic_cfg *cfg);
|
||||
int sw_filter_lib_run(TPDMFilter_InitStruct *pdm_filter,
|
||||
void *pdm_block, void *pcm_block,
|
||||
size_t pdm_size, size_t pcm_size);
|
||||
|
||||
#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s)
|
||||
int mpxxdtyy_i2s_read(struct device *dev, uint8_t stream, void **buffer,
|
||||
int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer,
|
||||
size_t *size, int32_t timeout);
|
||||
int mpxxdtyy_i2s_trigger(struct device *dev, enum dmic_trigger cmd);
|
||||
int mpxxdtyy_i2s_configure(struct device *dev, struct dmic_cfg *cfg);
|
||||
int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd);
|
||||
int mpxxdtyy_i2s_configure(const struct device *dev, struct dmic_cfg *cfg);
|
||||
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -25,10 +25,10 @@ LOG_MODULE_REGISTER(tlv320dac310x);
|
|||
#define CODEC_OUTPUT_VOLUME_MIN (-78 * 2)
|
||||
|
||||
struct codec_driver_config {
|
||||
struct device *i2c_device;
|
||||
const struct device *i2c_device;
|
||||
const char *i2c_dev_name;
|
||||
uint8_t i2c_address;
|
||||
struct device *gpio_device;
|
||||
const struct device *gpio_device;
|
||||
const char *gpio_dev_name;
|
||||
uint32_t gpio_pin;
|
||||
int gpio_flags;
|
||||
|
@ -55,25 +55,28 @@ static struct codec_driver_data codec_device_data;
|
|||
#define DEV_DATA(dev) \
|
||||
((struct codec_driver_data *const)(dev)->data)
|
||||
|
||||
static void codec_write_reg(struct device *dev, struct reg_addr reg, uint8_t val);
|
||||
static void codec_read_reg(struct device *dev, struct reg_addr reg, uint8_t *val);
|
||||
static void codec_soft_reset(struct device *dev);
|
||||
static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg);
|
||||
static int codec_configure_clocks(struct device *dev,
|
||||
struct audio_codec_cfg *cfg);
|
||||
static int codec_configure_filters(struct device *dev, audio_dai_cfg_t *cfg);
|
||||
static void codec_write_reg(const struct device *dev, struct reg_addr reg,
|
||||
uint8_t val);
|
||||
static void codec_read_reg(const struct device *dev, struct reg_addr reg,
|
||||
uint8_t *val);
|
||||
static void codec_soft_reset(const struct device *dev);
|
||||
static int codec_configure_dai(const struct device *dev, audio_dai_cfg_t *cfg);
|
||||
static int codec_configure_clocks(const struct device *dev,
|
||||
struct audio_codec_cfg *cfg);
|
||||
static int codec_configure_filters(const struct device *dev,
|
||||
audio_dai_cfg_t *cfg);
|
||||
static enum osr_multiple codec_get_osr_multiple(audio_dai_cfg_t *cfg);
|
||||
static void codec_configure_output(struct device *dev);
|
||||
static int codec_set_output_volume(struct device *dev, int vol);
|
||||
static void codec_configure_output(const struct device *dev);
|
||||
static int codec_set_output_volume(const struct device *dev, int vol);
|
||||
|
||||
#if (LOG_LEVEL >= LOG_LEVEL_DEBUG)
|
||||
static void codec_read_all_regs(struct device *dev);
|
||||
static void codec_read_all_regs(const struct device *dev);
|
||||
#define CODEC_DUMP_REGS(dev) codec_read_all_regs((dev))
|
||||
#else
|
||||
#define CODEC_DUMP_REGS(dev)
|
||||
#endif
|
||||
|
||||
static int codec_initialize(struct device *dev)
|
||||
static int codec_initialize(const struct device *dev)
|
||||
{
|
||||
struct codec_driver_config *const dev_cfg = DEV_CFG(dev);
|
||||
|
||||
|
@ -96,8 +99,8 @@ static int codec_initialize(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int codec_configure(struct device *dev,
|
||||
struct audio_codec_cfg *cfg)
|
||||
static int codec_configure(const struct device *dev,
|
||||
struct audio_codec_cfg *cfg)
|
||||
{
|
||||
struct codec_driver_config *const dev_cfg = DEV_CFG(dev);
|
||||
int ret;
|
||||
|
@ -127,7 +130,7 @@ static int codec_configure(struct device *dev,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void codec_start_output(struct device *dev)
|
||||
static void codec_start_output(const struct device *dev)
|
||||
{
|
||||
/* powerup DAC channels */
|
||||
codec_write_reg(dev, DATA_PATH_SETUP_ADDR, DAC_LR_POWERUP_DEFAULT);
|
||||
|
@ -138,7 +141,7 @@ static void codec_start_output(struct device *dev)
|
|||
CODEC_DUMP_REGS(dev);
|
||||
}
|
||||
|
||||
static void codec_stop_output(struct device *dev)
|
||||
static void codec_stop_output(const struct device *dev)
|
||||
{
|
||||
/* mute DAC channels */
|
||||
codec_write_reg(dev, VOL_CTRL_ADDR, VOL_CTRL_MUTE_DEFAULT);
|
||||
|
@ -147,21 +150,22 @@ static void codec_stop_output(struct device *dev)
|
|||
codec_write_reg(dev, DATA_PATH_SETUP_ADDR, DAC_LR_POWERDN_DEFAULT);
|
||||
}
|
||||
|
||||
static void codec_mute_output(struct device *dev)
|
||||
static void codec_mute_output(const struct device *dev)
|
||||
{
|
||||
/* mute DAC channels */
|
||||
codec_write_reg(dev, VOL_CTRL_ADDR, VOL_CTRL_MUTE_DEFAULT);
|
||||
}
|
||||
|
||||
static void codec_unmute_output(struct device *dev)
|
||||
static void codec_unmute_output(const struct device *dev)
|
||||
{
|
||||
/* unmute DAC channels */
|
||||
codec_write_reg(dev, VOL_CTRL_ADDR, VOL_CTRL_UNMUTE_DEFAULT);
|
||||
}
|
||||
|
||||
static int codec_set_property(struct device *dev,
|
||||
audio_property_t property, audio_channel_t channel,
|
||||
audio_property_value_t val)
|
||||
static int codec_set_property(const struct device *dev,
|
||||
audio_property_t property,
|
||||
audio_channel_t channel,
|
||||
audio_property_value_t val)
|
||||
{
|
||||
/* individual channel control not currently supported */
|
||||
if (channel != AUDIO_CHANNEL_ALL) {
|
||||
|
@ -189,13 +193,14 @@ static int codec_set_property(struct device *dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int codec_apply_properties(struct device *dev)
|
||||
static int codec_apply_properties(const struct device *dev)
|
||||
{
|
||||
/* nothing to do because there is nothing cached */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void codec_write_reg(struct device *dev, struct reg_addr reg, uint8_t val)
|
||||
static void codec_write_reg(const struct device *dev, struct reg_addr reg,
|
||||
uint8_t val)
|
||||
{
|
||||
struct codec_driver_data *const dev_data = DEV_DATA(dev);
|
||||
struct codec_driver_config *const dev_cfg = DEV_CFG(dev);
|
||||
|
@ -213,7 +218,8 @@ static void codec_write_reg(struct device *dev, struct reg_addr reg, uint8_t val
|
|||
reg.page, reg.reg_addr, val);
|
||||
}
|
||||
|
||||
static void codec_read_reg(struct device *dev, struct reg_addr reg, uint8_t *val)
|
||||
static void codec_read_reg(const struct device *dev, struct reg_addr reg,
|
||||
uint8_t *val)
|
||||
{
|
||||
struct codec_driver_data *const dev_data = DEV_DATA(dev);
|
||||
struct codec_driver_config *const dev_cfg = DEV_CFG(dev);
|
||||
|
@ -231,13 +237,13 @@ static void codec_read_reg(struct device *dev, struct reg_addr reg, uint8_t *val
|
|||
reg.page, reg.reg_addr, *val);
|
||||
}
|
||||
|
||||
static void codec_soft_reset(struct device *dev)
|
||||
static void codec_soft_reset(const struct device *dev)
|
||||
{
|
||||
/* soft reset the DAC */
|
||||
codec_write_reg(dev, SOFT_RESET_ADDR, SOFT_RESET_ASSERT);
|
||||
}
|
||||
|
||||
static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg)
|
||||
static int codec_configure_dai(const struct device *dev, audio_dai_cfg_t *cfg)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
|
@ -274,8 +280,8 @@ static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int codec_configure_clocks(struct device *dev,
|
||||
struct audio_codec_cfg *cfg)
|
||||
static int codec_configure_clocks(const struct device *dev,
|
||||
struct audio_codec_cfg *cfg)
|
||||
{
|
||||
int dac_clk, mod_clk;
|
||||
struct i2s_config *i2s;
|
||||
|
@ -373,7 +379,8 @@ static int codec_configure_clocks(struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int codec_configure_filters(struct device *dev, audio_dai_cfg_t *cfg)
|
||||
static int codec_configure_filters(const struct device *dev,
|
||||
audio_dai_cfg_t *cfg)
|
||||
{
|
||||
enum proc_block proc_blk;
|
||||
|
||||
|
@ -413,7 +420,7 @@ static enum osr_multiple codec_get_osr_multiple(audio_dai_cfg_t *cfg)
|
|||
return osr;
|
||||
}
|
||||
|
||||
static void codec_configure_output(struct device *dev)
|
||||
static void codec_configure_output(const struct device *dev)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
|
@ -453,7 +460,7 @@ static void codec_configure_output(struct device *dev)
|
|||
codec_write_reg(dev, HEADPHONE_DRV_ADDR, val);
|
||||
}
|
||||
|
||||
static int codec_set_output_volume(struct device *dev, int vol)
|
||||
static int codec_set_output_volume(const struct device *dev, int vol)
|
||||
{
|
||||
uint8_t vol_val;
|
||||
int vol_index;
|
||||
|
@ -492,7 +499,7 @@ static int codec_set_output_volume(struct device *dev, int vol)
|
|||
}
|
||||
|
||||
#if (LOG_LEVEL >= LOG_LEVEL_DEBUG)
|
||||
static void codec_read_all_regs(struct device *dev)
|
||||
static void codec_read_all_regs(const struct device *dev)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue