drivers: audio: drop DEV_DATA/DEV_CFG usage

Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-01-18 12:43:02 +01:00 committed by Carles Cufí
parent 6745333511
commit 224958c537
4 changed files with 15 additions and 21 deletions

View file

@ -24,7 +24,7 @@ int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer,
size_t *size, int32_t timeout)
{
int ret;
struct mpxxdtyy_data *const data = DEV_DATA(dev);
struct mpxxdtyy_data *const data = dev->data;
void *pdm_block, *pcm_block;
size_t pdm_size;
TPDMFilter_InitStruct *pdm_filter = &data->pdm_filter[0];
@ -54,7 +54,7 @@ int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer,
int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd)
{
int ret;
struct mpxxdtyy_data *const data = DEV_DATA(dev);
struct mpxxdtyy_data *const data = dev->data;
enum i2s_trigger_cmd i2s_cmd;
enum dmic_state tmp_state;
@ -92,7 +92,7 @@ int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd)
int mpxxdtyy_i2s_configure(const struct device *dev, struct dmic_cfg *cfg)
{
int ret;
struct mpxxdtyy_data *const data = DEV_DATA(dev);
struct mpxxdtyy_data *const data = dev->data;
uint8_t chan_size = cfg->streams->pcm_width;
uint32_t audio_freq = cfg->streams->pcm_rate;
uint16_t factor;

View file

@ -47,7 +47,7 @@ static uint8_t right_channel(uint8_t a, uint8_t b)
uint16_t sw_filter_lib_init(const struct device *dev, struct dmic_cfg *cfg)
{
struct mpxxdtyy_data *const data = DEV_DATA(dev);
struct mpxxdtyy_data *const data = dev->data;
TPDMFilter_InitStruct *pdm_filter = &data->pdm_filter[0];
uint16_t factor;
uint32_t audio_freq = cfg->streams->pcm_rate;
@ -150,7 +150,7 @@ static const struct _dmic_ops mpxxdtyy_driver_api = {
static int mpxxdtyy_initialize(const struct device *dev)
{
struct mpxxdtyy_data *const data = DEV_DATA(dev);
struct mpxxdtyy_data *const data = dev->data;
data->comm_master = device_get_binding(DT_INST_BUS_LABEL(0));

View file

@ -19,11 +19,6 @@ extern "C" {
#define MPXXDTYY_MIN_PDM_FREQ 1200000 /* 1.2MHz */
#define MPXXDTYY_MAX_PDM_FREQ 3250000 /* 3.25MHz */
#define DEV_CFG(dev) \
((const struct mpxxdtyy_config *const)(dev)->config)
#define DEV_DATA(dev) \
((struct mpxxdtyy_data *const)(dev)->data)
struct mpxxdtyy_data {
const struct device *comm_master;
enum dmic_state state;

View file

@ -50,11 +50,6 @@ static struct codec_driver_config codec_device_config = {
static struct codec_driver_data codec_device_data;
#define DEV_CFG(dev) \
((struct codec_driver_config *const)(dev)->config)
#define DEV_DATA(dev) \
((struct codec_driver_data *const)(dev)->data)
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,
@ -78,7 +73,8 @@ static void codec_read_all_regs(const struct device *dev);
static int codec_initialize(const struct device *dev)
{
struct codec_driver_config *const dev_cfg = DEV_CFG(dev);
struct codec_driver_config *const dev_cfg =
(struct codec_driver_config *)dev->config;
/* bind I2C */
dev_cfg->i2c_device = device_get_binding(dev_cfg->i2c_dev_name);
@ -102,7 +98,8 @@ static int codec_initialize(const struct device *dev)
static int codec_configure(const struct device *dev,
struct audio_codec_cfg *cfg)
{
struct codec_driver_config *const dev_cfg = DEV_CFG(dev);
struct codec_driver_config *const dev_cfg =
(struct codec_driver_config *)dev->config;
int ret;
if (cfg->dai_type != AUDIO_DAI_TYPE_I2S) {
@ -202,8 +199,9 @@ static int codec_apply_properties(const struct device *dev)
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);
struct codec_driver_data *const dev_data = dev->data;
struct codec_driver_config *const dev_cfg =
(struct codec_driver_config *)dev->config;
/* set page if different */
if (dev_data->reg_addr_cache.page != reg.page) {
@ -221,8 +219,9 @@ static void codec_write_reg(const struct device *dev, struct reg_addr reg,
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);
struct codec_driver_data *const dev_data = dev->data;
struct codec_driver_config *const dev_cfg =
(struct codec_driver_config *)dev->config;
/* set page if different */
if (dev_data->reg_addr_cache.page != reg.page) {